AOP controlled lifecycle (Was Re: [jboss-dev] @JMX and @DisableAOP live happily together_

Jason T. Greene jason.greene at redhat.com
Mon May 18 14:42:57 EDT 2009


It seems the other reason we are doing this, is to filter classes based 
on a pointcut expression. The problem is that 99% of the time our 
pointcuts look like this:

classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX">

So we are pulling in AOP's complex pattern matching mechanism, and 
complex class scanning logic, when all we need is:

if (map.contains(annotation))

Jason T. Greene wrote:
> Unsurprisingly I agree :) Even looking at the code it seems the only 
> reason this is using AOP is to get a lifecycle callback on install. Why 
> can't we just expand the already existing incallback to optionally pass 
> a BeanMetaData instance?
> 
> David M. Lloyd wrote:
>> OK, it seems like I had made a mistake in my test of this.
>>
>> But there's really no reason to use AOP for this kind of thing.  AOP 
>> is no replacement for proper API design.  In fact it appears that AOP 
>> is one of the big contributors to our slow MC startup time [1].  The 
>> best way to implement handling of @JMX is with a simple deployment 
>> lifecycle listener which gets an instance of the bean and its 
>> metadata, and looks for a @JMX annotation.  Why is AOP needed for this 
>> trivial problem?
>>
>> - DML
>>
>> [1] http://www.jboss.org/index.html?module=bb&op=viewtopic&t=155244 
>> which is really what this is all about
>>
>> On 05/18/2009 12:19 PM, David M. Lloyd wrote:
>>> As far as I'm aware, MBeans don't normally have lifecycle methods 
>>> outside of the methods on f.e. MBeanRegistration or PersistentMBean 
>>> or whatever (in other words, managed by the MBeanServer and not the 
>>> MC).  If the bean's mbean view is being registered to the 
>>> MBeanServer, what else could it be doing that it's not?
>>>
>>> The idea that @JMX doesn't work with @DisableAOP was (iirc) the 
>>> primary argument against having AOP disabled by default, but it seems 
>>> to me that this is not true.
>>>
>>> - DML
>>>
>>> On 05/18/2009 10:51 AM, Kabir Khan wrote:
>>>> Looks like a user error ;-) Or are you saying it actually invokes 
>>>> the lifecycle callback in this case?
>>>> On 18 May 2009, at 17:40, David M. Lloyd wrote:
>>>>
>>>>> So why should @DisableAOP be the annotation with enabling AOP being 
>>>>> the default?
>>>>>
>>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>>>
>>>>> <deployment xmlns="urn:jboss:bean-deployer:2.0">
>>>>>    <bean name="TestBean" 
>>>>> class="javax.management.monitor.GaugeMonitor">
>>>>> <annotation>@org.jboss.aop.microcontainer.annotations.DisableAOP()</annotation> 
>>>>>
>>>>> <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(exposedInterface=javax.management.monitor.GaugeMonitorMBean,name="test:name=Banana",registerDirectly=false)</annotation> 
>>>>>
>>>>>    </bean>
>>>>> </deployment>
>>>>>
>>>>> - DML
>>>>> _______________________________________________
>>>>> jboss-development mailing list
>>>>> jboss-development at lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/jboss-development
>>>>
>>>> _______________________________________________
>>>> jboss-development mailing list
>>>> jboss-development at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/jboss-development
>>>
>> _______________________________________________
>> jboss-development mailing list
>> jboss-development at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/jboss-development
> 
> 


-- 
Jason T. Greene
JBoss, a division of Red Hat



More information about the jboss-development mailing list