Thanks Cyrille ... that's along the line of what I was literally just about to do!! :)
On Thu, Feb 19, 2009 at 1:55 PM, Cyrille Le Clerc <[email protected]> wrote: > > Here is an implementation of InstrumentManager that relies on a Spring > MbeanExporter. > > Hope this helps, > > Cyrille > > SPRING CONFIGURATION > ================= > > <bean id="org.apache.cxf.management.InstrumentationManager" > class="com.mycompanie.cxf.management.jmx.InstrumentationManagerImpl"> > <property name="bus" ref="cxf" /> > <property name="mbeanExporter"> > <bean class="org.springframework.jmx.export.MBeanExporter"> > <property name="autodetect" value="false" /> > <property name="server" ref="mbeanserver" /> > </bean> > </property> > </bean> > > JAVA CODE > ======= > > import javax.annotation.PostConstruct; > import javax.annotation.Resource; > import javax.management.JMException; > import javax.management.MBeanServer; > import javax.management.ObjectName; > > import org.apache.cxf.Bus; > import org.apache.cxf.bus.ManagedBus; > import org.apache.cxf.management.InstrumentationManager; > import org.apache.cxf.management.ManagedComponent; > import org.apache.log4j.Logger; > import org.springframework.beans.factory.InitializingBean; > import org.springframework.jmx.export.MBeanExporter; > import org.springframework.util.Assert; > > /** > * Spring {...@link MBeanExporter} based implementation of CXF {...@link > InstrumentationManager}. > * Out of the box {...@link > org.apache.cxf.management.jmx.InstrumentationManagerImpl} creates a > dedicated {...@link MBeanServer} associated with agentId "org.apache.cxf" > * @author <a href="mailto:[email protected]">Cyrille Le Clerc</a> > */ > public class InstrumentationManagerImpl implements InstrumentationManager, > InitializingBean { > > private static final Logger logger = > Logger.getLogger(InstrumentationManagerImpl.class); > > private Bus bus; > > protected MBeanExporter mbeanExporter; > > public void afterPropertiesSet() throws Exception { > Assert.notNull(this.mbeanExporter, "mbeanExporter can NOT be null"); > } > > public Bus getBus() { > return bus; > } > > public MBeanServer getMBeanServer() { > return mbeanExporter.getServer(); > } > > @PostConstruct > public void register() { > if(logger.isDebugEnabled()) { > logger.debug(getClass() + "-postconstruct"); > } > if (null != bus) { > bus.setExtension(this, InstrumentationManager.class); > ManagedBus mbus = new ManagedBus(bus); > //mbeanExporter.registerManagedResource(mbus); > } > } > > public ObjectName register(ManagedComponent managedComponent) throws > JMException { > ObjectName name = register(managedComponent, false); > > return name; > } > > public ObjectName register(ManagedComponent managedComponent, boolean > forceRegistration) throws JMException { > ObjectName name = managedComponent.getObjectName(); > register(managedComponent, name, forceRegistration); > > return name; > } > > public void register(Object obj, ObjectName name) throws JMException { > register(obj, name, false); > } > > /** > * TODO handle forceRegistration == true > */ > public void register(Object obj, ObjectName name, boolean > forceRegistration) throws JMException { > if (logger.isDebugEnabled()) { > logger.debug("register object=" + obj + ", objectName=" + name + > ", forceRegistration=" + forceRegistration + ")"); > } > mbeanExporter.registerManagedResource(obj, name); > } > > @Resource(name = "cxf") > public void setBus(Bus bus) { > this.bus = bus; > } > > public void setMbeanExporter(MBeanExporter mbeanExporter) { > this.mbeanExporter = mbeanExporter; > } > > public void shutdown() { > } > > public void unregister(ManagedComponent component) throws JMException { > throw new UnsupportedOperationException(); > } > > public void unregister(ObjectName name) throws JMException { > throw new UnsupportedOperationException(); > } > > } > > > On Thu, Feb 19, 2009 at 10:30 AM, Adrian C <[email protected]>wrote: > > > > > Hi, > > > > I am hoping to used CXF's JMX's instrumentation and from the quick look > > that > > I had a this there does not seem to be an out of the box way to integrate > > with an existing MBeanServer. The only way that I can see to do this is to > > override the InstrumentationManagerImpl init's method ... > > > > Am I mistaken in this? Is there another way to do this? > > > > Thanks > > -- > > View this message in context: > > http://www.nabble.com/CXF-JMX-Intstrumentation-tp22096753p22096753.html > > Sent from the cxf-user mailing list archive at Nabble.com. > > > >
