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:org.camelcookbook.monitoring.managed.ManagedSpringTest.java
@Test public void testManagedResource() throws Exception { final ManagementAgent managementAgent = context.getManagementStrategy().getManagementAgent(); assertNotNull(managementAgent);//w ww . ja va 2 s . c o m final MBeanServer mBeanServer = managementAgent.getMBeanServer(); assertNotNull(mBeanServer); final String mBeanServerDefaultDomain = managementAgent.getMBeanServerDefaultDomain(); assertEquals("org.apache.camel", mBeanServerDefaultDomain); final String managementName = context.getManagementName(); assertNotNull("CamelContext should have a management name if JMX is enabled", managementName); LOG.info("managementName = {}", managementName); // Get the Camel Context MBean ObjectName onContext = ObjectName.getInstance(mBeanServerDefaultDomain + ":context=localhost/" + managementName + ",type=context,name=\"" + context.getName() + "\""); assertTrue("Should be registered", mBeanServer.isRegistered(onContext)); // Get myManagedBean ObjectName onManagedBean = ObjectName.getInstance(mBeanServerDefaultDomain + ":context=localhost/" + managementName + ",type=processors,name=\"myManagedBean\""); LOG.info("Canonical Name = {}", onManagedBean.getCanonicalName()); assertTrue("Should be registered", mBeanServer.isRegistered(onManagedBean)); // Send a couple of messages to get some route statistics template.sendBody("direct:start", "Hello Camel"); template.sendBody("direct:start", "Camel Rocks!"); // Get MBean attribute int camelsSeenCount = (Integer) mBeanServer.getAttribute(onManagedBean, "CamelsSeenCount"); assertEquals(2, camelsSeenCount); // Stop the route via JMX mBeanServer.invoke(onManagedBean, "resetCamelsSeenCount", null, null); camelsSeenCount = (Integer) mBeanServer.getAttribute(onManagedBean, "CamelsSeenCount"); assertEquals(0, camelsSeenCount); }
From source file:com.adaptris.core.runtime.AdapterManager.java
private void initRefs() throws MalformedObjectNameException, CoreException { myObjectName = ObjectName.getInstance(JMX_ADAPTER_TYPE + ID_PREFIX + getWrappedComponent().getUniqueId()); addChildJmxComponent(new AdapterComponentChecker(this)); for (Channel c : adapter.getChannelList()) { if (c.hasUniqueId()) { addChild(new ChannelManager(c, this, true), true); }//from w w w. j av a2s .co m } registerChildRuntime(adapter.getMessageErrorDigester()); registerChildRuntime(adapter.getFailedMessageRetrier()); registerChildRuntime(adapter.getMessageErrorHandler()); registerChildRuntime(adapter.logHandler()); marshalConfig(); }
From source file:com.adaptris.core.jmx.JmxNotificationConsumer.java
@Override public void init() throws CoreException { try {// w w w . jav a 2 s . c o m scheduler = Executors .newSingleThreadScheduledExecutor(new ManagedThreadFactory(getClass().getSimpleName())); connection = retrieveConnection(JmxConnection.class).mbeanServerConnection(); actualObjectName = ObjectName.getInstance(getDestination().getDestination()); } catch (Exception e) { throw ExceptionHelper.wrapCoreException(e); } }
From source file:org.rhq.plugins.jbosscache.JBossCacheDiscoveryComponent.java
@Override public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) { ResourceContext parentCtx = context.getParentResourceContext(); JMXComponent<JBossASServerComponent<?>> gparentComponent = (JMXComponent<JBossASServerComponent<?>>) parentCtx .getParentResourceComponent(); Set<DiscoveredResourceDetails> discovered = super.performDiscovery(context.getDefaultPluginConfiguration(), gparentComponent, context.getResourceType(), false); Set<DiscoveredResourceDetails> results = new HashSet<DiscoveredResourceDetails>(discovered.size()); // Normalize the base object names from the key for (DiscoveredResourceDetails detail : discovered) { boolean isTreeCache = false; String key = detail.getResourceKey(); if (key.contains("treecache-interceptor=")) isTreeCache = true;/*from w ww .j av a 2 s . c o m*/ try { ObjectName on = ObjectName.getInstance(key); key = on.getDomain(); key += ":"; Set<String> propKeys = on.getKeyPropertyList().keySet(); for (String prop : propKeys) { if (!(prop.contains("cache"))) { key += prop + "=" + on.getKeyProperty(prop); key += ","; } } if (key.endsWith(",")) key = key.substring(0, key.length() - 1); if (log.isDebugEnabled()) log.debug("Translated " + detail.getResourceKey() + " to " + key); detail.setResourceKey(key); detail.setResourceName(key); String descr = ""; if (isTreeCache) descr = "Tree"; descr += "Cache at " + key; detail.setResourceDescription(descr); Configuration pluginConfiguration = detail.getPluginConfiguration(); PropertySimple onProp = pluginConfiguration.getSimple("objectName"); onProp.setStringValue(key); PropertySimple isTC = new PropertySimple("isTreeCache", isTreeCache); pluginConfiguration.put(isTC); results.add(detail); } catch (MalformedObjectNameException e) { log.warn("Invalid obectname : " + key); } } return results; }
From source file:com.adaptris.core.runtime.AdapterRegistry.java
public static AdapterRegistryMBean findInstance(Properties cfg) throws MalformedObjectNameException, CoreException { MBeanServer mbs = JmxHelper.findMBeanServer(); AdapterRegistryMBean result = null;//from w w w. j a va 2s .co m ObjectName objName = ObjectName.getInstance(STANDARD_REGISTRY_JMX_NAME); if (mbs.isRegistered(objName)) { result = JMX.newMBeanProxy(mbs, objName, AdapterRegistryMBean.class); result.addConfiguration(cfg); } else { result = new AdapterRegistry(); result.registerMBean(); result.addConfiguration(cfg); } return result; }
From source file:com.chiralBehaviors.groo.configuration.ChakaalConfiguration.java
public Chakaal construct(MBeanServer mbs, Groo groo, Subject subject, ServiceScope scope) throws InvalidSyntaxException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException { Chakaal chakaal = new Chakaal(groo, scope, sourceMap, subject); for (String service : services) { chakaal.listenForService(service); }/*w w w . j a v a 2 s . co m*/ for (String query : queries) { chakaal.listenFor(query); } for (Map.Entry<String, String> entry : serviceQueries.entrySet()) { chakaal.listenForService(entry.getKey(), entry.getValue()); } mbs.registerMBean(groo, ObjectName.getInstance(grooName)); mbs.registerMBean(chakaal, ObjectName.getInstance(chakaalName)); return chakaal; }
From source file:fr.xebia.management.maven.WebApplicationMavenInformation.java
public ObjectName getObjectName() throws MalformedObjectNameException { if (objectName == null) { String objectNameString = jmxDomain + ":type=WebApplicationMavenInformation"; if (StringUtils.hasText(this.beanName)) { objectNameString += ",name=" + ObjectName.quote(this.beanName); }//w w w. j a v a 2 s . c om objectName = ObjectName.getInstance(objectNameString); } return objectName; }
From source file:com.adaptris.core.runtime.AdapterRegistryTest.java
@Override public void tearDown() throws Exception { JmxHelper.findMBeanServer()//from w ww . ja v a 2s .co m .unregisterMBean(ObjectName.getInstance(AdapterRegistry.STANDARD_REGISTRY_JMX_NAME)); super.tearDown(); }
From source file:com.adaptris.core.runtime.WorkflowManager.java
private void initMembers() throws MalformedObjectNameException, CoreException { if (isEmpty(managedWorkflow.getUniqueId())) { throw new CoreException("No UniqueID, this workflow cannot be managed"); }//from w w w . java2 s . c om // Builds up a name com.adaptris:type=Workflow, adapter=<adapter-id,>, id=<channel-id>, workflow=<workflow-id> myObjectName = ObjectName.getInstance( JMX_WORKFLOW_TYPE + ADAPTER_PREFIX + getParent().getParent().getUniqueId() + CHANNEL_PREFIX + getParent().getUniqueId() + ID_PREFIX + getWrappedComponent().getUniqueId()); configureDefaultInterceptors(); Collection<AdaptrisComponent> runtimeCandidates = CollectionUtils.union(managedWorkflow.getInterceptors(), Arrays.asList(new AdaptrisComponent[] { managedWorkflow.getConsumer(), managedWorkflow.getProducer(), defaultIfNull(managedWorkflow.getMessageErrorHandler()) })); for (AdaptrisComponent c : runtimeCandidates) { addChildJmxComponentQuietly((ChildRuntimeInfoComponent) RuntimeInfoComponentFactory.create(this, c)); } marshalConfig(); }
From source file:com.adaptris.core.runtime.AdapterRegistry.java
private AdapterRegistry() throws MalformedObjectNameException { mBeanServer = JmxHelper.findMBeanServer(); myObjectName = ObjectName.getInstance(STANDARD_REGISTRY_JMX_NAME); }