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


Java MBeanServer类代码示例

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


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

示例1: createRMIRegistry

import javax.management.MBeanServer; //导入依赖的package包/类
private void createRMIRegistry() throws Exception {
  if (!this.agentConfig.isRmiRegistryEnabled()) {
    return;
  }
  MBeanServer mbs = getMBeanServer();
  String host = this.agentConfig.getRmiBindAddress();
  int port = this.agentConfig.getRmiPort();

  /*
   * Register and start the rmi-registry naming MBean, which is needed by JSR 160
   * RMIConnectorServer
   */
  ObjectName registryName = getRMIRegistryNamingName();
  try {
    RMIRegistryService registryNamingService = null;
    if (host != null && !("".equals(host.trim()))) {
      registryNamingService = new RMIRegistryService(host, port);
    } else {
      registryNamingService = new RMIRegistryService(port);
    }
    mbs.registerMBean(registryNamingService, registryName);
  } catch (javax.management.InstanceAlreadyExistsException e) {
    logger.info(LocalizedMessage.create(LocalizedStrings.AgentImpl_0__IS_ALREADY_REGISTERED,
        registryName));
  }
  mbs.invoke(registryName, "start", null, null);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:28,代码来源:AgentImpl.java

示例2: registerMBean

import javax.management.MBeanServer; //导入依赖的package包/类
@SuppressWarnings({
		"unchecked", "rawtypes"
})
public static String registerMBean(final Object object) throws JMException {
	final ObjectName objectName = generateMBeanName(object.getClass());
	final MBeanServer context = ManagementFactory.getPlatformMBeanServer();
	final String mbeanName = object.getClass().getName() + "MBean";
	for (final Class c : object.getClass().getInterfaces()) {
		if (mbeanName.equals(c.getName())) {
			context.registerMBean(new AnnotatedStandardMBean(object, c), objectName);
			return objectName.getCanonicalName();
		}
	}
	context.registerMBean(object, objectName);
	return objectName.getCanonicalName();
}
 
开发者ID:ggrandes,项目名称:metrics-tomcat,代码行数:17,代码来源:AnnotatedStandardMBean.java

示例3: main

import javax.management.MBeanServer; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    RMIJRMPServerImplSub impl = new RMIJRMPServerImplSub();

    System.out.println("Creating connectorServer");
    connectorServer = new RMIConnectorServer(url, null, impl, mbs);
    System.out.println("Starting connectorServer");
    connectorServer.start();
    System.out.println("Making client");
    RMIConnection cc = impl.newClient(null);
    System.out.println("Closing client");
    cc.close();
    if (connectorServer.isActive()) {
        System.out.println("Stopping connectorServer");
        connectorServer.stop();
    }
    if (failure == null)
        System.out.println("TEST PASSED, no deadlock");
    else
        System.out.println("TEST FAILED");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:ConnectorStopDeadlockTest.java

示例4: initJvmRuntime

import javax.management.MBeanServer; //导入依赖的package包/类
/**
 * Initialization of the "JvmRuntime" group.
 *
 * To disable support of this group, redefine the
 * "createJvmRuntimeMetaNode()" factory method, and make it return "null"
 *
 * @param server    MBeanServer for this group (may be null)
 *
 **/
protected void initJvmRuntime(MBeanServer server)
    throws Exception {
    final String oid = getGroupOid("JvmRuntime", "1.3.6.1.4.1.42.2.145.3.163.1.1.4");
    ObjectName objname = null;
    if (server != null) {
        objname = getGroupObjectName("JvmRuntime", oid, mibName + ":name=sun.management.snmp.jvmmib.JvmRuntime");
    }
    final JvmRuntimeMeta meta = createJvmRuntimeMetaNode("JvmRuntime", oid, objname, server);
    if (meta != null) {
        meta.registerTableNodes( this, server );

        // Note that when using standard metadata,
        // the returned object must implement the "JvmRuntimeMBean"
        // interface.
        //
        final JvmRuntimeMBean group = (JvmRuntimeMBean) createJvmRuntimeMBean("JvmRuntime", oid, objname, server);
        meta.setInstance( group );
        registerGroupNode("JvmRuntime", oid, objname, meta, group, server);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:JVM_MANAGEMENT_MIB.java

示例5: initJvmThreading

import javax.management.MBeanServer; //导入依赖的package包/类
/**
 * Initialization of the "JvmThreading" group.
 *
 * To disable support of this group, redefine the
 * "createJvmThreadingMetaNode()" factory method, and make it return "null"
 *
 * @param server    MBeanServer for this group (may be null)
 *
 **/
protected void initJvmThreading(MBeanServer server)
    throws Exception {
    final String oid = getGroupOid("JvmThreading", "1.3.6.1.4.1.42.2.145.3.163.1.1.3");
    ObjectName objname = null;
    if (server != null) {
        objname = getGroupObjectName("JvmThreading", oid, mibName + ":name=sun.management.snmp.jvmmib.JvmThreading");
    }
    final JvmThreadingMeta meta = createJvmThreadingMetaNode("JvmThreading", oid, objname, server);
    if (meta != null) {
        meta.registerTableNodes( this, server );

        // Note that when using standard metadata,
        // the returned object must implement the "JvmThreadingMBean"
        // interface.
        //
        final JvmThreadingMBean group = (JvmThreadingMBean) createJvmThreadingMBean("JvmThreading", oid, objname, server);
        meta.setInstance( group );
        registerGroupNode("JvmThreading", oid, objname, meta, group, server);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:30,代码来源:JVM_MANAGEMENT_MIB.java

示例6: createSnmpRequestHandler

import javax.management.MBeanServer; //导入依赖的package包/类
private void createSnmpRequestHandler(SnmpAdaptorServer server,
                                      int id,
                                      DatagramSocket s,
                                      DatagramPacket p,
                                      SnmpMibTree tree,
                                      Vector<SnmpMibAgent> m,
                                      InetAddressAcl a,
                                      SnmpPduFactory factory,
                                      SnmpUserDataFactory dataFactory,
                                      MBeanServer f,
                                      ObjectName n) {
    final SnmpRequestHandler handler =
        new SnmpRequestHandler(this, id, s, p, tree, m, a, factory,
                               dataFactory, f, n);
    threadService.submitTask(handler);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:SnmpAdaptorServer.java

示例7: ClientHandler

import javax.management.MBeanServer; //导入依赖的package包/类
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.
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:ClientHandler.java

示例8: testPrivate

import javax.management.MBeanServer; //导入依赖的package包/类
private static void testPrivate(Class<?> iface) throws Exception {
    try {
        System.out.println("Creating a proxy for private M(X)Bean " +
                            iface.getName() + " ...");

        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
        ObjectName on = new ObjectName("test:type=Proxy");

        JMX.newMBeanProxy(mbs, on, iface);
        success("Created a proxy for private M(X)Bean - " + iface.getName());
    } catch (Exception e) {
        Throwable t = e;
        while (t != null && !(t instanceof NotCompliantMBeanException)) {
            t = t.getCause();
        }
        if (t != null) {
            fail("Proxy not created");
        } else {
            throw e;
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:JMXProxyFallbackTest.java

示例9: testSecondaryWebUi

import javax.management.MBeanServer; //导入依赖的package包/类
@Test
public void testSecondaryWebUi()
        throws IOException, MalformedObjectNameException,
               AttributeNotFoundException, MBeanException,
               ReflectionException, InstanceNotFoundException {
  MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
  ObjectName mxbeanName = new ObjectName(
          "Hadoop:service=SecondaryNameNode,name=SecondaryNameNodeInfo");

  String[] checkpointDir = (String[]) mbs.getAttribute(mxbeanName,
          "CheckpointDirectories");
  Assert.assertArrayEquals(checkpointDir, snn.getCheckpointDirectories());
  String[] checkpointEditlogDir = (String[]) mbs.getAttribute(mxbeanName,
          "CheckpointEditlogDirectories");
  Assert.assertArrayEquals(checkpointEditlogDir,
          snn.getCheckpointEditlogDirectories());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestSecondaryWebUi.java

示例10: preRegister

import javax.management.MBeanServer; //导入依赖的package包/类
/**
 * Initialization of the MIB with AUTOMATIC REGISTRATION in Java DMK.
 */
public ObjectName preRegister(MBeanServer server, ObjectName name)
        throws Exception {
    // Allow only one initialization of the MIB.
    //
    if (isInitialized == true) {
        throw new InstanceAlreadyExistsException();
    }

    // Initialize MBeanServer information.
    //
    this.server = server;

    populate(server, name);

    isInitialized = true;
    return name;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:JVM_MANAGEMENT_MIB.java

示例11: register

import javax.management.MBeanServer; //导入依赖的package包/类
public static ManagedConnection register ( final ManagedConnection connection, final SocketAddress socketAddress, final String baseName )
{
    try
    {
        final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer ();
        logger.debug ( "Creating name for: {}", socketAddress );

        final String remote = URLEncoder.encode ( socketAddress.toString (), "UTF-8" );

        final ObjectName name = new ObjectName ( baseName, "remote", remote );
        connection.setName ( name );
        mbs.registerMBean ( connection, name );
        return connection;
    }
    catch ( final Exception e )
    {
        logger.warn ( "Failed to register MXBean", e );
        return null;
    }

}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:22,代码来源:ManagedConnection.java

示例12: testPrivate

import javax.management.MBeanServer; //导入依赖的package包/类
private static void testPrivate(Class<?> iface, Object bean) throws Exception {
    try {
        System.out.println("Registering a private MBean " +
                            iface.getName() + " ...");

        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
        ObjectName on = new ObjectName("test:type=Compliant");

        mbs.registerMBean(bean, on);
        success("Registered a private MBean - " + iface.getName());
    } catch (Exception e) {
        Throwable t = e;
        while (t != null && !(t instanceof NotCompliantMBeanException)) {
            t = t.getCause();
        }
        if (t != null) {
            fail("MBean not registered");
        } else {
            throw e;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:MBeanFallbackTest.java

示例13: test

import javax.management.MBeanServer; //导入依赖的package包/类
private static boolean test(Object mbean, boolean expectImmutable)
        throws Exception {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    ObjectName on = new ObjectName("a:b=c");
    mbs.registerMBean(mbean, on);
    MBeanInfo mbi = mbs.getMBeanInfo(on);
    Descriptor d = mbi.getDescriptor();
    String immutableValue = (String) d.getFieldValue("immutableInfo");
    boolean immutable = ("true".equals(immutableValue));
    if (immutable != expectImmutable) {
        System.out.println("FAILED: " + mbean.getClass().getName() +
                " -> " + immutableValue);
        return false;
    } else {
        System.out.println("OK: " + mbean.getClass().getName());
        return true;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:ImmutableNotificationInfoTest.java

示例14: preRegister

import javax.management.MBeanServer; //导入依赖的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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:DefaultMBeanServerInterceptor.java

示例15: createServer

import javax.management.MBeanServer; //导入依赖的package包/类
/**
 * Create and configure (if necessary) and return the
 * <code>MBeanServer</code> with which we will be
 * registering our <code>DynamicMBean</code> implementations.
 */
public synchronized static MBeanServer createServer() {

    if (mserver == null) {
        try {
            mserver = Registry.getRegistry(null, null).getMBeanServer();
        } catch (Throwable t) {
            t.printStackTrace(System.out);
            System.exit(1);
        }
    }
    return (mserver);

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


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