java.util.ServiceLoader.Provider#javax.management.MBeanServer源码实例Demo

下面列出了java.util.ServiceLoader.Provider#javax.management.MBeanServer 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk8u-jdk   文件: JMXProxyFallbackTest.java
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;
        }
    }
}
 
源代码2 项目: openjdk-8   文件: SnmpRequestHandler.java
/**
 * Full constructor
 */
public SnmpRequestHandler(SnmpAdaptorServer server, int id,
                          DatagramSocket s, DatagramPacket p,
                          SnmpMibTree tree, Vector<SnmpMibAgent> m,
                          InetAddressAcl a,
                          SnmpPduFactory factory,
                          SnmpUserDataFactory dataFactory,
                          MBeanServer f, ObjectName n)
{
    super(server, id, f, n);

    // Need a reference on SnmpAdaptorServer for getNext & getBulk,
    // in case of oid equality (mib overlapping).
    //
    adaptor = server;
    socket = s;
    packet = p;
    root= tree;
    mibs = new Vector<>(m);
    subs= new Hashtable<>(mibs.size());
    ipacl = a;
    pduFactory = factory ;
    userDataFactory = dataFactory ;
    //thread.start();
}
 
源代码3 项目: gemfirexd-oss   文件: AgentImpl.java
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) {
    this.logWriter.info(LocalizedStrings.AgentImpl_0__IS_ALREADY_REGISTERED,
                        registryName);
  }
  mbs.invoke(registryName, "start", null, null);
}
 
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;
    }
}
 
源代码5 项目: jdk8u-jdk   文件: RandomMXBeanTest.java
private static <T> void test(MBeanServer mbs, Class<T> c) throws Exception {
    System.out.println("Testing " + c.getName());
    T merlin = c.cast(
        Proxy.newProxyInstance(c.getClassLoader(),
            new Class<?>[] {c},
            new DullInvocationHandler()));
    ObjectName merlinName = new ObjectName("a:type=" + c.getName());
    mbs.registerMBean(merlin, merlinName);
    System.out.println(mbs.getMBeanInfo(merlinName));
    T merlinProxy = JMX.newMXBeanProxy(mbs, merlinName, c);
    Method[] merlinMethods = c.getMethods();
    for (Method m : merlinMethods) {
        Class<?>[] types = m.getParameterTypes();
        Object[] params = new Object[types.length];
        for (int i = 0; i < types.length; i++)
            params[i] = DullInvocationHandler.zeroFor(types[i]);
        System.out.println("Invoking " + m.getName());
        m.invoke(merlinProxy, (Object[]) params);
    }
}
 
源代码6 项目: jdk8u-jdk   文件: ImmutableNotificationInfoTest.java
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;
    }
}
 
源代码7 项目: jdk8u_jdk   文件: MLetCommand.java
public static void main(String[] args) throws Exception {
    if (System.getSecurityManager() == null)
        throw new IllegalStateException("No security manager installed!");

    System.out.println("java.security.policy=" +
                       System.getProperty("java.security.policy"));

    // Instantiate the MBean server
    //
    System.out.println("Create the MBean server");
    MBeanServer mbs = MBeanServerFactory.createMBeanServer();
    // Register the MLetMBean
    //
    System.out.println("Create MLet MBean");
    ObjectName mlet = new ObjectName("MLetTest:name=MLetMBean");
    mbs.createMBean("javax.management.loading.MLet", mlet);
    // Test OK!
    //
    System.out.println("Bye! Bye!");
}
 
源代码8 项目: glowroot   文件: GaugeCollector.java
@Override
protected void runInternal() throws Exception {
    final List<GaugeValue> gaugeValues = Lists.newArrayList();
    if (priorRawCounterValues == null) {
        // wait to now to initialize priorGaugeValues inside of the dedicated thread
        priorRawCounterValues = Maps.newHashMap();
    }
    List<MBeanServer> mbeanServers = lazyPlatformMBeanServer.findAllMBeanServers();
    for (GaugeConfig gaugeConfig : configService.getGaugeConfigs()) {
        gaugeValues.addAll(collectGaugeValues(gaugeConfig, mbeanServers));
    }
    if (!pending.offer(gaugeValues)) {
        backPressureLogger.warn("not storing a gauge collection because of an excessive backlog"
                + " of {} gauge collections already waiting to be stored", PENDING_LIMIT);
    }
}
 
