001: /*
002: * Copyright (c) 2001 by Matt Welsh and The Regents of the University of
003: * California. All rights reserved.
004: *
005: * Permission to use, copy, modify, and distribute this software and its
006: * documentation for any purpose, without fee, and without written agreement is
007: * hereby granted, provided that the above copyright notice and the following
008: * two paragraphs appear in all copies of this software.
009: *
010: * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
011: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
012: * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
013: * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
014: *
015: * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
016: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
017: * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
018: * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
019: * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
020: *
021: * Author: Matt Welsh <mdw@cs.berkeley.edu>
022: *
023: */
024:
025: package seda.sandStorm.internal;
026:
027: import seda.sandStorm.api.*;
028: import seda.sandStorm.api.internal.*;
029: import seda.sandStorm.core.*;
030: import seda.sandStorm.main.*;
031: import java.util.*;
032:
033: /**
034: * A Stage is a basic implementation of StageIF for application-level
035: * stages.
036: *
037: * @author Matt Welsh
038: */
039: public class Stage implements StageIF {
040:
041: private String name;
042: private StageWrapperIF wrapper;
043: private SinkIF mainsink;
044:
045: // If true, instantate a SinkProxy for the stage's event queue
046: // when batchControllor or rtController are enabled. This should
047: // be obsolete; older implementations of these controllers relied
048: // on the proxy, but it's no longer needed.
049: private static final boolean ENABLE_SINK_PROXY = false;
050:
051: /**
052: * Create a Stage with the given name, wrapper, and sink.
053: */
054: public Stage(String name, StageWrapperIF wrapper, SinkIF mainsink,
055: ConfigDataIF config) {
056: this .name = name;
057: this .wrapper = wrapper;
058:
059: SandstormConfig cf = config.getManager().getConfig();
060: this .mainsink = mainsink;
061:
062: if (ENABLE_SINK_PROXY
063: && (cf.getBoolean("global.batchController.enable") || cf
064: .getBoolean("global.rtController.enable"))) {
065: this .mainsink = new SinkProxy((SinkIF) mainsink, config
066: .getManager(), wrapper);
067: }
068: }
069:
070: /**
071: * Create a Stage with the given name and wrapper, with no sink.
072: * This is used only for specialized stages.
073: */
074: public Stage(String name, StageWrapperIF wrapper) {
075: this .name = name;
076: this .wrapper = wrapper;
077: }
078:
079: /**
080: * Return the name of this stage.
081: */
082: public String getName() {
083: return name;
084: }
085:
086: /**
087: * Return the event sink.
088: */
089: public SinkIF getSink() {
090: return (SinkIF) mainsink;
091: }
092:
093: /**
094: * Return the stage wrapper for this stage.
095: */
096: public StageWrapperIF getWrapper() {
097: return wrapper;
098: }
099:
100: /**
101: * Destroy this stage.
102: */
103: public void destroy() {
104: throw new IllegalArgumentException("XXX Not yet implemented!");
105: }
106:
107: }
|