Java 类javax.management.ObjectName 实例源码

项目:hadoop-oss    文件:MBeanUtil.java   
/**
 * Register the MBean using our standard MBeanName format
 * "hadoop:service=<serviceName>,name=<nameName>"
 * Where the <serviceName> and <nameName> are the supplied parameters
 *    
 * @param serviceName
 * @param nameName
 * @param theMbean - the MBean to register
 * @return the named used to register the MBean
 */ 
static public ObjectName registerMBean(final String serviceName, 
                            final String nameName,
                            final Object theMbean) {
  final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
  ObjectName name = getMBeanName(serviceName, nameName);
  try {
    mbs.registerMBean(theMbean, name);
    return name;
  } catch (InstanceAlreadyExistsException ie) {
    // Ignore if instance already exists 
  } catch (Exception e) {
    e.printStackTrace();
  }
  return null;
}
项目:flume-release-1.7.0    文件:TestMonitoredCounterGroup.java   
private void assertChCounterState(ObjectName on, long channelSize,
    long eventPutAttempt, long eventTakeAttempt, long eventPutSuccess,
    long eventTakeSuccess) throws Exception {
  Assert.assertEquals("ChChannelSize",
      getChChannelSize(on),
      channelSize);
  Assert.assertEquals("ChEventPutAttempt",
      getChEventPutAttempt(on),
      eventPutAttempt);
  Assert.assertEquals("ChEventTakeAttempt",
      getChEventTakeAttempt(on),
      eventTakeAttempt);
  Assert.assertEquals("ChEventPutSuccess",
      getChEventPutSuccess(on),
      eventPutSuccess);
  Assert.assertEquals("ChEventTakeSuccess",
      getChEventTakeSuccess(on),
      eventTakeSuccess);
}
项目:hashsdn-controller    文件:DynamicWritableWrapperTest.java   
@Test
public void testObjectNameSetterWithONContainingTransaction_shouldBeTranslatedToReadOnlyON() throws Exception {
    TestingParallelAPSPModuleFactory testingParallelAPSPConfigBeanFactory = new TestingParallelAPSPModuleFactory();
    TestingParallelAPSPModule apspConfigBean = testingParallelAPSPConfigBeanFactory.createModule("", null, null);
    ModuleIdentifier moduleIdentifier2 = new ModuleIdentifier("apsp", "parallel");
    ObjectName dynON2 = ObjectNameUtil.createReadOnlyModuleON(moduleIdentifier2);
    AbstractDynamicWrapper dyn = getDynamicWrapper(apspConfigBean, moduleIdentifier2);
    platformMBeanServer.registerMBean(dyn, dynON2);
    try {
        TestingParallelAPSPConfigMXBean proxy = JMX.newMBeanProxy(platformMBeanServer, dynON2,
                TestingParallelAPSPConfigMXBean.class);
        ObjectName withTransactionName = ObjectNameUtil.createTransactionModuleON("transaction1", "moduleName",
                "instanceName");
        proxy.setThreadPool(withTransactionName);
        ObjectName withoutTransactionName = ObjectNameUtil.withoutTransactionName(withTransactionName);
        assertEquals(withoutTransactionName, proxy.getThreadPool());
    } finally {
        platformMBeanServer.unregisterMBean(dynON2);
    }
}
项目:openjdk-jdk10    文件:DefaultMBeanServerInterceptor.java   
private static ObjectName preRegister(
        DynamicMBean mbean, MBeanServer mbs, ObjectName name)
        throws InstanceAlreadyExistsException, MBeanRegistrationException {

    ObjectName newName = null;

    try {
        if (mbean instanceof MBeanRegistration)
            newName = ((MBeanRegistration) mbean).preRegister(mbs, name);
    } catch (Throwable t) {
        throwMBeanRegistrationException(t, "in preRegister method");
    }

    if (newName != null) return newName;
    else return name;
}
项目:jerrydog    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>UserDatabase</code> object.
 *
 * @param userDatabase The UserDatabase to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public static ModelMBean createMBean(UserDatabase userDatabase)
    throws Exception {

    String mname = createManagedName(userDatabase);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ModelMBean mbean = managed.createMBean(userDatabase);
    ObjectName oname = createObjectName(domain, userDatabase);
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:lams    文件:MBeanExporter.java   
/**
 * Unregister the configured {@link NotificationListener NotificationListeners}
 * from the {@link MBeanServer}.
 */
private void unregisterNotificationListeners() {
    for (Map.Entry<NotificationListenerBean, ObjectName[]> entry : this.registeredNotificationListeners.entrySet()) {
        NotificationListenerBean bean = entry.getKey();
        ObjectName[] mappedObjectNames = entry.getValue();
        for (ObjectName mappedObjectName : mappedObjectNames) {
            try {
                this.server.removeNotificationListener(mappedObjectName, bean.getNotificationListener(),
                        bean.getNotificationFilter(), bean.getHandback());
            }
            catch (Exception ex) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Unable to unregister NotificationListener", ex);
                }
            }
        }
    }
    this.registeredNotificationListeners.clear();
}
项目:tomcat7    文件:Registry.java   
/** Find the operation info for a method
 * 
 * @param oname
 * @param opName
 * @return the operation info for the specified operation
 */ 