源代码9 项目: dragonwell8_jdk   文件: ExceptionDiagnosisTest.java
private static void testCaseProb() throws Exception {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    ObjectName name = new ObjectName("a:b=c");
    mbs.registerMBean(new CaseProbImpl(), name);
    CaseProbMXBean proxy = JMX.newMXBeanProxy(mbs, name, CaseProbMXBean.class);
    try {
        CaseProb prob = proxy.getCaseProb();
        fail("No exception from proxy method getCaseProb");
    } catch (IllegalArgumentException e) {
        String messageChain = messageChain(e);
        if (messageChain.contains("URLPath")) {
            System.out.println("Message chain contains URLPath as required: "
                    + messageChain);
        } else {
            fail("Exception chain for CaseProb does not mention property" +
                    " URLPath differing only in case");
            System.out.println("Full stack trace:");
            e.printStackTrace(System.out);
        }
    }
}
 
源代码10 项目: commons-dbcp   文件: TestBasicDataSource.java
/**
 * Make sure setting jmxName to null suppresses JMX registration of connection and statement pools.
 * JIRA: DBCP-434
 */
@Test
public void testJmxDisabled() throws Exception {
    final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    // Unregister leftovers from other tests (TODO: worry about concurrent test execution)
    final ObjectName commons = new ObjectName("org.apache.commons.*:*");
    final Set<ObjectName> results = mbs.queryNames(commons, null);
    for (final ObjectName result : results) {
        mbs.unregisterMBean(result);
    }
    ds.setJmxName(null);  // Should disable JMX for both connection and statement pools
    ds.setPoolPreparedStatements(true);
    ds.getConnection();  // Trigger initialization
    // Nothing should be registered
    assertEquals(0, mbs.queryNames(commons, null).size());
}
 
