use of com.sun.enterprise.deployment.LifecycleCallbackDescriptor in project Payara by payara.
the class WebBundleDescriptorImpl method addPreDestroyDescriptor.
@Override
public void addPreDestroyDescriptor(LifecycleCallbackDescriptor preDestroyDesc) {
String className = preDestroyDesc.getLifecycleCallbackClass();
boolean found = false;
for (LifecycleCallbackDescriptor next : getPreDestroyDescriptors()) {
if (next.getLifecycleCallbackClass().equals(className)) {
found = true;
break;
}
}
if (!found) {
getPreDestroyDescriptors().add(preDestroyDesc);
}
}
use of com.sun.enterprise.deployment.LifecycleCallbackDescriptor in project Payara by payara.
the class WebBundleDescriptorImpl method addPostConstructDescriptor.
@Override
public void addPostConstructDescriptor(LifecycleCallbackDescriptor postConstructDesc) {
String className = postConstructDesc.getLifecycleCallbackClass();
boolean found = false;
for (LifecycleCallbackDescriptor next : getPostConstructDescriptors()) {
if (next.getLifecycleCallbackClass().equals(className)) {
found = true;
break;
}
}
if (!found) {
getPostConstructDescriptors().add(postConstructDesc);
}
}
use of com.sun.enterprise.deployment.LifecycleCallbackDescriptor in project Payara by payara.
the class AroundInvokeNotBusinessMethod method check.
public Result check(EjbDescriptor descriptor) {
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
ClassLoader cl = getVerifierContext().getClassLoader();
if (descriptor.hasAroundInvokeMethod()) {
Set<MethodDescriptor> businessMethods = descriptor.getMethodDescriptors();
Set<LifecycleCallbackDescriptor> aiDescriptors = descriptor.getAroundInvokeDescriptors();
for (LifecycleCallbackDescriptor aiDesc : aiDescriptors) {
try {
Method interceptorMethod = aiDesc.getLifecycleCallbackMethodObject(cl);
MethodDescriptor interceptorMD = new MethodDescriptor(interceptorMethod);
if (businessMethods.contains(interceptorMD)) {
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() + ".failed", "AroundInvoke method [ {0} ] is a business method.", new Object[] { interceptorMethod }));
}
}// will be caught in other tests
catch (Exception e) {
}
}
}
if (result.getStatus() != Result.FAILED) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed", "Valid Interceptor methods."));
}
return result;
}
use of com.sun.enterprise.deployment.LifecycleCallbackDescriptor in project Payara by payara.
the class EJBCreatePostConstruct method check.
public Result check(EjbSessionDescriptor descriptor) {
if (descriptor.isStateless() && descriptor.hasPostConstructMethod() && hasEJBCreateMethod(descriptor.getEjbClassName())) {
for (LifecycleCallbackDescriptor callbackDesc : descriptor.getPostConstructDescriptors()) {
String cmName = callbackDesc.getLifecycleCallbackMethod();
if (!cmName.contains("ejbCreate")) {
addErrorDetails(result, compName);
result.failed(smh.getLocalString(getClass().getName() + ".failed", "Wrong postconstruct method [ {0} ]", new Object[] { cmName }));
}
}
}
if (result.getStatus() != Result.FAILED) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed", "Valid postcontruct method(s) in Bean"));
}
return result;
}
use of com.sun.enterprise.deployment.LifecycleCallbackDescriptor in project Payara by payara.
the class CallbackMethodArgument method testInterceptorMethods.
void testInterceptorMethods(Set<LifecycleCallbackDescriptor> callbackDescs, String callbackMethodName, Boolean isBeanMethod) {
if (callbackMethodName.equals("AroundInvoke"))
// this test applies only to lifecycle callback methods
return;
ClassLoader cl = getVerifierContext().getClassLoader();
for (LifecycleCallbackDescriptor callbackDesc : callbackDescs) {
try {
Method method = callbackDesc.getLifecycleCallbackMethodObject(cl);
Class<?>[] args = method.getParameterTypes();
if (isBeanMethod && args.length != 0) {
logFailure(callbackMethodName, method);
} else if (!isBeanMethod && (args.length != 1 || !javax.interceptor.InvocationContext.class.isAssignableFrom(args[0]))) {
logFailure(callbackMethodName, method);
}
}// ignore as it will be caught in other tests
catch (Exception e) {
}
}
}
Aggregations