7 Replies Latest reply on Jan 12, 2005 6:15 PM by Juha Lindfors

    lifecylde api?

    Bill Burke Master

      Is there a lifecyle API? I couldn't find one at first glance.

      May I suggest the following API?

      create
      start
      stop
      destroy

      I know a bunch of mbeans that require 2 phase initialization and 2 phase shutdown

      suspend
      resume

      suspend would be called on the bean if one of its dependencies is being redeployed. Resume is called when all the dependencies are resolved. Having this type of event mechanism would allow pluggable containers to have a valve of their own design.

      Bill

        • 1. Re: lifecylde api?
          Adrian Brock Master

          No it is not implemented yet.

          In fact, some like the EJB container do a form three phase startup.

          You'll find there are three reasons for two phase startup.

          1) Need to lookup/use something from a different service which won't be in a useful
          state until it has been started.

          2) Need to do something beyond basic config, e.g. bind to jndi or a server socket.

          3) Similar to (1) and (2): do some of registry processing, e.g. a jms queue
          does destinationManger.addQueue() during start.

          All these are planned to be replaced by microcontainer aspects
          1) Dependency Injection
          2) Externalization of configuration:

          <bean name="whatever" .../>
          <bean name="whatever.jndi" bean="JNDIBinding">
           <attribute name="target"><depends name="whatever"/></attribute>
           <attribute name="jndiName">some/context/whatever</attribute>
          </bean>
          

          3) This is an aspect of the reverse dependency processing:
          <bean name="queue">
          ...
           <reverse-dependency name="destinationManager" method="addQueue"/>
          </bean>
          

          which means when queue is fully available do destinationManager.addQueue(this);

          • 2. Re: lifecylde api?
            Adrian Brock Master

            Additionally, the lifecycle will be implemented for backwards compatibility,
            but it will more flexible so you don't have to extend JBoss classes.

            There will be an implementation that does recognise the old jboss ServiceMBean
            rather than having to retrofit tags/xml config.

            @jboss.start
            public void bindToJNDI()
            {
            }
            @jboss.stop
            public void unbindToJNDI()
            {
            }
            


            More frequently, it will not need dependency processing on other beans.
            Instead it just wants to do what create() gives you. i.e. all config parameters
            have been set so do some additional processing:
            @jboss.afterInjection
            public void getGo()
            {
            }
            


            • 3. Re: lifecylde api?
              Ivelin Ivanov Expert

              reverse-dependency is a misleading term. The queue cannot be added before DestinationManager is available, so it is like normal dependency. On the other hand the DestManager does not really need the Queue in order to init and start. Maybe <reverse-inject>? It communicates that there is no tight dependency between the two beans, but they still work together.

              • 4. Re: lifecylde api?
                Adrian Brock Master

                I called it reverse-dependency because you are specify a dependency
                but it works the other way around.

                Instead of,
                depends:The Queue needs a DestinationManager
                you write
                reverse-depends The Queue should active the DestinationManager
                if it is not already active.

                This enables the on-demand/manual startup configuration.
                i.e. don't bootstrap JMS unless there are queue deployments.

                You are correct, that I do want to extend the idea to areas where it is not
                a strict dependency, more of a relationship.

                • 5. Re: lifecylde api?
                  Juha Lindfors Master

                  So call it "activate"... what with this "reverse" stuff, anyway? ;-)

                  • 6. Re: lifecylde api?
                    Adrian Brock Master

                    Humpty dumpty :-)

                    • 7. Re: lifecylde api?
                      Juha Lindfors Master

                      No, the right answer would have been: obfuscation is good for the services business ;-)