org.ow2.petals.transport.platform.nio.client
Class NioClientAgent

java.lang.Object
  extended by org.ow2.petals.transport.platform.nio.client.NioClientAgent
All Implemented Interfaces:
NioClient

public class NioClientAgent
extends java.lang.Object
implements NioClient

A client agent of the NIO transporter.

Author:
Christophe DENEUX (Capgemini Sud)

Constructor Summary
NioClientAgent(java.util.logging.Logger logger, NioSelector selectorAgent)
          NIO Client constructor.
 
Method Summary
 void connect(java.lang.String host, int port, long connectionTimeout)
          Realize a connection to the server part.
 void disconnect()
           
 boolean isUsable()
           This client can be used (i.e.
 void onClose(java.nio.channels.SocketChannel socketChannel)
          The callback caller will close the socket channel next.
 void onConnectionError(java.io.IOException exception)
           
 void onIsConnected(OutputSocketChannelContext oscc)
          Callbacks used by the TCP connection process
 void onIsWritten()
          Callbacks used by the TCP write process
 void onWriteError(java.io.IOException exception)
           
 void send(java.lang.Object obj, long timeout)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NioClientAgent

public NioClientAgent(java.util.logging.Logger logger,
                      NioSelector selectorAgent)
               throws java.io.IOException
NIO Client constructor.

Parameters:
logger -
selectorAgent -
serializationCacheCleanPeriod -
Throws:
java.io.IOException
Method Detail

connect

public void connect(java.lang.String host,
                    int port,
                    long connectionTimeout)
             throws java.io.IOException
Realize a connection to the server part. It's a blocking call until the connection is realized.

Parameters:
host - IP adress of the NIO server agent
port - TCP port of the NIO server agent
connectionTimeout - Connection timeout in millisecond
Throws:
java.io.IOException

onIsConnected

public void onIsConnected(OutputSocketChannelContext oscc)
Description copied from interface: NioClient
Callbacks used by the TCP connection process

Specified by:
onIsConnected in interface NioClient
See Also:
org.ow2.petals.extensions.transporter.nio.selector.NioClient#onIsConnected(org.ow2.petals.extensions.transporter.nio.selector.OutputSocketChannelContext)

onConnectionError

public void onConnectionError(java.io.IOException exception)
Specified by:
onConnectionError in interface NioClient
See Also:
org.ow2.petals.extensions.transporter.nio.selector.NioClient#onConnectionError(java.io.IOException)

send

public void send(java.lang.Object obj,
                 long timeout)
          throws java.io.IOException,
                 java.lang.InterruptedException
Specified by:
send in interface NioClient
Throws:
java.io.IOException
java.lang.InterruptedException

onIsWritten

public void onIsWritten()
                 throws java.io.IOException
Description copied from interface: NioClient
Callbacks used by the TCP write process

Specified by:
onIsWritten in interface NioClient
Throws:
java.io.IOException
See Also:
org.ow2.petals.extensions.transporter.nio.selector.NioClient#onIsWritten()

onWriteError

public void onWriteError(java.io.IOException exception)
                  throws java.io.IOException
Specified by:
onWriteError in interface NioClient
Throws:
java.io.IOException
See Also:
org.ow2.petals.extensions.transporter.nio.selector.NioClient#onWriteError(java.io.IOException)

onClose

public void onClose(java.nio.channels.SocketChannel socketChannel)
Description copied from interface: NioClient
The callback caller will close the socket channel next.

Specified by:
onClose in interface NioClient
Parameters:
socketChannel - The socket channel that has been detected as closed.
See Also:
org.ow2.petals.extensions.transporter.nio.selector.NioClient#onClose(java.nio.channels.SocketChannel)

disconnect

public void disconnect()
                throws java.io.IOException
Throws:
java.io.IOException

isUsable

public boolean isUsable()

This client can be used (i.e. the TCP connection is valid) ?

This method is thread-safe.

Returns:


Copyright © 2005-2011 Petals Link (EBM Websourcing). All Rights Reserved.