com.cafesoft.core.message
Class DefaultConnector

java.lang.Object
  |
  +--com.cafesoft.core.message.DefaultConnector
All Implemented Interfaces:
Connector, Lifecycle, Runnable

public class DefaultConnector
extends Object
implements Connector, Lifecycle, Runnable

Listens to a ServerSocket and creates Connection objects to handle incoming Socket connections.

Since:
1/31/02

Field Summary
static int DEFAULT_ACCEPT_COUNT
          The default server socket backlog length.
protected  int uniqueId
          The unique ID of this connector instance.
 
Fields inherited from interface com.cafesoft.core.lifecycle.Lifecycle
START_EVENT, STOP_EVENT
 
Constructor Summary
DefaultConnector(Logger logger)
          Constructs a new instance of a DefaultConnector using the specified Logger.
 
Method Summary
 void addLifecycleListener(LifecycleListener listener)
          Add a LifecycleEvent listener to this component.
 int getAcceptCount()
          Returns the accept count for connections to this connector.
 String getAddress()
          Returns the IP address to which this connector binds.
 ServerSocketFactory getFactory()
          Returns the server socket factory used by this connector.
 String getInfo()
          Returns descriptive information about this connector implementation.
 int getPort()
          Returns the port to which this connector binds.
 void initialize()
          Invokes pre-startup initialization.
 boolean isStarted()
          Determine if the implementing Lifecycle object has been started.
 void removeLifecycleListener(LifecycleListener listener)
          Remove a LifecycleEvent listener from this component.
 void run()
          Start accepting connections from the network.
 void setAcceptCount(int acceptCount)
          Sets the accept count for connections to this connector.
 void setAddress(String address)
          Sets the IP address to which this connector binds.
 void setFactory(ServerSocketFactory factory)
          Sets the server socket factory used by this connector.
 void setMessageServiceProvider(MessageServiceProvider msp)
          Set the MessageServiceProvider.
 void setPort(int port)
          Sets the port to which this connector binds.
 void start()
          Starts the connector listening for incoming connections.
 void stop()
          Stops the connector listening for incoming connections.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ACCEPT_COUNT

public static final int DEFAULT_ACCEPT_COUNT
The default server socket backlog length.

See Also:
Constant Field Values

uniqueId

protected int uniqueId
The unique ID of this connector instance.

Constructor Detail

DefaultConnector

public DefaultConnector(Logger logger)
Constructs a new instance of a DefaultConnector using the specified Logger.

Parameters:
logger - logs messages
Method Detail

setMessageServiceProvider

public void setMessageServiceProvider(MessageServiceProvider msp)
Set the MessageServiceProvider.

Specified by:
setMessageServiceProvider in interface Connector
Parameters:
msp - the MessageServiceProvider

setFactory

public void setFactory(ServerSocketFactory factory)
Sets the server socket factory used by this connector.

Specified by:
setFactory in interface Connector
Parameters:
factory - the new ServerSocketFactory for this connector

getFactory

public ServerSocketFactory getFactory()
Returns the server socket factory used by this connector.

Specified by:
getFactory in interface Connector
Returns:
the ServerSocketFactory for this connector

getInfo

public String getInfo()
Returns descriptive information about this connector implementation.

Specified by:
getInfo in interface Connector
Returns:
information about this Connector

setAddress

public void setAddress(String address)
Sets the IP address to which this connector binds.

Specified by:
setAddress in interface Connector
Parameters:
address - the new IP address for this Connector

getAddress

public String getAddress()
Returns the IP address to which this connector binds.

Specified by:
getAddress in interface Connector
Returns:
the IP address for this Connector

setPort

public void setPort(int port)
Sets the port to which this connector binds.

Specified by:
setPort in interface Connector
Parameters:
port - the port number

getPort

public int getPort()
Returns the port to which this connector binds.

Specified by:
getPort in interface Connector
Returns:
the port for this Connector

setAcceptCount

public void setAcceptCount(int acceptCount)
Sets the accept count for connections to this connector.

Specified by:
setAcceptCount in interface Connector
Parameters:
acceptCount - the new accept count for this Connector

getAcceptCount

public int getAcceptCount()
Returns the accept count for connections to this connector.

Specified by:
getAcceptCount in interface Connector
Returns:
the accept count for this Connector

addLifecycleListener

public void addLifecycleListener(LifecycleListener listener)
Add a LifecycleEvent listener to this component.

Specified by:
addLifecycleListener in interface Lifecycle
Parameters:
listener - the listener to add

removeLifecycleListener

public void removeLifecycleListener(LifecycleListener listener)
Remove a LifecycleEvent listener from this component.

Specified by:
removeLifecycleListener in interface Lifecycle
Parameters:
listener - the listener to remove

initialize

public void initialize()
                throws LifecycleException
Invokes pre-startup initialization. This is used to allow connectors to bind to restricted ports under Unix operating environments.

Specified by:
initialize in interface Connector
Throws:
LifecycleException - ff this Connector was already initialized

start

public void start()
           throws LifecycleException
Starts the connector listening for incoming connections.

Specified by:
start in interface Connector
Throws:
LifecycleException - if this Connector was already started

stop

public void stop()
          throws LifecycleException
Stops the connector listening for incoming connections.

Specified by:
stop in interface Connector
Throws:
LifecycleException - if this Connector was already stopped

isStarted

public boolean isStarted()
Determine if the implementing Lifecycle object has been started.

Specified by:
isStarted in interface Connector
Returns:
true if the Lifecycle object has been started, false otherwise

run

public void run()
Start accepting connections from the network.

Specified by:
run in interface Runnable


Generated on 10:40:31 AM September 10, 2003, © 1996-2003 Cafésoft LLC. All rights reserved.