HomeInterfaceNoFinderMethodNamespublic class HomeInterfaceNoFinderMethodNames extends com.sun.enterprise.tools.verifier.tests.ejb.EjbTest implements com.sun.enterprise.tools.verifier.tests.ejb.EjbCheckSession beans home interface no finder methods name test.
The following are the requirements for the enterprise Bean's home interface
signature:
Since all session objects hide their identity, there is no need to provide
a finder for them. The home interface for a session object must not define
any finder methods. |
Fields Summary |
---|
com.sun.enterprise.tools.verifier.Result | result | com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor | compName |
Methods Summary |
---|
public com.sun.enterprise.tools.verifier.Result | check(com.sun.enterprise.deployment.EjbDescriptor descriptor)Session beans home interface no finder methods name test.
The following are the requirements for the enterprise Bean's home interface
signature:
Since all session objects hide their identity, there is no need to provide
a finder for them. The home interface for a session object must not define
any finder methods.
result = getInitializedResult();
compName = getVerifierContext().getComponentNameConstructor();
if (descriptor instanceof EjbSessionDescriptor) {
// RULE: Session home interface are not allowed to have any
// finder methods
if(descriptor.getHomeClassName() != null && !"".equals(descriptor.getHomeClassName()))
commonToBothInterfaces(descriptor.getHomeClassName(),(EjbSessionDescriptor)descriptor);
if(descriptor.getLocalHomeClassName() != null && !"".equals(descriptor.getLocalHomeClassName()))
commonToBothInterfaces(descriptor.getLocalHomeClassName(),(EjbSessionDescriptor)descriptor);
}
if(result.getStatus() != Result.FAILED) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString
(getClass().getName() + ".passed",
"Valid: no finder methods were found. Session bean's home interface" +
" is not allowed to have any finder methods."));
}
return result;
| private void | commonToBothInterfaces(java.lang.String home, com.sun.enterprise.deployment.EjbSessionDescriptor descriptor)This method is responsible for the logic of the test. It is called for both local and remote interfaces.
try {
Class c = Class.forName(home,
false,
getVerifierContext().getClassLoader());
for(Method methods : c.getDeclaredMethods()) {
if(methods.getName().startsWith("find")) {
addErrorDetails(result, compName);
result.failed(smh.getLocalString
(getClass().getName() + ".debug1",
"For Home Interface [ {0} ] Method [ {1} ]",
new Object[] {c.getName(),methods.getName()}));
result.addErrorDetails(smh.getLocalString
(getClass().getName() + ".failed",
"Improperly named method [ {0} ] was found. Session bean's home interface is not allowed to have any finder methods.",
new Object[] {methods.getName()}));
}
}
} catch (ClassNotFoundException e) {
Verifier.debug(e);
addErrorDetails(result, compName);
result.failed(smh.getLocalString
(getClass().getName() + ".failedException",
"Error: Home interface [ {0} ] does not exist or is not loadable within bean [ {1} ]",
new Object[] {home, descriptor.getName()}));
}
|
|