0 Replies Latest reply on Feb 18, 2011 1:40 PM by Christian L.

    Observers for specific isntances

    Christian L. Newbie

      Hi,
      I'm using Weld SE for a simple swing application.
      I have the problem that I cannot force CDI to call an observer method on a specific instance.
      Instead it creates a new instance and calls the observer method on this one.
      Is there any way to get the Observer method called on  a specific instance(without @Singleton)?



      @Gui
      public class Dialog {
        protected Details details = new Details();//no injection
      
        public void listen(@Observes @Gui Something event) {
          details.handle(event);//details is null as cdi uses a new instance.
        }
      }
      
      @Gui
      public class Other {
        @Inject
        @Gui
        Event<Something> event;
      
        @Postconstruct 
        public void doIt() {
          event.fire(new Something());
        }
      }