org.jcoderz.commons.connector
Class ManagedConnectionFactoryBase

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

public abstract class ManagedConnectionFactoryBase
extends Object
implements ManagedConnectionFactory

This class implements the ManagedConnectionFactory interface and provides a set of abstract methods which have to be overrided by a derived class to provide the connector specific features.

See Also:
ManagedConnection, Serialized Form

Constructor Summary
ManagedConnectionFactoryBase()
           
 
Method Summary
 Object createConnectionFactory()
          
 Object createConnectionFactory(ConnectionManager cm)
          
protected abstract  Object createConnectionFactoryImpl(ConnectionManager cm)
          Creates a new ConnectionFactory.
 ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cri)
          
protected abstract  ManagedConnection createManagedConnectionImpl(UserPassword up, ConnectionRequestInfo cri)
           
 boolean equals(Object o)
          Returns true if this ManagedConnectionFactoryImpl is the same as the o argument.
 PrintWriter getLogWriter()
          
 UserPassword getUserPassword()
          Returns the UserPassword instance, containing the user name and password, set be deployment code.
 int hashCode()
          
protected abstract  boolean isMatchingManagedConnection(ManagedConnection mc, UserPassword up, ConnectionRequestInfo cri)
          Tests whether the given managed connection mc matchs for handling the connection allocation request.
 ManagedConnection matchManagedConnections(Set set, Subject subject, ConnectionRequestInfo cri)
          
 void setLogWriter(PrintWriter pw)
          
 void setPassword(String password)
          Sets the password for this factory.
 void setUserName(String userName)
          Sets the user name for this factory.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ManagedConnectionFactoryBase

public ManagedConnectionFactoryBase()
Method Detail

isMatchingManagedConnection

protected abstract boolean isMatchingManagedConnection(ManagedConnection mc,
                                                       UserPassword up,
                                                       ConnectionRequestInfo cri)
                                                throws ResourceException
Tests whether the given managed connection mc matchs for handling the connection allocation request.

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 abstract Object createConnectionFactoryImpl(ConnectionManager cm)
                                               throws ResourceException
Creates a new ConnectionFactory. A derived class may provide a CCI connection factory interface as recomended in the JCA Specification or a non-CCI interface that provides a resource adapter specific interface.

Parameters:
cm - The ConnectorManager to use.
Returns:
A new instance of connection factory (CCI or non-CCI).
Throws:
ResourceException - thrown in error cases.

createManagedConnectionImpl

protected abstract ManagedConnection createManagedConnectionImpl(UserPassword up,
                                                                 ConnectionRequestInfo cri)

createManagedConnection

public ManagedConnection createManagedConnection(Subject subject,
                                                 ConnectionRequestInfo cri)
                                          throws ResourceException

Specified by:
createManagedConnection in interface ManagedConnectionFactory
Throws:
ResourceException

createConnectionFactory

public Object createConnectionFactory(ConnectionManager cm)
                               throws ResourceException

Specified by:
createConnectionFactory in interface ManagedConnectionFactory
Throws:
ResourceException

createConnectionFactory

public Object createConnectionFactory()
                               throws ResourceException

Specified by:
createConnectionFactory in interface ManagedConnectionFactory
Throws:
ResourceException

matchManagedConnections

public ManagedConnection matchManagedConnections(Set set,
                                                 Subject subject,
                                                 ConnectionRequestInfo cri)
                                          throws ResourceException

Specified by:
matchManagedConnections in interface ManagedConnectionFactory
Throws:
ResourceException

setLogWriter

public void setLogWriter(PrintWriter pw)
                  throws ResourceException

Specified by:
setLogWriter in interface ManagedConnectionFactory
Throws:
ResourceException

getLogWriter

public PrintWriter getLogWriter()
                         throws ResourceException

Specified by:
getLogWriter in interface ManagedConnectionFactory
Throws:
ResourceException

setUserName

public void setUserName(String userName)
Sets the user name for this factory. This method should be called by deployment code.

Parameters:
userName - the user name to be set.

setPassword

public void setPassword(String password)
Sets the password for this factory. This method should be called by deployment code.

Parameters:
password - the passwor to be set.

getUserPassword

public UserPassword getUserPassword()
Returns the UserPassword instance, containing the user name and password, set be deployment code.

Returns:
the UserPassword instance.

hashCode

public int hashCode()

Specified by:
hashCode in interface ManagedConnectionFactory
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Returns true if this ManagedConnectionFactoryImpl is the same as the o argument.

Specified by:
equals in interface ManagedConnectionFactory
Overrides:
equals in class Object
Parameters:
o - Object to be compared with this.
Returns:
true if this ManagedConnectionFactoryImpl is the same as the o argument.


Copyright 2007 The jCoderZ Project.