KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > jca > ra > JEConnectionFactoryImpl


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: JEConnectionFactoryImpl.java,v 1.8 2006/10/30 21:14:18 bostic Exp $
7  */

8
9 package com.sleepycat.je.jca.ra;
10
11 import java.io.File JavaDoc;
12
13 import javax.naming.NamingException JavaDoc;
14 import javax.naming.Reference JavaDoc;
15 import javax.resource.ResourceException JavaDoc;
16 import javax.resource.spi.ConnectionManager JavaDoc;
17 import javax.resource.spi.ManagedConnectionFactory JavaDoc;
18
19 import com.sleepycat.je.EnvironmentConfig;
20 import com.sleepycat.je.TransactionConfig;
21
22 public class JEConnectionFactoryImpl implements JEConnectionFactory {
23
24     /*
25      * These are not transient because SJSAS seems to need to serialize
26      * them when leaving them in JNDI.
27      */

28     private /* transient */ ConnectionManager JavaDoc manager;
29     private /* transient */ ManagedConnectionFactory JavaDoc factory;
30     private Reference JavaDoc reference;
31
32     JEConnectionFactoryImpl(ConnectionManager JavaDoc manager,
33                 ManagedConnectionFactory JavaDoc factory) {
34     this.manager = manager;
35     this.factory = factory;
36     }
37
38     public JEConnection getConnection(String JavaDoc jeRootDir,
39                       EnvironmentConfig envConfig)
40     throws JEException {
41
42     return getConnection(jeRootDir, envConfig, null);
43     }
44
45
46     public JEConnection getConnection(String JavaDoc jeRootDir,
47                       EnvironmentConfig envConfig,
48                       TransactionConfig transConfig)
49     throws JEException {
50
51     JEConnection dc = null;
52     JERequestInfo jeInfo =
53         new JERequestInfo(new File JavaDoc(jeRootDir), envConfig, transConfig);
54     try {
55         dc = (JEConnection) manager.allocateConnection(factory, jeInfo);
56     } catch (ResourceException JavaDoc e) {
57         throw new JEException("Unable to get Connection: " + e);
58     }
59
60     return dc;
61     }
62
63     public void setReference(Reference JavaDoc reference) {
64     this.reference = reference;
65     }
66
67     public Reference JavaDoc getReference()
68     throws NamingException JavaDoc {
69
70     return reference;
71     }
72 }
73
Popular Tags