001    package biz.hammurapi.jms.adapter.jca;
002    
003    import javax.resource.ResourceException;
004    import javax.resource.spi.ConnectionManager;
005    
006    /**
007     * @author Pavel Vlasov
008     */
009    public class ConnectionFactoryImpl implements ConnectionFactory {
010            
011            private ConnectionManager connectionManager;
012            private ManagedConnectionFactoryImpl managedConnectionFactory;
013            
014            /**
015             * Constructor
016             */
017            public ConnectionFactoryImpl(ManagedConnectionFactoryImpl managedConnectionFactory, ConnectionManager connectionManager) {
018                    super();
019                    this.managedConnectionFactory = managedConnectionFactory;
020                    this.connectionManager = connectionManager;
021            }
022    
023            public Connection getConnection(boolean stateful) throws ResourceException {
024                    return (Connection) connectionManager.allocateConnection(managedConnectionFactory, managedConnectionFactory.new JmsConnectionRequestInfo(stateful));
025            }
026    
027            public Connection getConnection(Object state) throws ResourceException {
028                    return (Connection) connectionManager.allocateConnection(managedConnectionFactory, managedConnectionFactory.new JmsConnectionRequestInfo(state));
029            }
030    }