3 Replies Latest reply on Jun 23, 2009 7:34 PM by musketyr

    Conversation demarcation

    gonorrhea

      Seam has @Begin and @End to declaratively demarcate LRC promotion and demotion.  299 does not.  So in Web Beans you can instead programmatically begin and end conversations.



      To promote the conversation associated with the current request to a long-running conversation,
      call the begin() method from application code. To schedule the current long-running conversation
      context for destruction at the end of the current request, call end().

      Why were the Seam annotations not included in 299?  And what about beginning a conversation for a particular page from the pages.xml (which I guess is Seam specific)?  Is there an equivalent to that in Web Beans?

        • 1. Re: Conversation demarcation
          nickarls

          Those are convenience stuff that should be handled by frameworks built on top of 299.

          • 2. Re: Conversation demarcation
            musketyr
            I think this could by well done by two simple interceptors:

            @InterceptorBindingType
            @Target({METHOD, TYPE})
            @Retention(RUNTIME)
            public @interface ConversationBegin {
              @NonBinding String id() default "";
              @NonBinging long timeout() default 0;
            }

            @ConversationBegin @Interceptor ConverstaionBeginInterceptor {
              @Current Conversation conversation;

              @AroundInvoke public Object conversationBegin(InvocationContext ctx){
                ConversationBegin begin = ctx.getMethod().getAnnotation(ConversationBegin.class);
                if("".equals(begin.id()){
                  conversation.begin(begin.id());
                } else {
                  conversation.begin();
                }
                if(begin.timeout() != 0){
                  conversation.setTimeout(begin.timeout());
                }
                ctx.proceed();
              }
            }

            @InterceptorBindingType
            @Target({METHOD, TYPE})
            @Retention(RUNTIME)
            public @interface ConversationEnd {}

            @ConversationEnd @Interceptor ConverstaionEndInterceptor {
              @Current Conversation conversation;

              @AroundInvoke public Object conversationEnd(InvocationContext ctx){
                ctx.proceed();
                conversation.end();
              }
            }

            It would be fine to have this interceptors built in web beans standard.

            It would be also fine to have some way how to have interceptors enabled by default. e.g. autoenable property of InterceptorBindingType but it could break the interceptor contract with container :(
            • 3. Re: Conversation demarcation
              musketyr

              I've missed returning ctx.proceed() value :(
              sorry