1 2 Previous Next 21 Replies Latest reply on Feb 18, 2004 6:56 AM by adrian.brock Go to original post
      • 15. Re: Unification of invocation and interceptors

        So what would happen in the case of async invocations? Does the whole state contained in the invocation go across the wire, the interceptors stay in memory on the client, and when get the callback (with all it’s state), then returns back to interceptors that are waiting?

        • 16. Re: Unification of invocation and interceptors
          bill.burke

           

          "juha@jboss.org" wrote:
          "Bill Burke" wrote:

          I agree with Marc. 99% of use cases wil not want to chance the interceptor stack. try/catch simplifies the programming model.


          Try - finally simplicity is not a point (if - else achieves the same). Variable visibility for a <u>stateful</u> interceptor however is a good point.

          So we come back to the discussion of stateless vs. stateful interceptors. If state is needed, should it belong to the interceptor or to the invocation?


          For JBoss AOP it will not matter as it can be either way. In XML definitions of interceptors you will be able to define the scope of the interceptor. Whether an instance of the interceptor is created perVM, perClass, or perInstance. Currently you can get perVM and perClass because the framework provides a Factory plugin so you could pass in a pointer to an MBean if so desired. Aspects (classes that contain multiple advices) already work in this manner (defining allocation scope).

          In JBoss AOP intereptor state can also be stored in many different places. PerThread (in a threadlocal), PerInvocation (within the invocation object), PerInstance (within the Object itself), perClassMethod (metadata about the class), perClass(default data for the class). The interceptor asks the invocation to resolve state (metadata) and the invocation resolves it based on the context of the invocation, looking in each of the above "repositories". Eventually I want to add the ability to declare state/metadata defaults VM or Cluster wide, or even the ability to define Configuration Domains so you can define your own path to resolving.

          I hope myself or somebody eventually ports these ideas to JMX XMBean land.


          Should all interceptors be stateless and can be shared across POJO's (scalability). Or do we build stateful interceptors -- interceptor instance per POJO (very high number of instances even on a small interceptor stack if a lot of POJO's are instrumented).


          It should be fully flexible.


          What you're arguing for (or marc) is an interceptor instance per POJO (when stateful). However, intuition says keep everything stateless as much as possible (that is, let state live within an invocation -- like HTTP -- but the server should remain stateless).


          The instance scope has nothing to do whether you have different IN/OUT interceptor chains.


          Should there be a distinction in the interfaces between stateless and stateful interceptors (for instance, the Interceptor and SharedInterceptors that exist in the JMX base)? Do we always require a stack of interceptor instance per POJO?


          Fully flexible. It is this flexible in JBoss AOP as there is interceptor chains defined for each Class and you can also add interceptors at the instance, per POJO, level. For perClass defined interceptor chains, Aspects already support having the scope of the Aspect instance perVM, perClass, or perInstance. I just haven't ported it to work with interceptors yet. Again, I want this flexiblity in the JMX MBean level.

          Bill

          • 17. Re: Unification of invocation and interceptors
            bill.burke

             

            "juha@jboss.org" wrote:
            Thinking about it a little further, even the TX interceptor case state is only meaningful for the lifetime of that invocation. Keeping the state around in memory of the server when there is no ongoing invocation seems a little wasteful.

            Consider for instance a POJO I've instrumented as transactional. This POJO gets invoked once a week. Why should I keep the state of that transactional interceptor in memory on my server for a whole week if I only need it for few milliseconds once a week. For such a case it would make sense (from resource usage point of view) to have a stateless TX interceptor and hold that state in memory for the few milliseconds it takes to invoke my POJO.

            With EJB we did not have this issue as the interceptor stack was per container, not per object identity.

            Stateful implementations are usually easier to implement than stateless though. However, people have managed to build easy-to-use APIs on top of stateless HTTP invocations (Servlet API) that hides the complexity from the developer so why could we not do the same? Is implementing servlet Filters difficult, do we need a different model from that?




            Again, I don't think this is an either/or proposition.

            Bill

            • 18. Re: Unification of invocation and interceptors
              bill.burke

               

              "telrod" wrote:
              So what would happen in the case of async invocations? Does the whole state contained in the invocation go across the wire, the interceptors stay in memory on the client, and when get the callback (with all itÂ’s state), then returns back to interceptors that are waiting?


              Interesting question. The way I have it working in JBoss AOP, is that metadata(state) can have Payload attributes attached to them, whether they are TRANSIENT, AS-IS, or MARSHALLED (ya know, the current stuff in 3.2). When an invocation goes across the wire it squishes, mashes the different Metadata domains together into the Invocation object's payload before sending out across the wire. So Thread, Invocatoin, and Instance data is squished and sent across. Hope I am explaining this well!!!!

              Bill

              • 19. Re: Unification of invocation and interceptors

                Sure. Really trying to understand how the client side part of the interceptor stack will be maintained when making an async call that is waiting on a callback.

                Scenario would be walk through the interceptor chain and make async call and then return back up the interceptor chain. Then server makes callback on the client. Does the callback on the client have any visibility to the original invocation's interceptor chain?

                • 20. Re: Unification of invocation and interceptors

                  Whether an instance of the interceptor is created perVM, perClass, or perInstance. Currently you can get perVM and perClass because the framework provides a Factory plugin so you could pass in a pointer to an MBean if so desired.

                  So what is the semantics of Invocation.invokeNext(newInterceptors[]) in case of a shared interceptor?

                  • 21. Re: Unification of invocation and interceptors

                    invokeNext(newInterceptors[]) is a kludge I put it for remoting to work correctly.
                    Without it, it used the wrong stack when it got to the server pojo.

                    It needs to be redone properly, when we've defined how one "container" hands
                    an invocation to another one and restores the original state when it returns.

                    Regards,
                    Adrian

                    1 2 Previous Next