2014-06-09 5 views
1

weblogic에 연결하고 webapp이 사용하는 모든 라이브러리를 나열하는 간단한 클라이언트 응용 프로그램을 작성하고 있습니다. 그러나 objectname에 적합한 속성을 찾는 데 어려움이 있습니다. 당신이 oracle.com에 주어진 아래의 샘플 코드를 보면 예를 들어,objectname에 대한 weblogic jmx 속성을 찾는 방법

의 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 (서비스, "ConfigurationManager ");

JMX 속성 ConfigurationManger을 참조하십시오. weblogic에서 주어진 objectname 아래에있는 모든 속성을 어떻게 찾을 수 있습니까?

도움 주셔서 감사합니다.

+0

나는 대답을 발견 ... 상자에서 추가 통찰력을 줄 수 있습니다! –

답변

0

Nevermind! 해결책을 찾았습니다.

ServerConnection!에서 getBeanInfo를 호출하면 ObjectName에 대한 속성을 얻을 수 있습니다.

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

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