01: /*
02: * <copyright>
03: *
04: * Copyright 1997-2004 BBNT Solutions, LLC
05: * under sponsorship of the Defense Advanced Research Projects
06: * Agency (DARPA).
07: *
08: * You can redistribute this software and/or modify it under the
09: * terms of the Cougaar Open Source License as published on the
10: * Cougaar Open Source Website (www.cougaar.org).
11: *
12: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
16: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23: *
24: * </copyright>
25: */
26:
27: package org.cougaar.core.qos.frame;
28:
29: import java.util.StringTokenizer;
30:
31: import org.cougaar.core.component.ServiceBroker;
32: import org.cougaar.core.plugin.ParameterizedPlugin;
33: import org.cougaar.core.service.BlackboardService;
34: import org.cougaar.core.service.LoggingService;
35:
36: /**
37: * This plugin will load a frameset from xml. It expects two parameters.
38: * The "frame-set" parameter specifies the name to be given to the frameset.
39: * The "frame-set-files" parameter should be a comma-separated list of files,
40: * where the first file is defines the prototypes and the rest of the files
41: * provide data.
42: */
43: public class FrameSetLoaderPlugin extends ParameterizedPlugin {
44: private LoggingService log;
45: private FrameSet frameset;
46:
47: public void load() {
48: super .load();
49: ServiceBroker sb = getServiceBroker();
50: log = (LoggingService) sb.getService(this ,
51: LoggingService.class, null);
52: }
53:
54: public void start() {
55: String files = getParameter("frame-set-files");
56: String name = getParameter("frame-set");
57: if (files != null) {
58: StringTokenizer tk = new StringTokenizer(files, ",");
59: String[] xml_filenames = new String[tk.countTokens()];
60: int i = 0;
61: while (tk.hasMoreTokens())
62: xml_filenames[i++] = tk.nextToken();
63:
64: ServiceBroker sb = getServiceBroker();
65: BlackboardService bbs = getBlackboardService();
66: FrameSetService fss = (FrameSetService) sb.getService(this ,
67: FrameSetService.class, null);
68: frameset = fss.loadFrameSet(name, xml_filenames, sb, bbs);
69: sb.releaseService(this , FrameSetService.class, fss);
70: } else {
71: if (log.isWarnEnabled())
72: log.warn("No FrameSet XML files were specified");
73: }
74: super .start();
75: }
76:
77: protected void execute() {
78: frameset.processQueue();
79: }
80:
81: protected void setupSubscriptions() {
82: if (frameset != null) {
83: // Set up subscriptions for handling slot dependencies
84: frameset.initializeAggregators();
85: }
86: }
87: }
|