當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectInstance類代碼示例

本文整理匯總了Java中javax.management.ObjectInstance的典型用法代碼示例。如果您正苦於以下問題:Java ObjectInstance類的具體用法?Java ObjectInstance怎麽用?Java ObjectInstance使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ObjectInstance類屬於javax.management包,在下文中一共展示了ObjectInstance類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testJmxBeans

import javax.management.ObjectInstance; //導入依賴的package包/類
@Test
public void testJmxBeans() throws Exception {
  final int NUM_SERVERS = 3;
  final MiniRaftClusterWithSimulatedRpc cluster
      = MiniRaftClusterWithSimulatedRpc.FACTORY.newCluster(3, new RaftProperties());
  cluster.start();
  waitForLeader(cluster);

  MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
  Set<ObjectInstance> objectInstances = platformMBeanServer.queryMBeans(new ObjectName("Ratis:*"), null);
  Assert.assertEquals(NUM_SERVERS, objectInstances.size());

  for (ObjectInstance instance : objectInstances) {
    Object groupId = platformMBeanServer.getAttribute(instance.getObjectName(), "GroupId");
    Assert.assertEquals(cluster.getGroupId().toString(), groupId);
  }
  cluster.shutdown();
}
 
開發者ID:apache,項目名稱:incubator-ratis,代碼行數:19,代碼來源:TestRaftServerJmx.java

示例2: registerMBean

import javax.management.ObjectInstance; //導入依賴的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

示例3: scanMBeans

import javax.management.ObjectInstance; //導入依賴的package包/類
/**
 * scan out all monitor MBeans
 *
 * @param mbsc
 * @return
 * @throws IOException
 */
