Пример #1
0
  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;
  }
Пример #2
0
  void testInterceptorMethods(
      Set<LifecycleCallbackDescriptor> callbackDescs,
      String callbackMethodName,
      Boolean isBeanMethod) {
    if (callbackMethodName.equals("AroundInvoke"))
      return; // this test applies only to lifecycle callback methods

    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);
        }
      } catch (Exception e) {
      } // ignore as it will be caught in other tests
    }
  }