Revision 37927 trunk/libraries/libGDBMS/src/main/java/com/hardcode/gdbms/engine/data/AutomaticDataSource.java
AutomaticDataSource.java | ||
---|---|---|
33 | 33 |
private DataSource ds; |
34 | 34 |
private boolean opened = false; |
35 | 35 |
private long timeout; |
36 |
private Timer timer = new Timer(); |
|
36 |
// private Timer timer = new Timer();
|
|
37 | 37 |
private long lastReset = 0; |
38 | 38 |
|
39 | 39 |
/** |
... | ... | |
78 | 78 |
* the resetTimer is a long time operation. Will |
79 | 79 |
* only call it after a while |
80 | 80 |
*/ |
81 |
if ((System.currentTimeMillis() - lastReset) > (DataSourceFactory.DEFAULT_DELAY / 2)) { |
|
82 |
//reset the timer |
|
83 |
// logger.info("timer reset"); |
|
84 |
timer.resetTimer(); |
|
85 |
lastReset = System.currentTimeMillis(); |
|
86 |
} |
|
81 |
// if ((System.currentTimeMillis() - lastReset) > (DataSourceFactory.DEFAULT_DELAY / 2)) {
|
|
82 |
// //reset the timer
|
|
83 |
//// logger.info("timer reset");
|
|
84 |
//// timer.resetTimer();
|
|
85 |
// lastReset = System.currentTimeMillis();
|
|
86 |
// }
|
|
87 | 87 |
} else { |
88 | 88 |
opened = true; |
89 | 89 |
|
... | ... | |
96 | 96 |
// logger.info("timer start"); |
97 | 97 |
|
98 | 98 |
// Se inicia el timer |
99 |
timer.schedule(new Task() { |
|
100 |
/** |
|
101 |
* @see com.hardcode.gdbms.engine.internalExceptions.Task#execute() |
|
102 |
*/ |
|
103 |
public void execute() { |
|
104 |
try { |
|
105 |
synchronized (AutomaticDataSource.this) { |
|
106 |
if (opened){ |
|
107 |
close(); |
|
108 |
} |
|
109 |
} |
|
110 |
} catch (CloseDriverException e) { |
|
111 |
InternalExceptionCatcher.callExceptionRaised(new InternalExceptionEvent( |
|
112 |
AutomaticDataSource.this, |
|
113 |
new InternalException( |
|
114 |
"Could not automatically close the data source", |
|
115 |
e))); |
|
116 |
} |
|
117 |
} |
|
118 |
|
|
119 |
}, timeout); |
|
99 |
// timer.schedule(new Task() {
|
|
100 |
// /**
|
|
101 |
// * @see com.hardcode.gdbms.engine.internalExceptions.Task#execute()
|
|
102 |
// */
|
|
103 |
// public void execute() {
|
|
104 |
// try {
|
|
105 |
// synchronized (AutomaticDataSource.this) {
|
|
106 |
// if (opened){
|
|
107 |
// close();
|
|
108 |
// }
|
|
109 |
// }
|
|
110 |
// } catch (CloseDriverException e) {
|
|
111 |
// InternalExceptionCatcher.callExceptionRaised(new InternalExceptionEvent(
|
|
112 |
// AutomaticDataSource.this,
|
|
113 |
// new InternalException(
|
|
114 |
// "Could not automatically close the data source",
|
|
115 |
// e)));
|
|
116 |
// }
|
|
117 |
// }
|
|
118 |
// |
|
119 |
// }, timeout);
|
|
120 | 120 |
} |
121 | 121 |
} |
122 | 122 |
|
... | ... | |
132 | 132 |
|
133 | 133 |
// logger.info("datasource closed"); |
134 | 134 |
|
135 |
AutomaticDataSource.this.timer.cancelTimer(); |
|
136 |
AutomaticDataSource.this.timer = new Timer(); |
|
135 |
// AutomaticDataSource.this.timer.cancelTimer();
|
|
136 |
// AutomaticDataSource.this.timer = new Timer();
|
|
137 | 137 |
} |
138 | 138 |
} |
139 | 139 |
|
Also available in: Unified diff