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: ParticipantConfig.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.rep.participants;
09:
10: import com.uwyn.rife.config.Config;
11: import com.uwyn.rife.config.exceptions.ConfigErrorException;
12: import com.uwyn.rife.rep.BlockingParticipant;
13:
14: public class ParticipantConfig extends BlockingParticipant {
15: private Config mConfig = null;
16:
17: public ParticipantConfig() {
18: setInitializationMessage("Creating the config object ...");
19: setCleanupMessage("Cleaning up the config object ...");
20: }
21:
22: protected void initialize() {
23: try {
24: mConfig = new Config(this .getParameter(),
25: getResourceFinder());
26: } catch (ConfigErrorException e) {
27: throw new RuntimeException(
28: "Fatal error during the initialization while creating the config object.",
29: e);
30: }
31: }
32:
33: protected Object _getObject() {
34: return mConfig;
35: }
36:
37: protected Object _getObject(Object key) {
38: String key_string = String.valueOf(key);
39: Object result = mConfig.getString(key_string);
40: if (result != null) {
41: return result;
42: }
43:
44: return mConfig.getStringItems(key_string);
45: }
46: }
|