ApplicationExceptionComponentInterfaceMethodspublic class ApplicationExceptionComponentInterfaceMethods extends EjbTest implements EjbCheckThe Bean Provider defines the application exceptions in the throws clauses
of the methods of the remote interface. An application exception
is an exception defined in the throws clause of a method in the Bean's
remote 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 remote interface. An application exception
is an exception defined in the throws clause of a method in the Bean's
remote 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.getRemoteClassName() != null)
commonToBothInterfaces(descriptor.getRemoteClassName(),descriptor);
if(descriptor.getLocalClassName() != null)
commonToBothInterfaces(descriptor.getLocalClassName(),descriptor);
//EJB 3.0 business interface requirements
Set<String> localAndRemoteInterfaces = descriptor.getLocalBusinessClassNames();
localAndRemoteInterfaces.addAll(descriptor.getRemoteBusinessClassNames());
for (String localOrRemoteIntf : localAndRemoteInterfaces)
commonToBothInterfaces(localOrRemoteIntf, descriptor);
}
if(result.getStatus() != Result.FAILED) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString
(getClass().getName() + ".passed",
"All the business methods are defined properly"));
}
return result;
| private void | commonToBothInterfaces(java.lang.String remote, 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(remote, 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[] {remote, methods.getName()}));
}
} // for all the methods within the Remote interface class, loop
} catch (Exception e) {
Verifier.debug(e);
addErrorDetails(result, compName);
result.failed(smh.getLocalString
(getClass().getName() + ".failedException",
"Error: Remote interface [ {0} ] does not exist or is not " +
"loadable within bean [ {1} ]",
new Object[] {remote, descriptor.getName()}));
}
|
|