You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by "Soltysik, Seumas" <Se...@iona.com> on 2007/02/26 17:11:38 UTC

Dynamically deploying interceptors via JMX

I would like to expose the various InterceptorProviders (Bus, Service, Endpoint) as MBeans and provide methods on these MBeans to dynamically deploy interceptors into these providers. In order to do this, I need a mechanism to instantiate an interceptor before adding it to the provider. Now I could pass in a classname to the MBean [BusMBean.addInterceptor(classname)] and instantiate the interceptor that way but that seems lame. A better way would be if I could get a handle on the Spring BeanFactory used to create other CXF objects and use it as a factory for creating dynamic interceptors. So instead of using a classname to instantiate an object, I could simply use a spring id to get a handle on the desired interceptor. I am think that a user could specify their interceptor bean in the cxf*.xml file used to configure the bus and later reference the bean using the id.
Is it possible to get a handle on the BeanFactory used to load Bus configuration? Is this a reasonable approach?
Regards,
Seumas

RE: Dynamically deploying interceptors via JMX

Posted by "Soltysik, Seumas" <Se...@iona.com>.
What I want to do is add a wrapper around the Bus and expose this wrapper as a managed bean. The managed bean would have the addInInterceptor(Id)/addOutInterceptor(Id) methods on it and would create/fetch the inteceptor and add it to the Bus InterceptorProvider. So to be able to use the Spring BeanFactory for accessing beans this wrapper would need a handle to the ApplicationContext.

-----Original Message-----
From: Dan Diephouse [mailto:dan@envoisolutions.com]
Sent: Tuesday, February 27, 2007 10:59 AM
To: cxf-dev@incubator.apache.org
Subject: Re: Dynamically deploying interceptors via JMX


So you want the Bus to have the addInterceptor(id) method? Or would that be
the function of the instrumentationManager? It would seem rather odd to me
to have the former. If its the later, you could just make the
InstrumentationManager ApplicationContextAware, no? (of course I probably
don't understand all the ins and outs quite yet...)

- Dan

On 2/26/07, Soltysik, Seumas <Se...@iona.com> wrote:
>
> Hi Dan,
> In order to use the ApplicationContextAware mechanism, the object I am
> instrumenting would have to created by Spring itself which is not
> necessarily the case.
> Here is what I would like to do:
> 1)Expose the Bus as an MBean. In the CXFBusImpl constructor, construct an
> MBeanWrapper around the Bus and register it with the InstrumentationManager.
> This BusMBeanWrapper would have a addInterceptor(String id) method on it. It
> would be nice if this wrapper had a handle to the ApplicationContext which
> was used to create the Bus. However, since the Bus itself is not
> ApplicationContextAware, I am not sure how to do this.
> 2)Users call addInterceptor(String id) on Bus MBean. This id is used to
> lookup interceptor from ApplicationContext so that if this method is called
> several times, the same interceptor is always used for the given ID.
>
> For starters, users would have to define any interceptors that they
> expected to use in the bean.xml file used to configure the Bus. Later on
> we could make such that Interceptors beans could be specified at runtime.
> Seumas
>
> -----Original Message-----
> From: Dan Diephouse [mailto:dan@envoisolutions.com]
> Sent: Monday, February 26, 2007 12:33 PM
> To: cxf-dev@incubator.apache.org
> Subject: Re: Dynamically deploying interceptors via JMX
>
>
> In your JMX component you could implement ApplicationContextAware which
> will
> give you a handle on the ApplicationContext.
>
> What if the interceptor isn't previously defined in an XML file? For
> example, lets say I want to add a logging interceptor. I would have to
> have
> it predefined in my beans.xml then, right?
>
> - Dan
>
> On 2/26/07, Soltysik, Seumas <Se...@iona.com> wrote:
> >
> > I would like to expose the various InterceptorProviders (Bus, Service,
> > Endpoint) as MBeans and provide methods on these MBeans to dynamically
> > deploy interceptors into these providers. In order to do this, I need a
> > mechanism to instantiate an interceptor before adding it to the
> provider.
> > Now I could pass in a classname to the MBean [BusMBean.addInterceptor
> (classname)]
> > and instantiate the interceptor that way but that seems lame. A better
> way
> > would be if I could get a handle on the Spring BeanFactory used to
> create
> > other CXF objects and use it as a factory for creating dynamic
> interceptors.
> > So instead of using a classname to instantiate an object, I could simply
> use
> > a spring id to get a handle on the desired interceptor. I am think that
> a
> > user could specify their interceptor bean in the cxf*.xml file used to
> > configure the bus and later reference the bean using the id.
> > Is it possible to get a handle on the BeanFactory used to load Bus
> > configuration? Is this a reasonable approach?
> > Regards,
> > Seumas
> >
>
>
>
> --
> Dan Diephouse
> Envoi Solutions
> http://envoisolutions.com | http://netzooid.com/blog
>



