List of usage examples for javax.management ObjectName ObjectName
public ObjectName(String name) throws MalformedObjectNameException
From source file:catalina.mbeans.MBeanFactory.java
/** * Create a new JDBC Realm.//from w w w. j a v a 2 s .co m * * @param parent MBean Name of the associated parent component * * @exception Exception if an MBean cannot be created or registered */ public String createJDBCRealm(String parent) throws Exception { // Create a new JDBCRealm instance JDBCRealm realm = new JDBCRealm(); // Add the new instance to its parent component ObjectName pname = new ObjectName(parent); String type = pname.getKeyProperty("type"); Server server = ServerFactory.getServer(); Service service = server.findService(pname.getKeyProperty("service")); Engine engine = (Engine) service.getContainer(); if (type.equals("Context")) { Host host = (Host) engine.findChild(pname.getKeyProperty("host")); String pathStr = getPathStr(pname.getKeyProperty("path")); Context context = (Context) host.findChild(pathStr); context.setRealm(realm); } else if (type.equals("Engine")) { engine.setRealm(realm); } else if (type.equals("Host")) { Host host = (Host) engine.findChild(pname.getKeyProperty("host")); host.setRealm(realm); } // Return the corresponding MBean name ManagedBean managed = registry.findManagedBean("JDBCRealm"); ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), realm); return (oname.toString()); }
From source file:com.sun.grizzly.http.jk.server.JkMain.java
private JkHandler newHandler(String type, String localName, String fullName) { JkHandler handler;/* ww w . j ava 2 s. co m*/ String classN = modules.getProperty(type); if (classN == null) { LoggerUtils.getLogger().log(Level.SEVERE, "No class name for " + fullName + " " + type); return null; } try { Class channelclass = Class.forName(classN); handler = (JkHandler) channelclass.newInstance(); } catch (Throwable ex) { handler = null; LoggerUtils.getLogger().log(Level.SEVERE, "Can't create " + fullName, ex); return null; } if (this.domain != null) { try { ObjectName handlerOname = new ObjectName(this.domain + ":" + "type=JkHandler,name=" + fullName); Registry.getRegistry(null, null).registerComponent(handler, handlerOname, classN); } catch (Exception e) { LoggerUtils.getLogger().log(Level.SEVERE, "Error registering " + fullName, e); } } wEnv.addHandler(fullName, handler); return handler; }
From source file:com.jkoolcloud.tnt4j.streams.custom.kafka.interceptors.reporters.metrics.MetricsReporter.java
/** * Collects JMX attributes of MBeans defined by <tt>objNameStr</tt>. * * @param objNameStr/*from w w w.j a v a2 s .c o m*/ * MBeans object name pattern to query * @param mBeanServer * MBean server instance to use * @param activity * activity instance to put JMX metrics snapshots * @throws Exception * if JMX attributes collecting fails */ public void collectMetricsJMX(String objNameStr, MBeanServer mBeanServer, Activity activity) throws Exception { ObjectName oName = new ObjectName(objNameStr); Set<ObjectName> metricsBeans = mBeanServer.queryNames(oName, null); for (ObjectName mBeanName : metricsBeans) { try { PropertySnapshot snapshot = new PropertySnapshot(mBeanName.getCanonicalName()); MBeanInfo metricsBean = mBeanServer.getMBeanInfo(mBeanName); MBeanAttributeInfo[] pMetricsAttrs = metricsBean.getAttributes(); for (MBeanAttributeInfo pMetricsAttr : pMetricsAttrs) { try { String attrName = pMetricsAttr.getName(); Object attrValue = mBeanServer.getAttribute(mBeanName, attrName); processAttrValue(snapshot, new PropertyNameBuilder(pMetricsAttr.getName()), attrValue); } catch (Exception exc) { Utils.logThrowable(LOGGER, OpLevel.WARNING, StreamsResources.getBundle(KafkaStreamConstants.RESOURCE_BUNDLE_NAME), "MetricsReporter.bean.attr.fail", mBeanName, pMetricsAttr.getName(), exc); } } if (getSnapshotPropIgnoreCase(snapshot, OBJ_NAME_ENTRY_KEY) == null) { snapshot.add(OBJ_NAME_ENTRY_KEY, mBeanName.getCanonicalName()); } if (useObjectNameProperties) { snapshot.add("domain", mBeanName.getDomain()); // NON-NLS Map<String, String> objNameProps = mBeanName.getKeyPropertyList(); for (Map.Entry<String, String> objNameProp : objNameProps.entrySet()) { String propKey = objNameProp.getKey(); Object mv = snapshot.get(propKey); snapshot.add(propKey + (mv == null ? "" : "_"), objNameProp.getValue()); // NON-NLS } } activity.addSnapshot(snapshot); } catch (Exception exc) { Utils.logThrowable(LOGGER, OpLevel.WARNING, StreamsResources.getBundle(KafkaStreamConstants.RESOURCE_BUNDLE_NAME), "MetricsReporter.bean.info.fail", mBeanName, exc); } } }
From source file:com.springsource.hq.plugin.tcserver.plugin.appmgmt.TomcatJmxApplicationManager.java
private boolean isTcRuntime250OrLater(String objectName, String operationName, int expected25OrLaterArgumentCount, Properties config) throws PluginException { try {/* w w w . ja v a2 s . c om*/ MBeanServerConnection mBeanServer = mxUtil.getMBeanServer(config); MBeanInfo mBeanInfo = mBeanServer.getMBeanInfo(new ObjectName(objectName)); for (MBeanOperationInfo operationInfo : mBeanInfo.getOperations()) { if (operationName.equals(operationInfo.getName()) && expected25OrLaterArgumentCount == operationInfo.getSignature().length) { return true; } } return false; } catch (Exception e) { throw createPluginException(e); } }
From source file:com.springsource.hq.plugin.tcserver.plugin.appmgmt.TomcatJmxScriptingApplicationManager.java
private boolean isMBeanRegistered(String objectName, ConfigResponse config) throws IOException, MalformedObjectNameException { return mxUtil.getMBeanServer(config.toProperties()).isRegistered(new ObjectName(objectName)); }
From source file:com.funambol.server.db.RoutingDataSource.java
/** * Registers the given DataSouce as a MBean * @param ds the datasource/*from ww w . j a va 2s .c o m*/ * @param name the name * @throws java.lang.Exception if an error occurs */ private void registerMBean(DataSource ds, String name) throws Exception { ObjectName on = null; if (name != null && name.startsWith("partition/")) { name = name.substring(10); on = new ObjectName("com.funambol:type=RoutingDataSource,instance=" + getInstanceKey() + ",routing=partitions,name=" + name); } else { on = new ObjectName( "com.funambol:type=RoutingDataSource,instance=" + getInstanceKey() + ",name=" + name); } if (ds == null) { registry("NOT AVAILABLE", on); } else { registry(ds, on); } }
From source file:catalina.mbeans.MBeanFactory.java
/** * Create a new JNDI Realm.//from w ww . ja v a 2 s.c o m * * @param parent MBean Name of the associated parent component * * @exception Exception if an MBean cannot be created or registered */ public String createJNDIRealm(String parent) throws Exception { // Create a new JNDIRealm instance JNDIRealm realm = new JNDIRealm(); // Add the new instance to its parent component ObjectName pname = new ObjectName(parent); String type = pname.getKeyProperty("type"); Server server = ServerFactory.getServer(); Service service = server.findService(pname.getKeyProperty("service")); Engine engine = (Engine) service.getContainer(); if (type.equals("Context")) { Host host = (Host) engine.findChild(pname.getKeyProperty("host")); String pathStr = getPathStr(pname.getKeyProperty("path")); Context context = (Context) host.findChild(pathStr); context.setRealm(realm); } else if (type.equals("Engine")) { engine.setRealm(realm); } else if (type.equals("Host")) { Host host = (Host) engine.findChild(pname.getKeyProperty("host")); host.setRealm(realm); } // Return the corresponding MBean name ManagedBean managed = registry.findManagedBean("JNDIRealm"); ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), realm); return (oname.toString()); }
From source file:com.app.server.SARDeployer.java
public void stop() { try {/*from w w w .j a va 2 s . co m*/ for (int serviceCount = 0; serviceCount < serviceList.size(); serviceCount++) { mbeanServer.invoke(new ObjectName((String) serviceList.get(serviceCount)), "stop", null, null); } } catch (Exception ex) { log.error("could not stop service", ex); } try { this.deployerList.remove(OBJECT_NAME); for (int deployerCount = 0; deployerCount < deployerList.size(); deployerCount++) { mbeanServer.invoke(new ObjectName((String) deployerList.get(deployerCount)), "stop", null, null); } } catch (Exception ex) { log.error("could not stop deployer", ex); } log.info("stopped"); }
From source file:com.app.server.SARDeployer.java
public void destroy() { try {// w w w. j a va 2 s. c o m while (serviceList.size() != 0) { mbeanServer.invoke(new ObjectName((String) serviceList.get(0)), "destroy", null, null); } } catch (Exception ex) { log.error("could not stop service", ex); } try { while (deployerList.size() != 0) { mbeanServer.invoke(new ObjectName((String) deployerList.get(0)), "destroy", null, null); } } catch (Exception ex) { log.error("could not stop deployer", ex); } log.info("destroyed"); }
From source file:catalina.mbeans.MBeanFactory.java
/** * Create a new Memory Realm.// w w w. j a va 2s . c o m * * @param parent MBean Name of the associated parent component * * @exception Exception if an MBean cannot be created or registered */ public String createMemoryRealm(String parent) throws Exception { // Create a new MemoryRealm instance MemoryRealm realm = new MemoryRealm(); // Add the new instance to its parent component ObjectName pname = new ObjectName(parent); String type = pname.getKeyProperty("type"); Server server = ServerFactory.getServer(); Service service = server.findService(pname.getKeyProperty("service")); Engine engine = (Engine) service.getContainer(); if (type.equals("Context")) { Host host = (Host) engine.findChild(pname.getKeyProperty("host")); String pathStr = getPathStr(pname.getKeyProperty("path")); Context context = (Context) host.findChild(pathStr); context.setRealm(realm); } else if (type.equals("Engine")) { engine.setRealm(realm); } else if (type.equals("Host")) { Host host = (Host) engine.findChild(pname.getKeyProperty("host")); host.setRealm(realm); } // Return the corresponding MBean name ManagedBean managed = registry.findManagedBean("MemoryRealm"); ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), realm); return (oname.toString()); }