Mercurial > dive4elements > gnv-client
comparison geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/connectionpool/ArcSDEPoolableObjectFactory.java @ 130:e4eacd613356
Implementierung Datenzugriff auf die ArcSDE über java.sql. Methodiken
ChangeLog wird nachgereicht da SubversionClientincompatiblitäten vorhanden sind.
geo-backend/trunk@7 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Wed, 02 Sep 2009 15:15:52 +0000 |
parents | |
children | e5379e129799 |
comparison
equal
deleted
inserted
replaced
129:110e3ac1b7d2 | 130:e4eacd613356 |
---|---|
1 /** | |
2 * | |
3 */ | |
4 package de.intevation.gnv.geobackend.sde.connectionpool; | |
5 | |
6 import java.sql.Connection; | |
7 import java.util.Properties; | |
8 | |
9 import org.apache.commons.pool.PoolableObjectFactory; | |
10 import org.apache.log4j.Logger; | |
11 | |
12 import com.esri.sde.sdk.client.SeConnection; | |
13 | |
14 import de.intevation.gnv.geobackend.base.connectionpool.exception.ConnectionException; | |
15 import de.intevation.gnv.geobackend.sde.datasources.ArcSDEConnection; | |
16 | |
17 /** | |
18 * @author Tim Englich <tim.englich@intevation.de> | |
19 * | |
20 */ | |
21 public class ArcSDEPoolableObjectFactory implements PoolableObjectFactory { | |
22 | |
23 /** | |
24 * the logger, used to log exceptions and additonaly information | |
25 */ | |
26 private static Logger log = Logger.getLogger(ArcSDEPoolableObjectFactory.class); | |
27 | |
28 /** | |
29 * The URL to the ArcSDE Server | |
30 */ | |
31 private String server = null; | |
32 /** | |
33 * The Port the ArcSDE Server is connected to. | |
34 */ | |
35 private String port = null; | |
36 /** | |
37 * The Name of the Database | |
38 */ | |
39 private String database = null; | |
40 /** | |
41 * The Username for the Authentication | |
42 */ | |
43 private String username = null; | |
44 /** | |
45 * The Credentials which belongs to the User | |
46 */ | |
47 private String credentials = null; | |
48 | |
49 | |
50 /** | |
51 * Constructor of this Class | |
52 * @param properties the Properties which includes the ConnectionParams to the Database | |
53 */ | |
54 public ArcSDEPoolableObjectFactory(Properties properties) { | |
55 | |
56 this.server = properties.getProperty("server"); | |
57 this.port = properties.getProperty("port"); | |
58 this.database = properties.getProperty("database"); | |
59 this.username = properties.getProperty("username"); | |
60 this.credentials = properties.getProperty("credentials"); | |
61 | |
62 log.info("ArcSDEPoolableObjectFactory initialized"); | |
63 log.info("Server: "+this.server); | |
64 log.info("Port: "+this.port); | |
65 log.info("Database: "+this.database); | |
66 log.info("User: "+this.username); | |
67 } | |
68 | |
69 /** | |
70 * @see org.apache.commons.pool.PoolableObjectFactory#activateObject(java.lang.Object) | |
71 */ | |
72 public void activateObject(Object arg0) throws Exception { | |
73 log.debug("ArcSDEPoolableObjectFactory.activateObject"); | |
74 // TODO Was muss hier passieren? | |
75 } | |
76 | |
77 /** | |
78 * @see org.apache.commons.pool.PoolableObjectFactory#destroyObject(java.lang.Object) | |
79 */ | |
80 public void destroyObject(Object arg0) throws Exception { | |
81 log.debug("ArcSDEPoolableObjectFactory.destroyObjectb"); | |
82 if (arg0 instanceof SeConnection){ | |
83 ((SeConnection)arg0).close(); | |
84 }else{ | |
85 log.warn("Object cannot be handled"); | |
86 } | |
87 } | |
88 | |
89 /** | |
90 * @see org.apache.commons.pool.PoolableObjectFactory#makeObject() | |
91 */ | |
92 public Object makeObject() throws Exception { | |
93 log.debug("ArcSDEPoolableObjectFactory.makeObject"); | |
94 Connection con; | |
95 try { | |
96 con = new ArcSDEConnection(this.server, this.port, this.database, this.username, this.credentials); | |
97 } | |
98 catch (ConnectionException e) { | |
99 throw new ConnectionException("Establishing a connection to database failed: " + e.toString(), e); | |
100 } | |
101 return con; | |
102 } | |
103 | |
104 /** | |
105 * @see org.apache.commons.pool.PoolableObjectFactory#passivateObject(java.lang.Object) | |
106 */ | |
107 public void passivateObject(Object arg0) throws Exception { | |
108 log.debug("ArcSDEPoolableObjectFactory.passivateObject"); | |
109 // TODO Was muss hier passieren? | |
110 } | |
111 | |
112 /** | |
113 * @see org.apache.commons.pool.PoolableObjectFactory#validateObject(java.lang.Object) | |
114 */ | |
115 public boolean validateObject(Object arg0) { | |
116 // TODO Was muss hier passieren? | |
117 log.debug("ArcSDEPoolableObjectFactory.validateObject"); | |
118 return true; | |
119 } | |
120 } |