org.jppf.client
Class AbstractClientConnectionHandler

java.lang.Object
  extended by org.jppf.client.AbstractClientConnectionHandler
All Implemented Interfaces:
ClientConnectionHandler, ClientConnectionStatusHandler
Direct Known Subclasses:
AbstractClassServerDelegate, TaskServerConnectionHandler

public abstract class AbstractClientConnectionHandler
extends Object
implements ClientConnectionHandler

Common abstract superclass for client connections to a server.

Author:
Laurent Cohen, Jeff Rosen

Field Summary
protected  String host
          The name or IP address of the host the class server is running on.
protected  List<ClientConnectionStatusListener> listeners
          List of status listeners for this connection.
protected  String name
          The name given to this connection handler.
protected  JPPFClientConnection owner
          The client connection which owns this connection handler.
protected  int port
          The TCP port the class server is listening to.
protected  SocketWrapper socketClient
          The socket client uses to communicate over a socket connection.
protected  SocketInitializer socketInitializer
          Used to synchronize access to the underlying socket from multiple threads.
protected  AtomicReference<JPPFClientConnectionStatus> status
          Status of the connection.
 
Constructor Summary
protected AbstractClientConnectionHandler(JPPFClientConnection owner)
          Initialize this connection with the specified owner.
 
Method Summary
 void addClientConnectionStatusListener(ClientConnectionStatusListener listener)
          Add a connection status listener to this connection's list of listeners.
protected abstract  SocketInitializer createSocketInitializer()
          Create a socket initializer for this connection handler.
protected  void fireStatusChanged(JPPFClientConnectionStatus oldStatus)
          Notify all listeners that the status of this connection has changed.
 SocketWrapper getSocketClient()
          Get the socket client used to communicate over a socket connection.
 JPPFClientConnectionStatus getStatus()
          Get the status of this connection.
 void removeClientConnectionStatusListener(ClientConnectionStatusListener listener)
          Remove a connection status listener from this connection's list of listeners.
 void setStatus(JPPFClientConnectionStatus newStatus)
          Set the status of this connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jppf.client.ClientConnectionHandler
close, init, initSocketClient
 

Field Detail

socketClient

protected SocketWrapper socketClient
The socket client uses to communicate over a socket connection.


socketInitializer

protected SocketInitializer socketInitializer
Used to synchronize access to the underlying socket from multiple threads.


host

protected String host
The name or IP address of the host the class server is running on.


port

protected int port
The TCP port the class server is listening to.


owner

protected JPPFClientConnection owner
The client connection which owns this connection handler.


name

protected String name
The name given to this connection handler.


status

protected AtomicReference<JPPFClientConnectionStatus> status
Status of the connection.


listeners

protected List<ClientConnectionStatusListener> listeners
List of status listeners for this connection.

Constructor Detail

AbstractClientConnectionHandler

protected AbstractClientConnectionHandler(JPPFClientConnection owner)
Initialize this connection with the specified owner.

Parameters:
owner - the client connection which owns this connection handler.
Method Detail

getStatus

public JPPFClientConnectionStatus getStatus()
Get the status of this connection.

Specified by:
getStatus in interface ClientConnectionStatusHandler
Returns:
a JPPFClientConnectionStatus enumerated value.
See Also:
ClientConnectionStatusHandler.getStatus()

setStatus

public void setStatus(JPPFClientConnectionStatus newStatus)
Set the status of this connection.

Specified by:
setStatus in interface ClientConnectionStatusHandler
Parameters:
newStatus - a JPPFClientConnectionStatus enumerated value.
See Also:
ClientConnectionStatusHandler.setStatus(org.jppf.client.JPPFClientConnectionStatus)

addClientConnectionStatusListener

public void addClientConnectionStatusListener(ClientConnectionStatusListener listener)
Add a connection status listener to this connection's list of listeners.

Specified by:
addClientConnectionStatusListener in interface ClientConnectionStatusHandler
Parameters:
listener - the listener to add to the list.
See Also:
ClientConnectionStatusHandler.addClientConnectionStatusListener(org.jppf.client.event.ClientConnectionStatusListener)

removeClientConnectionStatusListener

public void removeClientConnectionStatusListener(ClientConnectionStatusListener listener)
Remove a connection status listener from this connection's list of listeners.

Specified by:
removeClientConnectionStatusListener in interface ClientConnectionStatusHandler
Parameters:
listener - the listener to remove from the list.
See Also:
ClientConnectionStatusHandler.removeClientConnectionStatusListener(org.jppf.client.event.ClientConnectionStatusListener)

createSocketInitializer

protected abstract SocketInitializer createSocketInitializer()
Create a socket initializer for this connection handler.

Returns:
a SocketInitializer instance.

fireStatusChanged

protected void fireStatusChanged(JPPFClientConnectionStatus oldStatus)
Notify all listeners that the status of this connection has changed.

Parameters:
oldStatus - the connection status before the change.

getSocketClient

public SocketWrapper getSocketClient()
                              throws Exception
Get the socket client used to communicate over a socket connection.

Specified by:
getSocketClient in interface ClientConnectionHandler
Returns:
a SocketWrapper instance.
Throws:
Exception - if any error occurs.


Copyright © 2005-2010 JPPF Team.