com.sun.jmx.remote.util.EnvHelp Java Examples

The following examples show how to use com.sun.jmx.remote.util.EnvHelp. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClientNotifForwarder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public ClientNotifForwarder(ClassLoader defaultClassLoader, Map<String, ?> env) {
    maxNotifications = EnvHelp.getMaxFetchNotifNumber(env);
    timeout = EnvHelp.getFetchTimeout(env);

    /* You can supply an Executor in which the remote call to
       fetchNotifications will be made.  The Executor's execute
       method reschedules another task, so you must not use
       an Executor that executes tasks in the caller's thread.  */
    Executor ex = (Executor)
        env.get("jmx.remote.x.fetch.notifications.executor");
    if (ex == null)
        ex = new LinearExecutor();
    else if (logger.traceOn())
        logger.trace("ClientNotifForwarder", "executor is " + ex);

    this.defaultClassLoader = defaultClassLoader;
    this.executor = ex;
    this.acc = AccessController.getContext();
}
 
Example #2
Source File: DefaultMBeanServerInterceptor.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public ObjectInstance createMBean(String className, ObjectName name,
                                  Object[] params, String[] signature)
    throws ReflectionException, InstanceAlreadyExistsException,
           MBeanRegistrationException, MBeanException,
           NotCompliantMBeanException  {

    try {
        return createMBean(className, name, null, true,
                           params, signature);
    } catch (InstanceNotFoundException e) {
        /* Can only happen if loaderName doesn't exist, but we just
           passed null, so we shouldn't get this exception.  */
        throw EnvHelp.initCause(
            new IllegalArgumentException("Unexpected exception: " + e), e);
    }
}
 
