KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jca > adapter > TestConnectionFactory


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software 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 software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.jca.adapter;
23
24 import javax.naming.NamingException JavaDoc;
25 import javax.naming.Reference JavaDoc;
26 import javax.resource.ResourceException JavaDoc;
27 import javax.resource.cci.Connection JavaDoc;
28 import javax.resource.cci.ConnectionFactory JavaDoc;
29 import javax.resource.cci.ConnectionSpec JavaDoc;
30 import javax.resource.cci.RecordFactory JavaDoc;
31 import javax.resource.cci.ResourceAdapterMetaData JavaDoc;
32 import javax.resource.spi.ConnectionManager JavaDoc;
33 import javax.resource.Referenceable JavaDoc;
34
35 import org.jboss.resource.connectionmanager.BaseConnectionManager2;
36
37 /**
38  * TestConnectionFactory.java
39  *
40  *
41  * Created: Tue Jan 1 01:02:16 2002
42  *
43  * @author <a HREF="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
44  * @version
45  */

46
47 public class TestConnectionFactory implements ConnectionFactory JavaDoc, Referenceable JavaDoc
48 {
49
50    /** The serialVersionUID */
51    private static final long serialVersionUID = 1L;
52
53    private final ConnectionManager JavaDoc cm;
54
55    private final TestManagedConnectionFactory mcf;
56
57    private Reference JavaDoc ref;
58    
59    public TestConnectionFactory(final ConnectionManager JavaDoc cm, final TestManagedConnectionFactory mcf)
60    {
61       this.cm = cm;
62       this.mcf = mcf;
63    }
64
65    // implementation of javax.resource.Referenceable interface
66

67    /**
68     *
69     * @param param1 <description>
70     */

71    public void setReference(Reference JavaDoc ref)
72    {
73       this.ref = ref;
74    }
75
76    // implementation of javax.naming.Referenceable interface
77

78    /**
79     *
80     * @return <description>
81     * @exception javax.naming.NamingException <description>
82     */

83    public Reference JavaDoc getReference() throws NamingException JavaDoc
84    {
85       return ref;
86    }
87
88    // implementation of javax.resource.cci.ConnectionFactory interface
89

90    /**
91     *
92     * @return <description>
93     * @exception javax.resource.ResourceException <description>
94     */

95    public Connection JavaDoc getConnection() throws ResourceException JavaDoc
96    {
97       return (Connection JavaDoc) cm.allocateConnection(mcf, null);
98    }
99
100    /**
101     *
102     * @param param1 <description>
103     * @return <description>
104     * @exception javax.resource.ResourceException <description>
105     */

106    public Connection JavaDoc getConnection(ConnectionSpec JavaDoc ignore) throws ResourceException JavaDoc
107    {
108       return (Connection JavaDoc) cm.allocateConnection(mcf, null);
109    }
110
111    public Connection JavaDoc getConnection(String JavaDoc failure) throws ResourceException JavaDoc
112    {
113       return (Connection JavaDoc) cm.allocateConnection(mcf, new TestConnectionRequestInfo(failure));
114    }
115
116    /**
117     *
118     * @return <description>
119     * @exception javax.resource.ResourceException <description>
120     */

121    public RecordFactory JavaDoc getRecordFactory() throws ResourceException JavaDoc
122    {
123       // TODO: implement this javax.resource.cci.ConnectionFactory method
124
return null;
125    }
126
127    /**
128     *
129     * @return <description>
130     * @exception javax.resource.ResourceException <description>
131     */

132    public ResourceAdapterMetaData JavaDoc getMetaData() throws ResourceException JavaDoc
133    {
134       // TODO: implement this javax.resource.cci.ConnectionFactory method
135
return null;
136    }
137
138    public void setFailure(String JavaDoc failure)
139    {
140       mcf.setFailure(failure);
141    }
142
143 }
144
Popular Tags