001/* 002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Florent Guillaume 011 */ 012 013package org.nuxeo.ecm.core.storage.sql.ra; 014 015import javax.resource.ResourceException; 016import javax.resource.cci.ConnectionFactory; 017import javax.resource.spi.ConnectionManager; 018import javax.resource.spi.ConnectionRequestInfo; 019import javax.resource.spi.ManagedConnection; 020import javax.resource.spi.ManagedConnectionFactory; 021 022/** 023 * This implementation of {@link ConnectionManager} is used in non-managed scenarios when there is no application server 024 * to provide one. 025 * <p> 026 * It receives connection requests from the {@link ConnectionFactory} and passes them to the application server. 027 * 028 * @author Florent Guillaume 029 */ 030public class ConnectionManagerImpl implements ConnectionManager { 031 032 private static final long serialVersionUID = 1L; 033 034 /* 035 * This method is called by the RA's connection factory. 036 */ 037 @Override 038 public Object allocateConnection(ManagedConnectionFactory managedConnectionFactory, 039 ConnectionRequestInfo connectionRequestInfo) throws ResourceException { 040 // connectionRequestInfo unused 041 ManagedConnection managedConnection = managedConnectionFactory.createManagedConnection(null, null); 042 return managedConnection.getConnection(null, null); 043 } 044}