public MBeanOperationInfo getMethodInfo( ObjectName oname, String opName )
{
    MBeanInfo info=null;
    try {
        info=server.getMBeanInfo(oname);
    } catch (Exception e) {
        log.info( "Can't find metadata " + oname );
        return null;
    }
    MBeanOperationInfo attInfo[]=info.getOperations();
    for( int i=0; i<attInfo.length; i++ ) {
        if( opName.equals(attInfo[i].getName())) {
            return attInfo[i];
        }
    }
    return null;
}
项目:hadoop    文件:TestJMXGet.java   
/**
 * test JMX connection to DataNode..
 * @throws Exception 
 */
@Test
public void testDataNode() throws Exception {
  int numDatanodes = 2;
  cluster = new MiniDFSCluster.Builder(config).numDataNodes(numDatanodes).build();
  cluster.waitActive();

  writeFile(cluster.getFileSystem(), new Path("/test"), 2);

  JMXGet jmx = new JMXGet();
  String serviceName = "DataNode";
  jmx.setService(serviceName);
  jmx.init();
  assertEquals(fileSize, Integer.parseInt(jmx.getValue("BytesWritten")));

  cluster.shutdown();
  MBeanServerConnection mbsc = ManagementFactory.getPlatformMBeanServer();
  ObjectName query = new ObjectName("Hadoop:service=" + serviceName + ",*");
  Set<ObjectName> names = mbsc.queryNames(query, null);
  assertTrue("No beans should be registered for " + serviceName, names.isEmpty());
}
项目:apache-tomcat-7.0.73-with-comment    文件:StandardPipeline.java   
public ObjectName[] getValveObjectNames() {

        ArrayList<ObjectName> valveList = new ArrayList<ObjectName>();
        Valve current = first;
        if (current == null) {
            current = basic;
        }
        while (current != null) {
            if (current instanceof ValveBase) {
                valveList.add(((ValveBase) current).getObjectName());
            }
            current = current.getNext();
        }

        return valveList.toArray(new ObjectName[0]);

    }
项目:OpenJSharp    文件:DefaultMBeanServerInterceptor.java   
/**
 * <p>Return the named {@link java.lang.ClassLoader}.
 * @param loaderName The ObjectName of the ClassLoader.
 * @return The named ClassLoader.
 * @exception InstanceNotFoundException if the named ClassLoader
 * is not found.
 */
public ClassLoader getClassLoader(ObjectName loaderName)
        throws InstanceNotFoundException {

    if (loaderName == null) {
        checkMBeanPermission((String) null, null, null, "getClassLoader");
        return server.getClass().getClassLoader();
    }

    DynamicMBean instance = getMBean(loaderName);
    checkMBeanPermission(instance, null, loaderName, "getClassLoader");

    Object resource = getResource(instance);

    /* Check if the given MBean is a ClassLoader */
    if (!(resource instanceof ClassLoader))
        throw new InstanceNotFoundException(loaderName.toString() +
                                            " is not a classloader");

    return (ClassLoader) resource;
}
项目:jerrydog    文件:MemoryUserDatabaseMBean.java   
/**
 * Return the MBean Name for the specified role name (if any);
 * otherwise return <code>null</code>.
 *
 * @param rolename Role name to look up
 */
