如何查找objectname的weblogic jmx属性



我正在编写简单的客户端应用程序来连接到weblogic并列出webapp所依赖的所有库。但是,我在为objectname找到正确的属性时遇到了困难。例如,

查看oracle.com上给出的连接MBeanServer的示例代码

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.edit";
  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");
     connector = JMXConnectorFactory.connect(serviceURL, h);
     connection = connector.getMBeanServerConnection();

}
public ObjectName startEditSession() throws Exception {
  // Get the object name for ConfigurationManagerMBean.
  ObjectName cfgMgr = (ObjectName) connection.getAttribute(service,
     "ConfigurationManager");

  // Instruct MBeanServerConnection to invoke
  // ConfigurationManager.startEdit(int waitTime int timeout).
  // The startEdit operation returns a handle to DomainMBean, which is
  // the root of the edit hierarchy.
  ObjectName domainConfigRoot = (ObjectName) 
     connection.invoke(cfgMgr,"startEdit", 
     new Object[] { new Integer(60000),
     new Integer(120000) }, new String[] { "java.lang.Integer",
     "java.lang.Integer" });
  if (domainConfigRoot == null) {
     // Couldn't get the lock
     throw new Exception("Somebody else is editing already");
  }
  return domainConfigRoot;


}



ObjectName cfgMgr = (ObjectName) connection.getAttribute(service," ConfigurationManager ");

引用JMX属性 configurationmanager 。如何在weblogic中找到给定objectname下的所有属性?

谢谢你的帮助!

别介意!我找到解决办法了。

通过在ServerConnection上调用getBeanInfo来获得ObjectName的属性!

的例子: MBeanAttributeInfo[] beanInfo = (connection.getMBeanInfo(objectName)).getAttributes();

for(MBeanAttributeInfo info:beanInfo) System.out.println(info.getType()+" "+info.getName());

也许WebLogic类加载器分析工具(CAT)可以提供额外的开箱即用的见解…

相关内容

  • 没有找到相关文章

最新更新