9 Replies Latest reply on Apr 28, 2010 11:48 AM by Pete Muir

    producing instance to alternate scope

    Arbi Sookazian Master

      So in Seam 2.x we are able to outject to any scope we want (wider spanning or shorter spanning).  So let's say the current Seam component is conversation-scoped, we could outject an object into session scope via:


      @Out(scope=ScopeType.SESSION)


      http://docs.jboss.org/seam/2.2.1.CR1/api/org/jboss/seam/annotations/Out.html


      In Weld, outjection is prohibited but simulated via @Produces annotation.


      http://java.sun.com/javaee/6/docs/api/index.html?javax/enterprise/inject/Produces.html



      A producer method is a method that acts as a source of bean instances. The method declaration itself describes
      the bean and the container invokes the method to obtain an instance of the bean when no instance exists in the
      specified context. A producer method lets the application take full control of the bean instantiation process.

      So what if in a Weld or Seam 3 app we need to outject from conversation-scoped managed bean or session bean to session scope?  Is this strictly prohibited?  If yes, then we'd have to subsequently manually set the object in the HttpSession.  There must be some valid use cases for this...