org.jboss.remoting.transport
Class Connector

java.lang.Object
  extended by org.jboss.remoting.transport.Connector
All Implemented Interfaces:
javax.management.MBeanRegistration, ConnectorMBean
Direct Known Subclasses:
MarshallLoaderConnector

public class Connector
extends java.lang.Object
implements javax.management.MBeanRegistration, ConnectorMBean

Connector is an implementation of the ConnectorMBean interface.

The Connector is root component for the remoting server. It binds the server transport, marshaller, and handler together to form the remoting server instance.

A transport connector is configured via *-service.xml such as:

1 303 304 60000 ${jboss.bind.address} 6666 false 200 org.jboss.remoting.transport.mock.MockServerInvocationHandler

2410

Version:
$Revision: 4897 $
Author:
Jeff Haynie, Adrian Brock, David Jencks, Juha Lindfors, Tom Elrod

Field Summary
protected  ServerInvoker invoker
           
protected  org.jboss.logging.Logger log
           
 
Constructor Summary
  Connector()
          Empty constructor.
protected Connector(boolean isMarshallerConnector)
           
  Connector(InvokerLocator locator)
          Creates Connector with specified locator.
  Connector(InvokerLocator locator, java.util.Map configuration)
          Constructs connector for given locator and configuration.
  Connector(java.util.Map configuration)
          Constructs connector and populates configuration information.
  Connector(java.lang.String locatorURI)
          Creates Connector with specified locator.
  Connector(java.lang.String locatorURI, java.util.Map configuration)
          Constructs connector for given locator and configuration.
 
Method Summary
 void addConnectionListener(ConnectionListener listener)
          Adds a connection listener to receive notification when a client connection is lost or disconnected.
 ServerInvocationHandler addInvocationHandler(java.lang.String subsystem, javax.management.ObjectName handlerObjectName)
          Adds a handler to the connector via OjbectName.
 ServerInvocationHandler addInvocationHandler(java.lang.String subsystem, ServerInvocationHandler handler)
          Adds an invocation handler for the named subsystem to the invoker we manage, and sets the mbean server on the invocation handler.
 void create()
          Creates the connector.
 void destroy()
          Destroys the connector.
 org.w3c.dom.Element getConfiguration()
          Configuration is an xml element indicating subsystems to be registered with the ServerInvoker we wrap.
 ServerInvocationHandler[] getInvocationHandlers()
          Will get array of all the handlers registered with the connector's server invoker.
 java.lang.String getInvokerLocator()
          Returns the invoker locator.
 long getLeasePeriod()
          Gets the lease period for client connections.
 InvokerLocator getLocator()
          Returns the locator to the connector.
 ServerInvoker getServerInvoker()
           
 javax.net.ServerSocketFactory getServerSocketFactory()
           
 javax.net.SocketFactory getSocketFactory()
           
 boolean isStarted()
          Indicates if the connector has been started yet.
 void postDeregister()
          This method is called by the MBeanServer after deregistration takes place.
 void postRegister(java.lang.Boolean registrationDone)
          This method is called by the MBeanServer after registration takes place or when registration fails.
 void preDeregister()
          This method is called by the MBeanServer before deregistration takes place.
 javax.management.ObjectName preRegister(javax.management.MBeanServer server, javax.management.ObjectName name)
          This method is called by the MBeanServer before registration takes place.
 void removeConnectionListener(ConnectionListener listener)
          Removes connection listener from receiving client connection lost/disconnected notifications.
 void removeInvocationHandler(java.lang.String subsystem)
          Removes an invocation handler for the supplied subsystem from the invoker we manage, and unsets the MBeanServer on the handler.
 void setConfiguration(org.w3c.dom.Element xml)
          Configuration is an xml element indicating subsystems to be registered with the ServerInvoker we wrap.
 void setInvokerLocator(java.lang.String locator)
          Sets the invoker locator.
 void setLeasePeriod(long leasePeriodValue)
          Sets the lease period for client connections.
 void setServerSocketFactory(javax.net.ServerSocketFactory serverSocketFactory)
          The server socket factory can only be set on the Connector before the create() method has been called.
 void setSocketFactory(javax.net.SocketFactory socketFactory)
          The socket factory (for callbacks) can only be set on the Connector before the create() method has been called.
 void start()
          Starts the connector.
 void start(boolean runAsNewThread)
          Starts the connector.
 void stop()
          Stops the connector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