public String findRole(String rolename) {

    UserDatabase database = (UserDatabase) this.resource;
    Role role = database.findRole(rolename);
    if (role == null) {
        return (null);
    }
    try {
        ObjectName oname =
            MBeanUtils.createObjectName(managedRole.getDomain(), role);
        return (oname.toString());
    } catch (MalformedObjectNameException e) {
        throw new IllegalArgumentException
            ("Cannot create object name for role " + role);
    }

}
项目:jerrydog    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Context</code> object.
 *
 * @param context The Context to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public static ModelMBean createMBean(Context context)
    throws Exception {

    String mname = createManagedName(context);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ModelMBean mbean = managed.createMBean(context);
    ObjectName oname = createObjectName(domain, context);
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:Pogamut3    文件:PogamutMBeanServer.java   
@Override
public synchronized void removeNotificationListener(ObjectName name,
        NotificationListener listener) throws InstanceNotFoundException,
        ListenerNotFoundException {     
    mbs.removeNotificationListener(name, listener);

    // TODO: slow implementation ... but fast one takes a lot of time to do :-)
    Iterator<Listener2> iter = listeners2.iterator();
    while(iter.hasNext()) {
        Listener2 l = iter.next();
        if (SafeEquals.equals(name, l.name) && SafeEquals.equals(listener, l.listener)) {
            listeners.remove(l);
            unregisteredListeners.remove(l);
            iter.remove();
        }
    }
}
项目:lams    文件:MBeanFactory.java   
/**
 * Create a new JNDI Realm.
 *
 * @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);
    ContainerBase containerBase = getParentContainerFromParent(pname);
    // Add the new instance to its parent component
    containerBase.setRealm(realm);
    // Return the corresponding MBean name
    ObjectName oname = realm.getObjectName();

    if (oname != null) {
        return (oname.toString());
    } else {
        return null;
    }   


}
项目:lazycat    文件:GroupMBean.java   
/**
 * Return the MBean Names of all users that are members of this group.
 */
public String[] getUsers() {

    Group group = (Group) this.resource;
    ArrayList<String> results = new ArrayList<String>();
    Iterator<User> users = group.getUsers();
    while (users.hasNext()) {
        User user = null;
        try {
            user = users.next();
            ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), user);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException(
                    "Cannot create object name for user " + user);
            iae.initCause(e);
            throw iae;
        }
    }
    return results.toArray(new String[results.size()]);

}
项目:OpenJSharp    文件:DefaultMBeanServerInterceptor.java   
public ObjectInstance registerMBean(Object object, ObjectName name)
    throws InstanceAlreadyExistsException, MBeanRegistrationException,
    NotCompliantMBeanException  {

    // ------------------------------
    // ------------------------------
    Class<?> theClass = object.getClass();

    Introspector.checkCompliance(theClass);

    final String infoClassName = getNewMBeanClassName(object);

    checkMBeanPermission(infoClassName, null, name, "registerMBean");
    checkMBeanTrustPermission(theClass);

    return registerObject(infoClassName, object, name);
}
项目:jdk8u-jdk    文件:ApplyWildcardTest.java   
private static int runPositiveTests() {
    int error = 0;
    for (int i = 0; i < positiveTests.length; i++) {
        System.out.println("----------------------------------------------");
        try {
            ObjectName on1 = ObjectName.getInstance(positiveTests[i][0]);
            ObjectName on2 = ObjectName.getInstance(positiveTests[i][1]);
            System.out.println("\"" + on1 + "\".apply(\"" + on2 + "\")");
            boolean result = on1.apply(on2);
            System.out.println("Result = " + result);
            if (result == false) {
                error++;
                System.out.println("Test failed!");
            } else {
                System.out.println("Test passed!");
            }
        } catch (Exception e) {
            error++;
            System.out.println("Got Unexpected Exception = " + e.toString());
            System.out.println("Test failed!");
        }
        System.out.println("----------------------------------------------");
    }
    return error;
}
项目:jdk8u-jdk    文件:Repository.java   
/**
 * Retrieves the named object contained in repository
 * from the given objectname.
 */
