Package javax.ejb

Examples of javax.ejb.ApplicationException


        if (aeHandler instanceof EjbBundleContext) {
            EjbBundleContext ejbBundleContext = (EjbBundleContext)aeHandler;
           
            EjbBundleDescriptorImpl ejbBundle = (EjbBundleDescriptorImpl) ejbBundleContext.getDescriptor();

            ApplicationException appExcAnn = (ApplicationException) annotation;

            EjbApplicationExceptionInfo appExcInfo = new
                EjbApplicationExceptionInfo();
            Class annotatedClass = (Class) ae;
            appExcInfo.setExceptionClassName(annotatedClass.getName());
            appExcInfo.setRollback(appExcAnn.rollback());
            appExcInfo.setInherited(appExcAnn.inherited());

            // Set on descriptor unless the same application exception was defined
            // in ejb-jar.xml
            if( !ejbBundle.getApplicationExceptions().containsKey(annotatedClass.getName()) ) {
                ejbBundle.addApplicationException(appExcInfo);
View Full Code Here


      super.handleEndTransactionException(e);
   }
  
   public void handleExceptionInOurTx(Invocation invocation, Throwable t, Transaction tx) throws Throwable
   {
      ApplicationException ae = TxUtil.getApplicationException(t.getClass(), invocation);
      if (ae != null)
      {
         if (ae.rollback()) setRollbackOnly(tx);
         throw t;
      }

      // if it's neither EJBException nor RemoteException
      if(!(t instanceof EJBException || t instanceof RemoteException))
View Full Code Here

      throw t;
   }

   public void handleInCallerTx(Invocation invocation, Throwable t, Transaction tx) throws Throwable
   {
      ApplicationException ae = TxUtil.getApplicationException(t.getClass(), invocation);
  
      if (ae != null)
      {
         if (ae.rollback()) setRollbackOnly(tx);
         throw t;
      }
     
      // if it's not EJBTransactionRolledbackException
      if(!(t instanceof EJBTransactionRolledbackException))
View Full Code Here

      throw new EJBException(e);
   }

   protected void handleInCallerTx(InvocationContext invocation, Throwable t, Transaction tx) throws Exception
   {
      ApplicationException ae = this.getApplicationException(t.getClass());
      if (ae != null)
      {
         if (ae.rollback())
         {
            setRollbackOnly(tx);
         }
         // an app exception can never be an Error
         throw (Exception) t;
View Full Code Here

      throw (Exception) t;
   }

   public void handleExceptionInOurTx(InvocationContext invocation, Throwable t, Transaction tx) throws Exception
   {
      ApplicationException ae = this.getApplicationException(t.getClass());
      if (ae != null)
      {
         if (ae.rollback())
         {
            setRollbackOnly(tx);
         }
         throw (Exception) t;
      }
View Full Code Here

        this.securityMetaData = ejbComponentCreateService.getSecurityMetaData();
    }

    @Override
    public ApplicationException getApplicationException(Class<?> exceptionClass) {
        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

        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

            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

            /*
             * @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

/* 47 */     super(finder);
/*    */   }
/*    */
/*    */   public ApplicationExceptionMetaData create(Class<?> element)
/*    */   {
/* 52 */     ApplicationException annotation = (ApplicationException)this.finder.getAnnotation(element, ApplicationException.class);
/* 53 */     if (annotation == null) {
/* 54 */       return null;
/*    */     }
/* 56 */     if (!Exception.class.isAssignableFrom(element)) {
/* 57 */       throw new IllegalArgumentException("ApplicationException is only valid on an Exception");
/*    */     }
/* 59 */     ApplicationExceptionMetaData metaData = new ApplicationExceptionMetaData();
/* 60 */     metaData.setExceptionClass(element.getName());
/* 61 */     metaData.setRollback(annotation.rollback());
/*    */
/* 63 */     return metaData;
/*    */   }
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.