Class FTPManagedConnection

  • All Implemented Interfaces:
    com.arjuna.ats.jta.resources.LastResourceCommitOptimisation, java.io.Serializable, javax.transaction.xa.XAResource, org.ikasan.connector.listener.TransactionCommitFailureObserverable

    public class FTPManagedConnection
    extends org.ikasan.connector.base.command.TransactionalCommandConnection
    implements java.io.Serializable
    This EJB implements the ManagedConnection for the FTP resource adapter. This is a representation of a real, physical connection to the server, so it has an object instance variable which remains allocated to a server for the life of this object. This class is responsible for creating virtual connections, of class EISConnection, when the application server calls getConnection() It extends a (1 Phase Commit and 2 Phase commit) managed connection TODO Max retry attempts is really a client parameter, which brings us the question of whether we even want to open a connection at this stage
    Author:
    Ikasan Development Team
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static org.slf4j.Logger logger
      The logger instance.
      • Fields inherited from class org.ikasan.connector.base.command.TransactionalCommandConnection

        instanceCount, instanceOrdinal, listeners, transactionJournal, xid
      • Fields inherited from interface javax.transaction.xa.XAResource

        TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
    • Constructor Summary

      Constructors 
      Constructor Description
      FTPManagedConnection​(FTPConnectionRequestInfo fcri)
      Constructor, sets the managed connection factory and the hibernate filter table client ID sits on EISManagedConnection
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean cleanupJournalOnComplete()  
      protected void closeSession()
      Close the FileTransferProtocolClient session
      void forget​(javax.transaction.xa.Xid arg0)
      Deal with forgetting this unit of work as a txn, in this case do nothing
      java.lang.String getClientID()  
      java.lang.Object getConnection​(org.ikasan.connector.util.chunking.model.dao.FileChunkDao fileChunkDao, org.ikasan.connector.basefiletransfer.outbound.persistence.BaseFileTransferDao baseFileTransferDao, int testtodo)
      Create a virtual connection (a BaseFileTransferConnection object) and add it to the list of managed instances before returning it to the client.
      java.lang.Object getConnection​(org.ikasan.connector.util.chunking.model.dao.FileChunkDao fileChunkDao, org.ikasan.connector.basefiletransfer.outbound.persistence.BaseFileTransferDao baseFileTransferDao, com.google.common.cache.Cache<java.lang.String,​java.lang.Boolean> duplicatesFileCache)
      Create a virtual connection (a BaseFileTransferConnection object) and add it to the list of managed instances before returning it to the client.
      protected org.ikasan.connector.base.command.TransactionalResource getTransactionalResource()  
      int getTransactionTimeout()
      Return the Transaction timeout, always set to 0
      javax.transaction.xa.XAResource getXAResource()
      Get the XA resource for this managed connection, in this case, itself.
      boolean isSameRM​(javax.transaction.xa.XAResource arg0)
      Return whether or not this resource manager is the same, always return false
      void openSession()
      openSession initiates the physical connection to the server and logs us in.
      protected void postCommit​(javax.transaction.xa.Xid arg0)
      Hook method to allow any connector specific post commit functionality
      protected void postRollback​(javax.transaction.xa.Xid arg0)
      Hook method to allow any connector specific post rollback functionality
      boolean setTransactionTimeout​(int arg0)
      Set the txn timeout, always return false
      • Methods inherited from class org.ikasan.connector.base.command.TransactionalCommandConnection

        addListener, addListenersToCommand, commit, commitCommands, end, executeCommand, preCommit, prepare, preRollback, recover, rollback, rollbackCommands, sendErrorEvent, setTransactionJournal, start, transactionInProgress
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • logger

        public static org.slf4j.Logger logger
        The logger instance.
    • Constructor Detail

      • FTPManagedConnection

        public FTPManagedConnection​(FTPConnectionRequestInfo fcri)
        Constructor, sets the managed connection factory and the hibernate filter table client ID sits on EISManagedConnection
        Parameters:
        fcri - connection request info
    • Method Detail

      • getConnection

        public java.lang.Object getConnection​(org.ikasan.connector.util.chunking.model.dao.FileChunkDao fileChunkDao,
                                              org.ikasan.connector.basefiletransfer.outbound.persistence.BaseFileTransferDao baseFileTransferDao,
                                              int testtodo)
        Create a virtual connection (a BaseFileTransferConnection object) and add it to the list of managed instances before returning it to the client.
        Parameters:
        fileChunkDao -
        baseFileTransferDao -
        Returns:
      • getConnection

        public java.lang.Object getConnection​(org.ikasan.connector.util.chunking.model.dao.FileChunkDao fileChunkDao,
                                              org.ikasan.connector.basefiletransfer.outbound.persistence.BaseFileTransferDao baseFileTransferDao,
                                              com.google.common.cache.Cache<java.lang.String,​java.lang.Boolean> duplicatesFileCache)
        Create a virtual connection (a BaseFileTransferConnection object) and add it to the list of managed instances before returning it to the client.
        Parameters:
        fileChunkDao -
        baseFileTransferDao -
        duplicatesFileCache -
        Returns:
      • getClientID

        public java.lang.String getClientID()
      • openSession

        public void openSession()
                         throws javax.resource.ResourceException
        openSession initiates the physical connection to the server and logs us in. This method is called by FTPManagedConnectionFactory immediately after creating the instance of this class. In this implementation of an FTP connector there is no real concept of a session (a connection is made per method call), openSession is left here as it initialises the ftpClient and also provides a starting point for true session functionality to be added if required
        Throws:
        javax.resource.ResourceException - Exception thrown by Connector
      • closeSession

        protected void closeSession()
        Close the FileTransferProtocolClient session
      • forget

        public void forget​(javax.transaction.xa.Xid arg0)
        Deal with forgetting this unit of work as a txn, in this case do nothing
        Specified by:
        forget in interface javax.transaction.xa.XAResource
        See Also:
        EISXAManagedConnection.forget(javax.transaction.xa.Xid)
      • getTransactionTimeout

        public int getTransactionTimeout()
        Return the Transaction timeout, always set to 0
        Specified by:
        getTransactionTimeout in interface javax.transaction.xa.XAResource
        Returns:
        0
        See Also:
        EISXAManagedConnection.getTransactionTimeout()
      • getXAResource

        public javax.transaction.xa.XAResource getXAResource()
        Get the XA resource for this managed connection, in this case, itself.
        Specified by:
        getXAResource in class org.ikasan.connector.base.command.TransactionalCommandConnection
        See Also:
        EISXAManagedConnection.getXAResource()
      • isSameRM

        public boolean isSameRM​(javax.transaction.xa.XAResource arg0)
        Return whether or not this resource manager is the same, always return false
        Specified by:
        isSameRM in interface javax.transaction.xa.XAResource
        Returns:
        false
        See Also:
        EISXAManagedConnection.isSameRM(javax.transaction.xa.XAResource)
      • setTransactionTimeout

        public boolean setTransactionTimeout​(int arg0)
        Set the txn timeout, always return false
        Specified by:
        setTransactionTimeout in interface javax.transaction.xa.XAResource
        Returns:
        false
        See Also:
        EISXAManagedConnection.setTransactionTimeout(int)
      • getTransactionalResource

        protected org.ikasan.connector.base.command.TransactionalResource getTransactionalResource()
        Specified by:
        getTransactionalResource in class org.ikasan.connector.base.command.TransactionalCommandConnection
      • postRollback

        protected void postRollback​(javax.transaction.xa.Xid arg0)
        Hook method to allow any connector specific post rollback functionality
        Overrides:
        postRollback in class org.ikasan.connector.base.command.TransactionalCommandConnection
        Parameters:
        arg0 - Transaction Id
      • postCommit

        protected void postCommit​(javax.transaction.xa.Xid arg0)
        Hook method to allow any connector specific post commit functionality
        Overrides:
        postCommit in class org.ikasan.connector.base.command.TransactionalCommandConnection
        Parameters:
        arg0 - Transaction Id
      • cleanupJournalOnComplete

        protected boolean cleanupJournalOnComplete()
        Overrides:
        cleanupJournalOnComplete in class org.ikasan.connector.base.command.TransactionalCommandConnection