6 Replies Latest reply on Nov 23, 2007 4:52 AM by wolfc

    Add @ApplicationException to EJBContainer?

    alrubinger

      Placed an ugly line in the other day:

      catch(Exception e)
      {
       if(e.getClass().getAnnotation(ApplicationException.class)!=null)
      {
       ...handle AppException
      } else {
       ...handle Exception as normal
      }


      This doesn't account for a couple things:

      1) XML-defined ApplicationExceptions in ejb-jar.xml assembly-descriptor/application-exceptions
      2) Inheritance (is an exception whose parent is @ApplicationException also an Application Exception?)

      Would propose adding a List of Application Exceptions to EJBContainer, which I think would entail:

      1) An additional method in Ejb3DescriptorHandler, "addApplicationExceptionAnnotations", to be called from addAssemblyAnnotations().
      2) Additional scanning for @ApplicationException at deployment time.

      Tricky thing here is that Application Exceptions are global per deployment unit (JAR), and would need to be referenced from all EJBs (Containers) in that unit.

      Or is the matadata project making some of this moot by merging the annotations and XML together into JBossAssemblyDescriptorMetaData, in which case we can skip the scanning step 2) above?

      S,
      ALR



        • 1. Re: Add
          alrubinger

          Damn you forum:

          Topic - Add @ApplicationException to EJBContainer?

          • 2. Re: Add @ApplicationException to EJBContainer?
            wolfc

            +1 for uglyness :-)

            catch(Exception e) {
             if(container.isApplicationException(e))


            boolean isApplicationException(Exception e) {
             return deployment.isApplicationException(e);
            }


            So the interesting code is in Ejb3Deployment and Ejb3DescriptorHandler.

            • 3. Re: Add @ApplicationException to EJBContainer?
              alrubinger

              OK, Ejb3Deployment is a better place for List<Class<?>> applicationExceptions.

              1) Spec is silent on inheritance of @ApplicationException from parent to subclass.

              2) How are we handling this:

              "EJB3 Specification 14.2.1" wrote:
              Application exceptions that are checked exceptions may be defined as such by being listed in the throws clauses of the methods of the bean's business interface, home interface, component interface, and web service endpoint.


              ?

              3) Is the metadata project merging annotations and XML into JBossAssemblyDescriptorMetaData, or do we have to scan for annotations separately?

              S,
              ALR


              • 4. Re: Add @ApplicationException to EJBContainer?
                starksm64

                 

                "ALRubinger" wrote:

                3) Is the metadata project merging annotations and XML into JBossAssemblyDescriptorMetaData, or do we have to scan for annotations separately?

                Yes, the annotation processing deployer merges the annotations into the deployment attachment metadata view. Once that is fully checked into trunk we need to start going through and removing the duplicate processing from the ejb3 deployers.


                • 5. Re: Add @ApplicationException to EJBContainer?
                  alrubinger
                  • 6. Re: Add @ApplicationException to EJBContainer?
                    wolfc

                    On hindsight this is completely out of style with the current implementation.

                    For now the implementation should be:

                    EJBContainer:

                    boolean isApplicationException(Exception e) {
                     return hasAnnotation(e, ApplicationException.class);
                    }


                    Ejb3DescriptorHandler:
                    void addApplicationException(...) {
                     'scan assembly descriptor and addAnnotation'
                    }


                    See addAssemblyAnnotations.

                    The EJBContainer.isApplicationException will always be the supported API.