KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//transaction/src/java/org/apache/commons/transaction/memory/jca/MapManagedConnectionFactory.java,v 1.1 2004/11/18 23:27:18 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 java.io.PrintWriter JavaDoc;
32 import java.util.Iterator JavaDoc;
33 import java.util.Set JavaDoc;
34
35 import javax.resource.ResourceException JavaDoc;
36 import javax.resource.spi.ConnectionManager JavaDoc;
37 import javax.resource.spi.ConnectionRequestInfo JavaDoc;
38 import javax.resource.spi.ManagedConnection JavaDoc;
39 import javax.resource.spi.ManagedConnectionFactory JavaDoc;
40 import javax.security.auth.Subject JavaDoc;
41
42
43 /**
44  *
45  * @version $Revision$
46  *
47  */

48 public class MapManagedConnectionFactory implements ManagedConnectionFactory JavaDoc {
49
50     private PrintWriter JavaDoc writer;
51
52     /**
53      * @see ManagedConnectionFactory#createConnectionFactory(ConnectionManager)
54      */

55     public Object JavaDoc createConnectionFactory(ConnectionManager JavaDoc cm)
56         throws ResourceException JavaDoc {
57
58         return new MapConnectionFactory(this, cm);
59     }
60
61     /**
62      * @see ManagedConnectionFactory#createConnectionFactory()
63      */

64     public Object JavaDoc createConnectionFactory() throws ResourceException JavaDoc {
65
66         return new MapConnectionFactory(this, null);
67     }
68
69     /**
70      * @see ManagedConnectionFactory#createManagedConnection(Subject, ConnectionRequestInfo)
71      */

72     public ManagedConnection JavaDoc createManagedConnection(
73         Subject JavaDoc subject,
74         ConnectionRequestInfo JavaDoc cxRequestInfo)
75         throws ResourceException JavaDoc {
76
77         return new MapManagedConnection(cxRequestInfo);
78     }
79
80     /**
81      * @see ManagedConnectionFactory#matchManagedConnections(Set, Subject, ConnectionRequestInfo)
82      */

83     public ManagedConnection JavaDoc matchManagedConnections(
84         Set JavaDoc connectionSet,
85         Subject JavaDoc subject,
86         ConnectionRequestInfo JavaDoc cxRequestInfo)
87         throws ResourceException JavaDoc {
88
89         ManagedConnection JavaDoc match = null;
90         Iterator JavaDoc iterator = connectionSet.iterator();
91         if (iterator.hasNext()) {
92             match = (ManagedConnection JavaDoc) iterator.next();
93         }
94
95         return match;
96     }
97
98     /**
99      * @see ManagedConnectionFactory#setLogWriter(PrintWriter)
100      */

101     public void setLogWriter(PrintWriter JavaDoc writer) throws ResourceException JavaDoc {
102
103         this.writer = writer;
104     }
105
106     /**
107      * @see ManagedConnectionFactory#getLogWriter()
108      */

109     public PrintWriter JavaDoc getLogWriter() throws ResourceException JavaDoc {
110
111         return writer;
112     }
113
114     public boolean equals(Object JavaDoc other) {
115
116         if (other instanceof MapManagedConnectionFactory) {
117             return true;
118         }
119         return false;
120     }
121
122     public int hashCode() {
123         
124         return 0;
125     }
126 }
127
Popular Tags