org.mule.transport.legstar.tcp
Class LegstarTcpSocketFactory

java.lang.Object
  extended by org.mule.transport.tcp.AbstractTcpSocketFactory
      extended by org.mule.transport.tcp.TcpSocketFactory
          extended by org.mule.transport.legstar.tcp.LegstarTcpSocketFactory
All Implemented Interfaces:
org.apache.commons.pool.KeyedPoolableObjectFactory

public class LegstarTcpSocketFactory
extends org.mule.transport.tcp.TcpSocketFactory

Deliver new socket connections when needed.

Satisfy the EZASOCKET need for an initial message.


Field Summary
static int MAX_PROT_REPLY_LEN
          Maximum size of the host reply for acknowledgements and error reports.
static String REPLY_ACK_MSG_EC
          Reply eye catcher for acknowledgements.
static String UOW_COMMIT
          Processing instructions for UOW commit.
static String UOW_KEEP
          Processing instructions for UOW keep.
static String UOW_ROLLBACK
          Processing instructions for UOW rollback.
 
Constructor Summary
LegstarTcpSocketFactory(LegstarTcpConnector connector)
          Creates a factory and binds it to a protocol.
 
Method Summary
protected  void exchangeCommitMessage(Socket socket)
          Commit the server transaction.
protected  void exchangeInitialMessage(Socket socket, org.mule.api.security.Credentials credentials)
          EZASOKET expects an initial message that includes credentials.
protected  void exchangeProbeMessage(Socket socket)
          Probe the server transaction to make sure it is not stale.
 LegstarTcpConnector getConnector()
           
 Object makeObject(Object key)
           The socket pool invokes this method when it needs to create a new socket.
 void passivateObject(Object key, Object object)
           When a socket is returned to the pool in opened state, we need to commit the mainframe transaction (otherwise the transaction would never end).
 boolean validateObject(Object key, Object object)
           When sockets are reused, the server transaction might have timed out or gone stale.
 
Methods inherited from class org.mule.transport.tcp.TcpSocketFactory
createSocket
 
Methods inherited from class org.mule.transport.tcp.AbstractTcpSocketFactory
activateObject, destroyObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REPLY_ACK_MSG_EC

public static final String REPLY_ACK_MSG_EC
Reply eye catcher for acknowledgements. TODO use CicsSocket.

See Also:
Constant Field Values

MAX_PROT_REPLY_LEN

public static final int MAX_PROT_REPLY_LEN
Maximum size of the host reply for acknowledgements and error reports. TODO use CicsSocket.

See Also:
Constant Field Values

UOW_COMMIT

public static final String UOW_COMMIT
Processing instructions for UOW commit. TODO use CicsSocket.

See Also:
Constant Field Values

UOW_ROLLBACK

public static final String UOW_ROLLBACK
Processing instructions for UOW rollback. TODO use CicsSocket.

See Also:
Constant Field Values

UOW_KEEP

public static final String UOW_KEEP
Processing instructions for UOW keep. TODO use CicsSocket.

See Also:
Constant Field Values
Constructor Detail

LegstarTcpSocketFactory

public LegstarTcpSocketFactory(LegstarTcpConnector connector)
Creates a factory and binds it to a protocol.

Parameters:
connector - to bind to this factory
Method Detail

makeObject

public Object makeObject(Object key)
                  throws Exception
The socket pool invokes this method when it needs to create a new socket. We need to override the standard behavior because EZASOCKET requires an initial client message before it becomes available for send/receive operations.

Specified by:
makeObject in interface org.apache.commons.pool.KeyedPoolableObjectFactory
Overrides:
makeObject in class org.mule.transport.tcp.AbstractTcpSocketFactory
Throws:
Exception

validateObject

public boolean validateObject(Object key,
                              Object object)
When sockets are reused, the server transaction might have timed out or gone stale. Here we probe the server to make sure the socket is usable.

Specified by:
validateObject in interface org.apache.commons.pool.KeyedPoolableObjectFactory
Overrides:
validateObject in class org.mule.transport.tcp.AbstractTcpSocketFactory

passivateObject

public void passivateObject(Object key,
                            Object object)
                     throws Exception
When a socket is returned to the pool in opened state, we need to commit the mainframe transaction (otherwise the transaction would never end).

Specified by:
passivateObject in interface org.apache.commons.pool.KeyedPoolableObjectFactory
Overrides:
passivateObject in class org.mule.transport.tcp.AbstractTcpSocketFactory
Throws:
Exception

exchangeInitialMessage

protected void exchangeInitialMessage(Socket socket,
                                      org.mule.api.security.Credentials credentials)
                               throws Exception
EZASOKET expects an initial message that includes credentials. TODO get authentication parameters from event

Parameters:
socket - the opened connection to EZASOKET
credentials - the host credentials
Throws:
Exception - if initial message cannot be exchanged with CICS server

exchangeProbeMessage

protected void exchangeProbeMessage(Socket socket)
                             throws Exception
Probe the server transaction to make sure it is not stale.

Parameters:
socket - the opened connection to EZASOKET
Throws:
Exception - if probe message cannot be exchanged with CICS server

exchangeCommitMessage

protected void exchangeCommitMessage(Socket socket)
                              throws Exception
Commit the server transaction.

Parameters:
socket - the opened connection to EZASOKET
Throws:
Exception - if probe message cannot be exchanged with CICS server

getConnector

public LegstarTcpConnector getConnector()
Returns:
the connector to which this factory is bound


Copyright © 2013 LegSem. All Rights Reserved.