invoker

protected ServerInvoker invoker

log

protected final org.jboss.logging.Logger log
Constructor Detail

Connector

public Connector()
Empty constructor.


Connector

public Connector(java.lang.String locatorURI)
Creates Connector with specified locator.

Parameters:
locatorURI -

Connector

public Connector(InvokerLocator locator)
Creates Connector with specified locator.

Parameters:
locator -

Connector

public Connector(java.util.Map configuration)
Constructs connector and populates configuration information.

Parameters:
configuration -

Connector

public Connector(java.lang.String locatorURI,
                 java.util.Map configuration)
Constructs connector for given locator and configuration.

Parameters:
locatorURI -
configuration -

Connector

public Connector(InvokerLocator locator,
                 java.util.Map configuration)
Constructs connector for given locator and configuration.

Parameters:
locator -
configuration -

Connector

protected Connector(boolean isMarshallerConnector)
Method Detail

isStarted

public boolean isStarted()
Indicates if the connector has been started yet.

Returns:

preRegister

public javax.management.ObjectName preRegister(javax.management.MBeanServer server,
                                               javax.management.ObjectName name)
                                        throws java.lang.Exception
This method is called by the MBeanServer before registration takes place. The MBean is passed a reference of the MBeanServer it is about to be registered with. The MBean must return the ObjectName it will be registered with. The MBeanServer can pass a suggested object depending upon how the MBean is registered.

The MBean can stop the registration by throwing an exception.The exception is forwarded to the invoker wrapped in an MBeanRegistrationException.

Specified by:
preRegister in interface javax.management.MBeanRegistration
Parameters:
server - the MBeanServer the MBean is about to be registered with.
name - the suggested ObjectName supplied by the MBeanServer.
Returns:
the actual ObjectName to register this MBean with.
Throws:
java.lang.Exception - for any error, the MBean is not registered.

postRegister

public void postRegister(java.lang.Boolean registrationDone)
This method is called by the MBeanServer after registration takes place or when registration fails.

Specified by:
postRegister in interface javax.management.MBeanRegistration
Parameters:
registrationDone - the MBeanServer passes true when the MBean was registered, false otherwise.

preDeregister

public void preDeregister()
                   throws java.lang.Exception
This method is called by the MBeanServer before deregistration takes place.

The MBean can throw an exception, this will stop the deregistration. The exception is forwarded to the invoker wrapped in an MBeanRegistrationException.

Specified by:
preDeregister in interface javax.management.MBeanRegistration
Throws:
java.lang.Exception

postDeregister

public void postDeregister()
This method is called by the MBeanServer after deregistration takes place.

Specified by:
postDeregister in interface javax.management.MBeanRegistration

start

public void start()
           throws java.lang.Exception
Starts the connector. This is when configuration will be applied and server invoker created.

Specified by:
start in interface ConnectorMBean
Throws:
java.lang.Exception

start

public void start(boolean runAsNewThread)
           throws java.lang.Exception
Starts the connector.

Specified by:
start in interface ConnectorMBean
Parameters:
runAsNewThread - indicates if should be started on new thread or the current one. If runAsNewThread is true, new thread will not be daemon thread.
Throws:
java.lang.Exception

addConnectionListener

public void addConnectionListener(ConnectionListener listener)
Adds a connection listener to receive notification when a client connection is lost or disconnected. Will only be triggered for notifications when leasing is turned on (via the lease period attribute being set to > 0).

Specified by:
addConnectionListener in interface ConnectorMBean
Parameters:
listener -

removeConnectionListener

public void removeConnectionListener(ConnectionListener listener)
Removes connection listener from receiving client connection lost/disconnected notifications.

Specified by:
removeConnectionListener in interface ConnectorMBean
Parameters:
listener -

setLeasePeriod

public void setLeasePeriod(long leasePeriodValue)
Sets the lease period for client connections. Value is in milliseconds.

Specified by:
setLeasePeriod in interface ConnectorMBean
Parameters:
leasePeriodValue -

getLeasePeriod

public long getLeasePeriod()
Gets the lease period for client connections. Value in milliseconds.

Specified by:
getLeasePeriod in interface ConnectorMBean
Returns:

stop

public void stop()
Stops the connector. Will also stop and destroy server invoker (transport)

