public static ManagementRuntimeException wrap(Exception cause) { return new ManagementRuntimeException(cause); }
public static ObjectName getObjectName(String name, String avas) { String qualifiedName = getQualifiedName(name) + "," + avas; try { return new ObjectName(qualifiedName); } catch (JMException e) { throw ManagementRuntimeException.wrap(name + " is not correct", e); } }
public static ObjectName getObjectName(String name) { String qualifiedName = getQualifiedName(name); try { return new ObjectName(qualifiedName); } catch (JMException e) { throw ManagementRuntimeException.wrap(name + " is not correct", e); } }
public static ManagementRuntimeException wrap(String message, Exception cause) { return new ManagementRuntimeException(message, cause); }
protected void doUnbind(Resource resource) { if (resource.mbean == null) { throw new IllegalStateException(resource.managementName + " is not bound"); } try { MBeanServer server = serverLocatorService.lookupServer(resource.managementName); server.unregisterMBean(resource.managementName); } catch (JMException e) { throw ManagementRuntimeException.wrap("Cannot unbind " + resource, e); } finally { resource.mbean = null; if (ResourcePublisherService.log.isDebugEnabled()) { ResourcePublisherService.log.debug("unbound " + resource); } } }
protected JMXServiceURL doFormatServerURL(ServerLocatorDescriptor descriptor) { try { return new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + descriptor.rmiPort + "/" + descriptor.domainName + "/jmxrmi"); } catch (MalformedURLException e) { throw new ManagementRuntimeException("Cannot format url for " + descriptor.domainName); } }
beanInfo = Introspector.getBeanInfo(iface); } catch (java.beans.IntrospectionException e) { throw ManagementRuntimeException.wrap("Cannot introspect " + iface, e);
@Override @SuppressWarnings("cast") public MBeanServer lookupServer(ObjectName qualifiedName) { if (defaultServer.isRegistered(qualifiedName)) { return defaultServer; } for (MBeanServer server : MBeanServerFactory.findMBeanServer(null)) { if (server.isRegistered(qualifiedName)) { return server; } } throw new ManagementRuntimeException(qualifiedName + " is not registered"); }
protected <T> T doResolveService(Class<T> resourceClass, ServiceDescriptor descriptor) { T service = Framework.getService(resourceClass); if (service == null) { throw new ManagementRuntimeException("Cannot locate resource using " + resourceClass); } return service; }
protected void doRegisterFactory(ResourceFactoryDescriptor descriptor) { ResourceFactory factory; Class<? extends ResourceFactory> factoryClass = descriptor.getFactoryClass(); try { factory = factoryClass.newInstance(); } catch (ReflectiveOperationException e) { throw new ManagementRuntimeException("Cannot create factory " + factoryClass, e); } factory.configure(ResourcePublisherService.this, descriptor); registry.put(factoryClass, factory); }
protected MBeanServer doCreateServer(final ServerLocatorDescriptor descriptor) { MBeanServer server = MBeanServerFactory.createMBeanServer(); JMXServiceURL url = doFormatServerURL(descriptor); if (!descriptor.remote) { return server; } final RMIConnectorServer connector; try { connector = new RMIConnectorServer(url, null, server); } catch (IOException e) { throw new ManagementRuntimeException("Cannot start connector for " + descriptor.domainName, e); } try { connector.start(); } catch (IOException e) { try { LocateRegistry.createRegistry(descriptor.rmiPort); } catch (RemoteException e2) { throw new ManagementRuntimeException("Cannot start RMI connector for " + descriptor.domainName, e); } try { connector.start(); } catch (IOException e2) { throw new ManagementRuntimeException("Cannot start RMI connector for " + descriptor.domainName, e2); } } assert connector.isActive(); log.info("Started a mbean server : " + url); return server; }