List of usage examples for javax.management MalformedObjectNameException MalformedObjectNameException
public MalformedObjectNameException(String message)
From source file:catalina.mbeans.MBeanUtils.java
/** * Create an <code>ObjectName</code> for this * <code>Connector</code> object. * * @param domain Domain in which this name is to be created * @param connector The Connector to be named * * @exception MalformedObjectNameException if a name cannot be created *///from w ww. ja va 2s. com public static ObjectName createObjectName(String domain, Connector connector) throws MalformedObjectNameException { ObjectName name = null; if (connector instanceof HttpConnector) { HttpConnector httpConnector = (HttpConnector) connector; Service service = httpConnector.getService(); String serviceName = null; if (service != null) serviceName = service.getName(); name = new ObjectName(domain + ":type=Connector" + ",service=" + serviceName + ",port=" + httpConnector.getPort() + ",address=" + httpConnector.getAddress()); return (name); } else if (connector instanceof org.apache.catalina.connector.http10.HttpConnector) { org.apache.catalina.connector.http10.HttpConnector httpConnector = (org.apache.catalina.connector.http10.HttpConnector) connector; Service service = httpConnector.getService(); String serviceName = null; if (service != null) serviceName = service.getName(); name = new ObjectName(domain + ":type=Connector" + ",service=" + serviceName + ",port=" + httpConnector.getPort() + ",address=" + httpConnector.getAddress()); return (name); } else if ("org.apache.ajp.tomcat4.Ajp13Connector".equals(connector.getClass().getName())) { try { String address = (String) PropertyUtils.getSimpleProperty(connector, "address"); Integer port = (Integer) PropertyUtils.getSimpleProperty(connector, "port"); Service service = connector.getService(); String serviceName = null; if (service != null) serviceName = service.getName(); name = new ObjectName(domain + ":type=Connector" + ",service=" + serviceName + ",port=" + port + ",address=" + address); return (name); } catch (Exception e) { throw new MalformedObjectNameException("Cannot create object name for " + connector + e); } } else if ("org.apache.coyote.tomcat4.CoyoteConnector".equals(connector.getClass().getName())) { try { String address = (String) PropertyUtils.getSimpleProperty(connector, "address"); Integer port = (Integer) PropertyUtils.getSimpleProperty(connector, "port"); Service service = connector.getService(); String serviceName = null; if (service != null) serviceName = service.getName(); name = new ObjectName(domain + ":type=Connector" + ",service=" + serviceName + ",port=" + port + ",address=" + address); return (name); } catch (Exception e) { throw new MalformedObjectNameException("Cannot create object name for " + connector + e); } } else { throw new MalformedObjectNameException("Cannot create object name for " + connector); } }
From source file:org.apache.cassandra.tools.NodeProbe.java
public ColumnFamilyStoreMBean getCfsProxy(String ks, String cf) { ColumnFamilyStoreMBean cfsProxy = null; try {//from w w w.j a v a2 s . c om String type = cf.contains(".") ? "IndexColumnFamilies" : "ColumnFamilies"; Set<ObjectName> beans = mbeanServerConn.queryNames( new ObjectName( "org.apache.cassandra.db:type=*" + type + ",keyspace=" + ks + ",columnfamily=" + cf), null); if (beans.isEmpty()) throw new MalformedObjectNameException("couldn't find that bean"); assert beans.size() == 1; for (ObjectName bean : beans) cfsProxy = JMX.newMBeanProxy(mbeanServerConn, bean, ColumnFamilyStoreMBean.class); } catch (MalformedObjectNameException mone) { System.err.println("ColumnFamilyStore for " + ks + "/" + cf + " not found."); System.exit(1); } catch (IOException e) { System.err.println("ColumnFamilyStore for " + ks + "/" + cf + " not found: " + e); System.exit(1); } return cfsProxy; }
From source file:org.apache.geode.admin.jmx.internal.MBeanUtil.java
/** * Creates and registers a <code>ModelMBean</code> for the specified <code>ManagedResource</code>. * State changing callbacks into the <code>ManagedResource</code> will also be made. * * @param resource the ManagedResource to create a managing MBean for * @param managed the ManagedBean definition to create the MBean with * @see ManagedResource#setModelMBean/*from www . ja v a 2 s.co m*/ */ static ObjectName createMBean(ManagedResource resource, ManagedBean managed) { try { DynamicManagedBean mb = new DynamicManagedBean(managed); resource.setModelMBean(mb.createMBean(resource)); // create the ObjectName and register the MBean... final ObjectName objName; try { objName = ObjectName.getInstance(resource.getMBeanName()); } catch (MalformedObjectNameException e) { throw new MalformedObjectNameException(LocalizedStrings.MBeanUtil_0_IN_1 .toLocalizedString(new Object[] { e.getMessage(), resource.getMBeanName() })); } synchronized (MBeanUtil.class) { // Only register a bean once. Otherwise, you risk race // conditions with things like the RMI connector accessing it. if (mbeanServer != null && !mbeanServer.isRegistered(objName)) { mbeanServer.registerMBean(resource.getModelMBean(), objName); synchronized (managedResources) { managedResources.put(objName, resource); } } } return objName; } catch (java.lang.Exception e) { throw new RuntimeAdminException(LocalizedStrings.MBeanUtil_FAILED_TO_CREATE_MBEAN_FOR_0 .toLocalizedString(new Object[] { resource.getMBeanName() }), e); } }