当前位置: 首页>>代码示例>>Java>>正文


Java ObjectName类代码示例

本文整理汇总了Java中javax.management.ObjectName的典型用法代码示例。如果您正苦于以下问题:Java ObjectName类的具体用法?Java ObjectName怎么用?Java ObjectName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ObjectName类属于javax.management包,在下文中一共展示了ObjectName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerMBean

import javax.management.ObjectName; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:26,代码来源:MBeanUtil.java

示例2: assertChCounterState

import javax.management.ObjectName; //导入依赖的package包/类
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);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:20,代码来源:TestMonitoredCounterGroup.java

示例3: testObjectNameSetterWithONContainingTransaction_shouldBeTranslatedToReadOnlyON

import javax.management.ObjectName; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:DynamicWritableWrapperTest.java

示例4: preRegister

import javax.management.ObjectName; //导入依赖的package包/类
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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:DefaultMBeanServerInterceptor.java

示例5: createMBean

import javax.management.ObjectName; //导入依赖的package包/类
/**
 * 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);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:27,代码来源:MBeanUtils.java

示例6: unregisterNotificationListeners

import javax.management.ObjectName; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:MBeanExporter.java

示例7: getMethodInfo

import javax.management.ObjectName; //导入依赖的package包/类
/** 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;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:24,代码来源:Registry.java

示例8: testDataNode

import javax.management.ObjectName; //导入依赖的package包/类
/**
 * 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());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestJMXGet.java

示例9: getValveObjectNames

import javax.management.ObjectName; //导入依赖的package包/类
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]);

    }
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:18,代码来源:StandardPipeline.java

示例10: getClassLoader

import javax.management.ObjectName; //导入依赖的package包/类
/**
 * <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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:DefaultMBeanServerInterceptor.java

示例11: findRole

import javax.management.ObjectName; //导入依赖的package包/类
/**
 * 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);
    }

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:24,代码来源:MemoryUserDatabaseMBean.java

示例12: removeNotificationListener

import javax.management.ObjectName; //导入依赖的package包/类
@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();
		}
	}
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:18,代码来源:PogamutMBeanServer.java

示例13: createJNDIRealm

import javax.management.ObjectName; //导入依赖的package包/类
/**
 * 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;
    }   


}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:MBeanFactory.java

示例14: getUsers

import javax.management.ObjectName; //导入依赖的package包/类
/**
 * 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()]);

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:25,代码来源:GroupMBean.java

示例15: registerMBean

import javax.management.ObjectName; //导入依赖的package包/类
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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:DefaultMBeanServerInterceptor.java


注:本文中的javax.management.ObjectName类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。