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);
}
}
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);
}
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations