KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > medor > datasource > lib > ConnectionFactoryDataStore


1 /**
2  * MEDOR: Middleware Enabling Distributed Object Requests
3  *
4  * Copyright (C) 2001-2003 France Telecom R&D
5  * Contact: alexandre.lefebvre@rd.francetelecom.com
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  * Initial developers: M. Alia, A. Lefebvre
22  */

23 package org.objectweb.medor.datasource.lib;
24
25 import org.objectweb.medor.api.DataSourceException;
26 import org.objectweb.medor.datasource.api.DataStore;
27
28 /**
29  * This implementation of the DataStore interface could be used in all cases
30  * where a data store could be identified by a connection factory. The reference
31  * is not typed in order to support various connection factory (
32  * javax.sql.Datasource, javax.resource.cci.ConnectionFactory, ...)
33  *
34  * @author S.Chassande-Barrioz
35  */

36 public class ConnectionFactoryDataStore extends BasicDataStore {
37     protected Object JavaDoc connectionFactory;
38
39     /**
40      * It builds a ConnectionFactoryDataStore.
41      * @param dataStoreType is the type of the DataStore
42      * (ex: DataStore.JDBC_STORE)
43      * @param sourceName is the name of the datastore
44      * @param capabilities is the capabilities of the datastore
45      * @param cf is the connection factory (cannot be null)
46      * @throws DataSourceException if the specified connection factory is null.
47      */

48     public ConnectionFactoryDataStore(short dataStoreType,
49                           String JavaDoc sourceName,
50                           short[] capabilities,
51                           Object JavaDoc cf)
52             throws DataSourceException {
53         super(dataStoreType, sourceName, capabilities);
54         if (cf == null)
55             throw new DataSourceException("Invalid connection factory reference");
56         connectionFactory = cf;
57     }
58
59     public Object JavaDoc getConnectionFactory() {
60         return connectionFactory;
61     }
62
63     /**
64      * Two ConnectionFactoryDataStore with the same connection factory are equals.
65      */

66     public boolean isSameAs(DataStore ds) {
67         return (ds instanceof ConnectionFactoryDataStore)
68                 && ((ConnectionFactoryDataStore) ds).connectionFactory.equals(connectionFactory);
69     }
70 }
71
Popular Tags