4 Replies Latest reply on May 15, 2007 2:25 PM by alesj

    disable lifecycle method calling for bean?

    kibbles

      Let's say I have a bean that just happens to have a method that matches one of the default lifecycle methods: create/destroy start/stop. How do I prevent the kernel from calling one of these methods when installing my bean in the container? My bean needs to implement an interface that has a create() method, but I don't want it being called by the kernel, but rather by clients of my bean. Do I have to add a child element with a bogus method name? It would be nice if there was either an annotation or an attribute on the lifecycle element (e.g. ignore="true") that supported this.

        • 1. Re: disable lifecycle method calling for bean?
          alesj

          Good point.
          I think it was once on my mind.
          I'll add it as a TODO - watch JIRA JBMICROCONT-23.
          For the moment do a bogus method name - and let me know me know how it goes.

          • 2. Re: disable lifecycle method calling for bean?
            kibbles

            Thanks for the quick response. I was hoping I was just missing something obvious. Looking at the code inside LifecycleAction, it looks like if I give a bogus method name, the exception will be eaten and logged, so that should be viable workaround until a cleaner solution is available.

            • 3. Re: disable lifecycle method calling for bean?
              alesj

               

              "kibbles" wrote:
              Looking at the code inside LifecycleAction, it looks like if I give a bogus method name, the exception will be eaten and logged, so that should be viable workaround until a cleaner solution is available.

              Yes. :-)
               try
               {
               ClassLoader cl = Configurator.getClassLoader(metaData);
               joinpoint = configurator.getMethodJoinPoint(info, cl, method, parameters, false, true);
               }
               catch (JoinpointException ignored)
               {
               if (trace)
               {
               if (parameters == null)
               log.trace("No " + method + " method for " + context);
               else
               log.trace("No " + method + parameters + " method for " + context);
               }
               return;
               }
              


              Will look at this issue ASAP.

              • 4. Re: disable lifecycle method calling for bean?
                alesj

                Done.
                It's commited in the trunk, together with test cases.