-- 
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog

Re: Dynamically deploying interceptors via JMX

Posted by Dan Diephouse <da...@envoisolutions.com>.
So you want the Bus to have the addInterceptor(id) method? Or would that be
the function of the instrumentationManager? It would seem rather odd to me
to have the former. If its the later, you could just make the
InstrumentationManager ApplicationContextAware, no? (of course I probably
don't understand all the ins and outs quite yet...)

- Dan

On 2/26/07, Soltysik, Seumas <Se...@iona.com> wrote:
>
> Hi Dan,
> In order to use the ApplicationContextAware mechanism, the object I am
> instrumenting would have to created by Spring itself which is not
> necessarily the case.
> Here is what I would like to do:
> 1)Expose the Bus as an MBean. In the CXFBusImpl constructor, construct an
> MBeanWrapper around the Bus and register it with the InstrumentationManager.
> This BusMBeanWrapper would have a addInterceptor(String id) method on it. It
> would be nice if this wrapper had a handle to the ApplicationContext which
> was used to create the Bus. However, since the Bus itself is not
> ApplicationContextAware, I am not sure how to do this.
> 2)Users call addInterceptor(String id) on Bus MBean. This id is used to
> lookup interceptor from ApplicationContext so that if this method is called
> several times, the same interceptor is always used for the given ID.
>
> For starters, users would have to define any interceptors that they
> expected to use in the bean.xml file used to configure the Bus. Later on
> we could make such that Interceptors beans could be specified at runtime.
> Seumas
>
> -----Original Message-----
> From: Dan Diephouse [mailto:dan@envoisolutions.com]
> Sent: Monday, February 26, 2007 12:33 PM
> To: cxf-dev@incubator.apache.org
> Subject: Re: Dynamically deploying interceptors via JMX
>
>
> In your JMX component you could implement ApplicationContextAware which
> will
> give you a handle on the ApplicationContext.
>
> What if the interceptor isn't previously defined in an XML file? For
> example, lets say I want to add a logging interceptor. I would have to
> have
> it predefined in my beans.xml then, right?
>
> - Dan
>
> On 2/26/07, Soltysik, Seumas <Se...@iona.com> wrote:
> >
> > I would like to expose the various InterceptorProviders (Bus, Service,
> > Endpoint) as MBeans and provide methods on these MBeans to dynamically
> > deploy interceptors into these providers. In order to do this, I need a
> > mechanism to instantiate an interceptor before adding it to the
> provider.
> > Now I could pass in a classname to the MBean [BusMBean.addInterceptor
> (classname)]
> > and instantiate the interceptor that way but that seems lame. A better
> way
> > would be if I could get a handle on the Spring BeanFactory used to
> create
> > other CXF objects and use it as a factory for creating dynamic
> interceptors.
> > So instead of using a classname to instantiate an object, I could simply
> use
> > a spring id to get a handle on the desired interceptor. I am think that
> a
> > user could specify their interceptor bean in the cxf*.xml file used to
> > configure the bus and later reference the bean using the id.
> > Is it possible to get a handle on the BeanFactory used to load Bus
> > configuration? Is this a reasonable approach?
> > Regards,
> > Seumas
> >
>
>
>
> --
> Dan Diephouse
> Envoi Solutions
> http://envoisolutions.com | http://netzooid.com/blog
>



