ApplicationExceptionHomeInterfaceMethodspublic class ApplicationExceptionHomeInterfaceMethods extends EjbTest implements EjbCheckThe Bean Provider defines the application exceptions in the throws clauses
of the methods of the home interface. An application exception
is an exception defined in the throws clause of a method in the Bean's home
interface, other than java.rmi.RemoteException. An application
exception must not be defined as a subclass of the
java.lang.RuntimeException, or of the java.rmi.RemoteException. These are
reserved for system exceptions.
The javax.ejb.CreateException, javax.ejb.RemoveException,
javax.ejb.FinderException, and subclasses thereof, are considered to be
application exceptions. |
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)The Bean Provider defines the application exceptions in the throws clauses
of the methods of the home interface. An application exception
is an exception defined in the throws clause of a method in the Bean's home
interface, other than java.rmi.RemoteException. An application
exception must not be defined as a subclass of the
java.lang.RuntimeException, or of the java.rmi.RemoteException. These are
reserved for system exceptions.
The javax.ejb.CreateException, javax.ejb.RemoveException,
javax.ejb.FinderException, and subclasses thereof, are considered to be
application exceptions.
result = getInitializedResult();
compName = getVerifierContext().getComponentNameConstructor();
if ((descriptor instanceof EjbSessionDescriptor) ||
(descriptor instanceof EjbEntityDescriptor)) {
if(descriptor.getHomeClassName() != null)
commonToBothInterfaces(descriptor.getHomeClassName(),descriptor);
if(descriptor.getLocalHomeClassName() != null)
commonToBothInterfaces(descriptor.getLocalHomeClassName(), descriptor);
}
if(result.getStatus() != Result.FAILED) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString
(getClass().getName() + ".passed",
"All the methods of Home interface are defined properly"));
}
return result;
| private void | commonToBothInterfaces(java.lang.String home, com.sun.enterprise.deployment.EjbDescriptor 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());
Class [] methodExceptionTypes;
for(Method methods : c.getDeclaredMethods()) {
methodExceptionTypes = methods.getExceptionTypes();
// methods must also throw java.rmi.RemoteException
if (!(EjbUtils.isValidApplicationException(methodExceptionTypes))) {
addErrorDetails(result, compName);
result.failed(smh.getLocalString
(getClass().getName() + ".failed",
"For the Interface [ {0} ] Method [ {1} ] does" +
" not throw valid application exceptions",
new Object[] {home, methods.getName()}));
}
} // for all the methods within the home interface class, loop
} catch (Exception 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()}));
}
|
|