Example usage for javax.management MBeanServerInvocationHandler newProxyInstance

List of usage examples for javax.management MBeanServerInvocationHandler newProxyInstance

Introduction

In this page you can find the example usage for javax.management MBeanServerInvocationHandler newProxyInstance.

Prototype

public static <T> T newProxyInstance(MBeanServerConnection connection, ObjectName objectName,
        Class<T> interfaceClass, boolean notificationBroadcaster) 

Source Link

Document

Return a proxy that implements the given interface by forwarding its methods through the given MBean server to the named MBean.

Usage

From source file:org.rhq.enterprise.installer.ServerInformation.java

private File getBinDirectory() {
    if (binDirectory == null) {
        MBeanServer mbs = getMBeanServer();
        ObjectName name = ObjectNameFactory.create("jboss.system:type=ServerConfig");
        Object mbean = MBeanServerInvocationHandler.newProxyInstance(mbs, name, ServerConfig.class, false);

        File homeDir = ((ServerConfig) mbean).getHomeDir();
        binDirectory = new File(homeDir.getParentFile(), "bin");
    }//  ww  w. j a  v  a  2  s .c om

    return binDirectory;
}

From source file:org.rhq.enterprise.installer.ServerInformation.java

File getLogDirectory() {
    if (logDirectory == null) {
        MBeanServer mbs = getMBeanServer();
        ObjectName name = ObjectNameFactory.create("jboss.system:type=ServerConfig");
        Object mbean = MBeanServerInvocationHandler.newProxyInstance(mbs, name, ServerConfig.class, false);

        File homeDir = ((ServerConfig) mbean).getHomeDir();
        logDirectory = new File(homeDir.getParentFile(), "logs");
        logDirectory.mkdirs(); // just in case it doesn't exist yet, let's create it now
    }// w  w w .ja  v  a2 s . c  o  m

    return logDirectory;
}

From source file:org.rhq.enterprise.installer.ServerInformation.java

public File getDataDirectory() {
    if (dataDirectory == null) {
        MBeanServer mbs = getMBeanServer();
        ObjectName name = ObjectNameFactory.create("jboss.system:type=ServerConfig");
        Object mbean = MBeanServerInvocationHandler.newProxyInstance(mbs, name, ServerConfig.class, false);

        dataDirectory = new File(((ServerConfig) mbean).getServerHomeDir(), "data");
        dataDirectory.mkdirs(); // just in case it doesn't exist yet, let's create it now
    }/*from   w ww  .j  ava  2 s . c  o m*/

    return dataDirectory;
}

From source file:org.rhq.enterprise.installer.ServerInformation.java

private File getConfDirectory() {
    if (confDirectory == null) {
        MBeanServer mbs = getMBeanServer();
        ObjectName name = ObjectNameFactory.create("jboss.system:type=ServerConfig");
        Object mbean = MBeanServerInvocationHandler.newProxyInstance(mbs, name, ServerConfig.class, false);

        confDirectory = new File(((ServerConfig) mbean).getServerHomeDir(), "conf");
    }//from   www  .  ja v  a2s . c o  m

    return confDirectory;
}

From source file:org.rhq.enterprise.installer.ServerInformation.java

public void restartLoginConfig() throws Exception {

    MBeanServer mbs = getMBeanServer();
    ObjectName name = ObjectNameFactory.create("jboss.security:service=XMLLoginConfig");
    Object mbean = MBeanServerInvocationHandler.newProxyInstance(mbs, name, XMLLoginConfigMBean.class, false);

    XMLLoginConfigMBean conf = (XMLLoginConfigMBean) mbean;
    conf.stop();// w ww  .  ja  v  a  2  s  . co m
    conf.start();
}

From source file:org.rhq.enterprise.server.core.comm.ServerCommunicationsServiceUtil.java

/**
 * This will obtain a proxy to the server bootstrap service - this is the service that provides the communications
 * services used to talk to agents./*ww  w  .  j av  a  2s . co m*/
 *
 * @return bootstrap proxy
 *
 * @throws WrappedRemotingException if the bootstrap service is not available
 */
public static ServerCommunicationsServiceMBean getService() {
    ServerCommunicationsServiceMBean serverBootstrapService;
    try {
        MBeanServer mbean_server = MBeanServerLocator.locateJBoss();
        serverBootstrapService = (ServerCommunicationsServiceMBean) MBeanServerInvocationHandler
                .newProxyInstance(mbean_server, ServerCommunicationsServiceMBean.OBJECT_NAME,
                        ServerCommunicationsServiceMBean.class, false);
    } catch (Exception e) {
        LOG.error("Could not find server comm service - agent communications are not allowed at this time");
        throw new WrappedRemotingException(
                new Exception("Cannot get server comm service; unable to communicate with agents", e));
    }

    return serverBootstrapService;
}

From source file:org.rhq.enterprise.server.core.CoreServer.java

public File getInstallDir() {
    MBeanServer mbs = getMBeanServer();
    ObjectName name = ObjectNameFactory.create("jboss.system:type=ServerConfig");
    Object mbean = MBeanServerInvocationHandler.newProxyInstance(mbs, name, ServerConfig.class, false);

    File homeDir = ((ServerConfig) mbean).getHomeDir();
    return homeDir.getParentFile(); // jboss homedir is "rhq-install-dir/jbossas", so the install dir is .. from jbossas
}

From source file:org.rhq.enterprise.server.core.CoreServer.java

public File getJBossServerHomeDir() {
    MBeanServer mbs = getMBeanServer();
    ObjectName name = ObjectNameFactory.create("jboss.system:type=ServerConfig");
    Object mbean = MBeanServerInvocationHandler.newProxyInstance(mbs, name, ServerConfig.class, false);
    File serverHomeDir = ((ServerConfig) mbean).getServerHomeDir();
    return serverHomeDir;
}

From source file:org.rhq.enterprise.server.core.CoreServer.java

public File getJBossServerDataDir() {
    MBeanServer mbs = getMBeanServer();
    ObjectName name = ObjectNameFactory.create("jboss.system:type=ServerConfig");
    Object mbean = MBeanServerInvocationHandler.newProxyInstance(mbs, name, ServerConfig.class, false);
    File serverDataDir = ((ServerConfig) mbean).getServerDataDir();
    return serverDataDir;
}

From source file:org.rhq.enterprise.server.core.CoreServer.java

public File getJBossServerTempDir() {
    MBeanServer mbs = getMBeanServer();
    ObjectName name = ObjectNameFactory.create("jboss.system:type=ServerConfig");
    Object mbean = MBeanServerInvocationHandler.newProxyInstance(mbs, name, ServerConfig.class, false);
    File serverTempDir = ((ServerConfig) mbean).getServerTempDir();
    return serverTempDir;
}