Search in sources :

Example 1 with JMXConnectionNotification

use of javax.management.remote.JMXConnectionNotification in project camel by apache.

the class SimpleBean method triggerConnectionNotification.

public void triggerConnectionNotification() {
    JMXConnectionNotification n = new JMXConnectionNotification("connection", this, "conn-123", mSequence++, "connection notification", null);
    n.setTimeStamp(mTimestamp);
    sendNotification(n);
}
Also used : JMXConnectionNotification(javax.management.remote.JMXConnectionNotification)

Example 2 with JMXConnectionNotification

use of javax.management.remote.JMXConnectionNotification in project felix by apache.

the class ConnectionNotificationEmitter method sendConnectionNotificationOpened.

public void sendConnectionNotificationOpened() {
    JMXConnectionNotification notification = new JMXConnectionNotification(JMXConnectionNotification.OPENED, connector, getConnectionId(), getNextNotificationNumber(), "Connection opened", null);
    sendNotification(notification);
}
Also used : JMXConnectionNotification(javax.management.remote.JMXConnectionNotification)

Example 3 with JMXConnectionNotification

use of javax.management.remote.JMXConnectionNotification in project jdk8u_jdk by JetBrains.

the class RMIConnector method connect.

/**
     * @throws IOException if the connection could not be made because of a
     *   communication problem, or in the case of the {@code iiop} protocol,
     *   that RMI/IIOP is not supported
     */
