posts - 156,  comments - 601,  trackbacks - 0
          兩種Java代碼實現方法:

           通過jmx rmi 連接:
                    HashMap env = new HashMap(1); 
                  
          final String[]    credentials    = new String[] { "admin""adminadmin" };
                  env.put( JMXConnector.CREDENTIALS, credentials );
                  
          // so our JMXConnectorProvider may be found
                  
          //env.put( JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "com.sun.enterprise.admin.jmx.remote.protocol" );
                  JMXServiceURL serviceURL = new JMXServiceURL( "service:jmx:rmi:///jndi/rmi://localhost:8686/management/rmi-jmx-connector");
                  JMXConnector connector 
          = JMXConnectorFactory.connect(serviceURL , env); 
                  MBeanServerConnection connection 
          = connector.getMBeanServerConnection(); 
                      
                  Object o 
          = connection.invoke(new ObjectName("com.sun.appserv:type=domain,category=config"), "getName"new Object[]{}, new String[]{});
                  System.out.println(o);
           通過jmx http連接
                  HashMap env = new HashMap(4);
                  env.put( 
          "com.sun.enterprise.as.http.auth""BASIC" );
                  env.put( 
          "USER""admin" );
                  env.put( 
          "PASSWORD""adminadmin" );
                  env.put( JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, 
          "com.sun.enterprise.admin.jmx.remote.protocol" );
                  JMXServiceURL serviceURL 
          = new JMXServiceURL("s1ashttp""localhost"4848);
                  
          final JMXConnector conn    = JMXConnectorFactory.connect( serviceURL, env );
                  MBeanServerConnection connection 
          = conn.getMBeanServerConnection(); 
                  
                  Object o 
          = connection.invoke(new ObjectName("com.sun.appserv:type=domain,category=config"), "getName"new Object[]{}, new String[]{});
                  System.out.println(o);


          Good Luck!
          Yours Matthew!

          posted on 2010-03-29 15:42 x.matthew 閱讀(2544) 評論(0)  編輯  收藏 所屬分類: Best Practise(JDK API)
          主站蜘蛛池模板: 灵台县| 宜兰县| 常州市| 禄丰县| 瓮安县| 阳信县| 类乌齐县| 东台市| 大足县| 侯马市| 化德县| 宁都县| 德兴市| 天等县| 绵阳市| 济源市| 响水县| 津市市| 梁平县| 丽江市| 桂平市| 新沂市| 邳州市| 泸水县| 宁南县| 玉溪市| 大港区| 云阳县| 保定市| 宜宾县| 张北县| 滕州市| 凯里市| 龙井市| 炎陵县| 和静县| 吉林省| 海安县| 兰溪市| 井研县| 云阳县|