Example usage for javax.management MalformedObjectNameException toString

List of usage examples for javax.management MalformedObjectNameException toString

Introduction

In this page you can find the example usage for javax.management MalformedObjectNameException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:at.ac.tuwien.dsg.cloud.salsa.engine.utils.SystemFunctions.java

/**
 * This command try to get Port which the service is listening to. The port should be in the parameter -httpPort when running, or Tomcat port
 *
 * @return// w ww .  jav a  2s  .c  o m
 */
public static String getPort() {
    try {
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        Set<ObjectName> objs = mbs.queryNames(new ObjectName("*:type=Connector,*"),
                Query.match(Query.attr("protocol"), Query.value("HTTP/1.1")));
        for (ObjectName obj : objs) {
            String port = obj.getKeyProperty("port");
            return port;
        }
    } catch (MalformedObjectNameException e) {
        EngineLogger.logger
                .error("Cannot get listening port of salsa-engine service. return 8080 as default. Error: "
                        + e.toString());
    }
    EngineLogger.logger.error("Cannot find listening port of salsa-engine service. return 8080 as default");
    return "8080";
}

From source file:com.webobjects.monitor.wotaskd.Application.java

/**
 * ============================================================================================
 *                  Methods Added for Enabling JMX in Wotaskd
 * ============================================================================================
 * This methods registers the MBean object in the MBeanServer
 * @param objMBean      - The MBean object to register
 * @param strDomainName - Domain name required for creating the ObjectName of the MBean
 * @param strMBeanName  - Name of the MBean
 *//*  w  w  w .jav  a  2  s  . c o  m*/
@Override
public void registerMBean(Object objMBean, String strDomainName, String strMBeanName)
        throws IllegalArgumentException {
    if (objMBean == null)
        throw new IllegalArgumentException("Error: Could not register null to PlatformMbeanServer.");
    if (strMBeanName == null)
        throw new IllegalArgumentException("Error: MBean name could not be null.");

    ObjectName objName = null;
    strDomainName = (strDomainName == null) ? getJMXDomain() : strDomainName;

    //Create the Object Name for the MBean
    try {
        objName = new ObjectName(strDomainName + ": name=" + strMBeanName);
    } catch (MalformedObjectNameException e) {
        e.printStackTrace();
    } catch (NullPointerException e) {
        e.printStackTrace();
    }

    // Register the MBean
    try {
        getMBeanServer().registerMBean(objMBean, objName);
    } catch (IllegalAccessException e) {
        NSLog.err.appendln("ERROR: security access problem registering bean: " + objMBean + " with ObjectName: "
                + objName + " " + e.toString());
    } catch (InstanceAlreadyExistsException e) {
        NSLog.err.appendln("ERROR: MBean already exists bean: " + objMBean + " with ObjectName: " + objName
                + " " + e.toString());
    } catch (MBeanRegistrationException e) {
        NSLog.err.appendln("ERROR: error registering bean: " + objMBean + " with ObjectName: " + objName + " "
                + e.toString());
    } catch (NotCompliantMBeanException e) {
        NSLog.err.appendln("ERROR: error registering bean: " + objMBean + " with ObjectName: " + objName + " "
                + e.toString());
    }
}

From source file:org.lsc.jmx.LscAgent.java

/**
 * Bind to the JMX Server // w w  w  .  j  a  va  2s.  c  o m
 */
public boolean jmxBind() {
    try {
        String sUrl = "service:jmx:rmi:///jndi/rmi://" + hostname + ":" + port + "/jmxrmi";
        LOGGER.info("Connecting to remote engine on : " + sUrl);
        url = new JMXServiceURL(sUrl);
        jmxC = new RMIConnector(url, null);
        jmxC.connect();
        jmxc = jmxC.getMBeanServerConnection();
        ObjectName lscServerName = new ObjectName("org.lsc.jmx:type=LscServer");
        lscServer = JMX.newMXBeanProxy(jmxc, lscServerName, LscServer.class, true);
        return true;
    } catch (MalformedObjectNameException e) {
        LOGGER.error(e.toString(), e);
    } catch (NullPointerException e) {
        LOGGER.error(e.toString(), e);
    } catch (MalformedURLException e) {
        LOGGER.error(e.toString(), e);
    } catch (IOException e) {
        LOGGER.error(e.toString(), e);
    }
    return false;
}

From source file:org.lsc.webai.services.LscRemoteCommands.java

private boolean jmxBind() {
    if (lscServer != null) {
        try {/*from w w  w . ja v a  2 s .  c  o m*/
            return lscServer.ping();
        } catch (UndeclaredThrowableException ce) {

        }
    }
    try {
        String sUrl = "service:jmx:rmi:///jndi/rmi://" + hostname + ":" + port + "/jmxrmi";
        LOGGER.info("Connecting to remote engine on : " + sUrl);
        url = new JMXServiceURL(sUrl);
        jmxC = new RMIConnector(url, null);
        jmxC.connect();
        jmxc = jmxC.getMBeanServerConnection();
        ObjectName lscServerName = new ObjectName("org.lsc.jmx:type=LscServer");
        lscServer = JMX.newMXBeanProxy(jmxc, lscServerName, LscServer.class, true);
        return true;
    } catch (MalformedObjectNameException e) {
        LOGGER.error(e.toString(), e);
    } catch (NullPointerException e) {
        LOGGER.error(e.toString(), e);
    } catch (MalformedURLException e) {
        LOGGER.error(e.toString(), e);
    } catch (IOException e) {
        if (!(e.getCause() instanceof ServiceUnavailableException)) {
            LOGGER.error(e.toString(), e);
        }
    }
    return false;
}

From source file:org.onehippo.forge.channelmanager.pagesupport.channel.event.DocumentManagementServiceClient.java

public ObjectName getMbeanName() {
    if (mbeanName == null) {
        try {// w  w  w  . j  a v a 2  s.  c o  m
            mbeanName = new ObjectName(DEFAULT_DOCUMENT_MANAGEMENT_SERVICE_NAME);
        } catch (MalformedObjectNameException e) {
            throw new IllegalStateException(e.toString(), e);
        }
    }

    return mbeanName;
}