1 Reply Latest reply on Aug 20, 2009 10:16 PM by asookazian

    ByPassInterceptors on Which Methods and Class

    ambrish_kumar

      Hi Everyone,


      I want to know that on which methods and class , we should apply @ByPassInterceptors.


      One more question :


      Which one should be used for improving performance.


      @In


      OR


      Component.getInstance();


      Thanks


      Ambrish

        • 1. Re: ByPassInterceptors on Which Methods and Class
          asookazian

          Performance can be improved if you substitute dynamic injection (@In) with a static getter (Component.getInstance(Foo.class)).


          Search the Seam core classes for examples on when/how to use @BypassInterceptors.


          You can use it for methods/classes that do not make use of Seam interceptors for bijection, etc.


          Just remember that injection for all @In annotated member variables in a component occurs prior to invocation of each and every business method.  It is very possible in some cases that a particular business method does not need dynamic injection of all the member variables prior to its invocation each time, possibly because it is not referencing any of those variables, for example.  In that case, you annotate that particular method using @BypassInterceptors.


          AFAIK, it is not yet possible in Seam to configure a subset of @In member variables to be injected prior to an invocation of method foo().  They're all injected prior to every business method invocation.  Which in my book is overkill and inefficient.


          From SiA:


          Since bijection is provided by a method interceptor, you can avert bijection by disabling
          the interceptors on a single method or on the entire component. You instruct
          Seam not to apply interceptors by adding the @BypassInterceptors annotation, summarized
          in table 6.6, at the class or method level. The method-level annotation is a
          good way to optimize one area of the code without cutting out the benefits of interceptors
          from the component as a whole.
          Unfortunately, if you disable interceptors, you end up stripping away all the other interceptor-
          based functionality, not only bijection. Such features include declarative conversation
          controls, transaction management, and event handling, to name a few. Just be
          aware that by disabling interceptors, you may get more than you bargained for.