- java.lang.Object
-
- javax.management.NotificationBroadcasterSupport
-
- javax.management.remote.JMXConnectorServer
-
- javax.management.remote.rmi.RMIConnectorServer
-
- All Implemented Interfaces:
- MBeanRegistration, NotificationBroadcaster, NotificationEmitter, JMXAddressable, JMXConnectorServerMBean
public class RMIConnectorServer extends JMXConnectorServer
A JMX API connector server that creates RMI-based connections from remote clients. Usually, such connector servers are made using
JMXConnectorServerFactory. However, specialized applications can use this class directly, for example with anRMIServerImplobject.- Since:
- 1.5
-
-
Field Summary
Fields Modifier and Type Field and Description static StringJNDI_REBIND_ATTRIBUTEName of the attribute that specifies whether theRMIServerstub that represents an RMI connector server should override an existing stub at the same address.static StringRMI_CLIENT_SOCKET_FACTORY_ATTRIBUTEName of the attribute that specifies theRMIClientSocketFactoryfor the RMI objects created in conjunction with this connector.static StringRMI_SERVER_SOCKET_FACTORY_ATTRIBUTEName of the attribute that specifies theRMIServerSocketFactoryfor the RMI objects created in conjunction with this connector.-
Fields inherited from class javax.management.remote.JMXConnectorServer
AUTHENTICATOR
-
-
Constructor Summary
Constructors Constructor and Description RMIConnectorServer(JMXServiceURL url, Map<String,?> environment)Makes anRMIConnectorServer.RMIConnectorServer(JMXServiceURL url, Map<String,?> environment, MBeanServer mbeanServer)Makes anRMIConnectorServerfor the given MBean server.RMIConnectorServer(JMXServiceURL url, Map<String,?> environment, RMIServerImpl rmiServerImpl, MBeanServer mbeanServer)Makes anRMIConnectorServerfor the given MBean server.
-
Method Summary
Methods Modifier and Type Method and Description protected voidconnectionClosed(String connectionId, String message, Object userData)Called by a subclass when a client connection is closed normally.protected voidconnectionFailed(String connectionId, String message, Object userData)Called by a subclass when a client connection fails.protected voidconnectionOpened(String connectionId, String message, Object userData)Called by a subclass when a new client connection is opened.JMXServiceURLgetAddress()The address of this connector server.Map<String,?>getAttributes()The attributes for this connector server.booleanisActive()Determines whether the connector server is active.voidsetMBeanServerForwarder(MBeanServerForwarder mbsf)Inserts an object that intercepts requests for the MBean server that arrive through this connector server.voidstart()Activates the connector server, that is starts listening for client connections.voidstop()Deactivates the connector server, that is, stops listening for client connections.JMXConnectortoJMXConnector(Map<String,?> env)Returns a client stub for this connector server.-
Methods inherited from class javax.management.remote.JMXConnectorServer
getConnectionIds, getMBeanServer, getNotificationInfo, postDeregister, postRegister, preDeregister, preRegister
-
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
-
-
-
-
Field Detail
-
JNDI_REBIND_ATTRIBUTE
public static final String JNDI_REBIND_ATTRIBUTE
Name of the attribute that specifies whether the
RMIServerstub that represents an RMI connector server should override an existing stub at the same address. The value associated with this attribute, if any, should be a string that is equal, ignoring case, to"true"or"false". The default value is false.- See Also:
- Constant Field Values
-
RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE
public static final String RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE
Name of the attribute that specifies the
RMIClientSocketFactoryfor the RMI objects created in conjunction with this connector. The value associated with this attribute must be of typeRMIClientSocketFactoryand can only be specified in theMapargument supplied when creating a connector server.- See Also:
- Constant Field Values
-
RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE
public static final String RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE
Name of the attribute that specifies the
RMIServerSocketFactoryfor the RMI objects created in conjunction with this connector. The value associated with this attribute must be of typeRMIServerSocketFactoryand can only be specified in theMapargument supplied when creating a connector server.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RMIConnectorServer
public RMIConnectorServer(JMXServiceURL url, Map<String,?> environment) throws IOException
Makes an
RMIConnectorServer. This is equivalent to callingRMIConnectorServer(directoryURL,environment,null,null)- Parameters:
url- the URL defining how to create the connector server. Cannot be null.environment- attributes governing the creation and storing of the RMI object. Can be null, which is equivalent to an empty Map.- Throws:
IllegalArgumentException- ifurlis null.MalformedURLException- ifurldoes not conform to the syntax for an RMI connector, or if its protocol is not recognized by this implementation. Only "rmi" and "iiop" are valid when this constructor is used.IOException- if the connector server cannot be created for some reason or if it is inevitable that itsstartmethod will fail.
-
RMIConnectorServer
public RMIConnectorServer(JMXServiceURL url, Map<String,?> environment, MBeanServer mbeanServer) throws IOException
Makes an
RMIConnectorServerfor the given MBean server. This is equivalent to callingRMIConnectorServer(directoryURL,environment,null,mbeanServer)- Parameters:
url- the URL defining how to create the connector server. Cannot be null.environment- attributes governing the creation and storing of the RMI object. Can be null, which is equivalent to an empty Map.mbeanServer- the MBean server to which the new connector server is attached, or null if it will be attached by being registered as an MBean in the MBean server.- Throws:
IllegalArgumentException- ifurlis null.MalformedURLException- ifurldoes not conform to the syntax for an RMI connector, or if its protocol is not recognized by this implementation. Only "rmi" and "iiop" are valid when this constructor is used.IOException- if the connector server cannot be created for some reason or if it is inevitable that itsstartmethod will fail.
-
RMIConnectorServer
public RMIConnectorServer(JMXServiceURL url, Map<String,?> environment, RMIServerImpl rmiServerImpl, MBeanServer mbeanServer) throws IOException
Makes an
RMIConnectorServerfor the given MBean server.- Parameters:
url- the URL defining how to create the connector server. Cannot be null.environment- attributes governing the creation and storing of the RMI object. Can be null, which is equivalent to an empty Map.rmiServerImpl- An implementation of the RMIServer interface, consistent with the protocol type specified in url. If this parameter is non null, the protocol type specified by url is not constrained, and is assumed to be valid. Otherwise, only "rmi" and "iiop" will be recognized.mbeanServer- the MBean server to which the new connector server is attached, or null if it will be attached by being registered as an MBean in the MBean server.- Throws:
IllegalArgumentException- ifurlis null.MalformedURLException- ifurldoes not conform to the syntax for an RMI connector, or if its protocol is not recognized by this implementation. Only "rmi" and "iiop" are recognized when rmiServerImpl is null.IOException- if the connector server cannot be created for some reason or if it is inevitable that itsstartmethod will fail.- See Also:
start()
-
-
Method Detail
-
toJMXConnector
public JMXConnector toJMXConnector(Map<String,?> env) throws IOException
Returns a client stub for this connector server. A client stub is a serializable object whose
connectmethod can be used to make one new connection to this connector server.- Specified by:
toJMXConnectorin interfaceJMXConnectorServerMBean- Overrides:
toJMXConnectorin classJMXConnectorServer- Parameters:
env- client connection parameters of the same sort that could be provided toJMXConnector.connect(Map). Can be null, which is equivalent to an empty map.- Returns:
- a client stub that can be used to make a new connection to this connector server.
- Throws:
UnsupportedOperationException- if this connector server does not support the generation of client stubs.IllegalStateException- if the JMXConnectorServer is not started (seeisActive()).IOException- if a communications problem means that a stub cannot be created.
-
start
public void start() throws IOExceptionActivates the connector server, that is starts listening for client connections. Calling this method when the connector server is already active has no effect. Calling this method when the connector server has been stopped will generate an
IOException.The behavior of this method when called for the first time depends on the parameters that were supplied at construction, as described below.
First, an object of a subclass of
RMIServerImplis required, to export the connector server through RMI:- If an
RMIServerImplwas supplied to the constructor, it is used. - Otherwise, if the protocol part of the
JMXServiceURLsupplied to the constructor wasiiop, an object of typeRMIIIOPServerImplis created. - Otherwise, if the
JMXServiceURLwas null, or its protocol part wasrmi, an object of typeRMIJRMPServerImplis created. - Otherwise, the implementation can create an
implementation-specific
RMIServerImplor it can throwMalformedURLException.
If the given address includes a JNDI directory URL as specified in the package documentation for
javax.management.remote.rmi, then thisRMIConnectorServerwill bootstrap by binding theRMIServerImplto the given address.If the URL path part of the
JMXServiceURLwas empty or a single slash (/), then the RMI object will not be bound to a directory. Instead, a reference to it will be encoded in the URL path of the RMIConnectorServer address (returned bygetAddress()). The encodings forrmiandiiopare described in the package documentation forjavax.management.remote.rmi.The behavior when the URL path is neither empty nor a JNDI directory URL, or when the protocol is neither
rminoriiop, is implementation defined, and may include throwingMalformedURLExceptionwhen the connector server is created or when it is started.- Throws:
IllegalStateException- if the connector server has not been attached to an MBean server.IOException- if the connector server cannot be started.
- If an
-
stop
public void stop() throws IOExceptionDeactivates the connector server, that is, stops listening for client connections. Calling this method will also close all client connections that were made by this server. After this method returns, whether normally or with an exception, the connector server will not create any new client connections.
Once a connector server has been stopped, it cannot be started again.
Calling this method when the connector server has already been stopped has no effect. Calling this method when the connector server has not yet been started will disable the connector server object permanently.
If closing a client connection produces an exception, that exception is not thrown from this method. A
JMXConnectionNotificationis emitted from this MBean with the connection ID of the connection that could not be closed.Closing a connector server is a potentially slow operation. For example, if a client machine with an open connection 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.
This method calls the method
closeon the connector server'sRMIServerImplobject.If the
RMIServerImplwas bound to a JNDI directory by thestartmethod, it is unbound from the directory by this method.- Throws:
IOException- if the server cannot be closed cleanly, or if theRMIServerImplcannot be unbound from the directory. When this exception is thrown, the server has already attempted to close all client connections, if appropriate; to callRMIServerImpl.close(); and to unbind theRMIServerImplfrom its directory, if appropriate. All client connections are closed except possibly those that generated exceptions when the server attempted to close them.
-
isActive
public boolean isActive()
Description copied from interface:JMXConnectorServerMBeanDetermines whether the connector server is active. A connector server starts being active when its
startmethod returns successfully and remains active until either itsstopmethod is called or the connector server fails.- Returns:
- true if the connector server is active.
-
getAddress
public JMXServiceURL getAddress()
Description copied from interface:JMXConnectorServerMBeanThe address of this connector server.
The address returned may not be the exact original
JMXServiceURLthat was supplied when creating the connector server, since the original address may not always be complete. For example the port number may be dynamically allocated when starting the connector server. Instead the address returned is the actualJMXServiceURLof theJMXConnectorServer. This is the address that clients supply toJMXConnectorFactory.connect(JMXServiceURL).Note that the address returned may be
nullif theJMXConnectorServeris not yetactive.- Returns:
- the address of this connector server, or null if it does not have one.
-
getAttributes
public Map<String,?> getAttributes()
Description copied from interface:JMXConnectorServerMBeanThe attributes for this connector server.
- Returns:
- a read-only map containing the attributes for this connector server. Attributes whose values are not serializable are omitted from this map. If there are no serializable attributes, the returned map is empty.
-
setMBeanServerForwarder
public void setMBeanServerForwarder(MBeanServerForwarder mbsf)
Description copied from interface:JMXConnectorServerMBeanInserts an object that intercepts requests for the MBean server that arrive through this connector server. This object will be supplied as the
MBeanServerfor any new connection created by this connector server. Existing connections are unaffected.This method can be called more than once with different
MBeanServerForwarderobjects. The result is a chain of forwarders. The last forwarder added is the first in the chain. In more detail:If this connector server is already associated with an
MBeanServerobject, then that object is given tombsf.setMBeanServer. If doing so produces an exception, this method throws the same exception without any other effect.If this connector is not already associated with an
MBeanServerobject, or if thembsf.setMBeanServercall just mentioned succeeds, thenmbsfbecomes this connector server'sMBeanServer.
- Specified by:
setMBeanServerForwarderin interfaceJMXConnectorServerMBean- Overrides:
setMBeanServerForwarderin classJMXConnectorServer- Parameters:
mbsf- the newMBeanServerForwarder.
-
connectionOpened
protected void connectionOpened(String connectionId, String message, Object userData)
Description copied from class:JMXConnectorServerCalled by a subclass when a new client connection is opened. Adds
connectionIdto the list returned byJMXConnectorServer.getConnectionIds(), then emits aJMXConnectionNotificationwith typeJMXConnectionNotification.OPENED.- Overrides:
connectionOpenedin classJMXConnectorServer- Parameters:
connectionId- the ID of the new connection. This must be different from the ID of any connection previously opened by this connector server.message- the message for the emittedJMXConnectionNotification. Can be null. SeeNotification.getMessage().userData- theuserDatafor the emittedJMXConnectionNotification. Can be null. SeeNotification.getUserData().
-
connectionClosed
protected void connectionClosed(String connectionId, String message, Object userData)
Description copied from class:JMXConnectorServerCalled by a subclass when a client connection is closed normally. Removes
connectionIdfrom the list returned byJMXConnectorServer.getConnectionIds(), then emits aJMXConnectionNotificationwith typeJMXConnectionNotification.CLOSED.- Overrides:
connectionClosedin classJMXConnectorServer- Parameters:
connectionId- the ID of the closed connection.message- the message for the emittedJMXConnectionNotification. Can be null. SeeNotification.getMessage().userData- theuserDatafor the emittedJMXConnectionNotification. Can be null. SeeNotification.getUserData().
-
connectionFailed
protected void connectionFailed(String connectionId, String message, Object userData)
Description copied from class:JMXConnectorServerCalled by a subclass when a client connection fails. Removes
connectionIdfrom the list returned byJMXConnectorServer.getConnectionIds(), then emits aJMXConnectionNotificationwith typeJMXConnectionNotification.FAILED.- Overrides:
connectionFailedin classJMXConnectorServer- Parameters:
connectionId- the ID of the failed connection.message- the message for the emittedJMXConnectionNotification. Can be null. SeeNotification.getMessage().userData- theuserDatafor the emittedJMXConnectionNotification. Can be null. SeeNotification.getUserData().
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/management/remote/rmi/RMIConnectorServer.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur van deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.