FileDocCategorySizeDatePackage
JmxConnectorMBean.javaAPI DocGlassfish v2 API4789Fri May 04 22:24:10 BST 2007com.sun.enterprise.admin.mbeans

JmxConnectorMBean

public class JmxConnectorMBean extends com.sun.enterprise.admin.config.BaseConfigMBean

Fields Summary
private static final String
HOST_HOLDER_VALUE
private static final int
PORT_HOLDER_VALUE
private static final com.sun.enterprise.util.i18n.StringManager
localStrings
public static final String
JMX_SERVICE_URL_ATTRNAME
Constructors Summary
Methods Summary
public java.lang.ObjectgetAttribute(java.lang.String name)
overriding of the super getAttribute() to provide "in mbean only" JMXServiceURL attribute


        if(name.equals(JMX_SERVICE_URL_ATTRNAME))
        {
            try {
                return getJMXServiceURL();
            } catch (UnknownHostException uhe) {
                throw new MBeanException(uhe);
            }
        }
        return super.getAttribute(name);
    
private java.lang.StringgetJMXServiceURL()

    
      
        
    
        
        //first create template
        JMXServiceURL url = 
        JmxServiceUrlFactory.forJconsoleOverRmiWithJndiInAppserver(
                HOST_HOLDER_VALUE, PORT_HOLDER_VALUE);
        String strUrl  = url.toString();
        //now - modify it
        JmxConnector bean = (JmxConnector)this.getBaseConfigBean();
        String host = bean.getAddress();
        if(host!=null && host.trim().equals("0.0.0.0"))
        {
           //host = InetAddress.getLocalHost().getHostName();    
           host = null; //left <host-name> placeholder in url
        }
        if(host!=null)
            strUrl = strUrl.replaceAll(HOST_HOLDER_VALUE, host);
        try {
           int port = Integer.parseInt(bean.getPort());
           strUrl = strUrl.replaceAll(String.valueOf(PORT_HOLDER_VALUE), 
                   String.valueOf(port));
        } catch (Exception e)
        {
           strUrl = strUrl.replaceAll(String.valueOf(PORT_HOLDER_VALUE), 
                   "<port>");
        }
        
        return strUrl;