protected Set<ObjectInstance> scanMBeans(MBeanServerConnection mbsc, String pattern) throws IOException {

    Set<ObjectInstance> monitorMBeans = null;
    int count = 2;
    while (count > 0) {
        try {
            monitorMBeans = mbsc.queryMBeans(new ObjectName(pattern), null);

            if (monitorMBeans == null || monitorMBeans.isEmpty()) {
                ThreadHelper.suspend(2000);
            }
            else {
                break;
            }

        }
        catch (MalformedObjectNameException e) {
            // ignore
        }
        count--;
    }

    return monitorMBeans;
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:32,代碼來源:BaseJMXMonitorDataCatchWorker.java

示例4: createMBean

import javax.management.ObjectInstance; //導入依賴的package包/類
/**
 * Call <code>checkCreate(className)</code>, then forward this method to the
 * wrapped object.
 */
public ObjectInstance createMBean(String className, ObjectName name)
    throws
    ReflectionException,
    InstanceAlreadyExistsException,
    MBeanRegistrationException,
    MBeanException,
    NotCompliantMBeanException {
    checkCreate(className);
    SecurityManager sm = System.getSecurityManager();
    if (sm == null) {
        Object object = getMBeanServer().instantiate(className);
        checkClassLoader(object);
        return getMBeanServer().registerMBean(object, name);
    } else {
        return getMBeanServer().createMBean(className, name);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:22,代碼來源:MBeanServerAccessController.java

示例5: queryMBeans

import javax.management.ObjectInstance; //導入依賴的package包/類
public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) {
    Set<ObjectInstance> instances = newSet();
    if (name == null)
        name = ObjectName.WILDCARD;
    if (query == null)
        query = trueQuery;
    MBeanServer oldMBS = QueryEval.getMBeanServer();
    try {
        query.setMBeanServer(this);
        for (ObjectName n : mbeans.keySet()) {
            if (name.apply(n)) {
                try {
                    if (query.apply(n))
                        instances.add(getObjectInstance(n));
                } catch (Exception e) {
                    // OK: Ignore this MBean in the result
                }
            }
        }
    } finally {
        query.setMBeanServer(oldMBS);
    }
    return instances;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:OldMBeanServerTest.java

示例6: getObjectInstance

import javax.management.ObjectInstance; //導入依賴的package包/類
public ObjectInstance getObjectInstance(ObjectName name)
throws InstanceNotFoundException,
        IOException {
    if (logger.debugOn())
        logger.debug("getObjectInstance", "name=" + name);

    final ClassLoader old = pushDefaultClassLoader();
    try {
        return connection.getObjectInstance(name, delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        return connection.getObjectInstance(name, delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:RMIConnector.java

示例7: queryMBeans

import javax.management.ObjectInstance; //導入依賴的package包/類
public Set<ObjectInstance> queryMBeans(ObjectName name,
        QueryExp query)
        throws IOException {
    if (logger.debugOn()) logger.debug("queryMBeans",
            "name=" + name + ", query=" + query);

    final MarshalledObject<QueryExp> sQuery =
            new MarshalledObject<QueryExp>(query);
    final ClassLoader old = pushDefaultClassLoader();
    try {
        return connection.queryMBeans(name, sQuery, delegationSubject);
    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        return connection.queryMBeans(name, sQuery, delegationSubject);
    } finally {
        popDefaultClassLoader(old);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:20,代碼來源:RMIConnector.java

示例8: createMBean

import javax.management.ObjectInstance; //導入依賴的package包/類
public ObjectInstance createMBean(String className, ObjectName name,
                                  Object[] params, String[] signature)
    throws ReflectionException, InstanceAlreadyExistsException,
           MBeanRegistrationException, MBeanException,
           NotCompliantMBeanException  {

    try {
        return createMBean(className, name, null, true,
                           params, signature);
    } catch (InstanceNotFoundException e) {
        /* Can only happen if loaderName doesn't exist, but we just
           passed null, so we shouldn't get this exception.  */
        throw EnvHelp.initCause(
            new IllegalArgumentException("Unexpected exception: " + e), e);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:17,代碼來源:DefaultMBeanServerInterceptor.java

示例9: createMBean

import javax.management.ObjectInstance; //導入依賴的package包/類
/**
 * Call <code>checkCreate(className)</code>, then forward this method to the
 * wrapped object.
 */
public ObjectInstance createMBean(String className,
                                  ObjectName name,
                                  ObjectName loaderName)
    throws
    ReflectionException,
    InstanceAlreadyExistsException,
    MBeanRegistrationException,
    MBeanException,
    NotCompliantMBeanException,
    InstanceNotFoundException {
    checkCreate(className);
    SecurityManager sm = System.getSecurityManager();
    if (sm == null) {
        Object object = getMBeanServer().instantiate(className,
                                                     loaderName);
        checkClassLoader(object);
        return getMBeanServer().registerMBean(object, name);
    } else {
        return getMBeanServer().createMBean(className, name, loaderName);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:26,代碼來源:MBeanServerAccessController.java

示例10: createMBean

import javax.management.ObjectInstance; //導入依賴的package包/類
public ObjectInstance createMBean(String className, ObjectName name,
                                  ObjectName loaderName,
                                  Object[] params, String[] signature)
    throws ReflectionException, InstanceAlreadyExistsException,
           MBeanRegistrationException, MBeanException,
           NotCompliantMBeanException, InstanceNotFoundException  {

    return createMBean(className, name, loaderName, false,
                       params, signature);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:DefaultMBeanServerInterceptor.java

示例11: createMBean

import javax.management.ObjectInstance; //導入依賴的package包/類
@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...");
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:9,代碼來源:PogamutMBeanServer.java

示例12: createMBean

import javax.management.ObjectInstance; //導入依賴的package包/類
public ObjectInstance createMBean(
        String className, ObjectName name, Object[] params, String[] signature)
throws ReflectionException, InstanceAlreadyExistsException,
        MBeanRegistrationException, MBeanException,
        NotCompliantMBeanException {
    try {
        return createMBean(className, name, clrName, params, signature);
    } catch (InstanceNotFoundException ex) {
        throw new RuntimeException(ex);  // can't happen
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:OldMBeanServerTest.java

示例13: registerMBean

import javax.management.ObjectInstance; //導入依賴的package包/類
@Override
public synchronized ObjectInstance registerMBean(Object object, ObjectName name)
		throws InstanceAlreadyExistsException, MBeanRegistrationException,
		NotCompliantMBeanException {		
	ObjectInstance obj = mbs.registerMBean(object, name);
	mBeans.add(new MBean1(name, object));
	unregisteredMBeans.remove(new MBean1(name, object));
	return obj;
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:10,代碼來源:PogamutMBeanServer.java

示例14: doExploit

import javax.management.ObjectInstance; //導入依賴的package包/類
private static void doExploit ( final Object payloadObject, MBeanServerConnection mbc )
        throws IOException, InstanceNotFoundException, IntrospectionException, ReflectionException {
    Object[] params = new Object[1];
    params[ 0 ] = payloadObject;
    System.err.println("Querying MBeans");
    Set<ObjectInstance> testMBeans = mbc.queryMBeans(null, null);
    System.err.println("Found " + testMBeans.size() + " MBeans");
    for ( ObjectInstance oi : testMBeans ) {
        MBeanInfo mBeanInfo = mbc.getMBeanInfo(oi.getObjectName());
        for ( MBeanOperationInfo opInfo : mBeanInfo.getOperations() ) {
            try {
                mbc.invoke(oi.getObjectName(), opInfo.getName(), params, new String[] {});
                System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> SUCCESS");
                return;
            }
            catch ( Throwable e ) {
                String msg = e.getMessage();
                if ( msg.startsWith("java.lang.ClassNotFoundException:") ) {
                    int start = msg.indexOf('"');
                    int stop = msg.indexOf('"', start + 1);
                    String module = ( start >= 0 && stop > 0 ) ? msg.substring(start + 1, stop) : "<unknown>";
                    if ( !"<unknown>".equals(module) && !"org.jboss.as.jmx:main".equals(module) ) {
                        int cstart = msg.indexOf(':');
                        int cend = msg.indexOf(' ', cstart + 2);
                        String cls = msg.substring(cstart + 2, cend);
                        System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> FAIL CNFE " + cls + " (" + module + ")");
                    }
                }
                else {
                    System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> SUCCESS|ERROR " + msg);
                    return;
                }
            }
        }
    }
}
 
開發者ID:hucheat,項目名稱:APacheSynapseSimplePOC,代碼行數:37,代碼來源:JBoss.java

示例15: init

import javax.management.ObjectInstance; //導入依賴的package包/類
public void init(String host, int port) throws Exception {
    int iport = 0;
    String shost = null;
    mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
    String onStr = "*:type=ThreadPool,*";
    ObjectName objectName = new ObjectName(onStr);
    Set<ObjectInstance> set = mBeanServer.queryMBeans(objectName, null);
    Iterator<ObjectInstance> iterator = set.iterator();
    while (iterator.hasNext()) {
        ObjectInstance oi = iterator.next();
        objName = oi.getObjectName();
        String name = objName.getKeyProperty("name");
          
        /* Name are:
         * http-8080
         * jk-10.33.144.3-8009
         * jk-jfcpc%2F10.33.144.3-8009
         */
        String [] elenames = name.split("-");
        String sport = elenames[elenames.length-1];
        iport = Integer.parseInt(sport);
        String [] shosts = elenames[1].split("%2F");
        shost = shosts[0];

        if (port==0 && host==null)
              break; /* Take the first one */
        if (host==null && iport==port)
            break; /* Only port done */
        if (shost.compareTo(host) == 0)
            break; /* Done port and host are the expected ones */
    }
    if (objName == null)
        throw(new Exception("Can't find connector for " + host + ":" + port));
    this.port = iport;
    this.host = shost;
    
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:38,代碼來源:CollectedInfo.java


注:本文中的javax.management.ObjectInstance類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。