List of usage examples for javax.management ObjectName getDomain
public String getDomain()
From source file:io.hawt.osgi.jmx.RBACDecorator.java
/** * see: <code>org.apache.karaf.management.KarafMBeanServerGuard#getNameSegments(javax.management.ObjectName)</code> * * Assuming <strong>full</strong> {@link ObjectName} (not null, not containing wildcards and other funny stuff), * split objectName to elements used then co contruct ordered list of PIDs to check for MBean permissions. * @return//from ww w .j a va 2 s.co m */ public static List<String> nameSegments(ObjectName objectName) { List<String> segments = new ArrayList<>(); segments.add(objectName.getDomain()); for (String s : objectName.getKeyPropertyListString().split(",")) { int index = s.indexOf('='); if (index < 0) { continue; } String key = objectName.getKeyProperty(s.substring(0, index)); if (s.substring(0, index).equals("type")) { segments.add(1, key); } else { segments.add(key); } } return segments; }
From source file:org.red5.server.jmx.JMXAgent.java
/** * Shuts down any instanced connectors./*from w w w .j ava2s . c o m*/ */ public static void shutdown() { log.info("Shutting down JMX agent"); if (null != cs) { try { //stop the connector cs.stop(); } catch (Exception e) { log.error("Exception stopping JMXConnector server {}", e); } } if (null != html) { html.stop(); } try { //unregister all the currently registered red5 mbeans String domain = JMXFactory.getDefaultDomain(); for (ObjectName oname : (Set<ObjectName>) mbs.queryNames(new ObjectName(domain + ":*"), null)) { log.debug("Bean domain: {}", oname.getDomain()); if (domain.equals(oname.getDomain())) { unregisterMBean(oname); } } } catch (Exception e) { log.error("Exception unregistering mbeans {}", e); } }
From source file:org.springframework.jmx.support.JmxUtils.java
/** * Append an additional key/value pair to an existing {@link ObjectName} with the key being * the static value {@code identity} and the value being the identity hash code of the * managed resource being exposed on the supplied {@link ObjectName}. This can be used to * provide a unique {@link ObjectName} for each distinct instance of a particular bean or * class. Useful when generating {@link ObjectName ObjectNames} at runtime for a set of * managed resources based on the template value supplied by a * {@link org.springframework.jmx.export.naming.ObjectNamingStrategy}. * @param objectName the original JMX ObjectName * @param managedResource the MBean instance * @return an ObjectName with the MBean identity added * @throws MalformedObjectNameException in case of an invalid object name specification * @see org.springframework.util.ObjectUtils#getIdentityHexString(Object) *//*from w w w. j a v a 2s. co m*/ public static ObjectName appendIdentityToObjectName(ObjectName objectName, Object managedResource) throws MalformedObjectNameException { Hashtable<String, String> keyProperties = objectName.getKeyPropertyList(); keyProperties.put(IDENTITY_OBJECT_NAME_KEY, ObjectUtils.getIdentityHexString(managedResource)); return ObjectNameManager.getInstance(objectName.getDomain(), keyProperties); }
From source file:org.apache.geode.admin.jmx.internal.MBeanUtil.java
/** * Unregisters all GemFire MBeans and then releases the MBeanServer for garbage collection. *//*from ww w . jav a 2s. c o m*/ static void releaseMBeanServer() { try { // unregister all GemFire mbeans... Iterator iter = mbeanServer.queryNames(null, null).iterator(); while (iter.hasNext()) { ObjectName name = (ObjectName) iter.next(); if (name.getDomain().startsWith(DEFAULT_DOMAIN)) { unregisterMBean(name); } } // last, release the mbean server... MBeanServerFactory.releaseMBeanServer(mbeanServer); mbeanServer = null; } catch (JMRuntimeException e) { logStackTrace(Level.WARN, e); } /* * See #42391. Cleaning up the static maps which might be still holding references to * ManagedResources */ synchronized (MBeanUtil.managedResources) { MBeanUtil.managedResources.clear(); } synchronized (refreshClients) { refreshClients.clear(); } /* * See #42391. Cleaning up the static maps which might be still holding references to * ManagedResources */ synchronized (MBeanUtil.managedResources) { MBeanUtil.managedResources.clear(); } synchronized (refreshClients) { refreshClients.clear(); } }
From source file:org.apache.hadoop.hbase.util.TestJSONMetricUtil.java
@Test public void testBuildObjectName() throws MalformedObjectNameException { String[] keys = { "type", "name" }; String[] values = { "MemoryPool", "Par Eden Space" }; Hashtable<String, String> properties = JSONMetricUtil.buldKeyValueTable(keys, values); ObjectName testObject = JSONMetricUtil.buildObjectName(JSONMetricUtil.JAVA_LANG_DOMAIN, properties); assertEquals(testObject.getDomain(), JSONMetricUtil.JAVA_LANG_DOMAIN); assertEquals(testObject.getKeyPropertyList(), properties); }
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. jav a 2 s. co 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:org.skfiy.typhon.AbstractMBeanLifecycle.java
@Override public ObjectName preRegister(final MBeanServer server, final ObjectName name) throws Exception { this.oname = name; this.domain = name.getDomain(); return oname; }
From source file:org.sakaiproject.kernel.loader.server.tomcat5.KernelLoader.java
/** * Get hold of the parent service./*from w ww. java 2s . com*/ * * @param oname the name of the service * @return the service * @throws Exception if there was a problem locating the service. */ private Service getService(final ObjectName oname) throws Exception { String domain = oname.getDomain(); Server server = ServerFactory.getServer(); Service[] services = server.findServices(); StandardService service = null; for (int i = 0; i < services.length; i++) { service = (StandardService) services[i]; if (domain.equals(service.getObjectName().getDomain())) { break; } } if (!service.getObjectName().getDomain().equals(domain)) { throw new Exception("Service with the domain is not found"); } return service; }
From source file:org.jolokia.client.request.J4pListRequest.java
/** * Constructor for fetching the meta data of a specific MBean * * @param pConfig proxy target configuration or <code>null</code> if no proxy should be used * @param pObjectName name of MBean for which to fetch the meta data *//*w w w. j av a 2 s .c om*/ public J4pListRequest(J4pTargetConfig pConfig, ObjectName pObjectName) { super(J4pType.LIST, pConfig); pathElements = new ArrayList<String>(); pathElements.add(pObjectName.getDomain()); pathElements.add(pObjectName.getCanonicalKeyPropertyListString()); }
From source file:dk.netarkivet.common.management.SingleMBeanObject.java
/** * Create a single mbean object./*from w w w . ja v a 2 s . com*/ * * This is a helper method for the constructor taking a domain, which take * the domain from a preconstructed ObjectName and replaces the * nameProperties with the properties from the given object name. Use this * if you have an object name created already, which you wish to use. * * @param name The object name to register under. * @param o The object to register. * @param asInterface The interface o should implement. * @param mBeanServer The mbean server to register o in. * * @throws ArgumentNotValid on any null parameter. */ public SingleMBeanObject(ObjectName name, I o, Class<I> asInterface, MBeanServer mBeanServer) { this(name.getDomain(), o, asInterface, mBeanServer); nameProperties.clear(); nameProperties.putAll(name.getKeyPropertyList()); }