This content has been marked as final.
Show 7 replies
-
1. Re: Emulating ServiceMBeanSupport
alesj Jul 22, 2007 6:11 AM (in response to genman)"genman" wrote:
I'd like to also intercept calls to the method "getState()" and return the Microcontainer state. Or, I'd like to "inject" state somehow.public class MyService { @InjectState State state; public State getState() { return state; } }
Just added new feature:<inject fromContext="getState" />
will do the job. ;-)
Follow this post for more info:
http://www.jboss.org/index.html?module=bb&op=viewtopic&t=113340&start=20 -
2. Re: Emulating ServiceMBeanSupport
alesj Jul 23, 2007 4:55 AM (in response to genman)"alesj" wrote:
Just added new feature:<inject fromContext="getState" />
will do the job. ;-)
But this is useless, since you'll only get this injected at the whenRequired state - which you can 'tell' in advance. ;-)
Perhaps use one of the [State]KernelControllerContextAware interfaces to get the ref to underlying KernelControllerContext. -
3. Re: Emulating ServiceMBeanSupport
alesj Jul 23, 2007 5:00 AM (in response to genman)"genman" wrote:
In JBoss 5.0 some of the state management is handled by the Microcontainer. But a lot is still handled by the ServiceController.
All of the state management is handled by MC, ServiceController is just a facade over MC - see actual code for more details: http://anonsvn.jboss.org/repos/jbossas/trunk/system-jmx/src/main/org/jboss/system/ServiceController.java -
4. Re: Emulating ServiceMBeanSupport
alesj Jul 23, 2007 5:02 AM (in response to genman)"genman" wrote:
When I write my Interceptor, how do I know if the Microcontainer is calling me due to Lifecycle transition, or the call is from "somebody else"?
You can always check the current execution stack. :-) -
5. Re: Emulating ServiceMBeanSupport
genman Jul 23, 2007 3:24 PM (in response to genman)"alesj" wrote:
All of the state management is handled by MC, ServiceController is just a facade over MC - see actual code for more details: http://anonsvn.jboss.org/repos/jbossas/trunk/system-jmx/src/main/org/jboss/system/ServiceController.java
What I see doesn't seem to be a light facade. The old states are really independent from the new ones. The new ones don't match exactly to the old, which means the ServiceController has to track state separately in a ServiceContext object. There's a bit of book keeping involved. I could probably live with the new state list, though it's a little odd the state names don't correspond to the methods that are actually called during the transitions.You can always check the current execution stack. :-)
-
6. Re: Emulating ServiceMBeanSupport
genman Jul 23, 2007 3:26 PM (in response to genman)You can always check the current execution stack. :-)
This feels like a hack, hence the smiley ...
I might be better off creating a central service controller that users would use to stop/start services by name. Exposing stop/start as MBean operations seems logical, but if there isn't a clean way to detect who's calling stop(), I probably should avoid this approach.
Could you point me to some examples on how to construct a method interceptor in the -beans.xml format, for beans marked with annotations? In case I change my mind again.<inject fromContext="getState" />
Also: Is there a way to inject "beaninfo" using annotations? I'd rather not have to copy the same injection XML for every declaration. :-) -
7. Re: Emulating ServiceMBeanSupport
alesj Jul 24, 2007 2:20 AM (in response to genman)"genman" wrote:
Could you point me to some examples on how to construct a method interceptor in the -beans.xml format, for beans marked with annotations? In case I change my mind again.
http://anonsvn.jboss.org/repos/jbossas/projects/microcontainer/trunk/docs/gettingstarted/src/docbkx/en/modules/aop.xml"genman" wrote:
Also: Is there a way to inject "beaninfo" using annotations? I'd rather not have to copy the same injection XML for every declaration. :-)<inject fromContext="beaninfo" />
The annotation support is just on its way.