private NamedObject retrieveNamedObject(ObjectName name) {

    // No patterns inside reposit
    if (name.isPattern()) return null;

    // Extract the domain name.
    String dom = name.getDomain().intern();

    // Default domain case
    if (dom.length() == 0) {
        dom = domain;
    }

    Map<String,NamedObject> moiTb = domainTb.get(dom);
    if (moiTb == null) {
        return null; // No domain containing registered object names
    }

    return moiTb.get(name.getCanonicalKeyPropertyListString());
}
项目:OpenJSharp    文件:ClientHandler.java   
public ClientHandler(CommunicatorServer server, int id, MBeanServer f, ObjectName n) {
    adaptorServer = server ;
    requestId = id ;
    mbs = f ;
    objectName = n ;
    interruptCalled = false ;
    dbgTag = makeDebugTag() ;
    //if (mbs == null ){
    //thread = new Thread (this) ;
    thread =  createThread(this);

    //} else {
    //thread = mbs.getThreadAllocatorSrvIf().obtainThread(objectName,this) ;
    //}
    // Note: the thread will be started by the subclass.
}
项目:lams    文件:JMXAccessorCondition.java   
/**
 * Get value from MBeans attribute 
 * @return The value
 */
protected String accessJMXValue() {
    try {
        Object result = getJMXConnection().getAttribute(
                new ObjectName(name), attribute);
        if(result != null)
            return result.toString();
    } catch (Exception e) {
        // ignore access or connection open errors
    }
    return null;
}
项目:lams    文件:StandardServer.java   
public ObjectName preRegister(MBeanServer server,
                              ObjectName name) throws Exception {
    oname=name;
    mserver=server;
    domain=name.getDomain();
    return name;
}
项目:lazycat    文件:StatusTransformer.java   
/**
 * Write detailed information about a manager.
 */
public static void writeManager(PrintWriter writer, ObjectName objectName, MBeanServer mBeanServer, int mode)
        throws Exception {

    if (mode == 0) {
        writer.print("<br>");
        writer.print(" Active sessions: ");
        writer.print(mBeanServer.getAttribute(objectName, "activeSessions"));
        writer.print(" Session count: ");
        writer.print(mBeanServer.getAttribute(objectName, "sessionCounter"));
        writer.print(" Max active sessions: ");
        writer.print(mBeanServer.getAttribute(objectName, "maxActive"));
        writer.print(" Rejected session creations: ");
        writer.print(mBeanServer.getAttribute(objectName, "rejectedSessions"));
        writer.print(" Expired sessions: ");
        writer.print(mBeanServer.getAttribute(objectName, "expiredSessions"));
        writer.print(" Longest session alive time: ");
        writer.print(formatSeconds(mBeanServer.getAttribute(objectName, "sessionMaxAliveTime")));
        writer.print(" Average session alive time: ");
        writer.print(formatSeconds(mBeanServer.getAttribute(objectName, "sessionAverageAliveTime")));
        writer.print(" Processing time: ");
        writer.print(formatTime(mBeanServer.getAttribute(objectName, "processingTime"), false));
    } else if (mode == 1) {
        // for now we don't write out the wrapper details
    }

}
项目:jdk8u-jdk    文件:AuthorizationTest.java   
protected int doInvokeRequest(MBeanServerConnection mbsc,
                              ObjectName on,
                              boolean expectedException) {
    int errorCount = 0;

    try {
        Utils.debug(Utils.DEBUG_STANDARD,
            "ClientSide::doInvokeRequest: Invoke operations on the MBean") ;

        mbsc.invoke(on, "operation", null, null) ;

        if (expectedException) {
            System.out.println("ClientSide::doInvokeRequest: " +
                "(ERROR) Invoke did not fail with expected SecurityException");
            errorCount++;
        } else {
            System.out.println("ClientSide::doInvokeRequest: (OK) Invoke succeed") ;
        }
    } catch(Exception e) {
        Utils.printThrowable(e, true) ;
        if (expectedException) {
            if (e instanceof java.lang.SecurityException) {
                System.out.println("ClientSide::doInvokeRequest: " +
                    "(OK) Invoke failed with expected SecurityException") ;
            } else {
                System.out.println("ClientSide::doInvokeRequest: " +
                    " (ERROR) Invoke failed with " +
                    e.getClass() + " instead of expected SecurityException");
                errorCount++;
            }
        } else {
            System.out.println("ClientSide::doInvokeRequest: " +
                "(ERROR) Invoke failed");
            errorCount++;
        }
    }
    return errorCount;
}
项目:openjdk-jdk10    文件:RelationNotification.java   
/**
 * Returns old value of updated role (only for role update).
 *
 * @return the old value of the updated role.
 */
