hti 发表于 2017-2-16 08:16:10

Accessing WebLogic Server MBeans with JMX (一)

  From oracle


Example: Connecting to the Domain Runtime MBean Server


public class MyConnection {

  


   private static MBeanServerConnection connection;
   private static JMXConnector connector;
   private static final ObjectName service;

  


   /*
   * Initialize connection to the Domain Runtime MBean Server.
   */
   public static void initConnection(String hostname, String portString,
      String username, String password) throws IOException,
      MalformedURLException {

  


      String protocol = "t3";
      Integer portInteger = Integer.valueOf(portString);
      int port = portInteger.intValue();
      String jndiroot = "/jndi/";
      String mserver = "weblogic.management.mbeanservers.domainruntime";

  


      JMXServiceURL serviceURL = new JMXServiceURL(protocol, hostname, port,
      jndiroot + mserver);

  


      Hashtable h = new Hashtable();
      h.put(Context.SECURITY_PRINCIPAL, username);
      h.put(Context.SECURITY_CREDENTIALS, password);
      h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,
         "weblogic.management.remote");
      h.put("jmx.remote.x.request.waiting.timeout", new Long(10000));
      connector = JMXConnectorFactory.connect(serviceURL, h);
      connection = connector.getMBeanServerConnection();
   }

  


   public static void main(String[] args) throws Exception {
      String hostname = args;
      String portString = args;
      String username = args;
      String password = args;

  


      MyConnection c= new MyConnection();
      initConnection(hostname, portString, username, password);
...
      connector.close();
   }
}



The WebLogic Server® MBean Reference AT:



http://download.oracle.com/docs/cd/E11035_01/wls100/wlsmbeanref/core/index.html




页: [1]
查看完整版本: Accessing WebLogic Server MBeans with JMX (一)