public synchronized void connect(Map<String, ?> environment) throws IOException {
    final boolean tracing = logger.traceOn();
    String idstr = (tracing ? "[" + this.toString() + "]" : null);
    if (terminated) {
        logger.trace("connect", idstr + " already closed.");
        throw new IOException("Connector closed");
    }
    if (connected) {
        logger.trace("connect", idstr + " already connected.");
        return;
    }
    try {
        if (tracing)
            logger.trace("connect", idstr + " connecting...");
        final Map<String, Object> usemap = new HashMap<String, Object>((this.env == null) ? Collections.<String, Object>emptyMap() : this.env);
        if (environment != null) {
            EnvHelp.checkAttributes(environment);
            usemap.putAll(environment);
        }
        // Get RMIServer stub from directory or URL encoding if needed.
        if (tracing)
            logger.trace("connect", idstr + " finding stub...");
        RMIServer stub = (rmiServer != null) ? rmiServer : findRMIServer(jmxServiceURL, usemap);
        // Check for secure RMIServer stub if the corresponding
        // client-side environment property is set to "true".
        //
        String stringBoolean = (String) usemap.get("jmx.remote.x.check.stub");
        boolean checkStub = EnvHelp.computeBooleanFromString(stringBoolean);
        if (checkStub)
            checkStub(stub, rmiServerImplStubClass);
        // Connect IIOP Stub if needed.
        if (tracing)
            logger.trace("connect", idstr + " connecting stub...");
        stub = connectStub(stub, usemap);
        idstr = (tracing ? "[" + this.toString() + "]" : null);
        // Calling newClient on the RMIServer stub.
        if (tracing)
            logger.trace("connect", idstr + " getting connection...");
        Object credentials = usemap.get(CREDENTIALS);
        try {
            connection = getConnection(stub, credentials, checkStub);
        } catch (java.rmi.RemoteException re) {
            if (jmxServiceURL != null) {
                final String pro = jmxServiceURL.getProtocol();
                final String path = jmxServiceURL.getURLPath();
                if ("rmi".equals(pro) && path.startsWith("/jndi/iiop:")) {
                    MalformedURLException mfe = new MalformedURLException("Protocol is rmi but JNDI scheme is iiop: " + jmxServiceURL);
                    mfe.initCause(re);
                    throw mfe;
                }
            }
            throw re;
        }
        //   or contextClassLoader at connect time.
        if (tracing)
            logger.trace("connect", idstr + " getting class loader...");
        defaultClassLoader = EnvHelp.resolveClientClassLoader(usemap);
        usemap.put(JMXConnectorFactory.DEFAULT_CLASS_LOADER, defaultClassLoader);
        rmiNotifClient = new RMINotifClient(defaultClassLoader, usemap);
        env = usemap;
        final long checkPeriod = EnvHelp.getConnectionCheckPeriod(usemap);
        communicatorAdmin = new RMIClientCommunicatorAdmin(checkPeriod);
        connected = true;
        // The connectionId variable is used in doStart(), when
        // reconnecting, to identify the "old" connection.
        //
        connectionId = getConnectionId();
        Notification connectedNotif = new JMXConnectionNotification(JMXConnectionNotification.OPENED, this, connectionId, clientNotifSeqNo++, "Successful connection", null);
        sendNotification(connectedNotif);
        if (tracing)
            logger.trace("connect", idstr + " done...");
    } catch (IOException e) {
        if (tracing)
            logger.trace("connect", idstr + " failed to connect: " + e);
        throw e;
    } catch (RuntimeException e) {
        if (tracing)
            logger.trace("connect", idstr + " failed to connect: " + e);
        throw e;
    } catch (NamingException e) {
        final String msg = "Failed to retrieve RMIServer stub: " + e;
        if (tracing)
            logger.trace("connect", idstr + " " + msg);
        throw EnvHelp.initCause(new IOException(msg), e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) HashMap(java.util.HashMap) WeakHashMap(java.util.WeakHashMap) IOException(java.io.IOException) JMXConnectionNotification(javax.management.remote.JMXConnectionNotification) Notification(javax.management.Notification) MBeanServerNotification(javax.management.MBeanServerNotification) MarshalledObject(java.rmi.MarshalledObject) RemoteObject(java.rmi.server.RemoteObject) NamingException(javax.naming.NamingException) JMXConnectionNotification(javax.management.remote.JMXConnectionNotification)

Example 4 with JMXConnectionNotification

use of javax.management.remote.JMXConnectionNotification in project geode by apache.

the class JMXShiroAuthenticator method handleNotification.

@Override
public void handleNotification(Notification notification, Object handback) {
    if (notification instanceof JMXConnectionNotification) {
        JMXConnectionNotification cxNotification = (JMXConnectionNotification) notification;
        String type = cxNotification.getType();
        if (JMXConnectionNotification.CLOSED.equals(type)) {
            this.securityService.logout();
        }
    }
}
Also used : JMXConnectionNotification(javax.management.remote.JMXConnectionNotification)

Example 5 with JMXConnectionNotification

use of javax.management.remote.JMXConnectionNotification in project geode by apache.

the class JMXConnectionListener method handleNotification.

@Override
public void handleNotification(Notification notification, Object handback) {
    if (JMXConnectionNotification.class.isInstance(notification)) {
        JMXConnectionNotification connNotif = (JMXConnectionNotification) notification;
        if (JMXConnectionNotification.CLOSED.equals(connNotif.getType()) || JMXConnectionNotification.FAILED.equals(connNotif.getType())) {
            this.invoker.isConnected.set(false);
            this.invoker.resetClusterId();
            if (!this.invoker.isSelfDisconnect.get()) {
                Gfsh.getCurrentInstance().notifyDisconnect(this.invoker.toString());
            }
        }
    }
}
Also used : JMXConnectionNotification(javax.management.remote.JMXConnectionNotification)

Aggregations

JMXConnectionNotification (javax.management.remote.JMXConnectionNotification)13 MBeanServerNotification (javax.management.MBeanServerNotification)3 Notification (javax.management.Notification)3 IOException (java.io.IOException)2 StringWriter (java.io.StringWriter)1 MalformedURLException (java.net.MalformedURLException)1 MarshalledObject (java.rmi.MarshalledObject)1 NoSuchObjectException (java.rmi.NoSuchObjectException)1 RemoteObject (java.rmi.server.RemoteObject)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 HashMap (java.util.HashMap)1 WeakHashMap (java.util.WeakHashMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AttributeChangeNotification (javax.management.AttributeChangeNotification)1 ListenerNotFoundException (javax.management.ListenerNotFoundException)1 MBeanServerConnection (javax.management.MBeanServerConnection)1 NotificationListener (javax.management.NotificationListener)1 ObjectName (javax.management.ObjectName)1