1 23 24 package com.sun.enterprise.connectors.system; 25 26 import java.io.IOException ; 27 import java.net.MalformedURLException ; 28 import java.util.Map ; 29 import java.util.logging.Level ; 30 import java.util.logging.Logger ; 31 32 import javax.management.MBeanServerConnection ; 33 import javax.management.remote.JMXConnector ; 34 import javax.management.remote.JMXConnectorFactory ; 35 import javax.management.remote.JMXServiceURL ; 36 37 import com.sun.enterprise.connectors.ConnectorRuntimeException; 38 import com.sun.logging.LogDomains; 39 40 48 public class MQJMXConnectorInfo { 49 private String jmxServiceURL = null; 50 private Map <String ,?> jmxConnectorEnv = null; 51 private String asInstanceName = null; 52 private String brokerInstanceName = null; 53 private String brokerType = null; 54 static Logger _logger = LogDomains.getLogger(LogDomains.RSR_LOGGER); 55 private JMXConnector connector = null; 56 57 public MQJMXConnectorInfo(String asInstanceName, String brokerInstanceName, 58 String brokerType, String jmxServiceURL, 59 Map <String , ?> jmxConnectorEnv) { 60 this.brokerInstanceName = brokerInstanceName; 61 this.asInstanceName = asInstanceName; 62 this.jmxServiceURL = jmxServiceURL; 63 this.brokerType = brokerType; 64 this.jmxConnectorEnv = jmxConnectorEnv; 65 if (_logger.isLoggable(Level.FINE)) { 66 _logger.log(Level.FINE, "MQJMXConnectorInfo : brokerInstanceName " + 67 brokerInstanceName + " ASInstanceName " + asInstanceName + 68 " jmxServiceURL " + jmxServiceURL + " BrokerType " + brokerType 69 + " jmxConnectorEnv " + jmxConnectorEnv); 70 } 71 } 72 73 public String getBrokerInstanceName(){ 74 return this.brokerInstanceName; 75 } 76 77 public String getBrokerType(){ 78 return this.brokerType; 79 } 80 81 public String getASInstanceName(){ 82 return this.asInstanceName; 83 } 84 85 public String getJMXServiceURL(){ 86 _logger.log(Level.FINE,"MQJMXConnectorInfo :: JMXServiceURL is " + this.jmxServiceURL); 87 return this.jmxServiceURL; 88 } 89 90 public Map <String , ?> getJMXConnectorEnv(){ 91 return this.jmxConnectorEnv; 92 } 93 94 100 public MBeanServerConnection getMQMBeanServerConnection() throws ConnectorRuntimeException { 104 try { 105 if (_logger.isLoggable(Level.FINE)) { 106 _logger.log(Level.FINE, 107 "creating MBeanServerConnection to MQ JMXServer with "+getJMXServiceURL()); 108 } 109 JMXServiceURL jmxServiceURL = new JMXServiceURL (getJMXServiceURL()); 110 connector = JMXConnectorFactory.connect(jmxServiceURL, this.jmxConnectorEnv); 111 MBeanServerConnection mbsc = connector.getMBeanServerConnection(); 113 return mbsc; 114 } catch (Exception e) { 115 e.printStackTrace(); 116 ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage()); 117 cre.initCause(e); 118 throw cre; 119 } 120 } 121 122 public void closeMQMBeanServerConnection() throws ConnectorRuntimeException { 123 try { 124 if (connector != null) { 125 connector.close(); 126 } 127 } catch (IOException e) { 128 ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage()); 129 cre.initCause(e); 130 throw cre; 131 } 132 } 133 } 134 | Popular Tags |