Jumpi v1.2.0

org.jumpi.impl.connector.tcp
Class TcpConnectionAcceptor

java.lang.Object
  |
  +--org.jumpi.impl.connector.tcp.TcpConnectionAcceptor
All Implemented Interfaces:
Component, Configurable, Manageable, java.lang.Runnable, Task

public class TcpConnectionAcceptor
extends java.lang.Object
implements Task, Component

Establishes a ServerSocket on the configured port, continuously accepting Sockets and notifying the TcpConnector of the accepted Sockets until shutdown.


Constructor Summary
TcpConnectionAcceptor()
          Creates a new TcpConnectionAcceptor object.
 
Method Summary
 void configure(java.lang.String name, Properties props)
          Configure the TcpConnectionAcceptor.
 java.net.InetAddress getAddress()
          Return the InetAddress.
 java.lang.String getName()
          Get the fully qualified name of the instance.
 int getPort()
          Return the ServerSocket's port.
 java.lang.String getTaskId()
          A unique name for the task in the VM.
 boolean isLongRunning()
          Returns true always since the ServerSocket acceptor works continuously and requires a dedicated Task.
 boolean isSchedulable()
          The acceptor is schedulable as long as the ServerSocket exists.
 void manage(Component root, Component parent, java.lang.String operation, java.util.Hashtable parameters)
          Perform a recursive management operation through the Jumpi component tree, using the parameters provided.
 void run()
          Accept a Socket from the ServerSocket and notify the TcpConnector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TcpConnectionAcceptor

public TcpConnectionAcceptor()
Creates a new TcpConnectionAcceptor object.

Method Detail

getAddress

public java.net.InetAddress getAddress()
Return the InetAddress.

Returns:
the InetAddress.

getPort

public int getPort()
Return the ServerSocket's port.

Returns:
the ServerSocket's port.

getName

public java.lang.String getName()
Get the fully qualified name of the instance. Identical to the name used in configure.

Specified by:
getName in interface Configurable
Returns:
the fully qualified name of the instance.
See Also:
configure(java.lang.String, org.jumpi.spi.Properties)

configure

public void configure(java.lang.String name,
                      Properties props)
               throws java.lang.Exception
Configure the TcpConnectionAcceptor.

The following configuration attributes are defined:

Specified by:
configure in interface Configurable
Parameters:
name - the fully qualified instance name.
props - the read-only properties to configure the instance with.
Throws:
java.lang.Exception - when configuration is unsuccessful.
java.lang.IllegalArgumentException - if name or properties are missing.

manage

public void manage(Component root,
                   Component parent,
                   java.lang.String operation,
                   java.util.Hashtable parameters)
            throws java.lang.Exception
Perform a recursive management operation through the Jumpi component tree, using the parameters provided.

The following management actions are handled:

Specified by:
manage in interface Manageable
Parameters:
root - the Jumpi instance at the root of the component tree.
parent - the immediate parent of the component.
operation - the operation.
parameters - the operation parameters.
Throws:
java.lang.Exception - if any failure to perform management occurs.
java.lang.IllegalArgumentException - when parameters are missing.

getTaskId

public java.lang.String getTaskId()
A unique name for the task in the VM.

Specified by:
getTaskId in interface Task
Returns:
a unique name for the task in the VM.

isSchedulable

public boolean isSchedulable()
The acceptor is schedulable as long as the ServerSocket exists.

Specified by:
isSchedulable in interface Task
Returns:
true if the ServerSocket exists.
See Also:
manage(org.jumpi.spi.Component, org.jumpi.spi.Component, java.lang.String, java.util.Hashtable)

isLongRunning

public boolean isLongRunning()
Returns true always since the ServerSocket acceptor works continuously and requires a dedicated Task.

Specified by:
isLongRunning in interface Task
Returns:
true always.

run

public void run()
Accept a Socket from the ServerSocket and notify the TcpConnector. If the TcpConnector decides not to accept the Socket then close it. If a read timeout occurs then the Task will be rescheduled, unless shutdown occurs in the meantime.

Specified by:
run in interface java.lang.Runnable

Jumpi v1.2.0

Copyright 2003, Peter Jonathan Klauser.