001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.jca.adapter;
023:
024: import javax.naming.NamingException;
025: import javax.naming.Reference;
026: import javax.resource.ResourceException;
027: import javax.resource.cci.Connection;
028: import javax.resource.cci.ConnectionFactory;
029: import javax.resource.cci.ConnectionSpec;
030: import javax.resource.cci.RecordFactory;
031: import javax.resource.cci.ResourceAdapterMetaData;
032: import javax.resource.spi.ConnectionManager;
033: import javax.resource.Referenceable;
034:
035: // Generated package name
036: /**
037: * TestConnectionFactory.java
038: *
039: *
040: * Created: Tue Jan 1 01:02:16 2002
041: *
042: * @author <a href="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
043: * @version
044: */
045:
046: public class TestConnectionFactory implements ConnectionFactory,
047: Referenceable {
048:
049: /** The serialVersionUID */
050: private static final long serialVersionUID = 1L;
051: private final ConnectionManager cm;
052: private final TestManagedConnectionFactory mcf;
053:
054: private Reference ref;
055:
056: public TestConnectionFactory(final ConnectionManager cm,
057: final TestManagedConnectionFactory mcf) {
058: this .cm = cm;
059: this .mcf = mcf;
060: }
061:
062: // implementation of javax.resource.Referenceable interface
063:
064: /**
065: *
066: * @param param1 <description>
067: */
068: public void setReference(Reference ref) {
069: this .ref = ref;
070: }
071:
072: // implementation of javax.naming.Referenceable interface
073:
074: /**
075: *
076: * @return <description>
077: * @exception javax.naming.NamingException <description>
078: */
079: public Reference getReference() throws NamingException {
080: return ref;
081: }
082:
083: // implementation of javax.resource.cci.ConnectionFactory interface
084:
085: /**
086: *
087: * @return <description>
088: * @exception javax.resource.ResourceException <description>
089: */
090: public Connection getConnection() throws ResourceException {
091: return (Connection) cm.allocateConnection(mcf, null);
092: }
093:
094: /**
095: *
096: * @param param1 <description>
097: * @return <description>
098: * @exception javax.resource.ResourceException <description>
099: */
100: public Connection getConnection(ConnectionSpec ignore)
101: throws ResourceException {
102: return (Connection) cm.allocateConnection(mcf, null);
103: }
104:
105: public Connection getConnection(String failure)
106: throws ResourceException {
107: return (Connection) cm.allocateConnection(mcf,
108: new TestConnectionRequestInfo(failure));
109: }
110:
111: /**
112: *
113: * @return <description>
114: * @exception javax.resource.ResourceException <description>
115: */
116: public RecordFactory getRecordFactory() throws ResourceException {
117: // TODO: implement this javax.resource.cci.ConnectionFactory method
118: return null;
119: }
120:
121: /**
122: *
123: * @return <description>
124: * @exception javax.resource.ResourceException <description>
125: */
126: public ResourceAdapterMetaData getMetaData()
127: throws ResourceException {
128: // TODO: implement this javax.resource.cci.ConnectionFactory method
129: return null;
130: }
131:
132: public void setFailure(String failure) {
133: mcf.setFailure(failure);
134: }
135:
136: }
|