List of usage examples for javax.management ObjectName getInstance
public static ObjectName getInstance(ObjectName name)
Return an instance of ObjectName that can be used anywhere the given object can be used.
From source file:com.adaptris.core.fs.FsConsumerCase.java
public void testFsMonitor() throws Exception { String subdir = new GuidGenerator().safeUUID(); FsConsumerImpl fs = createConsumer(subdir); fs.setUniqueId(getName());//from www. j ava 2 s . c om Adapter adapter = new Adapter(); adapter.setUniqueId(getName()); Channel channel = new Channel(); channel.setUniqueId(getName()); StandardWorkflow wf = new StandardWorkflow(); wf.setUniqueId(getName()); wf.setConsumer(fs); channel.getWorkflowList().add(wf); adapter.getChannelList().add(channel); AdapterManager am = new AdapterManager(adapter); try { am.registerMBean(); am.requestInit(); String objectNameString = String.format( "com.adaptris:type=ConsumerMonitor,adapter=%s,channel=%s,workflow=%s,id=%s", getName(), getName(), getName(), getName()); MBeanServer mBeanServer = JmxHelper.findMBeanServer(); FsConsumerMonitorMBean mbean = JMX.newMBeanProxy(mBeanServer, ObjectName.getInstance(objectNameString), FsConsumerMonitorMBean.class); assertEquals(0, mbean.messagesRemaining()); } finally { am.requestClose(); am.unregisterMBean(); } }
From source file:org.apache.geode.admin.jmx.internal.MBeanUtil.java
static void registerServerNotificationListener() { if (mbeanServer == null) { return;/*from w w w .j a va 2s. c o m*/ } try { // the MBeanServerDelegate name is spec'ed as the following... ObjectName delegate = ObjectName.getInstance("JMImplementation:type=MBeanServerDelegate"); mbeanServer.addNotificationListener(delegate, new NotificationListener() { public void handleNotification(Notification notification, Object handback) { MBeanServerNotification serverNotification = (MBeanServerNotification) notification; if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(serverNotification.getType())) { ObjectName objectName = serverNotification.getMBeanName(); synchronized (MBeanUtil.managedResources) { Object entry = MBeanUtil.managedResources.get(objectName); if (entry == null) return; if (!(entry instanceof ManagedResource)) { throw new ClassCastException(LocalizedStrings.MBeanUtil_0_IS_NOT_A_MANAGEDRESOURCE .toLocalizedString(new Object[] { entry.getClass().getName() })); } ManagedResource resource = (ManagedResource) entry; { // call cleanup on managedResource cleanupResource(resource); } } } } }, null, null); } catch (JMException e) { logStackTrace(Level.WARN, e, LocalizedStrings.MBeanUtil_FAILED_TO_REGISTER_SERVERNOTIFICATIONLISTENER.toLocalizedString()); } catch (JMRuntimeException e) { logStackTrace(Level.WARN, e, LocalizedStrings.MBeanUtil_FAILED_TO_REGISTER_SERVERNOTIFICATIONLISTENER.toLocalizedString()); } }
From source file:org.apache.geode.admin.jmx.internal.AgentImpl.java
/** Returns the JMX ObjectName for the RMI registry Naming MBean. */ private ObjectName getRMIRegistryNamingName() throws javax.management.MalformedObjectNameException { return ObjectName.getInstance("naming:type=rmiregistry"); }
From source file:com.evolveum.midpoint.gui.api.page.PageBase.java
protected void clearLessJsCache(AjaxRequestTarget target) { try {/*from w w w . j a v a 2s . c o m*/ ArrayList<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null); if (servers.size() > 1) { LOGGER.info("Too many mbean servers, cache won't be cleared."); for (MBeanServer server : servers) { LOGGER.info(server.getDefaultDomain()); } return; } MBeanServer server = servers.get(0); ObjectName objectName = ObjectName.getInstance(Wro4jConfig.WRO_MBEAN_NAME + ":type=WroConfiguration"); server.invoke(objectName, "reloadCache", new Object[] {}, new String[] {}); if (target != null) { target.add(PageBase.this); } } catch (Exception ex) { LoggingUtils.logUnexpectedException(LOGGER, "Couldn't clear less/js cache", ex); error("Error occurred, reason: " + ex.getMessage()); if (target != null) { target.add(getFeedbackPanel()); } } }