1 Reply Latest reply on Jun 15, 2011 7:49 AM by alin.heyoulin.qq.com

    Turning an object into managed bean?

    ozizka

      Hi,


      I have a CDI bean in a Java SE app.
      It has a method which currently looks like this:


         public void initModule( Foo foo ) {
            this.fooWrap = new FooWrap( foo );
         }
      



      I want fooWrap to be a managed bean (basically, I need injection to happen in it).
      What are the options?
      Which one is the best?


      Currently I have done this:


         @Inject Instance<FooWrap> fooWrapInst;
      
         public void initModule( Foo foo ) {
            this.fooWrap = fooWrapInst.get();
            this.fooWrap.setFoo( foo );
         }
      



      which works but is kinda verbose and I am looking for better.


      Thanks,
      Ondra