01: /*
02: *
03: * Copyright 2007 by BBN Technologies Corporation
04: *
05: */
06:
07: package org.cougaar.core.plugin;
08:
09: import java.util.List;
10: import java.util.Map;
11:
12: import org.cougaar.core.service.LoggingService;
13: import org.cougaar.core.service.UIDService;
14: import org.cougaar.util.Arguments;
15: import org.cougaar.util.annotations.Argument;
16: import org.cougaar.util.annotations.Cougaar;
17:
18: public abstract class ParameterizedPlugin extends ComponentPlugin {
19: protected Arguments args;
20:
21: /**
22: * TODO: Pull up to BlackboardClientComponent.
23: */
24: @Cougaar.ObtainService
25: public LoggingService log;
26:
27: /**
28: * TODO: Pull up to BlackboardClientComponent.
29: */
30: @Cougaar.ObtainService
31: public UIDService uids;
32:
33: public void setArguments(Arguments args) {
34: this .args = args;
35: try {
36: new Argument(args).setAllFields(this );
37: } catch (Exception e) {
38: // TODO: Add Logging support when it's ready
39: throw new RuntimeException(
40: "Exception during field initialization", e);
41: }
42: }
43:
44: /** @see Arguments#getString(String) */
45: protected String getParameter(String key) {
46: return args.getString(key);
47: }
48:
49: /** @see Arguments#getString(String,String) */
50: protected String getParameter(String key, String defaultValue) {
51: return args.getString(key, defaultValue);
52: }
53:
54: /** @see Arguments#getLong(String,long) */
55: public long getParameter(String key, long defaultValue) {
56: return args.getLong(key, defaultValue);
57: }
58:
59: /** @see Arguments#getDouble(String,double) */
60: public double getParameter(String key, double defaultValue) {
61: return args.getDouble(key, defaultValue);
62: }
63:
64: /** @see Arguments#getStrings(String) */
65: public List<String> getParameterValues(String key) {
66: return args.getStrings(key);
67: }
68:
69: /** @see Arguments */
70: public Map<String, List<String>> getParameterMap() {
71: return args;
72: }
73:
74: }
|