org.exolab.core.messenger.tcp
Class TcpConnector

java.lang.Object
  extended by org.exolab.core.messenger.tcp.TcpConnector
All Implemented Interfaces:
AcceptorEventListener, Connector, ManagedConnectionEventListener

public class TcpConnector
extends java.lang.Object
implements Connector, ManagedConnectionEventListener, AcceptorEventListener

A factory for TcpConnection and TcpManagedConnectionAcceptor objects

Version:
$Revision: 1.6 $ $Date: 2003/06/09 06:28:41 $
Author:
Tim Anderson
See Also:
Connector, TcpConnection, TcpConnectionAcceptor

Constructor Summary
TcpConnector()
          Create a new TcpConnector
 
Method Summary
protected  org.exolab.core.messenger.tcp.TcpManagedConnection accepted(java.net.Socket socket, java.util.HashMap handlers)
          Construct a new connection to process messages on a socket, accepted by a TcpConnectionAcceptor
 void closed(ManagedConnection connection)
          Invoked when a managed connection is closed
 void closed(ManagedConnectionAcceptor acceptor)
          Invoked when a connection acceptor is closed
 void error(ManagedConnectionAcceptor acceptor, java.lang.Exception exception)
          Invoked when a fatal connection acceptor error occurs, just before an Exception is thrown to the application
 void error(ManagedConnection connection, java.lang.Exception exception)
          Invoked when a fatal connection error occurs, just before an Exception is thrown to the application
 Connection getConnection(java.lang.String uri, ConnectionProperties properties)
          Returns a connection for the specified URI and connection properties
 ManagedConnectionAcceptor getManagedConnectionAcceptor(java.lang.String uri, ConnectionProperties properties)
          Returns a connection acceptor for the specified URI and connection properties
 java.lang.String getScheme()
          Returns the protocol that the connector supports
protected  ManagedConnection open(java.lang.String uri, ConnectionProperties properties)
          Opens a connection for the specified URI and connection properties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TcpConnector

public TcpConnector()
Create a new TcpConnector

Method Detail

getConnection

public Connection getConnection(java.lang.String uri,
                                ConnectionProperties properties)
                         throws java.net.MalformedURLException,
                                java.rmi.RemoteException
Returns a connection for the specified URI and connection properties

Specified by:
getConnection in interface Connector
Parameters:
uri - the connection address
properties - connection properties (may be null)
Returns:
a Connection if the connector finds an acceptable match, otherwise null
Throws:
java.net.MalformedURLException - if uri is an invalid URI
java.rmi.RemoteException - if a connection cannot be established
java.lang.IllegalArgumentException - if uri is null

getManagedConnectionAcceptor

public ManagedConnectionAcceptor getManagedConnectionAcceptor(java.lang.String uri,
                                                              ConnectionProperties properties)
                                                       throws java.net.MalformedURLException,
                                                              java.rmi.RemoteException
Returns a connection acceptor for the specified URI and connection properties

Specified by:
getManagedConnectionAcceptor in interface Connector
Parameters:
uri - the address to accept connections on
properties - connection properties (may be null)
Returns:
a connection acceptor, for accepting connection requests on the specified URI
Throws:
java.net.MalformedURLException - if uri is an invalid URI
java.rmi.RemoteException - if an I/O error occurs
java.lang.IllegalArgumentException - if uri is null

getScheme

public java.lang.String getScheme()
Returns the protocol that the connector supports

Specified by:
getScheme in interface Connector
Returns:
the protocol that the connector supports

closed

public void closed(ManagedConnection connection)
Invoked when a managed connection is closed

Specified by:
closed in interface ManagedConnectionEventListener
Parameters:
connection - the closed connection

error

public void error(ManagedConnection connection,
                  java.lang.Exception exception)
Invoked when a fatal connection error occurs, just before an Exception is thrown to the application

Specified by:
error in interface ManagedConnectionEventListener
Parameters:
connection - the connection the error occurred on
exception - the error

closed

public void closed(ManagedConnectionAcceptor acceptor)
Invoked when a connection acceptor is closed

Specified by:
closed in interface AcceptorEventListener
Parameters:
acceptor - the closed connection acceptor

error

public void error(ManagedConnectionAcceptor acceptor,
                  java.lang.Exception exception)
Invoked when a fatal connection acceptor error occurs, just before an Exception is thrown to the application

Specified by:
error in interface AcceptorEventListener
Parameters:
acceptor - the connection the error occurred on
exception - the error

open

protected ManagedConnection open(java.lang.String uri,
                                 ConnectionProperties properties)
                          throws java.net.MalformedURLException,
                                 java.rmi.RemoteException
Opens a connection for the specified URI and connection properties

Parameters:
uri - the connection address
properties - connection properties (may be null)
Returns:
a Connection if the connector finds an acceptable match, otherwise null
Throws:
java.net.MalformedURLException - if uri is an invalid URI
java.rmi.RemoteException - if a connection cannot be established

accepted

protected org.exolab.core.messenger.tcp.TcpManagedConnection accepted(java.net.Socket socket,
                                                                      java.util.HashMap handlers)
                                                               throws java.rmi.RemoteException
Construct a new connection to process messages on a socket, accepted by a TcpConnectionAcceptor

Parameters:
socket - the tcp socket
handlers - the set of connection handlers, keyed on name
Returns:
a new connection to process messages on the socket
Throws:
java.rmi.RemoteException - for any error
java.lang.IllegalArgumentException - if any argument is null


Copyright © 1999-2012 The Exolab Group. All Rights Reserved.