KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > transaction > memory > jca > MapConnectionFactory


1 /*
2  * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//transaction/src/java/org/apache/commons/transaction/memory/jca/MapConnectionFactory.java,v 1.1 2004/11/18 23:27:17 ozeigermann Exp $
3 <<<<<<< .mine
4  * $Revision: 1.1 $
5  * $Date: 2005-02-26 14:16:14 +0100 (Sa, 26 Feb 2005) $
6 =======
7  * $Revision$
8  * $Date: 2005-02-26 14:16:14 +0100 (Sa, 26 Feb 2005) $
9 >>>>>>> .r168169
10  *
11  * ====================================================================
12  *
13  * Copyright 1999-2002 The Apache Software Foundation
14  *
15  * Licensed under the Apache License, Version 2.0 (the "License");
16  * you may not use this file except in compliance with the License.
17  * You may obtain a copy of the License at
18  *
19  * http://www.apache.org/licenses/LICENSE-2.0
20  *
21  * Unless required by applicable law or agreed to in writing, software
22  * distributed under the License is distributed on an "AS IS" BASIS,
23  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24  * See the License for the specific language governing permissions and
25  * limitations under the License.
26  *
27  */

28
29 package org.apache.commons.transaction.memory.jca;
30
31 import javax.naming.NamingException JavaDoc;
32 import javax.naming.Reference JavaDoc;
33 import javax.resource.NotSupportedException JavaDoc;
34 import javax.resource.ResourceException JavaDoc;
35 import javax.resource.cci.Connection JavaDoc;
36 import javax.resource.cci.ConnectionFactory JavaDoc;
37 import javax.resource.cci.ConnectionSpec JavaDoc;
38 import javax.resource.cci.RecordFactory JavaDoc;
39 import javax.resource.cci.ResourceAdapterMetaData JavaDoc;
40 import javax.resource.spi.ConnectionManager JavaDoc;
41 import javax.resource.spi.ManagedConnectionFactory JavaDoc;
42
43 /**
44  *
45  * @version $Revision$
46  *
47  */

48 public class MapConnectionFactory implements ConnectionFactory JavaDoc {
49
50     Reference JavaDoc reference;
51     ConnectionManager JavaDoc cm;
52     ManagedConnectionFactory JavaDoc mcf;
53
54     String JavaDoc name;
55
56     public MapConnectionFactory(ManagedConnectionFactory JavaDoc mcf, ConnectionManager JavaDoc cm) {
57         System.out.println("MCF Init with mcf " + mcf + " cm " + cm);
58         this.mcf = mcf;
59         this.cm = cm;
60     }
61
62     public Connection JavaDoc getConnection() throws ResourceException JavaDoc {
63         throw new NotSupportedException JavaDoc("Need name of accessed map. Call getConnection(ConnectionSpec spec) instead");
64     }
65
66     public Connection JavaDoc getConnection(ConnectionSpec JavaDoc spec) throws ResourceException JavaDoc {
67         if (!(spec instanceof MapConnectionSpec)) {
68             throw new NotSupportedException JavaDoc("ConnectionSpec must be instance of MapConnectionSpec");
69         }
70         System.out.println("Getting connection with spec "+spec);
71         return (Connection JavaDoc) cm.allocateConnection(mcf, (MapConnectionSpec)spec);
72     }
73
74     public RecordFactory JavaDoc getRecordFactory() throws ResourceException JavaDoc {
75         return null;
76     }
77
78     public ResourceAdapterMetaData JavaDoc getMetaData() throws ResourceException JavaDoc {
79         return null;
80     }
81
82     public void setReference(Reference JavaDoc reference) {
83         this.reference = reference;
84     }
85
86     public Reference JavaDoc getReference() throws NamingException JavaDoc {
87         return reference;
88     }
89
90     public String JavaDoc getName() {
91         System.out.println("Getting name " + name);
92         return name;
93     }
94
95     public void setName(String JavaDoc string) {
96         System.out.println("Setting name " + string);
97         name = string;
98     }
99
100 }
101
Popular Tags