public List<ObjectName> getOldRoleValue() {
    List<ObjectName> result;
    if (oldRoleValue != null) {
        result = new ArrayList<ObjectName>(oldRoleValue);
    } else {
        result = Collections.emptyList();
    }
    return result;
}
项目:monarch    文件:DistributedSystemBridge.java   
/**
 * Removed the proxy from the map.
 *
 * @param objectName name of the proxy to be removed.
 * @param proxy actual reference to the proxy object
 * @return whether all proxies have been removed or not. In this case it will always be false.
 *         Kept it for consistency for MBeanAggregator.
 */
public boolean removeGatewaySenderFromSystem(ObjectName objectName, GatewaySenderMXBean proxy,
    FederationComponent oldState) {
  if (mapOfGatewaySenders != null) {
    mapOfGatewaySenders.remove(objectName);
    gatewaySenderSetSize = mapOfGatewaySenders.values().size();
    if (mapOfGatewaySenders.values().size() == 0) {
      gatewaySenderSetSize = 0;
      return true;

    }
  }
  updateGatewaySender(objectName, null, oldState);
  return false;
}
项目:jdk8u-jdk    文件:RMIConnector.java   
public ObjectInstance createMBean(String className,
        ObjectName name,
        Object params[],
        String signature[])
        throws ReflectionException,
        InstanceAlreadyExistsException,
        MBeanRegistrationException,
        MBeanException,
        NotCompliantMBeanException,
        IOException {
    if (logger.debugOn())
        logger.debug("createMBean(String,ObjectName,Object[],String[])",
                "className=" + className + ", name="
                + name + ", signature=" + strings(signature));

    final MarshalledObject<Object[]> sParams =
            new MarshalledObject<Object[]>(params);
    final ClassLoader old = pushDefaultClassLoader();
    try {
        return connection.createMBean(className,
                name,
                sParams,
                signature,
                delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        return connection.createMBean(className,
                name,
                sParams,
                signature,
                delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }
}
项目:monarch    文件:ShellCommandsController.java   
@RequestMapping(method = RequestMethod.POST, value = "/mbean/query")
public ResponseEntity<?> queryNames(@RequestBody final QueryParameterSource query) {
  try {
    final Set<ObjectName> objectNames =
        getMBeanServer().queryNames(query.getObjectName(), query.getQueryExpression());

    return new ResponseEntity<byte[]>(IOUtils.serializeObject(objectNames), HttpStatus.OK);
  } catch (IOException e) {
    return new ResponseEntity<String>(printStackTrace(e), HttpStatus.INTERNAL_SERVER_ERROR);
  }
}
项目:lams    文件:ContainerBase.java   
public ObjectName[] getChildren() {
    ObjectName result[]=new ObjectName[children.size()];
    Iterator it=children.values().iterator();
    int i=0;
    while( it.hasNext() ) {
        Object next=it.next();
        if( next instanceof ContainerBase ) {
            result[i++]=((ContainerBase)next).getJmxName();
        }
    }
    return result;
}
项目:monarch    文件:MX4JModelMBean.java   
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
  if (m_canBeRegistered) {
    m_mbeanServer = server;
    return name;
  } else {
    throw new MBeanRegistrationException(new IllegalStateException(
        LocalizedStrings.MX4JModelMBean_MODELMBEAN_CANNOT_BE_REGISTERED_UNTIL_SETMODELMBEANINFO_HAS_BEEN_CALLED
            .toLocalizedString()));
  }
}
项目:monarch    文件:MonitoringRegionCacheListener.java   
@Override
public void afterUpdate(EntryEvent<String, Object> event) {
  ObjectName objectName = null;
  try {

    if (!service.isStartedAndOpen() || !service.isManager()) {
      // NO OP return; No work for Non Manager Nodes
      return;
    }
    objectName = ObjectName.getInstance(event.getKey());

    FederationComponent oldObject = (FederationComponent) event.getOldValue();
    FederationComponent newObject = (FederationComponent) event.getNewValue();
    String className = newObject.getMBeanInterfaceClass();
    Class interfaceClass;
    if (classRef.get(className) != null) {
      interfaceClass = classRef.get(className);
    } else {
      interfaceClass = ClassLoadUtil.classFromName(className);
      classRef.put(className, interfaceClass);
    }

    service.afterUpdateProxy(objectName, interfaceClass, null, newObject, oldObject);

  } catch (Exception e) {
    if (logger.isDebugEnabled()) {
      logger.debug("Aggregation Failed failed for {} with exception {}", e);
    }
  }

}
项目:OpenJSharp    文件:JvmMemMgrPoolRelTableMeta.java   
public synchronized void addEntry(SnmpOid rowOid, ObjectName objname,
             Object entry)
    throws SnmpStatusException {
    if (! (entry instanceof JvmMemMgrPoolRelEntryMBean) )
        throw new ClassCastException("Entries for Table \"" +
                       "JvmMemMgrPoolRelTable" + "\" must implement the \"" +
                       "JvmMemMgrPoolRelEntryMBean" + "\" interface.");
    super.addEntry(rowOid, objname, entry);
}
项目:Byter    文件:JmxUtils.java   
/**
 * creates a ObjectName with specific packagename and type.
 * @param packageName desired packageName
 * @param type desired type
 * @param concatRandomInt concat a int at the type
 * @return null(default) | instanced ObjectName
 */
public static ObjectName objectName(final String packageName, final String type, final boolean concatRandomInt){
    try{
        if(!concatRandomInt)
            return new ObjectName( packageName+":type="+type);
        else{
            writerId++;
            return new ObjectName( packageName+":type="+type+"-id-"+writerId);
        }
    } catch (MalformedObjectNameException e) {
        log.log(Level.WARNING, "ObjectName is malformed!");
        return null;
    }
}
项目:Pogamut3    文件:PogamutJMX.java   
/**
 * Creates hierarchical ObjectNames given a parent and name of the MBean.
 * Extra elements can be inserted into the path through typeExtra param.
 * 
 * @param parent 
 *            parent's ObjectName
 * @param childName
 *            name of this object, if null no name element will be appended
 * @return ObjectName of form: domain=[parent's domain],type=[parent's
 *         type].[parent's name],name=[name]
 * @throws PogamutJMXNameException
 */
public static ObjectName getObjectName(ObjectName parent, String childName) throws PogamutJMXNameException {
    NullCheck.check(parent, "parent");
    NullCheck.check(childName, "childName");

    String parentDomain = parent.getKeyProperty("domain");
    String parentType = parent.getKeyProperty("type");
    String parentName = parent.getKeyProperty("name");

    String childType = parentType + "." + parentName;

    return getObjectName(parentDomain, childType, childName);       
}
项目:tomcat7    文件:StatusTransformer.java   
/**
 * Write JSP monitoring information.
 */
public static void writeJspMonitor(PrintWriter writer,
                                   Set<ObjectName> jspMonitorONs,
                                   MBeanServer mBeanServer,
                                   int mode)
        throws Exception {

    int jspCount = 0;
    int jspReloadCount = 0;

    Iterator<ObjectName> iter = jspMonitorONs.iterator();
    while (iter.hasNext()) {
        ObjectName jspMonitorON = iter.next();
        Object obj = mBeanServer.getAttribute(jspMonitorON, "jspCount");
        jspCount += ((Integer) obj).intValue();
        obj = mBeanServer.getAttribute(jspMonitorON, "jspReloadCount");
        jspReloadCount += ((Integer) obj).intValue();
    }

    if (mode == 0) {
        writer.print("<br>");
        writer.print(" JSPs loaded: ");
        writer.print(jspCount);
        writer.print(" JSPs reloaded: ");
        writer.print(jspReloadCount);
    } else if (mode == 1) {
        // for now we don't write out anything
    }
}
项目:jdk8u-jdk    文件:SystemClassLoaderTest.java   
public static void main(String[] args) throws Exception {
    // Instantiate the MBean server
    //
    System.out.println("Create the MBean server");
    MBeanServer mbs = MBeanServerFactory.createMBeanServer();

    ClassLoader mbsClassLoader = mbs.getClass().getClassLoader();

    String testClassName = Test.class.getName();

    // Check that the MBeanServer class loader does not know our test class
    try {
        Class.forName(testClassName, true, mbsClassLoader);
        System.out.println("TEST IS INVALID: MBEANSERVER'S CLASS LOADER " +
                           "KNOWS OUR TEST CLASS");
        System.exit(1);
    } catch (ClassNotFoundException e) {
        // As required
    }

    // Register the MBean
    //
    System.out.println("Create MBean from this class");
    ObjectName objectName = new ObjectName("whatever:type=whatever");
    mbs.createMBean(testClassName, objectName);
    // Test OK!
    //
    System.out.println("Bye! Bye!");
}
项目:hashsdn-controller    文件:ConfigRegistryImplLookupTest.java   
private static void registerRuntimeBean(final RuntimeBean object, final BaseJMXRegistrator baseJMXRegistrator,
        final ObjectName runtimeON) throws InstanceAlreadyExistsException {
    String factoryName = ObjectNameUtil.getFactoryName(runtimeON);
    String instanceName = ObjectNameUtil.getInstanceName(runtimeON);
    Map<String, String> properties = ObjectNameUtil.getAdditionalPropertiesOfRuntimeBeanName(runtimeON);

    RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator = baseJMXRegistrator
            .createRuntimeBeanRegistrator(new ModuleIdentifier(factoryName, instanceName));

    assertThat(properties.isEmpty(), is(true));

    runtimeBeanRegistrator.registerRoot(object);
}
项目:Pogamut3    文件:PogamutMBeanServer.java   
@Override
public synchronized void addNotificationListener(ObjectName name, ObjectName listener,
        NotificationFilter filter, Object handback)
        throws InstanceNotFoundException {
    mbs.addNotificationListener(name, listener, filter, handback);
    Listener1 l = new Listener1(name, listener, filter, handback);
    listeners.add(l);
    listeners1.add(l);
}
项目:Pogamut3    文件:PogamutMBeanServer.java   
@Override
public synchronized ObjectInstance createMBean(String className, ObjectName name)
        throws ReflectionException, InstanceAlreadyExistsException,
        MBeanRegistrationException, MBeanException,
        NotCompliantMBeanException {
    throw new UnsupportedOperationException("Not supported by PogamutMBeanServer yet...");
}
项目:Pogamut3    文件:PogamutMBeanServer.java   
@Override
public synchronized ObjectInstance createMBean(String className, ObjectName name,
        ObjectName loaderName) throws ReflectionException,
        InstanceAlreadyExistsException, MBeanRegistrationException,
        MBeanException, NotCompliantMBeanException,
        InstanceNotFoundException {
    throw new UnsupportedOperationException("Not supported by PogamutMBeanServer yet...");
}
项目:jdk8u-jdk    文件:ScanManager.java   
public Map<String,DirectoryScannerMXBean> getDirectoryScanners() {
    final Map<String,DirectoryScannerMXBean> proxyMap = newHashMap();
    for (Entry<ObjectName,DirectoryScannerMXBean> item : scanmap.entrySet()){
        proxyMap.put(item.getKey().getKeyProperty("name"),item.getValue());
    }
    return proxyMap;
}