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


Java MBeanServerInvocationHandler.newProxyInstance方法代码示例

本文整理汇总了Java中javax.management.MBeanServerInvocationHandler.newProxyInstance方法的典型用法代码示例。如果您正苦于以下问题:Java MBeanServerInvocationHandler.newProxyInstance方法的具体用法?Java MBeanServerInvocationHandler.newProxyInstance怎么用?Java MBeanServerInvocationHandler.newProxyInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.management.MBeanServerInvocationHandler的用法示例。


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

示例1: getWorkManager

import javax.management.MBeanServerInvocationHandler; //导入方法依赖的package包/类
/**
 * Obtain the default JBoss JCA WorkManager through a JMX lookup
 * for the JBossWorkManagerMBean.
 * @param mbeanName the JMX object name to use
 * @see org.jboss.resource.work.JBossWorkManagerMBean
 */
public static WorkManager getWorkManager(String mbeanName) {
	Assert.hasLength(mbeanName, "JBossWorkManagerMBean name must not be empty");
	try {
		Class<?> mbeanClass = JBossWorkManagerUtils.class.getClassLoader().loadClass(JBOSS_WORK_MANAGER_MBEAN_CLASS_NAME);
		InitialContext jndiContext = new InitialContext();
		MBeanServerConnection mconn = (MBeanServerConnection) jndiContext.lookup(MBEAN_SERVER_CONNECTION_JNDI_NAME);
		ObjectName objectName = ObjectName.getInstance(mbeanName);
		Object workManagerMBean = MBeanServerInvocationHandler.newProxyInstance(mconn, objectName, mbeanClass, false);
		Method getInstanceMethod = workManagerMBean.getClass().getMethod("getInstance");
		return (WorkManager) getInstanceMethod.invoke(workManagerMBean);
	}
	catch (Exception ex) {
		throw new IllegalStateException(
				"Could not initialize JBossWorkManagerTaskExecutor because JBoss API is not available", ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:JBossWorkManagerUtils.java

示例2: carryOverAndClose

import javax.management.MBeanServerInvocationHandler; //导入方法依赖的package包/类
/**
 * Reads the counters from the prior instance of this class, increments this instances counters and closes the prior.
 */
protected void carryOverAndClose() {
	final ManagedScriptMBean oldScript = MBeanServerInvocationHandler.newProxyInstance(JMXHelper.getHeliosMBeanServer(), objectName, ManagedScriptMBean.class, false);
	deploymentId = oldScript.getDeploymentId()+1;
	totalErrors.add(oldScript.getTotalCollectionErrors());
	Date dt = oldScript.getLastCollectionErrorDate();
	if(dt!=null) {
		lastError.set(dt.getTime());
	}
	dt = oldScript.getLastCollectionDate();
	if(dt!=null) {
		lastCompleteCollection.set(dt.getTime());
	}
	final Long lastElapsed = oldScript.getLastCollectionElapsed();
	if(lastElapsed!=null) {
		lastCollectionElapsed.set(lastElapsed);
	}
	try { oldScript.close(); } catch (Exception x) {/* No Op */}
	
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:23,代码来源:ManagedScript.java

示例3: testBrowseExpiredMessages

import javax.management.MBeanServerInvocationHandler; //导入方法依赖的package包/类
public void testBrowseExpiredMessages() throws Exception {
   JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1199/jmxrmi");
   JMXConnector connector = JMXConnectorFactory.connect(url, null);
   connector.connect();
   MBeanServerConnection connection = connector.getMBeanServerConnection();
   ObjectName name = new ObjectName("org.apache.activemq:type=Broker,brokerName=localhost," + "destinationType=Queue,destinationName=TEST.Q");
   QueueViewMBean queueMbean = MBeanServerInvocationHandler.newProxyInstance(connection, name, QueueViewMBean.class, true);
   HashMap<String, String> headers = new HashMap<>();
   headers.put("timeToLive", Long.toString(2000));
   headers.put("JMSDeliveryMode", Integer.toString(DeliveryMode.PERSISTENT));
   queueMbean.sendTextMessage(headers, "test", "system", "manager");
   // allow message to expire on the queue
   TimeUnit.SECONDS.sleep(4);

   Connection c = new ActiveMQConnectionFactory("vm://localhost").createConnection("system", "manager");
   c.start();

   // browser consumer will force expiration check on addConsumer
   QueueBrowser browser = c.createSession(false, Session.AUTO_ACKNOWLEDGE).createBrowser(new ActiveMQQueue("TEST.Q"));
   assertTrue("no message in the q", !browser.getEnumeration().hasMoreElements());

   // verify dlq got the message, no security exception as brokers context is now used
   browser = c.createSession(false, Session.AUTO_ACKNOWLEDGE).createBrowser(new ActiveMQQueue("ActiveMQ.DLQ"));
   assertTrue("one message in the dlq", browser.getEnumeration().hasMoreElements());
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:SecurityJMXTest.java

示例4: displayAllDestinations

import javax.management.MBeanServerInvocationHandler; //导入方法依赖的package包/类
private void displayAllDestinations() throws Exception {

        String query = JmxMBeansUtil.createQueryString(queryString, "*");
        List<?> queueList = JmxMBeansUtil.queryMBeans(createJmxConnection(), query);

        final String header = "%-50s  %10s  %10s  %10s  %10s  %10s  %10s";
        final String tableRow = "%-50s  %10d  %10d  %10d  %10d  %10d  %10d";

        context.print(String.format(Locale.US, header, "Name", "Queue Size", "Producer #", "Consumer #", "Enqueue #", "Dequeue #", "Memory %"));

        // Iterate through the queue result
        for (Object view : queueList) {
            ObjectName queueName = ((ObjectInstance)view).getObjectName();
            QueueViewMBean queueView = MBeanServerInvocationHandler.
                newProxyInstance(createJmxConnection(), queueName, QueueViewMBean.class, true);

            context.print(String.format(Locale.US, tableRow,
                    queueView.getName(),
                    queueView.getQueueSize(),
                    queueView.getProducerCount(),
                    queueView.getConsumerCount(),
                    queueView.getEnqueueCount(),
                    queueView.getDequeueCount(),
                    queueView.getMemoryPercentUsage()));
        }
    }
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:27,代码来源:DstatCommand.java

示例5: displayQueueStats

import javax.management.MBeanServerInvocationHandler; //导入方法依赖的package包/类
private void displayQueueStats() throws Exception {

        String query = JmxMBeansUtil.createQueryString(queryString, "Queue");
        List<?> queueList = JmxMBeansUtil.queryMBeans(createJmxConnection(), query);

        final String header = "%-50s  %10s  %10s  %10s  %10s  %10s  %10s";
        final String tableRow = "%-50s  %10d  %10d  %10d  %10d  %10d  %10d";

        context.print(String.format(Locale.US, header, "Name", "Queue Size", "Producer #", "Consumer #", "Enqueue #", "Dequeue #", "Memory %"));

        // Iterate through the queue result
        for (Object view : queueList) {
            ObjectName queueName = ((ObjectInstance)view).getObjectName();
            QueueViewMBean queueView = MBeanServerInvocationHandler.
                newProxyInstance(createJmxConnection(), queueName, QueueViewMBean.class, true);

            context.print(String.format(Locale.US, tableRow,
                    queueView.getName(),
                    queueView.getQueueSize(),
                    queueView.getProducerCount(),
                    queueView.getConsumerCount(),
                    queueView.getEnqueueCount(),
                    queueView.getDequeueCount(),
                    queueView.getMemoryPercentUsage()));
        }
    }
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:27,代码来源:DstatCommand.java

示例6: displayTopicStats

import javax.management.MBeanServerInvocationHandler; //导入方法依赖的package包/类
private void displayTopicStats() throws Exception {

        String query = JmxMBeansUtil.createQueryString(queryString, "Topic");
        List<?> topicsList = JmxMBeansUtil.queryMBeans(createJmxConnection(), query);

        final String header = "%-50s  %10s  %10s  %10s  %10s  %10s  %10s";
        final String tableRow = "%-50s  %10d  %10d  %10d  %10d  %10d  %10d";

        context.print(String.format(Locale.US, header, "Name", "Queue Size", "Producer #", "Consumer #", "Enqueue #", "Dequeue #", "Memory %"));

        // Iterate through the topics result
        for (Object view : topicsList) {
            ObjectName topicName = ((ObjectInstance)view).getObjectName();
            TopicViewMBean topicView = MBeanServerInvocationHandler.
                newProxyInstance(createJmxConnection(), topicName, TopicViewMBean.class, true);

            context.print(String.format(Locale.US, tableRow,
                    topicView.getName(),
                    topicView.getQueueSize(),
                    topicView.getProducerCount(),
                    topicView.getConsumerCount(),
                    topicView.getEnqueueCount(),
                    topicView.getDequeueCount(),
                    topicView.getMemoryPercentUsage()));
        }
    }
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:27,代码来源:DstatCommand.java

示例7: getMonitor

import javax.management.MBeanServerInvocationHandler; //导入方法依赖的package包/类
/**
 * get an mbean instance for a remote jmx-enabled jvm.
 * 
 * @param jmxServerUrl
 *            jmx service url, for example
 *            <code>service:jmx:rmi:///jndi/rmi://:9999/jmxrmi</code>
 * @param host
 *            channel pool's tcp host
 * @param port
 *            channel pool's tcp port
 * @return a proxy for the monitor associated with the pool
 */
public static ChannelPoolMonitorMBean getMonitor(String jmxServerUrl, String host, int port) throws IOException {
	ObjectName objectName = null;
	try {
		objectName = makeObjectName(host, port);
	} catch (MalformedObjectNameException e) {
		throw new IllegalArgumentException(e);
	}

	JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:9999/jmxrmi");
	JMXConnector jmxc = JMXConnectorFactory.connect(url, null);

	MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();

	Set<ObjectInstance> set = mbsc.queryMBeans(objectName, null);
	if (set == null || set.isEmpty()) {
		return null;
	} else {
		return MBeanServerInvocationHandler.newProxyInstance(mbsc, objectName, ChannelPoolMonitorMBean.class, true);
	}
}
 
开发者ID:jrialland,项目名称:ajp-client,代码行数:33,代码来源:JmxExporter.java

示例8: expireAppMasterZKSession

import javax.management.MBeanServerInvocationHandler; //导入方法依赖的package包/类
private boolean expireAppMasterZKSession(TwillController controller, long timeout, TimeUnit timeoutUnit) {
  MBeanServer mbeanServer = MBeanRegistry.getInstance().getPlatformMBeanServer();
  QueryExp query = Query.isInstanceOf(new StringValueExp(ConnectionMXBean.class.getName()));

  Stopwatch stopwatch = new Stopwatch();

  do {
    // Find the AM session and expire it
    Set<ObjectName> connectionBeans = mbeanServer.queryNames(ObjectName.WILDCARD, query);
    for (ObjectName objectName : connectionBeans) {

      ConnectionMXBean connectionBean = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName,
                                                                                      ConnectionMXBean.class, false);
      for (String node : connectionBean.getEphemeralNodes()) {
        if (node.endsWith("/instances/" + controller.getRunId().getId())) {
          // This is the AM, expire the session.
          LOG.info("Kill AM session {}", connectionBean.getSessionId());
          connectionBean.terminateSession();
          return true;
        }
      }
    }
  } while (stopwatch.elapsedTime(timeoutUnit) < timeout);

  return false;
}
 
开发者ID:chtyim,项目名称:incubator-twill,代码行数:27,代码来源:SessionExpireTestRun.java

示例9: connect

import javax.management.MBeanServerInvocationHandler; //导入方法依赖的package包/类
private void connect() throws IOException {
    JMXServiceURL jmxUrl = new JMXServiceURL(String.format(fmtUrl, host, port));
    JMXConnector jmxc = JMXConnectorFactory.connect(jmxUrl, null);
    mbeanServerConn = jmxc.getMBeanServerConnection();

    try {
        ObjectName name = new ObjectName(DOMAINLIST_OBJECT_NAME);
        domainListProcxy = (DomainListManagementMBean) MBeanServerInvocationHandler.newProxyInstance(mbeanServerConn, name, DomainListManagementMBean.class, true);
        name = new ObjectName(VIRTUALUSERTABLE_OBJECT_NAME);
        virtualUserTableProxy = (RecipientRewriteTableManagementMBean) MBeanServerInvocationHandler.newProxyInstance(mbeanServerConn, name, RecipientRewriteTableManagementMBean.class, true);
        name = new ObjectName(USERSREPOSITORY_OBJECT_NAME);
        usersRepositoryProxy = (UsersRepositoryManagementMBean) MBeanServerInvocationHandler.newProxyInstance(mbeanServerConn, name, UsersRepositoryManagementMBean.class, true);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException("Invalid ObjectName? Please report this as a bug.", e);
    }
}
 
开发者ID:twachan,项目名称:James,代码行数:17,代码来源:JmxServerProbe.java

示例10: Ex4Service

import javax.management.MBeanServerInvocationHandler; //导入方法依赖的package包/类
public Ex4Service() throws URISyntaxException {
  CachingProvider cachingProvider = Caching.getCachingProvider("org.ehcache.jsr107.EhcacheCachingProvider");

  CacheManager cacheManager = cachingProvider.getCacheManager(
      getClass().getResource("/ehcache-ex4.xml").toURI(),
      getClass().getClassLoader());
  cache = cacheManager.getCache("someCache4", Long.class, Person.class);

  try {
    MBeanServer beanServer = ManagementFactory.getPlatformMBeanServer();
    ObjectName objectName = new ObjectName("javax.cache:type=CacheStatistics,CacheManager="
        + getClass().getResource("/ehcache-ex4.xml")
        .toURI()
        .toString()
        .replace(":", ".") + ",Cache=someCache4");
    cacheStatisticsMXBean = MBeanServerInvocationHandler.newProxyInstance(beanServer, objectName, CacheStatisticsMXBean.class, false);
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:aurbroszniowski,项目名称:DevoxxFr2017,代码行数:21,代码来源:Ex4Service.java

示例11: main

import javax.management.MBeanServerInvocationHandler; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	// InternalLoggerFactory.setDefaultFactory(new SimpleLoggerFactory());

	AHessianJmxClient _ahessianClient = new AHessianJmxClient("test",
			15009, false, null);
	_ahessianClient.start();
	MBeanServerConnection jmxc = _ahessianClient.getMBeanServer();
	MBeanServerDelegateMBean proxy = (MBeanServerDelegateMBean) MBeanServerInvocationHandler
			.newProxyInstance(jmxc, new ObjectName(
					"JMImplementation:type=MBeanServerDelegate"),
					MBeanServerDelegateMBean.class, false);
	System.out.println(proxy.getMBeanServerId());
	boolean ok = false;
	while (true)
		try
		{
			System.out.println(proxy.getMBeanServerId());
			ok = true;
			Thread.sleep(1000);
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
			Thread.sleep(1000);
		}

}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:29,代码来源:AHessianJmxClient.java

示例12: run

import javax.management.MBeanServerInvocationHandler; //导入方法依赖的package包/类
@Override
public void run(CommandLine line, ToolRunningContext context) throws Exception {

    OnlineWorkflowStartParameters startconfig = OnlineWorkflowStartParameters.loadDefault();

    String host = line.getOptionValue(OnlineWorkflowCommand.HOST);
    String port = line.getOptionValue(OnlineWorkflowCommand.PORT);
    String threads = line.getOptionValue(OnlineWorkflowCommand.THREADS);
    if (host != null) {
        startconfig.setJmxHost(host);
    }
    if (port != null) {
        startconfig.setJmxPort(Integer.valueOf(port));
    }
    if (threads != null) {
        startconfig.setThreads(Integer.valueOf(threads));
    }


    String urlString = "service:jmx:rmi:///jndi/rmi://" + startconfig.getJmxHost() + ":" + startconfig.getJmxPort() + "/jmxrmi";

    JMXServiceURL serviceURL = new JMXServiceURL(urlString);
    Map<String, String> jmxEnv = new HashMap<>();
    JMXConnector connector = JMXConnectorFactory.connect(serviceURL, jmxEnv);
    MBeanServerConnection mbsc = connector.getMBeanServerConnection();

    ObjectName name = new ObjectName(LocalOnlineApplicationMBean.BEAN_NAME);
    LocalOnlineApplicationMBean application = MBeanServerInvocationHandler.newProxyInstance(mbsc, name, LocalOnlineApplicationMBean.class, false);


    boolean emptyContingency = line.hasOption("empty-contingency");
    Path caseFile = Paths.get(line.getOptionValue("case-file"));
    application.runTDSimulations(startconfig, caseFile.toString(), line.getOptionValue("contingencies"), Boolean.toString(emptyContingency), line.getOptionValue("output-folder"));
}
 
开发者ID:itesla,项目名称:ipst,代码行数:35,代码来源:RunTDSimulationsMpiTool.java

示例13: expireAppMasterZKSession

import javax.management.MBeanServerInvocationHandler; //导入方法依赖的package包/类
private boolean expireAppMasterZKSession(TwillController controller, long timeout, TimeUnit timeoutUnit) {
  MBeanServer mbeanServer = MBeanRegistry.getInstance().getPlatformMBeanServer();
  QueryExp query = Query.isInstanceOf(new StringValueExp(ConnectionMXBean.class.getName()));

  Stopwatch stopwatch = new Stopwatch();
  stopwatch.start();
  do {
    // Find the AM session and expire it
    Set<ObjectName> connectionBeans = mbeanServer.queryNames(ObjectName.WILDCARD, query);
    for (ObjectName objectName : connectionBeans) {

      ConnectionMXBean connectionBean = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName,
                                                                                      ConnectionMXBean.class, false);
      for (String node : connectionBean.getEphemeralNodes()) {
        if (node.endsWith("/instances/" + controller.getRunId().getId())) {
          // This is the AM, expire the session.
          LOG.info("Kill AM session {}", connectionBean.getSessionId());
          connectionBean.terminateSession();
          return true;
        }
      }
    }
    Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
  } while (stopwatch.elapsedTime(timeoutUnit) < timeout);

  return false;
}
 
开发者ID:apache,项目名称:twill,代码行数:28,代码来源:SessionExpireTestRun.java

示例14: Jmx

import javax.management.MBeanServerInvocationHandler; //导入方法依赖的package包/类
public Jmx() throws IOException, MalformedObjectNameException {
    // I got this from the log messages when I was starting ActiveMQ
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi");
    JMXConnector connector = JMXConnectorFactory.connect(url);
    connector.connect();

    MBeanServerConnection connection = connector.getMBeanServerConnection();

    // This is jmxDomain:ObjectName...see ActiveMQ MBeans Reference in http://activemq.apache.org/jmx.html
    ObjectName name = new ObjectName("org.apache.activemq:brokerName=localhost,type=Broker");
    BrokerViewMBean mbean = MBeanServerInvocationHandler.newProxyInstance(connection, name, BrokerViewMBean.class, true);

    System.out.println(mbean.getTotalMessageCount());
}
 
开发者ID:aquaplanet,项目名称:activemq-demo,代码行数:15,代码来源:Jmx.java

示例15: newProxyClient

import javax.management.MBeanServerInvocationHandler; //导入方法依赖的package包/类
public <T> T newProxyClient(ObjectName name, Class<T> mbean) {
    if (isRegistered(name)) {
        ObjectName on = mbeansRegistered.get(name);
        return MBeanServerInvocationHandler.newProxyInstance(server, on != null ? on : name, mbean, false);
    } else {
        return null;
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:DefaultManagementAgent.java


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