Mercurial > dive4elements > gnv-client
comparison geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEConnection.java @ 553:5b536542ef56
Another attempt to fix gnv/issue34. Implemented an internal idle time checking.
geo-backend/trunk@619 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 25 Jan 2010 12:12:31 +0000 |
parents | 1f6e2b256247 |
children | 12f88239fb33 |
comparison
equal
deleted
inserted
replaced
552:7615ee5d1345 | 553:5b536542ef56 |
---|---|
41 private static Logger log = Logger.getLogger(ArcSDEPoolableObjectFactory.class); | 41 private static Logger log = Logger.getLogger(ArcSDEPoolableObjectFactory.class); |
42 | 42 |
43 private SeConnection seConnection = null; | 43 private SeConnection seConnection = null; |
44 | 44 |
45 private long serverRoundtripInterval; | 45 private long serverRoundtripInterval; |
46 | |
47 private long inactiveInterval; | |
48 | |
49 private long lastTouch; | |
46 | 50 |
47 | 51 |
48 | |
49 /** | 52 /** |
50 * Constructor | 53 * Constructor |
51 */ | 54 */ |
52 public ArcSDEConnection(String server,String port,String database,String username,String credentials, long serverRoundtripInterval) throws ConnectionException { | 55 public ArcSDEConnection( |
56 String server, | |
57 String port, | |
58 String database, | |
59 String username, | |
60 String credentials, | |
61 long serverRoundtripInterval, | |
62 long inactiveInterval | |
63 ) | |
64 throws ConnectionException | |
65 { | |
66 this.serverRoundtripInterval = serverRoundtripInterval; | |
67 this.inactiveInterval = inactiveInterval; | |
68 lastTouch = System.currentTimeMillis(); | |
69 | |
53 try { | 70 try { |
54 seConnection = new SeConnection(server,port,database,username,credentials); | 71 seConnection = new SeConnection( server, port, database, username, credentials); |
55 this.serverRoundtripInterval = serverRoundtripInterval; | 72 } |
56 } catch (SeException e) { | 73 catch (SeException e) { |
57 log.error(e,e); | 74 log.error(e,e); |
58 throw new ConnectionException(e); | 75 throw new ConnectionException(e); |
59 } | 76 } |
60 } | 77 } |
78 | |
79 public boolean isActive() { | |
80 long current = System.currentTimeMillis(); | |
81 long last; | |
82 synchronized (this) { | |
83 last = lastTouch; | |
84 } | |
85 return Math.abs(current - last) < inactiveInterval; | |
86 } | |
87 | |
88 public void touch() { | |
89 long time = System.currentTimeMillis(); | |
90 synchronized (this) { | |
91 lastTouch = time; | |
92 } | |
93 } | |
61 | 94 |
62 /** | 95 /** |
63 * @see java.sql.Connection#clearWarnings() | 96 * @see java.sql.Connection#clearWarnings() |
64 */ | 97 */ |
65 public void clearWarnings() throws SQLException { | 98 public void clearWarnings() throws SQLException { |