⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rmiinvocationhandler.java

📁 jmx codeJava源码
💻 JAVA
字号:

package book.jmx.examples;

import java.util.*;
import java.net.*;
import java.lang.reflect.*;
import java.rmi.*;


public class RMIInvocationHandler 
    implements InvocationHandler, RMIConnectorConstants {

  /* Remote reference to the connector server. */
  private MBeanServerInvoker invoker = null;

  /* Property values. */
  private String host = null;
  private String name = null;
  private int port    = 1099;
  
  
  /* Constructor */

  public RMIInvocationHandler(Properties props) 
      throws NotBoundException, MalformedURLException,
      RemoteException {
          
    /* Retrieve properties for remote connection. */
    host = props.getProperty(HOST, "localhost");
    port = Integer.parseInt(props.getProperty(PORT, "1099"));  
    name = props.getProperty(REMOTE_NAME,"jmx/RMIConnector");
    
    /* Retrieve the stub implementing MBeanServerInvoker */
    String lookup = "//" + host + ":" + port + "/" + name;
    invoker = (MBeanServerInvoker)Naming.lookup(lookup);        
  }   

  
  /* InvocationHandler implementation */

  public Object invoke(Object proxy, Method method,
                       Object[] args) throws Throwable {
    
    /* Create and initialize serializable MI object. */                   
    MethodInvocation mi = new MethodInvocation(method);
    mi.setParams(args);

    /* Remote call to the connector server. */
    return invoker.invoke(mi);
  }
      
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -