01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: ParticipantDatasources.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.rep.participants;
09:
10: import com.uwyn.rife.database.Datasources;
11: import com.uwyn.rife.database.exceptions.DatasourcesException;
12: import com.uwyn.rife.rep.BlockingParticipant;
13:
14: public class ParticipantDatasources extends BlockingParticipant {
15: private Datasources mDatasources = null;
16:
17: public ParticipantDatasources() {
18: setInitializationMessage("Creating the datasources object ...");
19: setCleanupMessage("Cleaning up the datasources object ...");
20: }
21:
22: protected void initialize() {
23: try {
24: mDatasources = new Datasources(getParameter(),
25: getResourceFinder());
26: } catch (DatasourcesException e) {
27: throw new RuntimeException(
28: "Fatal error during the initialization while creating the datasources object.",
29: e);
30: }
31: }
32:
33: protected Object _getObject() {
34: return mDatasources;
35: }
36:
37: protected Object _getObject(Object key) {
38: return mDatasources.getDatasource(String.valueOf(key));
39: }
40:
41: protected void cleanup() {
42: if (mDatasources != null) {
43: mDatasources.cleanup();
44: }
45: }
46: }
|