Specified by:
stop in interface ConnectorMBean

create

public void create()
            throws java.lang.Exception
Creates the connector.

Specified by:
create in interface ConnectorMBean
Throws:
java.lang.Exception

destroy

public void destroy()
Destroys the connector.

Specified by:
destroy in interface ConnectorMBean

getServerInvoker

public ServerInvoker getServerInvoker()

getInvocationHandlers

public ServerInvocationHandler[] getInvocationHandlers()
Will get array of all the handlers registered with the connector's server invoker.

Returns:

getLocator

public InvokerLocator getLocator()
Returns the locator to the connector. Locator is the actual InvokerLocator object used to identify and get the ServerInvoker we are wrapping.

Specified by:
getLocator in interface ConnectorMBean

setInvokerLocator

public void setInvokerLocator(java.lang.String locator)
                       throws java.lang.Exception
Sets the invoker locator. InvokerLocator is the string URI representation of the InvokerLocator used to get and identify the ServerInvoker we are wrapping.

Specified by:
setInvokerLocator in interface ConnectorMBean
Throws:
java.lang.Exception

getInvokerLocator

public java.lang.String getInvokerLocator()
                                   throws java.lang.Exception
Returns the invoker locator. InvokerLocator is the string URI representation of the InvokerLocator used to get and identify the ServerInvoker we are wrapping.

Specified by:
getInvokerLocator in interface ConnectorMBean
Throws:
java.lang.Exception

setConfiguration

public void setConfiguration(org.w3c.dom.Element xml)
                      throws java.lang.Exception
Configuration is an xml element indicating subsystems to be registered with the ServerInvoker we wrap. Using mbean subsystems that call registerSubsystem is more flexible.

Specified by:
setConfiguration in interface ConnectorMBean
Throws:
java.lang.Exception

getConfiguration

public org.w3c.dom.Element getConfiguration()
Configuration is an xml element indicating subsystems to be registered with the ServerInvoker we wrap. Using mbean subsystems that call registerSubsystem is more flexible.

Specified by:
getConfiguration in interface ConnectorMBean

addInvocationHandler

public ServerInvocationHandler addInvocationHandler(java.lang.String subsystem,
                                                    javax.management.ObjectName handlerObjectName)
                                             throws java.lang.Exception
Adds a handler to the connector via OjbectName. This will create a mbean proxy of type of ServerInvocationHandler for the MBean specified by object name passed (so has to implement ServerInvocationHandler interface).

Specified by:
addInvocationHandler in interface ConnectorMBean
Parameters:
subsystem -
handlerObjectName -
Returns:
Previous ServerInvocatioHandler with the same subsystem value (case insensitive) or null if one did not previously exist.
Throws:
java.lang.Exception

addInvocationHandler

public ServerInvocationHandler addInvocationHandler(java.lang.String subsystem,
                                                    ServerInvocationHandler handler)
                                             throws java.lang.Exception
Adds an invocation handler for the named subsystem to the invoker we manage, and sets the mbean server on the invocation handler.

Specified by:
addInvocationHandler in interface ConnectorMBean
Returns:
Previous ServerInvocatioHandler with the same subsystem value (case insensitive) or null if one did not previously exist.
Throws:
java.lang.Exception

removeInvocationHandler

public void removeInvocationHandler(java.lang.String subsystem)
                             throws java.lang.Exception
Removes an invocation handler for the supplied subsystem from the invoker we manage, and unsets the MBeanServer on the handler.

Specified by:
removeInvocationHandler in interface ConnectorMBean
Throws:
java.lang.Exception

setServerSocketFactory

public void setServerSocketFactory(javax.net.ServerSocketFactory serverSocketFactory)
The server socket factory can only be set on the Connector before the create() method has been called. Otherwise, a runtime exception will be thrown.

Parameters:
serverSocketFactory -

getServerSocketFactory

public javax.net.ServerSocketFactory getServerSocketFactory()

setSocketFactory

public void setSocketFactory(javax.net.SocketFactory socketFactory)
The socket factory (for callbacks) can only be set on the Connector before the create() method has been called. Otherwise, a runtime exception will be thrown.

Parameters:
socketFactory -

getSocketFactory

public javax.net.SocketFactory getSocketFactory()


Copyright © 1998-2005 JBoss Inc . All Rights Reserved.