2 Replies Latest reply on May 6, 2010 1:52 PM by umajeric

    Seam 2.x components in Weld

    umajeric

      How to get those behaviours in Weld:


      Contexts.isSessionContextActive()




      Component.getInstance(clazz, ScopeType.SESSION)
      Component.getInstance("componentName")




      What about for example in Theme.java (Seam 2.2)


          public static ThemeSelector instance() {
              //beanManager has to be static!
              if (!Contexts.isSessionContextActive()) {
                  throw new IllegalStateException("No active session context");
              }
              return (ThemeSelector) Component.getInstance(ThemeSelector.class, ScopeType.SESSION);
          }



      is it possible to inject static BeanManager:


      @Inject static BeanManager beanManager;



      Thanks, Uros

        • 1. Re: Seam 2.x components in Weld
          pmuir

          Uros Majeric wrote on May 06, 2010 09:15:


          How to get those behaviours in Weld:

          Contexts.isSessionContextActive()




          try {
             beanManager.getContext(SessionScoped.class);
          } catch (ContextNotActiveException e) {
             return false;
          }
          return true;




          Component.getInstance(clazz, ScopeType.SESSION)




          @Inject Instance<Object> instance;
          
          instance.get(clazz);




          Component.getInstance("componentName")




          Not really relevant, components don't have names



          is it possible to inject static BeanManager:

          @Inject static BeanManager beanManager;



          Thanks, Uros



          No.

          • 2. Re: Seam 2.x components in Weld
            umajeric

            thank you...


            Uros