Mercurial > dive4elements > gnv-client
comparison geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/connectionpool/ArcSDEPoolableObjectFactory.java @ 274:ff1b7967e6b9
General CodecCleanup:
Remove deprecated TODOS.
Replaced Tabs against whitespaces
Organize some Imports
geo-backend/trunk@280 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Mon, 02 Nov 2009 10:53:06 +0000 |
parents | e5379e129799 |
children | 1f6e2b256247 |
comparison
equal
deleted
inserted
replaced
273:69ddef25e822 | 274:ff1b7967e6b9 |
---|---|
17 * @author Tim Englich <tim.englich@intevation.de> | 17 * @author Tim Englich <tim.englich@intevation.de> |
18 * | 18 * |
19 */ | 19 */ |
20 public class ArcSDEPoolableObjectFactory implements PoolableObjectFactory { | 20 public class ArcSDEPoolableObjectFactory implements PoolableObjectFactory { |
21 | 21 |
22 /** | 22 /** |
23 * the logger, used to log exceptions and additonaly information | 23 * the logger, used to log exceptions and additonaly information |
24 */ | 24 */ |
25 private static Logger log = Logger.getLogger(ArcSDEPoolableObjectFactory.class); | 25 private static Logger log = Logger.getLogger(ArcSDEPoolableObjectFactory.class); |
26 | 26 /** |
27 /** | 27 * The URL to the ArcSDE Server |
28 * The URL to the ArcSDE Server | 28 */ |
29 */ | 29 private String server = null; |
30 private String server = null; | 30 /** |
31 /** | 31 * The Port the ArcSDE Server is connected to. |
32 * The Port the ArcSDE Server is connected to. | 32 */ |
33 */ | 33 private String port = null; |
34 private String port = null; | 34 /** |
35 /** | 35 * The Name of the Database |
36 * The Name of the Database | 36 */ |
37 */ | 37 private String database = null; |
38 private String database = null; | 38 /** |
39 /** | 39 * The Username for the Authentication |
40 * The Username for the Authentication | 40 */ |
41 */ | 41 private String username = null; |
42 private String username = null; | 42 /** |
43 /** | 43 * The Credentials which belongs to the User |
44 * The Credentials which belongs to the User | 44 */ |
45 */ | 45 private String credentials = null; |
46 private String credentials = null; | |
47 | 46 |
48 | 47 /** |
49 /** | 48 * Constructor of this Class |
50 * Constructor of this Class | 49 * @param properties the Properties which includes the ConnectionParams to the Database |
51 * @param properties the Properties which includes the ConnectionParams to the Database | 50 */ |
52 */ | 51 public ArcSDEPoolableObjectFactory(Properties properties) { |
53 public ArcSDEPoolableObjectFactory(Properties properties) { | 52 log.debug("ArcSDEPoolableObjectFactory.Constructor"); |
54 | 53 this.server = properties.getProperty("server"); |
55 this.server = properties.getProperty("server"); | 54 this.port = properties.getProperty("port"); |
56 this.port = properties.getProperty("port"); | 55 this.database = properties.getProperty("database"); |
57 this.database = properties.getProperty("database"); | 56 this.username = properties.getProperty("username"); |
58 this.username = properties.getProperty("username"); | 57 this.credentials = properties.getProperty("credentials"); |
59 this.credentials = properties.getProperty("credentials"); | 58 |
60 | 59 log.info("ArcSDEPoolableObjectFactory initialized"); |
61 log.info("ArcSDEPoolableObjectFactory initialized"); | 60 log.info("Server: "+this.server); |
62 log.info("Server: "+this.server); | 61 log.info("Port: "+this.port); |
63 log.info("Port: "+this.port); | 62 log.info("Database: "+this.database); |
64 log.info("Database: "+this.database); | 63 log.info("User: "+this.username); |
65 log.info("User: "+this.username); | 64 } |
66 } | |
67 | 65 |
68 /** | 66 /** |
69 * @see org.apache.commons.pool.PoolableObjectFactory#activateObject(java.lang.Object) | 67 * @see org.apache.commons.pool.PoolableObjectFactory#activateObject(java.lang.Object) |
70 */ | 68 */ |
71 public void activateObject(Object arg0) throws Exception { | 69 public void activateObject(Object arg0) throws Exception { |
72 log.debug("ArcSDEPoolableObjectFactory.activateObject"); | 70 log.debug("ArcSDEPoolableObjectFactory.activateObject"); |
73 // TODO Was muss hier passieren? | 71 } |
74 } | |
75 | 72 |
76 /** | 73 /** |
77 * @see org.apache.commons.pool.PoolableObjectFactory#destroyObject(java.lang.Object) | 74 * @see org.apache.commons.pool.PoolableObjectFactory#destroyObject(java.lang.Object) |
78 */ | 75 */ |
79 public void destroyObject(Object arg0) throws Exception { | 76 public void destroyObject(Object arg0) throws Exception { |
80 log.debug("ArcSDEPoolableObjectFactory.destroyObjectb"); | 77 log.debug("ArcSDEPoolableObjectFactory.destroyObjectb"); |
81 if (arg0 instanceof ArcSDEConnection) { | 78 if (arg0 instanceof ArcSDEConnection) { |
82 ((ArcSDEConnection)arg0).close(); | 79 ((ArcSDEConnection)arg0).close(); |
83 }else{ | 80 }else{ |
84 log.warn("Object cannot be handled"); | 81 log.warn("Object cannot be handled"); |
85 } | 82 } |
86 } | 83 } |
87 | 84 |
88 /** | 85 /** |
89 * @see org.apache.commons.pool.PoolableObjectFactory#makeObject() | 86 * @see org.apache.commons.pool.PoolableObjectFactory#makeObject() |
90 */ | 87 */ |
91 public Object makeObject() throws Exception { | 88 public Object makeObject() throws Exception { |
92 log.debug("ArcSDEPoolableObjectFactory.makeObject"); | 89 log.debug("ArcSDEPoolableObjectFactory.makeObject"); |
93 Connection con; | 90 Connection con; |
94 try { | 91 try { |
95 con = new ArcSDEConnection(this.server, this.port, this.database, this.username, this.credentials); | 92 con = new ArcSDEConnection(this.server, this.port, this.database, this.username, this.credentials); |
96 } | 93 } |
97 catch (ConnectionException e) { | 94 catch (ConnectionException e) { |
98 throw new ConnectionException("Establishing a connection to database failed: " + e.toString(), e); | 95 throw new ConnectionException("Establishing a connection to database failed: " + e.toString(), e); |
99 } | 96 } |
100 return con; | 97 return con; |
101 } | 98 } |
102 | 99 |
103 /** | 100 /** |
104 * @see org.apache.commons.pool.PoolableObjectFactory#passivateObject(java.lang.Object) | 101 * @see org.apache.commons.pool.PoolableObjectFactory#passivateObject(java.lang.Object) |
105 */ | 102 */ |
106 public void passivateObject(Object arg0) throws Exception { | 103 public void passivateObject(Object arg0) throws Exception { |
107 log.debug("ArcSDEPoolableObjectFactory.passivateObject"); | 104 log.debug("ArcSDEPoolableObjectFactory.passivateObject"); |
108 // TODO Was muss hier passieren? | 105 } |
109 } | |
110 | 106 |
111 /** | 107 /** |
112 * @see org.apache.commons.pool.PoolableObjectFactory#validateObject(java.lang.Object) | 108 * @see org.apache.commons.pool.PoolableObjectFactory#validateObject(java.lang.Object) |
113 */ | 109 */ |
114 public boolean validateObject(Object arg0) { | 110 public boolean validateObject(Object arg0) { |
115 // TODO Was muss hier passieren? | 111 log.debug("ArcSDEPoolableObjectFactory.validateObject"); |
116 log.debug("ArcSDEPoolableObjectFactory.validateObject"); | |
117 boolean returnValue = false; | 112 boolean returnValue = false; |
118 try { | 113 try { |
119 returnValue = arg0 instanceof ArcSDEConnection | 114 returnValue = arg0 instanceof ArcSDEConnection |
120 ? !((ArcSDEConnection)arg0).isClosed() | 115 ? !((ArcSDEConnection)arg0).isClosed() |
121 : false; | 116 : false; |
122 } | 117 } |
123 catch (SQLException sqle) {} | 118 catch (SQLException sqle) {} |
124 return returnValue; | 119 return returnValue; |
125 } | 120 } |
126 } | 121 } |