简体   繁体   English

如何查找对象名称的weblogic jmx属性

[英]How to find the weblogic jmx attributes for a objectname

I am writing simple client application to connect to weblogic and list all the libraries that a webapp is depending on.However, I am having difficulty in finding the right attributes for a objectname. 我正在编写简单的客户端应用程序以连接到weblogic并列出该webapp所依赖的所有库。但是,我很难找到对象名称的正确属性。 For example, 例如,

If you look at the below sample code given on oracle.com to connect MBeanServer 如果您查看下面在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;




}

The line 线

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

Is referring to a JMX attribute ConfigurationManger . 指的是JMX属性ConfigurationManger How can we find all the attributes that are under a given objectname in weblogic? 我们如何在weblogic中找到给定对象名下的所有属性?

Thanks for your help!! 谢谢你的帮助!!

Nevermind! 没关系! I found the solution. 我找到了解决方案。

You get attributes for a ObjectName by calling getBeanInfo on the ServerConnection! 您可以通过在ServerConnection上调用getBeanInfo来获得ObjectName的属性!

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

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

也许WebLogic Classloader分析工具(CAT)可以提供其他开箱即用的见解...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM