org.exolab.jms.net.connector
Class AbstractConnectionManager

java.lang.Object
  |
  +--org.exolab.jms.net.connector.AbstractConnectionManager
All Implemented Interfaces:
ConnectionFactory, ConnectionManager
Direct Known Subclasses:
DefaultConnectionManager

public abstract class AbstractConnectionManager
extends java.lang.Object
implements ConnectionManager, ConnectionFactory

Abstract implementation of the ConnectionManager interface.

Version:
$Revision: 1.6 $ $Date: 2005/06/04 14:43:59 $
Author:
Tim Anderson

Constructor Summary
AbstractConnectionManager(InvocationHandler handler, Authenticator authenticator, java.util.Map properties)
          Construct a new AbstractConnectionManager.
 
Method Summary
 void accept(ManagedConnectionFactory factory, ConnectionRequestInfo info)
          Start accepting connections.
 void accept(URI uri)
          Listen for new connections on the specified URI, using the default connection acceptor properties.
 void accept(URI uri, java.util.Map properties)
          Listen for new connections on the specified URI, using the specified acceptor properties.
protected  void addManagedConnectionFactory(ManagedConnectionFactory factory)
          Register a managed connection factory.
 Connection allocateConnection(ManagedConnectionFactory factory, java.security.Principal principal, ConnectionRequestInfo info)
          Allocate a new connection.
 boolean canAccept(URI uri)
          Determines if this factory supports listening for new connections on the specified URI.
 boolean canConnect(URI uri)
          Determines if this factory supports connections to the specified URI.
 void close()
          Close this connection manager.
protected  ConnectionPool createConnectionPool(ManagedConnectionFactory factory, InvocationHandler handler, ConnectionFactory resolver)
          Creates a new connection pool.
 Connection getConnection(java.security.Principal principal, URI uri)
          Returns a connection to the specified URI, using the default connection properties.
 Connection getConnection(java.security.Principal principal, URI uri, java.util.Map properties)
          Returns a connection to the specified URI, using the specified connection properties.
protected  ConnectionPool getConnectionPool(ManagedConnectionFactory factory)
          Returns the ConnectionPool which pools connections for the specified factory.
protected  ConnectionFactory getFactoryForAccept(URI uri)
          Returns the first factory which can accept connections on the specified URI.
protected  ConnectionFactory getFactoryForConnect(URI uri)
          Returns the first factory which can support connections to the specified URI.
protected  java.util.Collection getManagedConnectionFactories()
          Returns all registered managed connection factories.
 void setCallerListener(CallerListener listener)
          Sets the caller event listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractConnectionManager

public AbstractConnectionManager(InvocationHandler handler,
                                 Authenticator authenticator,
                                 java.util.Map properties)
Construct a new AbstractConnectionManager.
Parameters:
handler - the invocation handler
authenticator - the connection authenticator
properties - configuration properties. May be null
Method Detail

allocateConnection

public Connection allocateConnection(ManagedConnectionFactory factory,
                                     java.security.Principal principal,
                                     ConnectionRequestInfo info)
                              throws ResourceException
Allocate a new connection.
Specified by:
allocateConnection in interface ConnectionManager
Parameters:
factory - used by application server to delegate connection matching/creation
principal - the security principal
info - the connection request info
Returns:
the new connection
Throws:
ResourceException - if the connection cannot be allocated

accept

public void accept(ManagedConnectionFactory factory,
                   ConnectionRequestInfo info)
            throws ResourceException
Start accepting connections.
Specified by:
accept in interface ConnectionManager
Parameters:
factory - used to delegate acceptor matching/creation
info - connection request info
Throws:
ResourceException - if the connections cannot be accepted

canConnect

public boolean canConnect(URI uri)
Determines if this factory supports connections to the specified URI.
Specified by:
canConnect in interface ConnectionFactory
Parameters:
uri - the connection address
Returns:
true if this factory supports the URI; false otherwise

getConnection

public Connection getConnection(java.security.Principal principal,
                                URI uri)
                         throws ResourceException
Returns a connection to the specified URI, using the default connection properties.
Specified by:
getConnection in interface ConnectionFactory
Parameters:
principal - the security principal. May be null
uri - the connection address
Returns:
a connection to uri
Throws:
ResourceException - if a connection cannot be established

getConnection

public Connection getConnection(java.security.Principal principal,
                                URI uri,
                                java.util.Map properties)
                         throws ResourceException
Returns a connection to the specified URI, using the specified connection properties.
Specified by:
getConnection in interface ConnectionFactory
Parameters:
principal - the security principal. May be null
uri - the connection address
properties - connection properties. If null, use the default connection properties
Returns:
a connection to uri
Throws:
ResourceException - if a connection cannot be established

canAccept

public boolean canAccept(URI uri)
Determines if this factory supports listening for new connections on the specified URI.
Specified by:
canAccept in interface ConnectionFactory
Parameters:
uri - the connection address
Returns:
true if this factory supports the URI; false otherwise

accept

public void accept(URI uri)
            throws ResourceException
Listen for new connections on the specified URI, using the default connection acceptor properties.
Specified by:
accept in interface ConnectionFactory
Parameters:
uri - the connection address
Throws:
ResourceException - if connections can't be accepted on the specified URI

accept

public void accept(URI uri,
                   java.util.Map properties)
            throws ResourceException
Listen for new connections on the specified URI, using the specified acceptor properties.
Specified by:
accept in interface ConnectionFactory
Parameters:
uri - the connection address
properties - acceptor properties. May be null
Throws:
ResourceException - if connections can't be accepted on the specified URI

setCallerListener

public void setCallerListener(CallerListener listener)
Sets the caller event listener.
Parameters:
listener - the listener

close

public void close()
           throws ResourceException
Close this connection manager.
Throws:
ResourceException - if a connection pool cannot be closed

getFactoryForConnect

protected ConnectionFactory getFactoryForConnect(URI uri)
Returns the first factory which can support connections to the specified URI.
Parameters:
uri - the URI
Returns:
the first factory which can support connections to uri, or null if none support it

getFactoryForAccept

protected ConnectionFactory getFactoryForAccept(URI uri)
Returns the first factory which can accept connections on the specified URI.
Parameters:
uri - the URI
Returns:
the first factory which can accept connections on uri, or null if none support it

addManagedConnectionFactory

protected void addManagedConnectionFactory(ManagedConnectionFactory factory)
                                    throws ResourceException
Register a managed connection factory.
Parameters:
factory - the factory to register
Throws:
ResourceException - if the registration fails

getManagedConnectionFactories

protected java.util.Collection getManagedConnectionFactories()
Returns all registered managed connection factories.
Returns:
all registered managed connection factories

createConnectionPool

protected ConnectionPool createConnectionPool(ManagedConnectionFactory factory,
                                              InvocationHandler handler,
                                              ConnectionFactory resolver)
                                       throws ResourceException
Creates a new connection pool.
Parameters:
factory - the managed connection factory
handler - the invocation handler, assigned to each new managed connection
resolver - the connection factory for resolving connections via their URI
Throws:
ResourceException - if the pool can't be created

getConnectionPool

protected ConnectionPool getConnectionPool(ManagedConnectionFactory factory)
                                    throws ResourceException
Returns the ConnectionPool which pools connections for the specified factory.
Parameters:
factory - the factory to locate the pool for
Returns:
the connection pool for factory
Throws:
ResourceException - if no connection pool exists


Copyright © 1999-2007 The OpenJMS Group. All Rights Reserved.