源代码11 项目: brooklyn-server   文件: PerformanceTestUtils.java
/** Not very fine-grained so not very useful; use {@link #getProcessCpuTime(Duration)} */ 
public static double getProcessCpuAverage() {
    try {
        MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
        ObjectName osMBeanName = ObjectName.getInstance(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
        return (Double) mbeanServer.getAttribute(osMBeanName, "ProcessCpuLoad");
    } catch (Exception e) {
        if (!hasLoggedProcessCpuLoadUnavailable) {
            hasLoggedProcessCpuLoadUnavailable = true;
            LOG.warn("ProcessCpuLoad not available in local JVM MXBean "+ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME+" (only available in sun JVM?)");
        }
        return -1;
    }
}
 
源代码12 项目: tomee   文件: EjbdJmxTest.java
@Test
public void test() throws Exception {
    System.setProperty("openejb.jmx.active", "true");
    final MBeanServer server = LocalMBeanServer.get();

    OpenEJB.init(new Properties());

    final Properties p = new Properties();
    p.put("server", "org.apache.openejb.server.ejbd.EjbServer");
    p.put("bind", "127.0.0.1");
    p.put("port", "0");
    p.put("disabled", "false");
    p.put("threads", "10");
    p.put("backlog", "200");
    p.put("discovery", "ejb:ejbd://{bind}:{port}");
    final ServerService service = ServiceManager.manage("ejbd", p, new EjbServer());
    service.init(p);
    service.start();

    ServiceManager.register("ejbd", service, server);

    ObjectName invocationsName = new ObjectName("openejb:type=ServerService,name=ejbd");

    MBeanInfo beanInfo = server.getMBeanInfo(invocationsName);

    for (MBeanAttributeInfo info : beanInfo.getAttributes()) {
        System.out.println(info);
    }

    service.stop();
    OpenEJB.destroy();
}
 
源代码13 项目: lucene-solr   文件: JmxMetricsReporter.java
private JmxListener(MBeanServer mBeanServer, String name, MetricFilter filter, TimeUnit rateUnit, TimeUnit durationUnit,
                    ObjectNameFactory objectNameFactory, String tag) {
  this.mBeanServer = mBeanServer;
  this.name = name;
  this.filter = filter;
  this.rateUnit = rateUnit;
  this.durationUnit = durationUnit;
  this.registered = new ConcurrentHashMap<>();
  this.objectNameFactory = objectNameFactory;
  this.tag = tag;
  this.exp = Query.eq(Query.attr(INSTANCE_TAG), Query.value(tag));
}
 
源代码14 项目: TencentKona-8   文件: MBeanServerBuilderImpl.java
public MBeanServer newMBeanServer(String defaultDomain,
                                  MBeanServer outer,
                                  MBeanServerDelegate delegate) {
    final MBeanServerForwarder mbsf =
        MBeanServerForwarderInvocationHandler.newProxyInstance();

    final MBeanServer innerMBeanServer =
        inner.newMBeanServer(defaultDomain,
                             (outer == null ? mbsf : outer),
                             delegate);

    mbsf.setMBeanServer(innerMBeanServer);
    return mbsf;
}
 
源代码15 项目: jdk8u-jdk   文件: DcmdMBeanInvocationTest.java
public static void main(String[] args) throws Exception {
    System.out.println("--->JRCMD MBean Test: invocation on \"help -all\" ...");

    ObjectName name = new ObjectName(HOTSPOT_DIAGNOSTIC_MXBEAN_NAME);
    String[] helpArgs = {"-all"};
    Object[] dcmdArgs = {helpArgs};
    String[] signature = {String[].class.getName()};

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    JMXServiceURL url = new JMXServiceURL("rmi", null, 0);
    JMXConnectorServer cs = null;
    JMXConnector cc = null;
    try {
        cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
        cs.start();
        JMXServiceURL addr = cs.getAddress();
        cc = JMXConnectorFactory.connect(addr);
        MBeanServerConnection mbsc = cc.getMBeanServerConnection();

        String result = (String) mbsc.invoke(name, "help", dcmdArgs, signature);
        System.out.println(result);
    } finally {
        try {
            cc.close();
            cs.stop();
        } catch (Exception e) {
        }
    }

    System.out.println("Test passed");
}
 
源代码16 项目: hottub   文件: UnregisterMBeanExceptionTest.java
public static void main(String[] args) throws Exception {

        // Instantiate the MBean server
        //
        System.out.println("Create the MBean server");
        MBeanServer mbs = MBeanServerFactory.createMBeanServer();

        // Register the MBean
        //
        System.out.println("Create a TestDynamicMBean");
        TestDynamicMBean obj = new TestDynamicMBean();
        ObjectName n = new ObjectName("d:k=v");
        System.out.println("Register a TestDynamicMBean");
        mbs.registerMBean(obj, n);
        obj.throwException = true;
        System.out.println("Unregister a TestDynamicMBean");
        try {
            mbs.unregisterMBean(n);
        } catch (Exception e) {
            throw new IllegalArgumentException("Test failed", e);
        }
        boolean isRegistered = mbs.isRegistered(n);
        System.out.println("Is MBean Registered? " + isRegistered);

        if (isRegistered) {
            throw new IllegalArgumentException(
                "Test failed: the MBean is still registered");
        } else {
            System.out.println("Test passed");
        }
    }
 
@Test
public void testMBeanServerNotification_REGISTRATION_NOTIFICATIONUsingMsc() throws Exception {
    KernelServices kernelServices = setup(new MBeanInfoAdditionalInitialization(ProcessType.STANDALONE_SERVER, new SubystemWithSingleFixedChildExtension()));
    ServiceController<?> service = kernelServices.getContainer().getService(MBeanServerService.SERVICE_NAME);
    MBeanServer mbeanServer = MBeanServer.class.cast(service.getValue());

    doTestMBeanServerNotification_REGISTRATION_NOTIFICATION(mbeanServer, true);
}
 
源代码18 项目: hottub   文件: QueryMatchTest.java
private static int query(MBeanServer mbs,
                         String pattern,
                         String[][] data) throws Exception {

    int error = 0;

    System.out.println("\nAttribute Value Pattern = " + pattern + "\n");
    for (int i = 0; i < data.length; i++) {
        ObjectName on = new ObjectName("domain:type=Simple,pattern=" +
                                       ObjectName.quote(pattern) +
                                       ",name=" + i);
        Simple s = new Simple(data[i][0]);
        mbs.registerMBean(s, on);
        QueryExp q =
            Query.match(Query.attr("StringNumber"), Query.value(pattern));
        q.setMBeanServer(mbs);
        boolean r = q.apply(on);
        System.out.print("Attribute Value = " +
            mbs.getAttribute(on, "StringNumber"));
        if (r && "OK".equals(data[i][1])) {
            System.out.println(" OK");
        } else if (!r && "KO".equals(data[i][1])) {
            System.out.println(" KO");
        } else {
            System.out.println(" Error");
            error++;
        }
    }

    return error;
}
 
源代码19 项目: jdk8u-dev-jdk   文件: DefaultLoaderRepository.java
private static Class<?> load(ClassLoader without, String className)
        throws ClassNotFoundException {
    final List<MBeanServer> mbsList = MBeanServerFactory.findMBeanServer(null);

    for (MBeanServer mbs : mbsList) {
        ClassLoaderRepository clr = mbs.getClassLoaderRepository();
        try {
            return clr.loadClassWithout(without, className);
        } catch (ClassNotFoundException e) {
            // OK : Try with next one...
        }
    }
    throw new ClassNotFoundException(className);
}
 
源代码20 项目: jdk8u-dev-jdk   文件: HotspotInternal.java
public ObjectName preRegister(MBeanServer server,
                              ObjectName name) throws java.lang.Exception {
    // register all internal MBeans when this MBean is instantiated
    // and to be registered in a MBeanServer.
    ManagementFactoryHelper.registerInternalMBeans(server);
    this.server = server;
    return objName;
}
 
源代码21 项目: openjdk-jdk8u-backup   文件: MXBeanTest.java
private static void testMXBean(MBeanServer mbs, ObjectName on)
        throws Exception {
    MBeanInfo mbi = mbs.getMBeanInfo(on);
    MBeanAttributeInfo[] attrs = mbi.getAttributes();
    int nattrs = attrs.length;
    if (mbi.getAttributes().length != 1)
        failure("wrong number of attributes: " + attrs);
    else {
        MBeanAttributeInfo mbai = attrs[0];
        if (mbai.getName().equals("Ints")
            && mbai.isReadable() && !mbai.isWritable()
            && mbai.getDescriptor().getFieldValue("openType")
                .equals(new ArrayType<int[]>(SimpleType.INTEGER, true))
            && attrs[0].getType().equals("[I"))
            success("MBeanAttributeInfo");
        else
            failure("MBeanAttributeInfo: " + mbai);
    }

    int[] ints = (int[]) mbs.getAttribute(on, "Ints");
    if (equal(ints, new int[] {1, 2, 3}, null))
        success("getAttribute");
    else
        failure("getAttribute: " + Arrays.toString(ints));

    ExplicitMXBean proxy =
        JMX.newMXBeanProxy(mbs, on, ExplicitMXBean.class);
    int[] pints = proxy.getInts();
    if (equal(pints, new int[] {1, 2, 3}, null))
        success("getAttribute through proxy");
    else
        failure("getAttribute through proxy: " + Arrays.toString(pints));
}
 
源代码22 项目: lams   文件: MappingProvidersDecodeAction.java
/** Decrypt the secret using the cipherKey.
 *
 * @param secret - the encrypted secret to decrypt.
 * @return the decrypted secret
 * @throws Exception
 */
private byte[] decode64(String secret)
   throws Exception
{
   SecurityManager sm = System.getSecurityManager();
   if( sm != null )
      sm.checkPermission(decodePermission);

   MBeanServer server = MBeanServerLocator.locateJBoss();
   return (byte[]) server.invoke(serviceName, "decode64", new Object[] {secret}, 
         new String[] {String.class.getName()});
}
 
源代码23 项目: jdk8u-jdk   文件: Server.java
public static String start() throws Exception {
    int serverPort = 12345;
    ObjectName name = new ObjectName("test", "foo", "bar");
    MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    SteMBean bean = new Ste();
    jmxServer.registerMBean(bean, name);
    boolean exported = false;
    Random rnd = new Random(System.currentTimeMillis());
    do {
        try {
            LocateRegistry.createRegistry(serverPort);
            exported = true;
        } catch (ExportException ee) {
            if (ee.getCause() instanceof BindException) {
                serverPort = rnd.nextInt(10000) + 4096;
            } else {
                throw ee;
            }
        }

    } while (!exported);
    JMXServiceURL serverUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + serverPort + "/test");
    JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(serverUrl, null, jmxServer);
    jmxConnector.start();

    return serverUrl.toString();
}
 
