mx4j.tools.remote

Class AbstractConnectionManager

Implemented Interfaces:
ConnectionManager
Known Direct Subclasses:
HTTPConnectionManager

public abstract class AbstractConnectionManager
extends java.lang.Object
implements ConnectionManager

Implementation of the ConnectionManager interface that implements emission of connection notifications, authentication, and proper closing of connections.

Version:
$Revision: 1.7 $

Constructor Summary

AbstractConnectionManager(AbstractJMXConnectorServer server, Map environment)
Called by subclasses.

Method Summary

protected Subject
authenticate(Object credentials)
Authenticates a Subject with the given credentials, by looking up a JMXAuthenticator in the environment returned by getEnvironment().
void
close()
Implemented using the template method pattern
void
closeConnection(Connection connection)
Implemented using the template method pattern, handles the emission of the connection notification of type "closed".
Connection
connect(Object credentials)
Implemented using the template method pattern, it handles authentication, creation of the connection ID, emission of connection notification of type "opened".
protected String
createConnectionID(Subject subject)
Returns a connection ID as specified by JSR 160.
protected void
doClose()
Closes this ConnectionManager but not the connections it manages
protected void
doCloseConnection(Connection connection)
Closes the given Connection.
protected Connection
doConnect(String connectionId, Subject subject)
Template method to be implemented by subclasses; must return the server-side part of a connection.
protected Map
getEnvironment()
Returns the environment passed when creating the JMXConnectorServer
protected AccessControlContext
getSecurityContext()
Returns a security context at the moment of creation of this ConnectionManager.
protected boolean
isClosed()
Returns whether the close() method has been called.

Constructor Details

AbstractConnectionManager

protected AbstractConnectionManager(AbstractJMXConnectorServer server,
                                    Map environment)
Called by subclasses.

Parameters:
server - The JMXConnectorServer that will emit connection notifications
environment - The environment passed when the JMXConnectorServer is created.

Method Details

authenticate

protected Subject authenticate(Object credentials)
            throws IOException,
                   SecurityException


close

public void close()
            throws IOException
Implemented using the template method pattern
Specified by:
close in interface ConnectionManager

See Also:
doClose(), closeConnection(Connection)


closeConnection

public void closeConnection(Connection connection)
            throws IOException
Implemented using the template method pattern, handles the emission of the connection notification of type "closed". This method is called both when closing the connector server and when closing a connector.
Specified by:
closeConnection in interface ConnectionManager

See Also:
doCloseConnection(Connection)


connect

public Connection connect(Object credentials)
            throws IOException,
                   SecurityException
Implemented using the template method pattern, it handles authentication, creation of the connection ID, emission of connection notification of type "opened".
Specified by:
connect in interface ConnectionManager

See Also:
doConnect(String,Subject), authenticate(Object), createConnectionID(Subject)


createConnectionID

protected String createConnectionID(Subject subject)
Returns a connection ID as specified by JSR 160.

Parameters:
subject - The authenticated Subject


doClose

protected void doClose()
            throws IOException
Closes this ConnectionManager but not the connections it manages


doCloseConnection

protected void doCloseConnection(Connection connection)
            throws IOException
Closes the given Connection.


doConnect

protected Connection doConnect(String connectionId,
                               Subject subject)
            throws IOException
Template method to be implemented by subclasses; must return the server-side part of a connection. When an remote invocation arrives, it will lookup the corrispondent server-side part of the connection and delegate the call to it. The server-side part of the connection must then (eventually) call the MBeanServer to satisfy the request.

Parameters:
connectionId - The connection ID for connection that is returned
subject - The authenticated Subject

Returns:
The server-side part of a connection (with the given connection ID)


getEnvironment

protected Map getEnvironment()
Returns the environment passed when creating the JMXConnectorServer


getSecurityContext

protected AccessControlContext getSecurityContext()
Returns a security context at the moment of creation of this ConnectionManager. This security context is the restricting context that should be used when a call from a remote client is invoked in a doPrivileged() block.


isClosed

protected boolean isClosed()
Returns whether the close() method has been called.


Copyright © 2001-2005 The MX4J Contributors. All Rights Reserved.