Example #3
Source File: RMIConnector.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private RMIServer findRMIServer(JMXServiceURL directoryURL,
        Map<String, Object> environment)
        throws NamingException, IOException {
    final boolean isIiop = RMIConnectorServer.isIiopURL(directoryURL,true);
    if (isIiop) {
        // Make sure java.naming.corba.orb is in the Map.
        environment.put(EnvHelp.DEFAULT_ORB,resolveOrb(environment));
    }

    String path = directoryURL.getURLPath();
    int end = path.indexOf(';');
    if (end < 0) end = path.length();
    if (path.startsWith("/jndi/"))
        return findRMIServerJNDI(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/stub/"))
        return findRMIServerJRMP(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/ior/")) {
        if (!IIOPHelper.isAvailable())
            throw new IOException("iiop protocol not available");
        return findRMIServerIIOP(path.substring(5,end), environment, isIiop);
    } else {
        final String msg = "URL path must begin with /jndi/ or /stub/ " +
                "or /ior/: " + path;
        throw new MalformedURLException(msg);
    }
}
 
Example #4
Source File: ClientNotifForwarder.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Import: should not remove a listener during reconnection, the reconnection
 * needs to change the listener list and that will possibly make removal fail.
 */
private synchronized void beforeRemove() throws IOException {
    while (beingReconnected) {
        if (state == TERMINATED) {
            throw new IOException("Terminated.");
        }

        try {
            wait();
        } catch (InterruptedException ire) {
            IOException ioe = new IOException(ire.toString());
            EnvHelp.initCause(ioe, ire);

            throw ioe;
        }
    }

    if (state == TERMINATED) {
        throw new IOException("Terminated.");
    }
}
 
Example #5
Source File: RMIConnector.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private RMIServer findRMIServer(JMXServiceURL directoryURL,
        Map<String, Object> environment)
        throws NamingException, IOException {
    final boolean isIiop = RMIConnectorServer.isIiopURL(directoryURL,true);
    if (isIiop) {
        // Make sure java.naming.corba.orb is in the Map.
        environment.put(EnvHelp.DEFAULT_ORB,resolveOrb(environment));
    }

    String path = directoryURL.getURLPath();
    int end = path.indexOf(';');
    if (end < 0) end = path.length();
    if (path.startsWith("/jndi/"))
        return findRMIServerJNDI(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/stub/"))
        return findRMIServerJRMP(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/ior/")) {
        if (!IIOPHelper.isAvailable())
            throw new IOException("iiop protocol not available");
        return findRMIServerIIOP(path.substring(5,end), environment, isIiop);
    } else {
        final String msg = "URL path must begin with /jndi/ or /stub/ " +
                "or /ior/: " + path;
        throw new MalformedURLException(msg);
    }
}
 
Example #6
Source File: DefaultMBeanServerInterceptor.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public ObjectInstance createMBean(String className, ObjectName name,
                                  Object[] params, String[] signature)
    throws ReflectionException, InstanceAlreadyExistsException,
           MBeanRegistrationException, MBeanException,
           NotCompliantMBeanException  {

    try {
        return createMBean(className, name, null, true,
                           params, signature);
    } catch (InstanceNotFoundException e) {
        /* Can only happen if loaderName doesn't exist, but we just
           passed null, so we shouldn't get this exception.  */
        throw EnvHelp.initCause(
            new IllegalArgumentException("Unexpected exception: " + e), e);
    }
}
 
Example #7
Source File: RMIConnector.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private RMIServer findRMIServer(JMXServiceURL directoryURL,
        Map<String, Object> environment)
        throws NamingException, IOException {
    final boolean isIiop = RMIConnectorServer.isIiopURL(directoryURL,true);
    if (isIiop) {
        // Make sure java.naming.corba.orb is in the Map.
        environment.put(EnvHelp.DEFAULT_ORB,resolveOrb(environment));
    }

    String path = directoryURL.getURLPath();
    int end = path.indexOf(';');
    if (end < 0) end = path.length();
    if (path.startsWith("/jndi/"))
        return findRMIServerJNDI(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/stub/"))
        return findRMIServerJRMP(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/ior/")) {
        if (!IIOPHelper.isAvailable())
            throw new IOException("iiop protocol not available");
        return findRMIServerIIOP(path.substring(5,end), environment, isIiop);
    } else {
        final String msg = "URL path must begin with /jndi/ or /stub/ " +
                "or /ior/: " + path;
        throw new MalformedURLException(msg);
    }
}
 
Example #8
Source File: DefaultMBeanServerInterceptor.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public ObjectInstance createMBean(String className, ObjectName name,
                                  Object[] params, String[] signature)
    throws ReflectionException, InstanceAlreadyExistsException,
           MBeanRegistrationException, MBeanException,
           NotCompliantMBeanException  {

    try {
        return createMBean(className, name, null, true,
                           params, signature);
    } catch (InstanceNotFoundException e) {
        /* Can only happen if loaderName doesn't exist, but we just
           passed null, so we shouldn't get this exception.  */
        throw EnvHelp.initCause(
            new IllegalArgumentException("Unexpected exception: " + e), e);
    }
}
 
Example #9
Source File: ClientNotifForwarder.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Import: should not remove a listener during reconnection, the reconnection
 * needs to change the listener list and that will possibly make removal fail.
 */
private synchronized void beforeRemove() throws IOException {
    while (beingReconnected) {
        if (state == TERMINATED) {
            throw new IOException("Terminated.");
        }

        try {
            wait();
        } catch (InterruptedException ire) {
            IOException ioe = new IOException(ire.toString());
            EnvHelp.initCause(ioe, ire);

            throw ioe;
        }
    }

    if (state == TERMINATED) {
        throw new IOException("Terminated.");
    }
}
 
Example #10
Source File: RMIJRMPServerImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void export(Remote obj) throws RemoteException {
    final RMIExporter exporter =
        (RMIExporter) env.get(RMIExporter.EXPORTER_ATTRIBUTE);
    final boolean daemon = EnvHelp.isServerDaemon(env);

    if (daemon && exporter != null) {
        throw new IllegalArgumentException("If "+EnvHelp.JMX_SERVER_DAEMON+
                " is specified as true, "+RMIExporter.EXPORTER_ATTRIBUTE+
                " cannot be used to specify an exporter!");
    }

    if (daemon) {
        if (csf == null && ssf == null) {
            new UnicastServerRef(port).exportObject(obj, null, true);
        } else {
            new UnicastServerRef2(port, csf, ssf).exportObject(obj, null, true);
        }
    } else if (exporter != null) {
        exporter.exportObject(obj, port, csf, ssf);
    } else {
        UnicastRemoteObject.exportObject(obj, port, csf, ssf);
    }
}
 
Example #11
Source File: JMXPluggableAuthenticator.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static void authenticationFailure(String method,
                                          Exception exception)
    throws SecurityException {
    String msg;
    SecurityException se;
    if (exception instanceof SecurityException) {
        msg = exception.getMessage();
        se = (SecurityException) exception;
    } else {
        msg = "Authentication failed! " + exception.getMessage();
        final SecurityException e = new SecurityException(msg);
        EnvHelp.initCause(e, exception);
        se = e;
    }
    logException(method, msg, se);
    throw se;
}
 
Example #12
Source File: ClientNotifForwarder.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Import: should not remove a listener during reconnection, the reconnection
 * needs to change the listener list and that will possibly make removal fail.
 */
private synchronized void beforeRemove() throws IOException {
    while (beingReconnected) {
        if (state == TERMINATED) {
            throw new IOException("Terminated.");
        }

        try {
            wait();
        } catch (InterruptedException ire) {
            IOException ioe = new IOException(ire.toString());
            EnvHelp.initCause(ioe, ire);

            throw ioe;
        }
    }

    if (state == TERMINATED) {
        throw new IOException("Terminated.");
    }
}
 
Example #13
Source File: RMIConnector.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private RMIServer findRMIServer(JMXServiceURL directoryURL,
        Map<String, Object> environment)
        throws NamingException, IOException {
    final boolean isIiop = RMIConnectorServer.isIiopURL(directoryURL,true);
    if (isIiop) {
        // Make sure java.naming.corba.orb is in the Map.
        environment.put(EnvHelp.DEFAULT_ORB,resolveOrb(environment));
    }

    String path = directoryURL.getURLPath();
    int end = path.indexOf(';');
    if (end < 0) end = path.length();
    if (path.startsWith("/jndi/"))
        return findRMIServerJNDI(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/stub/"))
        return findRMIServerJRMP(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/ior/")) {
        if (!IIOPHelper.isAvailable())
            throw new IOException("iiop protocol not available");
        return findRMIServerIIOP(path.substring(5,end), environment, isIiop);
    } else {
        final String msg = "URL path must begin with /jndi/ or /stub/ " +
                "or /ior/: " + path;
        throw new MalformedURLException(msg);
    }
}
 
Example #14
Source File: RMIConnector.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private RMIServer findRMIServer(JMXServiceURL directoryURL,
        Map<String, Object> environment)
        throws NamingException, IOException {
    final boolean isIiop = RMIConnectorServer.isIiopURL(directoryURL,true);
    if (isIiop) {
        // Make sure java.naming.corba.orb is in the Map.
        environment.put(EnvHelp.DEFAULT_ORB,resolveOrb(environment));
    }

    String path = directoryURL.getURLPath();
    int end = path.indexOf(';');
    if (end < 0) end = path.length();
    if (path.startsWith("/jndi/"))
        return findRMIServerJNDI(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/stub/"))
        return findRMIServerJRMP(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/ior/")) {
        if (!IIOPHelper.isAvailable())
            throw new IOException("iiop protocol not available");
        return findRMIServerIIOP(path.substring(5,end), environment, isIiop);
    } else {
        final String msg = "URL path must begin with /jndi/ or /stub/ " +
                "or /ior/: " + path;
        throw new MalformedURLException(msg);
    }
}
 
Example #15
Source File: DefaultMBeanServerInterceptor.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private NotificationListener getListener(ObjectName listener)
    throws ListenerNotFoundException {
    // ----------------
    // Get listener object
    // ----------------
    DynamicMBean instance;
    try {
        instance = getMBean(listener);
    } catch (InstanceNotFoundException e) {
        throw EnvHelp.initCause(
                      new ListenerNotFoundException(e.getMessage()), e);
    }

    Object resource = getResource(instance);
    if (!(resource instanceof NotificationListener)) {
        final RuntimeException exc =
            new IllegalArgumentException(listener.getCanonicalName());
        final String msg =
            "MBean " + listener.getCanonicalName() + " does not " +
            "implement " + NotificationListener.class.getName();
        throw new RuntimeOperationsException(exc, msg);
    }
    return (NotificationListener) resource;
}
 
Example #16
Source File: RMIConnector.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private RMIServer findRMIServer(JMXServiceURL directoryURL,
        Map<String, Object> environment)
        throws NamingException, IOException {
    final boolean isIiop = RMIConnectorServer.isIiopURL(directoryURL,true);
    if (isIiop) {
        // Make sure java.naming.corba.orb is in the Map.
        environment.put(EnvHelp.DEFAULT_ORB,resolveOrb(environment));
    }

    String path = directoryURL.getURLPath();
    int end = path.indexOf(';');
    if (end < 0) end = path.length();
    if (path.startsWith("/jndi/"))
        return findRMIServerJNDI(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/stub/"))
        return findRMIServerJRMP(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/ior/")) {
        if (!IIOPHelper.isAvailable())
            throw new IOException("iiop protocol not available");
        return findRMIServerIIOP(path.substring(5,end), environment, isIiop);
    } else {
        final String msg = "URL path must begin with /jndi/ or /stub/ " +
                "or /ior/: " + path;
        throw new MalformedURLException(msg);
    }
}
 
Example #17
Source File: DefaultMBeanServerInterceptor.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private NotificationListener getListener(ObjectName listener)
    throws ListenerNotFoundException {
    // ----------------
    // Get listener object
    // ----------------
    DynamicMBean instance;
    try {
        instance = getMBean(listener);
    } catch (InstanceNotFoundException e) {
        throw EnvHelp.initCause(
                      new ListenerNotFoundException(e.getMessage()), e);
    }

    Object resource = getResource(instance);
    if (!(resource instanceof NotificationListener)) {
        final RuntimeException exc =
            new IllegalArgumentException(listener.getCanonicalName());
        final String msg =
            "MBean " + listener.getCanonicalName() + " does not " +
            "implement " + NotificationListener.class.getName();
        throw new RuntimeOperationsException(exc, msg);
    }
    return (NotificationListener) resource;
}
 
Example #18
Source File: DefaultMBeanServerInterceptor.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public ObjectInstance createMBean(String className, ObjectName name,
                                  Object[] params, String[] signature)
    throws ReflectionException, InstanceAlreadyExistsException,
           MBeanRegistrationException, MBeanException,
           NotCompliantMBeanException  {

    try {
        return createMBean(className, name, null, true,
                           params, signature);
    } catch (InstanceNotFoundException e) {
        /* Can only happen if loaderName doesn't exist, but we just
           passed null, so we shouldn't get this exception.  */
        throw EnvHelp.initCause(
            new IllegalArgumentException("Unexpected exception: " + e), e);
    }
}
 
Example #19
Source File: ClientNotifForwarder.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Import: should not remove a listener during reconnection, the reconnection
 * needs to change the listener list and that will possibly make removal fail.
 */
private synchronized void beforeRemove() throws IOException {
    while (beingReconnected) {
        if (state == TERMINATED) {
            throw new IOException("Terminated.");
        }

        try {
            wait();
        } catch (InterruptedException ire) {
            IOException ioe = new IOException(ire.toString());
            EnvHelp.initCause(ioe, ire);

            throw ioe;
        }
    }

    if (state == TERMINATED) {
        throw new IOException("Terminated.");
    }
}
 
Example #20
Source File: RMIConnector.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private RMIServer findRMIServer(JMXServiceURL directoryURL,
        Map<String, Object> environment)
        throws NamingException, IOException {
    final boolean isIiop = RMIConnectorServer.isIiopURL(directoryURL,true);
    if (isIiop) {
        // Make sure java.naming.corba.orb is in the Map.
        environment.put(EnvHelp.DEFAULT_ORB,resolveOrb(environment));
    }

    String path = directoryURL.getURLPath();
    int end = path.indexOf(';');
    if (end < 0) end = path.length();
    if (path.startsWith("/jndi/"))
        return findRMIServerJNDI(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/stub/"))
        return findRMIServerJRMP(path.substring(6,end), environment, isIiop);
    else if (path.startsWith("/ior/")) {
        if (!IIOPHelper.isAvailable())
            throw new IOException("iiop protocol not available");
        return findRMIServerIIOP(path.substring(5,end), environment, isIiop);
    } else {
        final String msg = "URL path must begin with /jndi/ or /stub/ " +
                "or /ior/: " + path;
        throw new MalformedURLException(msg);
    }
}
 
Example #21
Source File: ServerNotifForwarder.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public ServerNotifForwarder(MBeanServer mbeanServer,
                            Map<String, ?> env,
                            NotificationBuffer notifBuffer,
                            String connectionId) {
    this.mbeanServer = mbeanServer;
    this.notifBuffer = notifBuffer;
    this.connectionId = connectionId;
    connectionTimeout = EnvHelp.getServerConnectionTimeout(env);

    String stringBoolean = (String) env.get("jmx.remote.x.check.notification.emission");
    checkNotificationEmission = EnvHelp.computeBooleanFromString( stringBoolean );
    notificationAccessController =
            EnvHelp.getNotificationAccessController(env);
}
 
Example #22
Source File: ArrayNotificationBuffer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void createListeners() {
    logger.debug("createListeners", "starts");

    synchronized (this) {
        createdDuringQuery = new HashSet<ObjectName>();
    }

    try {
        addNotificationListener(MBeanServerDelegate.DELEGATE_NAME,
                                creationListener, creationFilter, null);
        logger.debug("createListeners", "added creationListener");
    } catch (Exception e) {
        final String msg = "Can't add listener to MBean server delegate: ";
        RuntimeException re = new IllegalArgumentException(msg + e);
        EnvHelp.initCause(re, e);
        logger.fine("createListeners", msg + e);
        logger.debug("createListeners", e);
        throw re;
    }

    /* Spec doesn't say whether Set returned by QueryNames can be modified
       so we clone it. */
    Set<ObjectName> names = queryNames(null, broadcasterQuery);
    names = new HashSet<ObjectName>(names);

    synchronized (this) {
        names.addAll(createdDuringQuery);
        createdDuringQuery = null;
    }

    for (ObjectName name : names)
        addBufferListener(name);
    logger.debug("createListeners", "ends");
}
 
Example #23
Source File: ServerNotifForwarder.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public ServerNotifForwarder(MBeanServer mbeanServer,
                            Map<String, ?> env,
                            NotificationBuffer notifBuffer,
                            String connectionId) {
    this.mbeanServer = mbeanServer;
    this.notifBuffer = notifBuffer;
    this.connectionId = connectionId;
    connectionTimeout = EnvHelp.getServerConnectionTimeout(env);

    String stringBoolean = (String) env.get("jmx.remote.x.check.notification.emission");
    checkNotificationEmission = EnvHelp.computeBooleanFromString( stringBoolean );
    notificationAccessController =
            EnvHelp.getNotificationAccessController(env);
}
 
Example #24
Source File: OpenMBeanAttributeInfoSupport.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static <T> T valueFrom(Descriptor d, String name, OpenType<T> openType) {
    Object x = d.getFieldValue(name);
    if (x == null)
        return null;
    try {
        return convertFrom(x, openType);
    } catch (Exception e) {
        final String msg =
            "Cannot convert descriptor field " + name + "  to " +
            openType.getTypeName();
        throw EnvHelp.initCause(new IllegalArgumentException(msg), e);
    }
}
 
Example #25
Source File: MapNullValuesTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private int mapToHashtableTests() {
    int errorCount = 0;
    echo("");
    echo(dashedMessage("Run MapToHashtable Tests"));
    for (int i = 0; i < maps.length; i++) {
        echo("\n>>> MapToHashtable Test [" + i + "]");
        try {
            echo("\tMap = " + maps[i]);
            Hashtable t = EnvHelp.mapToHashtable(maps[i]);
            echo("\tHashtable = " + t);
            checkContents(maps[i], t);
            echo("\tTest [" + i + "] PASSED!");
        } catch (Exception e) {
            errorCount++;
            echo("\tTest [" + i + "] FAILED!");
            e.printStackTrace(System.out);
        }
    }
    if (errorCount == 0) {
        echo("");
        echo(dashedMessage("MapToHashtable Tests PASSED!"));
    } else {
        echo("");
        echo(dashedMessage("MapToHashtable Tests FAILED!"));
    }
    return errorCount;
}
 
Example #26
Source File: OpenMBeanAttributeInfoSupport.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static <T> T valueFrom(Descriptor d, String name, OpenType<T> openType) {
    Object x = d.getFieldValue(name);
    if (x == null)
        return null;
    try {
        return convertFrom(x, openType);
    } catch (Exception e) {
        final String msg =
            "Cannot convert descriptor field " + name + "  to " +
            openType.getTypeName();
        throw EnvHelp.initCause(new IllegalArgumentException(msg), e);
    }
}
 
Example #27
Source File: OpenMBeanAttributeInfoSupport.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static <T> T valueFrom(Descriptor d, String name, OpenType<T> openType) {
    Object x = d.getFieldValue(name);
    if (x == null)
        return null;
    try {
        return convertFrom(x, openType);
    } catch (Exception e) {
        final String msg =
            "Cannot convert descriptor field " + name + "  to " +
            openType.getTypeName();
        throw EnvHelp.initCause(new IllegalArgumentException(msg), e);
    }
}
 
Example #28
Source File: ServerNotifForwarder.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public ServerNotifForwarder(MBeanServer mbeanServer,
                            Map<String, ?> env,
                            NotificationBuffer notifBuffer,
                            String connectionId) {
    this.mbeanServer = mbeanServer;
    this.notifBuffer = notifBuffer;
    this.connectionId = connectionId;
    connectionTimeout = EnvHelp.getServerConnectionTimeout(env);

    String stringBoolean = (String) env.get("jmx.remote.x.check.notification.emission");
    checkNotificationEmission = EnvHelp.computeBooleanFromString( stringBoolean );
    notificationAccessController =
            EnvHelp.getNotificationAccessController(env);
}
 
Example #29
Source File: ArrayNotificationBuffer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void createListeners() {
    logger.debug("createListeners", "starts");

    synchronized (this) {
        createdDuringQuery = new HashSet<ObjectName>();
    }

    try {
        addNotificationListener(MBeanServerDelegate.DELEGATE_NAME,
                                creationListener, creationFilter, null);
        logger.debug("createListeners", "added creationListener");
    } catch (Exception e) {
        final String msg = "Can't add listener to MBean server delegate: ";
        RuntimeException re = new IllegalArgumentException(msg + e);
        EnvHelp.initCause(re, e);
        logger.fine("createListeners", msg + e);
        logger.debug("createListeners", e);
        throw re;
    }

    /* Spec doesn't say whether Set returned by QueryNames can be modified
       so we clone it. */
    Set<ObjectName> names = queryNames(null, broadcasterQuery);
    names = new HashSet<ObjectName>(names);

    synchronized (this) {
        names.addAll(createdDuringQuery);
        createdDuringQuery = null;
    }

    for (ObjectName name : names)
        addBufferListener(name);
    logger.debug("createListeners", "ends");
}
 
Example #30
Source File: OpenMBeanAttributeInfoSupport.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static <T> T valueFrom(Descriptor d, String name, OpenType<T> openType) {
    Object x = d.getFieldValue(name);
    if (x == null)
        return null;
    try {
        return convertFrom(x, openType);
    } catch (Exception e) {
        final String msg =
            "Cannot convert descriptor field " + name + "  to " +
            openType.getTypeName();
        throw EnvHelp.initCause(new IllegalArgumentException(msg), e);
    }
}