Closed TuomasKiviaho closed 10 years ago
I only used AspectJ for private studies so far and I have no real idea about what you want to accomplish using AOP here. Can you show some pseudo-code or pattern that clarifies your thoughts? What cumbersome plumbing examples could we get rid of using AOP here? Thanks in advance for your input.
Sorry about not responding any time sooner. Mixin support of AspectJ removed all of the plumbing quite elegantly so I don't think it's worth declaring an optional aspectj dependency to your project since the solution was in the end so simple. I just leave the code here if someone else is considering AOP alternative.
@Aspect
public class JMXBeanWrapperAspect {
@DeclareMixin("!*Aspect")
public static DynamicMBean createMixin(Object instance) throws IntrospectionException, SecurityException {
return new JMXBeanWrapper(instance);
}
}
Thanks for the sorting,
Here's a BIT more trickier proposal involving aspects and possibly runtime weaving as well.
Utilization of JMXWrapper involves somewhat cumbersome plumbing in some situations and I propose an optional AOP solution to get rid of this.
AspectJ is a bit too big cannon for the job and ASM itself is a bit low level. In the middle, there is one http://jodd.org/doc/proxetta/ that bases itself upon ASM and doesn't leave marks of itself like some other libraries (javassist) would when used for poor mans AOP. CGLIB seems to a bit outdated.
I guess I'd be forced to declare my bean as abstract so that it would still implement DynamicMBean due to my setup but anyway I already asked if it would be possible to create a proxy so that it would declare the extra interface on-the-fly. This would drop the need for referencing javax.management.jmx packages alltogether (if one doesn't use Tabular/CompositeData etc.)
I might be able do a pull request for this one after I've played around with Proxetta myself.