CallbacksOnBeanClasspublic class CallbacksOnBeanClass extends com.sun.enterprise.tools.verifier.tests.ejb.EjbTest If the PostConstruct lifecycle callback interceptor method is the ejbCreate
method, if the PreDestroy lifecycle callback interceptor method is the
ejbRemove method, if the PostActivate lifecycle callback interceptor method
is the ejbActivate method, or if the Pre-Passivate lifecycle callback
interceptor method is the ejbPassivate method, these callback methods must
be implemented on the bean class itself (or on its superclasses). |
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)
result = getInitializedResult();
compName = getVerifierContext().getComponentNameConstructor();
Set<EjbInterceptor> interceptors = descriptor.getInterceptorClasses();
for (EjbInterceptor interceptor : interceptors) {
if (interceptor.hasCallbackDescriptor(
LifecycleCallbackDescriptor.CallbackType.POST_ACTIVATE)) {
Set<LifecycleCallbackDescriptor> callBackDescs =
interceptor.getCallbackDescriptors(
LifecycleCallbackDescriptor.CallbackType.POST_ACTIVATE);
reportError(callBackDescs, "ejbActivate",interceptor.getInterceptorClassName());
}
if (interceptor.hasCallbackDescriptor(
LifecycleCallbackDescriptor.CallbackType.PRE_PASSIVATE)) {
Set<LifecycleCallbackDescriptor> callBackDescs =
interceptor.getCallbackDescriptors(
LifecycleCallbackDescriptor.CallbackType.PRE_PASSIVATE);
reportError(callBackDescs, "ejbPassivate",interceptor.getInterceptorClassName());
}
if (interceptor.hasCallbackDescriptor(
LifecycleCallbackDescriptor.CallbackType.POST_CONSTRUCT)) {
Set<LifecycleCallbackDescriptor> callBackDescs =
interceptor.getCallbackDescriptors(
LifecycleCallbackDescriptor.CallbackType.POST_CONSTRUCT);
reportError(callBackDescs, "ejbCreate",interceptor.getInterceptorClassName());
}
if (interceptor.hasCallbackDescriptor(
LifecycleCallbackDescriptor.CallbackType.PRE_DESTROY)) {
Set<LifecycleCallbackDescriptor> callBackDescs =
interceptor.getCallbackDescriptors(
LifecycleCallbackDescriptor.CallbackType.PRE_DESTROY);
reportError(callBackDescs, "ejbRemove",interceptor.getInterceptorClassName());
}
}
if(result.getStatus() != Result.FAILED) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString
(getClass().getName()+".passed",
"Valid lifecycle callback method(s)"));
}
return result;
| private void | reportError(java.util.Set callBackDescs, java.lang.String callbackMethodName, java.lang.String interceptorClassName)
for (LifecycleCallbackDescriptor callbackDesc : callBackDescs) {
String callbackMethod = callbackDesc.getLifecycleCallbackMethod();
if(callbackMethod.contains(callbackMethodName)) {
result.getFaultLocation().setFaultyClassName(interceptorClassName);
result.getFaultLocation().setFaultyMethodName(callbackMethod);
addErrorDetails(result, compName);
result.failed(smh.getLocalString
(getClass().getName()+".failed",
"Wrong method [ {0} ] in class [ {1} ]",
new Object[] {callbackMethod, interceptorClassName}));
}
}
|
|