Code to get Get JMX Connector Object


package com.connection;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.HashMap;

import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import javax.naming.Context;
public class GetJMXConnector {
private static JMXConnector connector;
private static String hostName = "localhost"; 
private static int port = 7001;
private static String username = "weblogic";
private static String password = "weblogic1";
private static String protocol = "t3";;
private static String wlserver = "weblogic.management.mbeanservers.domainruntime";
private static String jndi_root = "/jndi/";

public  static JMXConnector getJMXConnection(){ 
 JMXServiceURL url;
 try {
  url = new JMXServiceURL(protocol, hostName, port, jndi_root + wlserver); 
  HashMap<String, Object> env = new HashMap<String, Object>();
  env.put(Context.SECURITY_PRINCIPAL, username);
  env.put(Context.SECURITY_CREDENTIALS, password);
  env.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,"weblogic.management.remote"); 
  connector = JMXConnectorFactory.connect(url, env);
 } 
 catch (MalformedURLException e) {  
  e.printStackTrace();
 }catch (IOException e) {  
  e.printStackTrace();
 }
 return connector;
}
 
 
}

No comments:

Post a Comment

About OIM

Oracle Identity Management enables organizations to effectively manage the end - to - end life - cycle of user ide...

Popular Posts