Package javax.ejb

Examples of javax.ejb.ApplicationException


            /*
             * @ApplicationException
             */
            for (Method method : clazz.getMethods()) {
                for (Class<?> exception : method.getExceptionTypes()) {
                    ApplicationException annotation = exception.getAnnotation(ApplicationException.class);
                    if (annotation == null) continue;
                    if (assemblyDescriptor.getApplicationException(exception) != null) {
                        mergeApplicationExceptionAnnotation(assemblyDescriptor, exception, annotation);
                    } else {
                        logger.debug("Found previously undetected application exception {0} listed on a method {1} with annotation {2}", method, exception, annotation);
                        assemblyDescriptor.addApplicationException(exception, annotation.rollback(), annotation.inherited());
                    }
                }
            }
        }
View Full Code Here


            startupLogger.debug("Searching for annotated application exceptions (see OPENEJB-980)");
            List<Class<?>> appExceptions = finder.findAnnotatedClasses(ApplicationException.class);
            for (Class<?> exceptionClass : appExceptions) {
                startupLogger.debug("...handling " + exceptionClass);
                ApplicationException annotation = exceptionClass.getAnnotation(ApplicationException.class);
                if (assemblyDescriptor.getApplicationException(exceptionClass) == null) {
                    startupLogger.debug("...adding " + exceptionClass + " with rollback=" + annotation.rollback());
                    assemblyDescriptor.addApplicationException(exceptionClass, annotation.rollback(), annotation.inherited());
                } else {
                    mergeApplicationExceptionAnnotation(assemblyDescriptor, exceptionClass, annotation);
                }
            }
View Full Code Here

            inherited = true;
        }

        // Unregistered - runtime exceptions are system exception and the rest are application exceptions
        final Class<? extends Throwable> eClass = e.getClass();
        final ApplicationException applicationException = eClass.getAnnotation(ApplicationException.class);
        if (applicationException != null) {
            addApplicationException(eClass, applicationException.rollback(), applicationException.inherited());
            return getExceptionType(e);
        }

        if (e instanceof RuntimeException) {
            return ExceptionType.SYSTEM;
View Full Code Here

      }

      // Everything after this line is a hack.

      // TODO: we have no facility that picks up annotations from shared libs, so lets do some emergency annotation scanning.
      ApplicationException annotation = exceptionType.getAnnotation(ApplicationException.class);
      if(annotation != null)
         return annotation;
     
      // This feels like a hack around shortcomings in jboss-metadata
      Class[] exceptionTypes = invokedMethod.getExceptionTypes();
View Full Code Here

        if (exceptionClassName == null || exceptionClassName.isEmpty()) {
            throw new IllegalArgumentException("Invalid exception class name: " + exceptionClassName);
        }
        //TODO: Is this a good idea? ApplicationException's equals/hashCode
        //will not work the way that would be expected
        ApplicationException appException = new ApplicationException() {
            @Override
            public boolean inherited() {
                return inherited;
            }
View Full Code Here

            throw new IllegalStateException("View of type " + viewInterface + " not found on bean " + this);
        }
    }

    public ApplicationException getApplicationException(Class<?> exceptionClass, Method invokedMethod) {
        ApplicationException applicationException = this.applicationExceptions.get(exceptionClass);
        if (applicationException != null) {
            return applicationException;
        }
        // Check if the super class of the passed exception class, is an application exception.
        Class<?> superClass = exceptionClass.getSuperclass();
        while (superClass != null && !(superClass.equals(Exception.class) || superClass.equals(Object.class))) {
            applicationException = this.applicationExceptions.get(superClass);
            // check whether the "inherited" attribute is set. A subclass of an application exception
            // is an application exception only if the inherited attribute on the parent application exception
            // is set to true.
            if (applicationException != null) {
                if (applicationException.inherited()) {
                    return applicationException;
                }
                // Once we find a super class which is an application exception,
                // we just stop there (no need to check the grand super class), irrespective of whether the "inherited"
                // is true or false
View Full Code Here

            /*
             * @ApplicationException
             */
            for (final Method method : clazz.getMethods()) {
                for (final Class<?> exception : method.getExceptionTypes()) {
                    final ApplicationException annotation = exception.getAnnotation(ApplicationException.class);
                    if (annotation == null) {
                        continue;
                    }
                    if (assemblyDescriptor.getApplicationException(exception) != null) {
                        mergeApplicationExceptionAnnotation(assemblyDescriptor, exception, annotation);
                    } else {
                        logger.debug("Found previously undetected application exception {0} listed on a method {1} with annotation {2}", method, exception, annotation);
                        assemblyDescriptor.addApplicationException(exception, annotation.rollback(), annotation.inherited());
                    }
                }
            }
        }
View Full Code Here

            startupLogger.debug("Searching for annotated application exceptions (see OPENEJB-980)");
            final List<Class<?>> appExceptions = finder.findAnnotatedClasses(ApplicationException.class);
            for (final Class<?> exceptionClass : appExceptions) {
                startupLogger.debug("...handling " + exceptionClass);
                final ApplicationException annotation = exceptionClass.getAnnotation(ApplicationException.class);
                if (assemblyDescriptor.getApplicationException(exceptionClass) == null) {
                    startupLogger.debug("...adding " + exceptionClass + " with rollback=" + annotation.rollback());
                    assemblyDescriptor.addApplicationException(exceptionClass, annotation.rollback(), annotation.inherited());
                } else {
                    mergeApplicationExceptionAnnotation(assemblyDescriptor, exceptionClass, annotation);
                }
            }
View Full Code Here

            inherited = true;
        }

        // Unregistered - runtime exceptions are system exception and the rest are application exceptions
        final Class<? extends Throwable> eClass = e.getClass();
        final ApplicationException applicationException = eClass.getAnnotation(ApplicationException.class);
        if (applicationException != null) {
            addApplicationException(eClass, applicationException.rollback(), applicationException.inherited());
            return getExceptionType(e);
        }

        if (e instanceof RuntimeException) {
            return ExceptionType.SYSTEM;
View Full Code Here

      }

      // Everything after this line is a hack.

      // TODO: we have no facility that picks up annotations from shared libs, so lets do some emergency annotation scanning.
      ApplicationException annotation = exceptionType.getAnnotation(ApplicationException.class);
      if(annotation != null)
         return annotation;
     
      // An unchecked-exception is only an application exception if annotated (or described) as such.
      // (see EJB 3.1 FR 14.2.1)
View Full Code Here

TOP

Related Classes of javax.ejb.ApplicationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.