org.jcoderz.commons.connector.file
Class FsManagedConnectionFactoryImpl

java.lang.Object
  extended by org.jcoderz.commons.connector.ManagedConnectionFactoryBase
      extended by org.jcoderz.commons.connector.file.FsManagedConnectionFactoryImpl
All Implemented Interfaces:
Serializable, ManagedConnectionFactory

public class FsManagedConnectionFactoryImpl
extends ManagedConnectionFactoryBase

Implements the ManagedConnectionFactory interface.

See Also:
Serialized Form

Field Summary
static long FILE_TRANSFER_CHUNK_SIZE_MAX_VALUE
          Max value for chunk size, just Integer.MAX_VALUE.
static long FILE_TRANSFER_CHUNK_SIZE_MIN_VALUE
          Min value for chunk size, just 1KByte.
 
Constructor Summary
FsManagedConnectionFactoryImpl()
           
 
Method Summary
protected  Object createConnectionFactoryImpl(ConnectionManager cm)
          Creates a new FsConnectionFactoryImpl instance.
protected  ManagedConnection createManagedConnectionImpl(UserPassword up, ConnectionRequestInfo cri)
           
protected  boolean isMatchingManagedConnection(ManagedConnection mc, UserPassword up, ConnectionRequestInfo cri)
          Tests whether the given managed connection mc matchs for handling the connection allocation request.
 void setFileTransferChunkSize(Long size)
          Sets the chunk size used while file transfering.
 void setTempDir(String dir)
          Defines the temporary directory to be used by this connector.
 
Methods inherited from class org.jcoderz.commons.connector.ManagedConnectionFactoryBase
createConnectionFactory, createConnectionFactory, createManagedConnection, equals, getLogWriter, getUserPassword, hashCode, matchManagedConnections, setLogWriter, setPassword, setUserName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_TRANSFER_CHUNK_SIZE_MIN_VALUE

public static final long FILE_TRANSFER_CHUNK_SIZE_MIN_VALUE
Min value for chunk size, just 1KByte.

See Also:
Constant Field Values

FILE_TRANSFER_CHUNK_SIZE_MAX_VALUE

public static final long FILE_TRANSFER_CHUNK_SIZE_MAX_VALUE
Max value for chunk size, just Integer.MAX_VALUE.

See Also:
Constant Field Values
Constructor Detail

FsManagedConnectionFactoryImpl

public FsManagedConnectionFactoryImpl()
Method Detail

createManagedConnectionImpl

protected ManagedConnection createManagedConnectionImpl(UserPassword up,
                                                        ConnectionRequestInfo cri)
Specified by:
createManagedConnectionImpl in class ManagedConnectionFactoryBase

isMatchingManagedConnection

protected boolean isMatchingManagedConnection(ManagedConnection mc,
                                              UserPassword up,
                                              ConnectionRequestInfo cri)
                                       throws ResourceException
Description copied from class: ManagedConnectionFactoryBase
Tests whether the given managed connection mc matchs for handling the connection allocation request.

Specified by:
isMatchingManagedConnection in class ManagedConnectionFactoryBase
Parameters:
mc - The managed connection to be tested.
up - The caller's security information.
cri - A resource adapter specific connection request information.
Returns:
True if the given managed connection mc matchs for handling the connection allocation request. Otherwise false.
Throws:
ResourceException - thrown in error cases.

createConnectionFactoryImpl

protected Object createConnectionFactoryImpl(ConnectionManager cm)
                                      throws ResourceException
Creates a new FsConnectionFactoryImpl instance.

Specified by:
createConnectionFactoryImpl in class ManagedConnectionFactoryBase
Parameters:
cm - The ConectionManager to use.
Returns:
A new instance of connection factory (CCI or non-CCI).
Throws:
ResourceException - thrown in error cases.
See Also:
ManagedConnectionFactoryBase.createConnectionFactoryImpl(javax.resource.spi.ConnectionManager)

setFileTransferChunkSize

public void setFileTransferChunkSize(Long size)
Sets the chunk size used while file transfering. If a file size exceeds the chunk size, the file will be transfered chunk by chunk until all bytes will have been transfered. The Min value for this property is FILE_TRANSFER_CHUNK_SIZE_MIN_VALUE, the Max value is FILE_TRANSFER_CHUNK_SIZE_MAX_VALUE. If this property is not defined in the deployment descriptor the file connector will use the default value FsConnectionFactory.FILE_TRANSFER_CHUNK_SIZE_DEF_VALUE. Too small value will probably slow the performance down, and too large value may cause a resource's allocation problem. The value of this property should be adjusted to the underlying os, file system and available memory. A connection client can overwrite this value by passing a property object while retrieving a connection by calling the method FsConnectionFactory.getConnection(Properties).

Parameters:
size - the new chunk size to set.

setTempDir

public void setTempDir(String dir)
Defines the temporary directory to be used by this connector. The default value will be retrieved from the system property 'java.io.tmpdir'. A connection client can overwrite this value by passing the property FsConnectionFactory.PROP_TEMP_DIR while retrieving a connection by calling the method FsConnectionFactory.getConnection(Properties).

Parameters:
dir - temp dir to set.


Copyright 2007 The jCoderZ Project.