01:/*
02: * Created on March 3, 2004
03: *
04: * DefaultConnectionManager.java is used to test the J2EE Connector
05: * as implemented by JOnAS.
06: *
07:*/
08:package ersatz.resourceadapter;
09:
10:import java.io.Serializable;
11:import javax.resource.ResourceException;
12:import javax.resource.spi.ConnectionManager;
13:import javax.resource.cci.ConnectionFactory;
14:import javax.resource.spi.ConnectionRequestInfo;
15:import javax.resource.spi.ManagedConnectionFactory;
16:import javax.resource.spi.ResourceAdapterInternalException;
17:
18:/**
19: * @author Bob Kruse
20: *
21: * used to test the J2EE Connector as implemented by JOnAS.
22: *
23: */
24:public class DefaultConnectionManager
25: implements ConnectionManager, Serializable
26:{
27:
28: String cName = "DefaultConnectionManager";
29:
30: /** <p>This method gets called by the connection factory instance.
31: * </p>
32: *
33: * @param ManagedConnectionFactory
34: * used by application server to delegate
35: * connection matching/creation
36: * @param ConnectionRequestInfo
37: * connection request Information
38: *
39: * @return connection handle to the appropriate GCOS system
40: *
41: *
42: * @throws ResourceException Generic exception
43: * @throws ResourceAllocationException
44: * Failed to allocate system resources for
45: * connection request
46: * @throws ResourceAdapterInternalException
47: * Resource adapter related error condition
48: **/
49: public Object allocateConnection(ManagedConnectionFactory MCF,
50: ConnectionRequestInfo info)
51: throws ResourceException
52: {
53: Object obj;
54:
55: ManagedConnectionFactoryImpl mcf = (ManagedConnectionFactoryImpl) MCF;
56: try {
57: ManagedConnectionImpl mc =
58: (ManagedConnectionImpl) mcf.createManagedConnection(null, info);
59: obj = mc.getConnection(null, info);
60: Utility.log(cName+".allocateConnection mc.getConnection(null, info) obj="+obj);
61: return obj;
62: }
63: catch (ResourceAdapterInternalException raie)
64: {
65: throw raie;
66: }
67: catch (Exception ex)
68: {
69: ResourceException re = new ResourceException(ex.getMessage());
70: throw re;
71: }
72: }
73:
74:}
75:
|