1 /* 2 * Copyright (c) 2001 by Matt Welsh and The Regents of the University of 3 * California. All rights reserved. 4 * 5 * Permission to use, copy, modify, and distribute this software and its 6 * documentation for any purpose, without fee, and without written agreement is 7 * hereby granted, provided that the above copyright notice and the following 8 * two paragraphs appear in all copies of this software. 9 * 10 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR 11 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT 12 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF 13 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 * 15 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 16 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 17 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 18 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO 19 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 20 * 21 * Author: Matt Welsh <mdw@cs.berkeley.edu> 22 * 23 */ 24 25 package seda.sandStorm.internal; 26 27 import seda.sandStorm.api.*; 28 import seda.sandStorm.api.internal.*; 29 import seda.sandStorm.core.*; 30 import seda.sandStorm.main.*; 31 import java.util.*; 32 33 /** 34 * A Stage is a basic implementation of StageIF for application-level 35 * stages. 36 * 37 * @author Matt Welsh 38 */ 39 public class Stage implements StageIF { 40 41 private String name; 42 private StageWrapperIF wrapper; 43 private SinkIF mainsink; 44 45 // If true, instantate a SinkProxy for the stage's event queue 46 // when batchControllor or rtController are enabled. This should 47 // be obsolete; older implementations of these controllers relied 48 // on the proxy, but it's no longer needed. 49 private static final boolean ENABLE_SINK_PROXY = false; 50 51 /** 52 * Create a Stage with the given name, wrapper, and sink. 53 */ Stage(String name, StageWrapperIF wrapper, SinkIF mainsink, ConfigDataIF config)54 public Stage(String name, StageWrapperIF wrapper, SinkIF mainsink, ConfigDataIF config) { 55 this.name = name; 56 this.wrapper = wrapper; 57 58 SandstormConfig cf = config.getManager().getConfig(); 59 this.mainsink = mainsink; 60 61 if (ENABLE_SINK_PROXY && 62 (cf.getBoolean("global.batchController.enable") || 63 cf.getBoolean("global.rtController.enable"))) { 64 this.mainsink = new SinkProxy((SinkIF)mainsink, config.getManager(), wrapper); 65 } 66 } 67 68 /** 69 * Create a Stage with the given name and wrapper, with no sink. 70 * This is used only for specialized stages. 71 */ Stage(String name, StageWrapperIF wrapper)72 public Stage(String name, StageWrapperIF wrapper) { 73 this.name = name; 74 this.wrapper = wrapper; 75 } 76 77 /** 78 * Return the name of this stage. 79 */ getName()80 public String getName() { 81 return name; 82 } 83 84 /** 85 * Return the event sink. 86 */ getSink()87 public SinkIF getSink() { 88 return (SinkIF)mainsink; 89 } 90 91 /** 92 * Return the stage wrapper for this stage. 93 */ getWrapper()94 public StageWrapperIF getWrapper() { 95 return wrapper; 96 } 97 98 /** 99 * Destroy this stage. 100 */ destroy()101 public void destroy() { 102 throw new IllegalArgumentException("XXX Not yet implemented!"); 103 } 104 105 } 106 107