001: /*
002: * Copyright (c) 2000 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.lib.aDisk;
026:
027: import seda.sandStorm.api.*;
028: import seda.sandStorm.api.internal.*;
029: import seda.sandStorm.core.*;
030: import seda.sandStorm.internal.*;
031: import java.util.*;
032:
033: /**
034: * Internal stage wrapper implementation for AFileTPImpl.
035: *
036: * @author Matt Welsh
037: */
038: class AFileTPStageWrapper implements StageWrapperIF {
039:
040: private String name;
041: private StageIF stage;
042: private EventHandlerIF handler;
043: private ConfigDataIF config;
044: private ThreadManagerIF tm;
045:
046: // This stagewrapper has no (real) event queue: Threads created
047: // by AFileTPTM will poll across the per-AFile queues instead.
048: // This class is just used for bookkeeping purposes.
049:
050: AFileTPStageWrapper(String name, EventHandlerIF handler,
051: ConfigDataIF config, ThreadManagerIF tm) {
052: this .name = name;
053: this .handler = handler;
054: this .config = config;
055: this .tm = tm;
056: this .stage = new Stage(name, this , null, config);
057: this .config.setStage(this .stage);
058: }
059:
060: /**
061: * Initialize this stage.
062: */
063: public void init() throws Exception {
064: if (handler != null)
065: handler.init(config);
066: tm.register(this );
067: }
068:
069: /**
070: * Destroy this stage.
071: */
072: public void destroy() throws Exception {
073: tm.deregister(this );
074: if (handler != null)
075: handler.destroy();
076: }
077:
078: /**
079: * Return the event handler associated with this stage.
080: */
081: public EventHandlerIF getEventHandler() {
082: return handler;
083: }
084:
085: /**
086: * Return the stage handle for this stage.
087: */
088: public StageIF getStage() {
089: return stage;
090: }
091:
092: /**
093: * Return the source from which events should be pulled to
094: * pass to this EventHandlerIF.
095: */
096: public SourceIF getSource() {
097: // Not used
098: return null;
099: }
100:
101: /**
102: * Return the thread manager for this stage.
103: */
104: public ThreadManagerIF getThreadManager() {
105: return tm;
106: }
107:
108: /** Not implemented. */
109: public StageStatsIF getStats() {
110: return null;
111: }
112:
113: /** Not implemented. */
114: public ResponseTimeControllerIF getResponseTimeController() {
115: return null;
116: }
117:
118: public String toString() {
119: return "AFILETPSW[" + stage.getName() + "]";
120: }
121:
122: }
|