1

我正在编写简单的客户端应用程序以连接到 weblogic 并列出 webapp 所依赖的所有库。但是,我很难找到对象名的正确属性。例如,

如果您查看 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 属性ConfigurationManger。我们如何在 weblogic 中找到给定对象名下的所有属性?

谢谢你的帮助!!

4

2 回答 2

0

没关系!我找到了解决方案。

您可以通过在 ServerConnection 上调用 getBeanInfo 来获取 ObjectName 的属性!

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

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

于 2014-06-10T15:58:04.897 回答
0

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

于 2014-06-10T16:03:00.747 回答