3 Replies Latest reply on Jan 6, 2014 12:57 PM by wdfink

    Reset EJB 'slsb' pool : force reinject ESB instances

    pleutre

      Hi all,

       

      We use @Inject on our @Stateless beans to load configuration. It works well with a @Producer to inject configuration parameters.

       

      But, the already instantiated EJB are not reinjected (logical after all) and are not aware of the new configuration.

       

      Any way to reset the stateless session bean pool ?

      I took a look in the code, StrictMaxPool do not have reset method, yeah...

       

      If you have a better idea than add my own pool (if possible) that will have reset and that will be accessible from my application...

       

      I know it's a kind of hack for the Container architecture but I need this functionnality.

       

      Regards,

       

      P.

        • 1. Re: Reset EJB 'slsb' pool : force reinject ESB instances
          wdfink

          Did you load the configuration from the filesystem? This is against the EJB specification.

           

          Anyway, If you inject a EJB it will have the same lifecycle as the injection target. It depends on the method how you initialize the configuration.

          If you use @PostConstruct that mean after the container creates the EJB and it will not be done again. Only if the container does not pool both instances the EJB will be created and destroyed every invocation.

          That might help, but may cause performance issues.

           

          Other option, which is against the spec, is to check a timestamp whether the configuration is out of date.

          • 2. Re: Reset EJB 'slsb' pool : force reinject ESB instances
            pleutre

            Hi,

            Sorry for delay, vacation was welcome

             

            1) my configuration is loaded from database. I think it's authorized.

            2) I use @Inject on private attribute from the EJB instance, I understand that this injection is done only once per instance.

            Example :

             

            @Inject
            @Configurable
            @ConfigurableOptions(...)
            private Integer maxResultForSearch;

             

            3) even if I could use timestamp, I don't see how to force JBoss to destroy a particular EJB instance which could be "timed-out".

             

            Anyway, thanks for your reply

             

            • 3. Re: Reset EJB 'slsb' pool : force reinject ESB instances
              wdfink

              From the EJB specification the container is responsible to create and destroy the Bean.

              You could not have contol for this.