[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Lifecycle aspects revisited
kabir.khan@jboss.com
do-not-reply at jboss.com
Tue Mar 6 07:23:27 EST 2007
http://jira.jboss.com/jira/browse/JBMICROCONT-154
I should be ready to commit something later today - question is to which branch?
What we have is a new LifecycleCallbackMetaData which gets populated by the DescribeAction + AOPDependencyBuilder. It does not really use AOP much for anything other than the matching of the classes pointcuts. These lifecycle callbacks are then added to the BeanMetaData.
I've modified KernelControllerContextAction install/uninstall to look for lifecycle callback metadata and if this exists to invoke the callbacks.
It is configured as follows
| <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0"
| name="DependencyAdvice"
| class="org.jboss.aop.microcontainer.aspects.jmx.JMXLifecycleCallback"
| classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX">
| <property name="mbeanServer"><inject bean="MBeanServer"/></property>
| </aop:lifecycle-configure>
|
Which translates to
| <bean name="DependencyAdvice" class="org.jboss.aop.microcontainer.aspects.jmx.JMXLifecycleCallback">
| <property name="mbeanServer"><inject bean="MBeanServer"/></property>
| </bean>
|
| <bean name="DependencyAdvice$Binding" class="org.jboss.aop.microcontainer.beans.LifecycleBinding">
| <property name="callbackBean">DependencyAdvice</property>
| <property name="manager"><inject bean="AspectManager"/></property>
| <property name="classes">@org.jboss.aop.microcontainer.aspects.jmx.JMX</property>
| <property name="state">Configured</property>
| </bean>
|
|
The callbacks are no longer "interceptors", so there is no chain, and by default it will look for methods called install and uninstall. Callback methods must take the KernelControllerContext as a parameter:
| public class JMXLifecycleCallback
| {
| private MBeanServer server;
|
| public void setMbeanServer(MBeanServer server)
| {
| this.server = server;
| }
|
| public void install(KernelControllerContext context) throws Exception
| {
| JMX jmx = readJmxAnnotation(context);
| ObjectName objectName = createObjectName(context, jmx);
|
| //register in jmx
| }
|
| public void uninstall(KernelControllerContext context) throws Exception
| {
| JMX jmx = readJmxAnnotation(context);
| ObjectName objectName = createObjectName(context, jmx);
|
| //unregister in jmx
| }
|
| private JMX readJmxAnnotation(KernelControllerContext context) throws Exception
| {
| if (context.getMetaData() != null)
| {
| return context.getMetaData().getAnnotation(JMX.class);
| }
| return null;
| }
|
| private ObjectName createObjectName(KernelControllerContext context, JMX jmx) throws Exception
| {
| ...
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4025364#4025364
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4025364
More information about the jboss-dev-forums
mailing list