TaglibFunctionMethodTestpublic class TaglibFunctionMethodTest extends com.sun.enterprise.tools.verifier.tests.TagLibTest implements WebCheckThe specified method, in function-signature element, must be a public static
method in the specified class, and must be specified using a fully-qualified
return type followed by the method name, followed by the fully-qualified
argument types in parenthesis, separated by commas. |
Methods Summary |
---|
public com.sun.enterprise.tools.verifier.Result | check(com.sun.enterprise.deployment.WebBundleDescriptor descriptor)
ComponentNameConstructor compName =
getVerifierContext().getComponentNameConstructor();
Result result = getInitializedResult();
Context context = getVerifierContext();
TagLibDescriptor tlds[] = context.getTagLibDescriptors();
FunctionDescriptor[] fnDesc = null;
if (tlds == null) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString
(getClass().getName() + ".passed",
"No tag lib files are specified"));
return result;
}
for (TagLibDescriptor tld : tlds) {
if (tld.getSpecVersion().compareTo("2.0") >= 0) {
fnDesc = tld.getFunctionDescriptors();
if (fnDesc != null)
for (FunctionDescriptor fd : fnDesc)
checkMethodExistence(result, fd, tld, compName);
}
}
if (result.getStatus() != Result.FAILED) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass()
.getName() +
".passed", "All methods defined in the function-signature element" +
"of the tag lib descriptor are properly defined."));
}
return result;
| private void | checkMethodExistence(com.sun.enterprise.tools.verifier.Result result, com.sun.enterprise.tools.verifier.web.FunctionDescriptor fnDesc, com.sun.enterprise.tools.verifier.TagLibDescriptor tld, com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor compName)
ClassLoader cl = getVerifierContext().getClassLoader();
String signature = fnDesc.getFunctionSignature();
String className = fnDesc.getFunctionClass();
String methodName = getName(signature);
String retType = getRetType(signature);
String[] par = getParameters(signature);
Class [] param = getParamTypeClass(par, cl);
try {
Class c = Class.forName(className, false, cl);
boolean passed = false;
Method[] methods= c.getMethods();
for (Method m : methods) {
if (m.getName().equals(methodName) &&
parametersMatch(m, param) &&
Modifier.toString(m.getModifiers()).contains("static") &&
returnTypeMatch(m, retType)) {
passed = true;
break;
}
}
if(!passed) {
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() +
".failed",
"Error: The method [ {0} ] as defined in function-signature" +
"element of [ {1} ] does not exists or is not a" +
"public static method in class [ {2} ]",
new Object[]{methodName, tld.getUri(), className }));
}
} catch (ClassNotFoundException e) {
//do nothing. If class is not found, JSP compiler will anyway report
}
|
|