Class: javax.management.remote.rmi.RMIConnector
- public class RMIConnector
- implements JMXConnector, Serializable, JMXAddressable
A connection to a remote RMI connector. Usually, such connections are made using JMXConnectorFactory. However, specialized applications can use this class directly, for example with an javax.management.remote.rmi.RMIServer stub obtained without going through JNDI.
Methods
-
RMIConnectortop
public RMIConnector(JMXServiceURL url, Map<?> environment)Constructs an
RMIConnectorthat will connect the RMI connector server with the given address.The address can refer directly to the connector server, using one of the following syntaxes:
service:jmx:rmi://[host[:port]]/stub/encoded-stub service:jmx:iiop://[host[:port]]/ior/encoded-IOR
(Here, the square brackets
[]are not part of the address but indicate that the host and port are optional.)The address can instead indicate where to find an RMI stub through JNDI, using one of the following syntaxes:
service:jmx:rmi://[host[:port]]/jndi/jndi-name service:jmx:iiop://[host[:port]]/jndi/jndi-name
An implementation may also recognize additional address syntaxes, for example:
service:jmx:iiop://[host[:port]]/stub/encoded-stub
-
RMIConnectortop
Constructs an
RMIConnectorusing the given RMI stub. -
RMIConnectortop
-
addConnectionNotificationListenertop
public void addConnectionNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)Adds a listener to be informed of changes in connection status. The listener will receive notifications of type javax.management.remote.JMXConnectionNotification. An implementation can send other types of notifications too.
Any number of listeners can be added with this method. The same listener can be added more than once with the same or different values for the filter and handback. There is no special treatment of a duplicate entry. For example, if a listener is registered twice with no filter, then its
handleNotificationmethod will be called twice for each notification.- Specified by:
- addConnectionNotificationListener from JMXConnector
-
addListenerWithSubjecttop
private Integer addListenerWithSubject(ObjectName name, MarshalledObject filter, Subject delegationSubject, boolean reconnect) throws InstanceNotFoundException, IOException -
addListenersWithSubjectstop
private Integer[] addListenersWithSubjects(ObjectName[] names, MarshalledObject[] filters, Subject[] delegationSubjects, boolean reconnect) throws InstanceNotFoundException, IOException -
base64ToByteArraytop
static private byte[] base64ToByteArray(String s) -
base64toInttop
static private int base64toInt(char c)Translates the specified character, which is assumed to be in the "Base 64 Alphabet" into its equivalent 6-bit positive integer. -
checkStubtop
-
closetop
public synchronized void close() throws IOExceptionCloses the client connection to its server. Any ongoing or new request using the MBeanServerConnection returned by javax.management.remote.JMXConnector.getMBeanServerConnection() will get an
IOException.If
closehas already been called successfully on this object, calling it again has no effect. Ifclosehas never been called, or if it was called but produced an exception, an attempt will be made to close the connection. This attempt can succeed, in which caseclosewill return normally, or it can generate an exception.Closing a connection is a potentially slow operation. For example, if the server has crashed, the close operation might have to wait for a network protocol timeout. Callers that do not want to block in a close operation should do it in a separate thread.
- Specified by:
- close from JMXConnector
- close from Closeable
-
closetop
synchronized private void close(boolean intern) throws IOException -
connecttop
public void connect() throws IOExceptionEstablishes the connection to the connector server. This method is equivalent to connect(null).
- Specified by:
- connect from JMXConnector
-
connecttop
public synchronized void connect(Map<?> environment) throws IOExceptionEstablishes the connection to the connector server.
If
connecthas already been called successfully on this object, calling it again has no effect. If, however, javax.management.remote.JMXConnector.close() was called afterconnect, the newconnectwill throw anIOException.Otherwise, either
connecthas never been called on this object, or it has been called but produced an exception. Then callingconnectwill attempt to establish a connection to the connector server.- Specified by:
- connect from JMXConnector
-
connectStubtop
In order to be usable, an IIOP stub must be connected to an ORB. The stub is automatically connected to the ORB if:
- It was returned by the COS naming
- Its server counterpart has been registered in COS naming through JNDI.
A stub which is not connected can't be serialized, and thus can't be registered in Jini. A stub which is not connected can't be used to invoke methods on the server.In order to palliate this, this method will connect the given stub if it is not yet connected. If the given RMIServer is not an instance of javax.rmi.CORBA.Stub, then the method do nothing and simply returns that stub. Otherwise, this method will attempt to connect the stub to an ORB as follows:
This method looks in the provided environment for the "java.naming.corba.orb" property. If it is found, the referenced object (an ORB) is used to connect the stub. Otherwise, a new org.omg.CORBA.ORB is created by calling org.omg.CORBA.ORB.init((String[])null,(Properties)null)
The new created ORB is kept in a static java.lang.ref.WeakReference and can be reused for connecting other stubs. However, no reference is ever kept on the ORB provided in the environment map, if any.
-
findRMIServertop
private RMIServer findRMIServer(JMXServiceURL directoryURL, Map<String, Object> environment) throws NamingException, IOException -
findRMIServerIIOPtop
-
findRMIServerJNDItop
private RMIServer findRMIServerJNDI(String jndiURL, Map<?> env, boolean isIiop) throws NamingExceptionLookup the RMIServer stub in a directory. -
findRMIServerJRMPtop
-
getAddresstop
public JMXServiceURL getAddress()The address of this connector.
- Specified by:
- getAddress from JMXAddressable
-
getConnectiontop
static private RMIConnection getConnection(RMIServer server, Object credentials, boolean checkStub) throws IOException -
getConnectionIdtop
public synchronized String getConnectionId() throws IOExceptionGets this connection's ID from the connector server. For a given connector server, every connection will have a unique id which does not change during the lifetime of the connection.
- Specified by:
- getConnectionId from JMXConnector
-
getMBeanServerConnectiontop
public synchronized MBeanServerConnection getMBeanServerConnection() throws IOExceptionReturns an
MBeanServerConnectionobject representing a remote MBean server. For a givenJMXConnector, two successful calls to this method will usually return the sameMBeanServerConnectionobject, though this is not required.For each method in the returned
MBeanServerConnection, calling the method causes the corresponding method to be called in the remote MBean server. The value returned by the MBean server method is the value returned to the client. If the MBean server method produces anException, the sameExceptionis seen by the client. If the MBean server method, or the attempt to call it, produces anError, theErroris wrapped in a javax.management.remote.JMXServerErrorException, which is seen by the client.Calling this method is equivalent to calling getMBeanServerConnection(null) meaning that no delegation subject is specified and that all the operations called on the
MBeanServerConnectionmust use the authenticated subject, if any.- Specified by:
- getMBeanServerConnection from JMXConnector
-
getMBeanServerConnectiontop
public synchronized MBeanServerConnection getMBeanServerConnection(Subject delegationSubject) throws IOExceptionReturns an
MBeanServerConnectionobject representing a remote MBean server on which operations are performed on behalf of the supplied delegation subject. For a givenJMXConnectorandSubject, two successful calls to this method will usually return the sameMBeanServerConnectionobject, though this is not required.For each method in the returned
MBeanServerConnection, calling the method causes the corresponding method to be called in the remote MBean server on behalf of the given delegation subject instead of the authenticated subject. The value returned by the MBean server method is the value returned to the client. If the MBean server method produces anException, the sameExceptionis seen by the client. If the MBean server method, or the attempt to call it, produces anError, theErroris wrapped in a javax.management.remote.JMXServerErrorException, which is seen by the client.- Specified by:
- getMBeanServerConnection from JMXConnector
-
initTransientstop
private void initTransients() -
narrowIIOPServertop
-
narrowJRMPServertop
-
objectstop
-
popDefaultClassLoadertop
private void popDefaultClassLoader(ClassLoader old) -
pushDefaultClassLoadertop
private ClassLoader pushDefaultClassLoader() -
readObjecttop
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundExceptionRead RMIConnector fields from an ObjectInputStream. Callss.defaultReadObject()and then initializes all transient variables that need initializing. -
removeConnectionNotificationListenertop
public void removeConnectionNotificationListener(NotificationListener listener) throws ListenerNotFoundExceptionRemoves a listener from the list to be informed of changes in status. The listener must previously have been added. If there is more than one matching listener, all are removed.
- Specified by:
- removeConnectionNotificationListener from JMXConnector
-
removeConnectionNotificationListenertop
public void removeConnectionNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundExceptionRemoves a listener from the list to be informed of changes in status. The listener must previously have been added with the same three parameters. If there is more than one matching listener, only one is removed.
- Specified by:
- removeConnectionNotificationListener from JMXConnector
-
resolveOrbtop
Get the ORB specified by environment, or create a new one.This method looks in the provided environment for the "java.naming.corba.orb" property. If it is found, the referenced object (an ORB) is returned. Otherwise, a new org.omg.CORBA.ORB is created by calling org.omg.CORBA.ORB.init((String[])null,(Properties)null)
The new created ORB is kept in a static java.lang.ref.WeakReference and can be reused for connecting other stubs. However, no reference is ever kept on the ORB provided in the environment map, if any.
-
sendNotificationtop
private void sendNotification(Notification n) -
shadowIiopStubtop
static private RMIConnection shadowIiopStub(Stub stub) throws InstantiationException, IllegalAccessException -
shadowJrmpStubtop
static private RMIConnection shadowJrmpStub(RemoteObject stub) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, NoSuchMethodException -
stringstop
-
toStringtop
public String toString()Returns a string representation of this object. In general, the
toStringmethod returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. -
writeObjecttop
private void writeObject(ObjectOutputStream s) throws IOExceptionWrites the RMIConnector fields to an ObjectOutputStream.Connects the underlying RMIServer stub to an ORB, if needed, before serializing it. This is done using the environment map that was provided to the constructor, if any, and as documented in javax.management.remote.rmi.
This method then calls
s.defaultWriteObject(). Usually, rmiServer is null if this object was constructed with a JMXServiceURL, and jmxServiceURL is null if this object is constructed with a RMIServer stub.Note that the environment Map is not serialized, since the objects it contains are assumed to be contextual and relevant only with respect to the local environment (class loader, ORB, etc...).
After an RMIConnector is deserialized, it is assumed that the user will call javax.management.remote.rmi.RMIConnector.connect(java.util.Map), providing a new Map that can contain values which are contextually relevant to the new local environment.
Since connection to the ORB is needed prior to serializing, and since the ORB to connect to is one of those contextual parameters, it is not recommended to re-serialize a just de-serialized object - as the de-serialized object has no map. Thus, when an RMIConnector object is needed for serialization or transmission to a remote application, it is recommended to obtain a new RMIConnector stub by calling javax.management.remote.rmi.RMIConnectorServer.toJMXConnector(java.util.Map).
Fields
-
base64ToInt
static final private byte[] base64ToIntThis array is a lookup table that translates unicode characters drawn from the "Base64 Alphabet" (as specified in Table 1 of RFC 2045) into their 6-bit positive integer equivalents. Characters that are not in the Base64 alphabet but fall within the bounds of the array are translated to -1. -
clientNotifCounter
transient private long clientNotifCounter -
clientNotifSeqNo
transient private long clientNotifSeqNo -
closeException
transient private Exception closeException -
communicatorAdmin
transient private ClientCommunicatorAdmin communicatorAdmin -
connected
transient private boolean connected -
connection
transient private RMIConnection connection -
connectionBroadcaster
transient private NotificationBroadcasterSupport connectionBroadcaster -
connectionId
transient private String connectionId -
defaultClassLoader
transient private ClassLoader defaultClassLoader -
env
-
iiopConnectionStubClassName
static final private String iiopConnectionStubClassName = "org.omg.stub.javax.management.remote.rmi._RMIConnection_Stub" -
jmxServiceURL
final private JMXServiceURL jmxServiceURL -
logger
static final private ClassLogger logger -
orb
static private WeakReference<ORB> orbA static WeakReference to an ORB to connect unconnected stubs. -
pInputStreamClassName
static final private String pInputStreamClassName = "com.sun.jmx.remote.internal.PInputStream" -
pRefClassName
static final private String pRefClassName = "com.sun.jmx.remote.internal.PRef" -
proxyRefConstructor
static final private Constructor proxyRefConstructor -
proxyStubClass
static final private Class proxyStubClass -
proxyStubClassName
static final private String proxyStubClassName = "com.sun.jmx.remote.internal.ProxyStub" -
rmbscMap
-
rmiConnectionImplStubClass
static final private Class<?> rmiConnectionImplStubClass -
rmiConnectionImplStubClassName
static final private String rmiConnectionImplStubClassName -
rmiNotifClient
transient private RMIConnector.RMINotifClient rmiNotifClient -
rmiServer
final private RMIServer rmiServer -
rmiServerImplStubClass
static final private Class rmiServerImplStubClass -
rmiServerImplStubClassName
static final private String rmiServerImplStubClassName -
serialVersionUID
static final private long serialVersionUID = 817323035842634473 -
terminated
transient private boolean terminated
