Search in sources :

Example 41 with JMException

use of javax.management.JMException in project wildfly by wildfly.

the class LogStoreProbeHandler method probeTransactions.

private Resource probeTransactions(MBeanServer mbs, boolean exposeAllLogs) throws OperationFailedException {
    try {
        ObjectName on = new ObjectName(osMBeanName);
        mbs.setAttribute(on, new javax.management.Attribute("ExposeAllRecordsAsMBeans", Boolean.valueOf(exposeAllLogs)));
        mbs.invoke(on, "probe", null, null);
        Set<ObjectInstance> transactions = mbs.queryMBeans(new ObjectName(osMBeanName + ",*"), null);
        final Resource resource = Resource.Factory.create();
        addTransactions(resource, transactions, mbs);
        return resource;
    } catch (JMException e) {
        throw new OperationFailedException("Transaction discovery error: ", e);
    } catch (IOException e) {
        throw new OperationFailedException("Transaction discovery error: ", e);
    }
}
Also used : ObjectInstance(javax.management.ObjectInstance) Resource(org.jboss.as.controller.registry.Resource) JMException(javax.management.JMException) OperationFailedException(org.jboss.as.controller.OperationFailedException) IOException(java.io.IOException) ObjectName(javax.management.ObjectName)

Example 42 with JMException

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

the class ServerImpl method initDestination.

private void initDestination(DestinationFactory destinationFactory) throws BusException, IOException {
    EndpointInfo ei = endpoint.getEndpointInfo();
    // Of course its not an ideal situation here to use a hard-coded prefix. To be refactored.
    if (destinationFactory == null) {
        if (ei.getAddress() != null && ei.getAddress().indexOf("local://") != -1) {
            destinationFactory = bus.getExtension(DestinationFactoryManager.class).getDestinationFactoryForUri(ei.getAddress());
        }
        if (destinationFactory == null) {
            destinationFactory = bus.getExtension(DestinationFactoryManager.class).getDestinationFactory(ei.getTransportId());
        }
    }
    destination = destinationFactory.getDestination(ei, bus);
    String wantFilter = ei.getAddress();
    if (wantFilter != null && wantFilter.startsWith("jms")) {
        RegexLoggingFilter filter = new RegexLoggingFilter();
        filter.setPattern("jms(.*?)password=+([^ ]+)");
        filter.setGroup(2);
        wantFilter = filter.filter(wantFilter).toString();
    }
    LOG.info("Setting the server's publish address to be " + wantFilter);
    serverRegistry = bus.getExtension(ServerRegistry.class);
    mep = new ManagedEndpoint(bus, endpoint, this);
    slcMgr = bus.getExtension(ServerLifeCycleManager.class);
    if (slcMgr != null) {
        slcMgr.registerListener(mep);
    }
    iMgr = bus.getExtension(InstrumentationManager.class);
    if (iMgr != null) {
        try {
            iMgr.register(mep);
        } catch (JMException jmex) {
            LOG.log(Level.WARNING, "Registering ManagedEndpoint failed.", jmex);
        }
    }
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) RegexLoggingFilter(org.apache.cxf.common.logging.RegexLoggingFilter) JMException(javax.management.JMException) InstrumentationManager(org.apache.cxf.management.InstrumentationManager)

Example 43 with JMException

use of javax.management.JMException in project spring-framework by spring-projects.

the class MBeanExporter method registerManagedResource.

@Override
public void registerManagedResource(Object managedResource, ObjectName objectName) throws MBeanExportException {
    Assert.notNull(managedResource, "Managed resource must not be null");
    Assert.notNull(objectName, "ObjectName must not be null");
    try {
        if (isMBean(managedResource.getClass())) {
            doRegister(managedResource, objectName);
        } else {
            ModelMBean mbean = createAndConfigureMBean(managedResource, managedResource.getClass().getName());
            doRegister(mbean, objectName);
            injectNotificationPublisherIfNecessary(managedResource, mbean, objectName);
        }
    } catch (JMException ex) {
        throw new UnableToRegisterMBeanException("Unable to register MBean [" + managedResource + "] with object name [" + objectName + "]", ex);
    }
}
Also used : RequiredModelMBean(javax.management.modelmbean.RequiredModelMBean) ModelMBean(javax.management.modelmbean.ModelMBean) JMException(javax.management.JMException)

Example 44 with JMException

use of javax.management.JMException in project druid by alibaba.

the class JMXUtils method register.

public static ObjectName register(String name, Object mbean) {
    try {
        ObjectName objectName = new ObjectName(name);
        MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
        try {
            mbeanServer.registerMBean(mbean, objectName);
        } catch (InstanceAlreadyExistsException ex) {
            mbeanServer.unregisterMBean(objectName);
            mbeanServer.registerMBean(mbean, objectName);
        }
        return objectName;
    } catch (JMException e) {
        throw new IllegalArgumentException(name, e);
    }
}
Also used : InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) JMException(javax.management.JMException) ObjectName(javax.management.ObjectName) MBeanServer(javax.management.MBeanServer)

Example 45 with JMException

use of javax.management.JMException in project druid by alibaba.

the class JMXUtils method unregister.

public static void unregister(String name) {
    try {
        MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
        mbeanServer.unregisterMBean(new ObjectName(name));
    } catch (JMException e) {
        throw new IllegalArgumentException(name, e);
    }
}
Also used : JMException(javax.management.JMException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Aggregations

JMException (javax.management.JMException)114 ObjectName (javax.management.ObjectName)65 MBeanServer (javax.management.MBeanServer)35 IOException (java.io.IOException)21 InstrumentationManager (org.apache.cxf.management.InstrumentationManager)13 MalformedObjectNameException (javax.management.MalformedObjectNameException)12 MBeanInfo (javax.management.MBeanInfo)10 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)8 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 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)4