Exemple #1
0
 private void initApplicationExceptions(final EjbModule jar, final EjbJarInfo ejbJarInfo) {
   for (final ApplicationException applicationException :
       jar.getEjbJar().getAssemblyDescriptor().getApplicationException()) {
     final ApplicationExceptionInfo info = new ApplicationExceptionInfo();
     info.exceptionClass = applicationException.getExceptionClass();
     info.rollback = applicationException.isRollback();
     info.inherited = applicationException.isInherited();
     ejbJarInfo.applicationException.add(info);
   }
 }
  public void validate(EjbModule module) {
    Set<String> applicationExceptions = new HashSet<String>();
    for (ApplicationException applicationException :
        module.getEjbJar().getAssemblyDescriptor().getApplicationException()) {
      applicationExceptions.add(applicationException.getExceptionClass());
    }
    for (EnterpriseBean bean : module.getEjbJar().getEnterpriseBeans()) {
      Class<?> ejbClass = null;
      try {
        ejbClass = loadClass(bean.getEjbClass());
      } catch (OpenEJBException e) {
        continue;
      }
      if (bean instanceof SessionBean) {
        SessionBean session = (SessionBean) bean;
        for (AsyncMethod asyncMethod : session.getAsyncMethod()) {
          Method method = getMethod(ejbClass, asyncMethod);
          if (method == null) {
            fail(
                bean,
                "asynchronous.missing",
                asyncMethod.getMethodName(),
                ejbClass.getName(),
                getParameters(asyncMethod.getMethodParams()));
          } else {
            checkAsynchronousMethod(session, ejbClass, method, applicationExceptions);
          }
        }

        for (String className : session.getAsynchronousClasses()) {
          try {
            Class<?> cls = loadClass(className);
            for (Method method : cls.getDeclaredMethods()) {
              if (Modifier.isPublic(method.getModifiers()) && !method.isSynthetic()) {
                checkAsynchronousMethod(session, ejbClass, method, applicationExceptions);
              } else {
                // warn(session, "asynchronous.methodignored", ejbClass.getName(),
                // method.getName());
              }
            }
          } catch (OpenEJBException e) {
            // ignore ?
          }
        }
      } else {
        ClassFinder classFinder = new ClassFinder(ejbClass);
        for (Method method : classFinder.findAnnotatedMethods(Asynchronous.class)) {
          ignoredMethodAnnotation(
              "Asynchronous",
              bean,
              bean.getEjbClass(),
              method.getName(),
              bean.getClass().getSimpleName());
        }
        if (ejbClass.getAnnotation(Asynchronous.class) != null) {
          ignoredClassAnnotation(
              "Asynchronous", bean, bean.getEjbClass(), bean.getClass().getSimpleName());
        }
      }
    }
  }