源代码24 项目: flink   文件: MemoryLogger.java
/**
 * Creates a new memory logger that logs in the given interval and lives until the
 * given termination future completes.
 *
 * @param logger The logger to use for outputting the memory statistics.
 * @param interval The interval in which the thread logs.
 * @param monitored termination future for the system to whose life the thread is bound. The thread terminates
 *                  once the system terminates.
 */
public MemoryLogger(Logger logger, long interval, CompletableFuture<Void> monitored) {
	super("Memory Logger");
	setDaemon(true);
	setPriority(Thread.MIN_PRIORITY);
	
	this.logger = logger;
	this.interval = interval;
	this.monitored = monitored;

	this.memoryBean = ManagementFactory.getMemoryMXBean();
	this.poolBeans = ManagementFactory.getMemoryPoolMXBeans();
	this.gcBeans = ManagementFactory.getGarbageCollectorMXBeans();

	// The direct buffer pool bean needs to be accessed via the bean server
	MBeanServer beanServer = ManagementFactory.getPlatformMBeanServer();
	BufferPoolMXBean directBufferBean = null;
	try {
		directBufferBean = ManagementFactory.newPlatformMXBeanProxy(
				beanServer,
				"java.nio:type=BufferPool,name=direct",
				BufferPoolMXBean.class);
	}
	catch (Exception e) {
		logger.warn("Failed to initialize direct buffer pool bean.", e);
	}
	finally {
		this.directBufferBean = directBufferBean;
	}
}
 
