001: /*
002: * <copyright>
003: *
004: * Copyright 1997-2004 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: */
026:
027: package org.cougaar.planning.plugin.legacy;
028:
029: import org.cougaar.core.component.BindingSite;
030: import org.cougaar.core.component.ServiceBroker;
031: import org.cougaar.core.mts.MessageAddress;
032: import org.cougaar.core.plugin.PluginBase;
033: import org.cougaar.core.service.AgentIdentificationService;
034: import org.cougaar.util.ConfigFinder;
035: import org.cougaar.util.GenericStateModelAdapter;
036:
037: /**
038: * First cut at a class that performs basic new-fangled Plugin functions
039: **/
040:
041: public abstract class PluginSupport extends GenericStateModelAdapter
042: implements PluginBase {
043:
044: private PluginBindingSite pluginBindingSite = null;
045:
046: public void setBindingSite(final BindingSite bs) {
047: pluginBindingSite = new PluginBindingSite() {
048: public MessageAddress getAgentIdentifier() {
049: return PluginSupport.this .getAgentIdentifier();
050: }
051:
052: public ConfigFinder getConfigFinder() {
053: return PluginSupport.this .getConfigFinder();
054: }
055:
056: public ServiceBroker getServiceBroker() {
057: return bs.getServiceBroker();
058: }
059:
060: public void requestStop() {
061: bs.requestStop();
062: }
063: };
064: }
065:
066: private MessageAddress agentId = null;
067:
068: public final void setAgentIdentificationService(
069: AgentIdentificationService ais) {
070: this .agentId = ais.getMessageAddress();
071: }
072:
073: public MessageAddress getAgentIdentifier() {
074: return agentId;
075: }
076:
077: public ConfigFinder getConfigFinder() {
078: return ConfigFinder.getInstance();
079: }
080:
081: protected final PluginBindingSite getBindingSite() {
082: return pluginBindingSite;
083: }
084:
085: /** storage for wasAwakened.
086: **/
087: private boolean explicitlyAwakened = false;
088:
089: /** true IFF were we awakened explicitly (i.e. we were asked to run
090: * even if no subscription activity has happened).
091: * The value is valid only while running in the main plugin thread.
092: */
093: protected boolean wasAwakened() {
094: return explicitlyAwakened;
095: }
096:
097: /** For PluginBinder use only **/
098: public final void setAwakened(boolean value) {
099: explicitlyAwakened = value;
100: }
101:
102: }
|