-- 
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog

RE: Dynamically deploying interceptors via JMX

Posted by "Soltysik, Seumas" <Se...@iona.com>.
Hi Dan,
In order to use the ApplicationContextAware mechanism, the object I am instrumenting would have to created by Spring itself which is not necessarily the case. 
Here is what I would like to do:
1)Expose the Bus as an MBean. In the CXFBusImpl constructor, construct an MBeanWrapper around the Bus and register it with the InstrumentationManager. This BusMBeanWrapper would have a addInterceptor(String id) method on it. It would be nice if this wrapper had a handle to the ApplicationContext which was used to create the Bus. However, since the Bus itself is not ApplicationContextAware, I am not sure how to do this.
2)Users call addInterceptor(String id) on Bus MBean. This id is used to lookup interceptor from ApplicationContext so that if this method is called several times, the same interceptor is always used for the given ID.

For starters, users would have to define any interceptors that they expected to use in the bean.xml file used to configure the Bus. Later on we could make such that Interceptors beans could be specified at runtime.
Seumas

-----Original Message-----
From: Dan Diephouse [mailto:dan@envoisolutions.com]
Sent: Monday, February 26, 2007 12:33 PM
To: cxf-dev@incubator.apache.org
Subject: Re: Dynamically deploying interceptors via JMX


In your JMX component you could implement ApplicationContextAware which will
give you a handle on the ApplicationContext.

What if the interceptor isn't previously defined in an XML file? For
example, lets say I want to add a logging interceptor. I would have to have
it predefined in my beans.xml then, right?

- Dan

On 2/26/07, Soltysik, Seumas <Se...@iona.com> wrote:
>
> I would like to expose the various InterceptorProviders (Bus, Service,
> Endpoint) as MBeans and provide methods on these MBeans to dynamically
> deploy interceptors into these providers. In order to do this, I need a
> mechanism to instantiate an interceptor before adding it to the provider.
> Now I could pass in a classname to the MBean [BusMBean.addInterceptor(classname)]
> and instantiate the interceptor that way but that seems lame. A better way
> would be if I could get a handle on the Spring BeanFactory used to create
> other CXF objects and use it as a factory for creating dynamic interceptors.
> So instead of using a classname to instantiate an object, I could simply use
> a spring id to get a handle on the desired interceptor. I am think that a
> user could specify their interceptor bean in the cxf*.xml file used to
> configure the bus and later reference the bean using the id.
> Is it possible to get a handle on the BeanFactory used to load Bus
> configuration? Is this a reasonable approach?
> Regards,
> Seumas
>



-- 
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog

Re: Dynamically deploying interceptors via JMX

Posted by Dan Diephouse <da...@envoisolutions.com>.
In your JMX component you could implement ApplicationContextAware which will
give you a handle on the ApplicationContext.

What if the interceptor isn't previously defined in an XML file? For
example, lets say I want to add a logging interceptor. I would have to have
it predefined in my beans.xml then, right?

- Dan

On 2/26/07, Soltysik, Seumas <Se...@iona.com> wrote:
>
> I would like to expose the various InterceptorProviders (Bus, Service,
> Endpoint) as MBeans and provide methods on these MBeans to dynamically
> deploy interceptors into these providers. In order to do this, I need a
> mechanism to instantiate an interceptor before adding it to the provider.
> Now I could pass in a classname to the MBean [BusMBean.addInterceptor(classname)]
> and instantiate the interceptor that way but that seems lame. A better way
> would be if I could get a handle on the Spring BeanFactory used to create
> other CXF objects and use it as a factory for creating dynamic interceptors.
> So instead of using a classname to instantiate an object, I could simply use
> a spring id to get a handle on the desired interceptor. I am think that a
> user could specify their interceptor bean in the cxf*.xml file used to
> configure the bus and later reference the bean using the id.
> Is it possible to get a handle on the BeanFactory used to load Bus
> configuration? Is this a reasonable approach?
> Regards,
> Seumas
>



-- 
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog