Search in sources :

Example 51 with JMException

use of javax.management.JMException in project cxf by apache.

the class WorkQueueManagerImpl method setBus.

@Resource
public final void setBus(Bus bus) {
    this.bus = bus;
    if (null != bus) {
        bus.setExtension(this, WorkQueueManager.class);
        imanager = bus.getExtension(InstrumentationManager.class);
        if (null != imanager) {
            try {
                imanager.register(new WorkQueueManagerImplMBeanWrapper(this));
            } catch (JMException jmex) {
                LOG.log(Level.WARNING, jmex.getMessage(), jmex);
            }
        }
        ConfiguredBeanLocator locator = bus.getExtension(ConfiguredBeanLocator.class);
        Collection<? extends AutomaticWorkQueue> q = locator.getBeansOfType(AutomaticWorkQueue.class);
        if (q != null) {
            for (AutomaticWorkQueue awq : q) {
                addNamedWorkQueue(awq.getName(), awq);
            }
        }
        if (!namedQueues.containsKey(DEFAULT_QUEUE_NAME)) {
            AutomaticWorkQueue defaultQueue = locator.getBeanOfType(DEFAULT_WORKQUEUE_BEAN_NAME, AutomaticWorkQueue.class);
            if (defaultQueue != null) {
                addNamedWorkQueue(DEFAULT_QUEUE_NAME, defaultQueue);
            }
        }
        bus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(new WQLifecycleListener());
    }
}
Also used : ConfiguredBeanLocator(org.apache.cxf.configuration.ConfiguredBeanLocator) JMException(javax.management.JMException) AutomaticWorkQueue(org.apache.cxf.workqueue.AutomaticWorkQueue) BusLifeCycleManager(org.apache.cxf.buslifecycle.BusLifeCycleManager) InstrumentationManager(org.apache.cxf.management.InstrumentationManager) Resource(javax.annotation.Resource)

Example 52 with JMException

use of javax.management.JMException in project cxf by apache.

the class RMManager method initialise.

@PostConstruct
void initialise() {
    if (configuration == null) {
        getConfiguration().setExponentialBackoff(true);
    }
    DeliveryAssurance da = configuration.getDeliveryAssurance();
    if (da == null) {
        configuration.setDeliveryAssurance(DeliveryAssurance.AT_LEAST_ONCE);
    }
    if (null == sourcePolicy) {
        setSourcePolicy(null);
    }
    if (null == destinationPolicy) {
        DestinationPolicyType dp = new DestinationPolicyType();
        dp.setAcksPolicy(new AcksPolicyType());
        setDestinationPolicy(dp);
    }
    if (null == retransmissionQueue) {
        retransmissionQueue = new RetransmissionQueueImpl(this);
    }
    if (null == redeliveryQueue) {
        redeliveryQueue = new RedeliveryQueueImpl(this);
    }
    if (null == idGenerator) {
        idGenerator = new DefaultSequenceIdentifierGenerator();
    }
    if (null != bus) {
        managedManager = new ManagedRMManager(this);
        instrumentationManager = bus.getExtension(InstrumentationManager.class);
        if (instrumentationManager != null) {
            try {
                instrumentationManager.register(managedManager);
            } catch (JMException jmex) {
                LOG.log(Level.WARNING, "Registering ManagedRMManager failed.", jmex);
            }
        }
    }
}
Also used : AcksPolicyType(org.apache.cxf.ws.rm.manager.AcksPolicyType) RedeliveryQueueImpl(org.apache.cxf.ws.rm.soap.RedeliveryQueueImpl) RetransmissionQueueImpl(org.apache.cxf.ws.rm.soap.RetransmissionQueueImpl) DeliveryAssurance(org.apache.cxf.ws.rm.RMConfiguration.DeliveryAssurance) JMException(javax.management.JMException) DestinationPolicyType(org.apache.cxf.ws.rm.manager.DestinationPolicyType) InstrumentationManager(org.apache.cxf.management.InstrumentationManager) PostConstruct(javax.annotation.PostConstruct)

Example 53 with JMException

use of javax.management.JMException in project cxf by apache.

the class ManagedRMEndpoint method terminateSourceSequence.

@ManagedOperation(description = "Terminate Source Sequence")
@ManagedOperationParameters({ @ManagedOperationParameter(name = "sequenceId", description = "The sequence identifier") })
public void terminateSourceSequence(String sid) throws JMException {
    SourceSequence ss = getSourceSeq(sid);
    if (null == ss) {
        throw new JMException("no source sequence");
    }
    Proxy proxy = endpoint.getProxy();
    try {
        proxy.terminate(ss);
        ss.getSource().removeSequence(ss);
    } catch (RMException e) {
        throw new JMException("Error terminating sequence: " + e.getMessage());
    }
}
Also used : JMException(javax.management.JMException) ManagedOperationParameters(org.apache.cxf.management.annotation.ManagedOperationParameters) ManagedOperation(org.apache.cxf.management.annotation.ManagedOperation)

Example 54 with JMException

use of javax.management.JMException in project cxf by apache.

the class ManagedRMEndpoint method terminateDestinationSequence.

@ManagedOperation(description = "Terminate Destination Sequence")
@ManagedOperationParameters({ @ManagedOperationParameter(name = "sequenceId", description = "The sequence identifier") })
public void terminateDestinationSequence(String sid) throws JMException {
    DestinationSequence ds = getDestinationSeq(sid);
    if (null == ds) {
        throw new JMException("no destination sequence");
    }
    Proxy proxy = endpoint.getProxy();
    try {
        proxy.terminate(ds);
        ds.getDestination().removeSequence(ds);
    } catch (RMException e) {
        throw new JMException("Error terminating sequence: " + e.getMessage());
    }
}
Also used : JMException(javax.management.JMException) ManagedOperationParameters(org.apache.cxf.management.annotation.ManagedOperationParameters) ManagedOperation(org.apache.cxf.management.annotation.ManagedOperation)

Example 55 with JMException

use of javax.management.JMException in project cxf by apache.

the class JMXManagedComponentManagerTest method testRegisterInstrumentation.

@Test
public void testRegisterInstrumentation() throws Exception {
    AnnotationTestInstrumentation im = new AnnotationTestInstrumentation();
    ObjectName name = new ObjectName("org.apache.cxf:type=foo,name=bar");
    im.setName("John Smith");
    manager.register(im, name);
    Object val = manager.getMBeanServer().getAttribute(name, NAME_ATTRIBUTE);
    assertEquals("Incorrect result", "John Smith", val);
    try {
        manager.register(im, name);
        fail("Registering with existing name should fail.");
    } catch (JMException jmex) {
    // Expected
    }
    manager.register(im, name, true);
    val = manager.getMBeanServer().getAttribute(name, NAME_ATTRIBUTE);
    assertEquals("Incorrect result", "John Smith", val);
    manager.unregister(name);
    im.setName("Foo Bar");
    name = manager.register(im);
    val = manager.getMBeanServer().getAttribute(name, NAME_ATTRIBUTE);
    assertEquals("Incorrect result", "Foo Bar", val);
    try {
        manager.register(im);
        fail("Registering with existing name should fail.");
    } catch (JMException jmex) {
    // Expected
    }
    name = manager.register(im, true);
    val = manager.getMBeanServer().getAttribute(name, NAME_ATTRIBUTE);
    assertEquals("Incorrect result", "Foo Bar", val);
    manager.unregister(im);
}
Also used : AnnotationTestInstrumentation(org.apache.cxf.management.jmx.export.AnnotationTestInstrumentation) JMException(javax.management.JMException) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Aggregations

JMException (javax.management.JMException)116 ObjectName (javax.management.ObjectName)66 MBeanServer (javax.management.MBeanServer)33 IOException (java.io.IOException)22 InstrumentationManager (org.apache.cxf.management.InstrumentationManager)13 MBeanInfo (javax.management.MBeanInfo)11 MalformedObjectNameException (javax.management.MalformedObjectNameException)11 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)9 SnmpStatusException (com.sun.management.snmp.SnmpStatusException)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 Map (java.util.Map)7 StandardMBean (javax.management.StandardMBean)7 RequiredModelMBean (javax.management.modelmbean.RequiredModelMBean)6 Date (java.util.Date)5 Attribute (javax.management.Attribute)5 InvalidTargetObjectTypeException (javax.management.modelmbean.InvalidTargetObjectTypeException)5 Element (org.w3c.dom.Element)5 PostConstruct (javax.annotation.PostConstruct)4 ModelMBeanInfo (javax.management.modelmbean.ModelMBeanInfo)4