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);
}
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);
}
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);
}
}
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();
}
}
}
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());
}
}
}
}
Aggregations