源代码25 项目: hadoop   文件: MBeans.java
static public void unregister(ObjectName mbeanName) {
  LOG.debug("Unregistering "+ mbeanName);
  final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
  if (mbeanName == null) {
    LOG.debug("Stacktrace: ", new Throwable());
    return;
  }
  try {
    mbs.unregisterMBean(mbeanName);
  } catch (Exception e) {
    LOG.warn("Error unregistering "+ mbeanName, e);
  }
  DefaultMetricsSystem.removeMBeanName(mbeanName);
}
 
public static void check(String attr, MBeanServer server, ObjectName mon,
        ObjectName mbean, long start) throws Exception {
    final Object obj = server.getAttribute(mon, "DerivedGauge");
    final long now = System.currentTimeMillis();
    final long gran = (Long)server.getAttribute(mon, "GranularityPeriod");
    if (now > start +2*gran) {
        throw new Exception(attr+": Can't verify test case: " +
                "granularity period expired!");
    }
    check(attr,server,mon,mbean,obj);
}
 
源代码27 项目: dragonwell8_jdk   文件: ImplVersionCommand.java
public static void main(String[] args) throws Exception {
    // Instantiate the MBean server
    //
    System.out.println("Create the MBean server");
    MBeanServer mbs = MBeanServerFactory.createMBeanServer();

    // Get the JMX implementation version from the MBeanServerDelegateMBean
    //
    System.out.println("Get the JMX implementation version");
    ObjectName mbsdName =
        new ObjectName("JMImplementation:type=MBeanServerDelegate");
    String mbsdAttribute = "ImplementationVersion";
    String mbsdVersion = (String) mbs.getAttribute(mbsdName, mbsdAttribute);

    // Display JMX implementation version and JVM implementation version
    //
    System.out.println("JMX implementation version          = " +
                       mbsdVersion);
    System.out.println("Java Runtime implementation version = " +
                       args[0]);

    // Check JMX implementation version vs. JVM implementation version
    //
    if (Boolean.valueOf(args[1]).booleanValue()) {
        if (!mbsdVersion.equals(args[0]))
            throw new IllegalArgumentException(
              "JMX and Java Runtime implementation versions do not match!");
        // Test OK!
        //
        System.out.println("JMX and Java Runtime implementation " +
                           "versions match!");
    } else {
        // Test OK!
        //
        System.out.println("JMX and Java Runtime implementation " +
                           "versions do not match because the test " +
                           "is using an unbundled version of JMX!");
    }
    System.out.println("Bye! Bye!");
}
 
源代码28 项目: stratio-cassandra   文件: EndpointSnitchInfo.java
public static void create()
{
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    try
    {
        mbs.registerMBean(new EndpointSnitchInfo(), new ObjectName("org.apache.cassandra.db:type=EndpointSnitchInfo"));
    }
    catch (Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
源代码29 项目: activemq-artemis   文件: ActiveMQServerImpl.java
@Override
public void setMBeanServer(MBeanServer mbeanServer) {
   if (state == SERVER_STATE.STARTING || state == SERVER_STATE.STARTED) {
      throw ActiveMQMessageBundle.BUNDLE.cannotSetMBeanserver();
   }
   this.mbeanServer = mbeanServer;
}
 
源代码30 项目: tomcatsrc   文件: JmxPasswordTest.java
@Test
public void testPassword() throws Exception {
    Assert.assertEquals("Passwords should match when not using JMX.",password,datasource.getPoolProperties().getPassword());
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    ConnectionPoolMBean mbean = JMX.newMBeanProxy(mbs, oname, ConnectionPoolMBean.class);
    String jmxPassword = mbean.getPassword();
    Properties jmxProperties = mbean.getDbProperties();
    Assert.assertFalse("Passwords should not match.", password.equals(jmxPassword));
    Assert.assertFalse("Password property should be missing", jmxProperties.containsKey(PoolUtilities.PROP_PASSWORD));
}