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.logistics.ldm;
028:
029: import java.util.*;
030:
031: import org.cougaar.core.mts.MessageAddress;
032: import org.cougaar.core.service.AgentIdentificationService;
033: import org.cougaar.core.service.DomainService;
034:
035: import org.cougaar.core.domain.*;
036: import org.cougaar.core.component.ServiceBroker;
037:
038: import org.cougaar.core.domain.DomainAdapter;
039:
040: import org.cougaar.logistics.ldm.asset.PropertyGroupFactory;
041: import org.cougaar.logistics.ldm.asset.AssetFactory;
042:
043: import org.cougaar.planning.ldm.LDMServesPlugin;
044: import org.cougaar.planning.ldm.PlanningFactory;
045: import org.cougaar.planning.service.LDMService;
046:
047: /**
048: * COUGAAR Domain package definition.
049: **/
050:
051: public class LogisticsDomain extends DomainAdapter {
052:
053: public static final String LOGISTICS_NAME = "logistics";
054:
055: private MessageAddress self;
056: private AgentIdentificationService agentIdService;
057: private DomainService domainService;
058: private LDMService ldmService;
059:
060: public String getDomainName() {
061: return LOGISTICS_NAME;
062: }
063:
064: public LogisticsDomain() {
065: super ();
066: }
067:
068: public void setAgentIdentificationService(
069: AgentIdentificationService ais) {
070: this .agentIdService = ais;
071: if (ais == null) {
072: // Revocation
073: } else {
074: this .self = ais.getMessageAddress();
075: }
076: }
077:
078: public void setDomainService(DomainService domainService) {
079: this .domainService = domainService;
080: }
081:
082: public void setLDMService(LDMService ldmService) {
083: this .ldmService = ldmService;
084: }
085:
086: public void initialize() {
087: super .initialize();
088: Constants.Role.init(); // Insure that our Role constants are initted
089: }
090:
091: public void unload() {
092: ServiceBroker sb = getBindingSite().getServiceBroker();
093: if (ldmService != null) {
094: sb.releaseService(this , LDMService.class, ldmService);
095: ldmService = null;
096: }
097: if (domainService != null) {
098: sb.releaseService(this , DomainService.class, domainService);
099: domainService = null;
100: }
101: if (agentIdService != null) {
102: sb.releaseService(this , AgentIdentificationService.class,
103: agentIdService);
104: agentIdService = null;
105: }
106: super .unload();
107: }
108:
109: public Collection getAliases() {
110: ArrayList l = new ArrayList(3);
111: l.add("logistics");
112: l.add("albbn");
113: return l;
114: }
115:
116: protected void loadFactory() {
117: LDMServesPlugin ldm = ldmService.getLDM();
118: PlanningFactory ldmf = (PlanningFactory) ldm
119: .getFactory("planning");
120: if (ldmf == null) {
121: throw new RuntimeException("Missing \"planning\" factory!");
122: }
123:
124: ldmf.addPropertyGroupFactory(new PropertyGroupFactory());
125: ldmf.addAssetFactory(new AssetFactory());
126: }
127:
128: protected void loadXPlan() {
129: // no logistics-specific plan
130: }
131:
132: protected void loadLPs() {
133: RootPlan rootplan = (RootPlan) getXPlanForDomain("root");
134: if (rootplan == null) {
135: throw new RuntimeException("Missing \"root\" plan!");
136: }
137:
138: PlanningFactory ldmf = (PlanningFactory) domainService
139: .getFactory("planning");
140: if (ldmf == null) {
141: throw new RuntimeException("Missing \"planning\" factory!");
142: }
143:
144: /**
145: * We have no new logistics LPs for the time being.
146: *
147: GLMFactory glmFactory = (GLMFactory)
148: domainService.getFactory("glm");
149:
150: addLogicProvider(new ReceiveTransferableLP(rootplan, ldmf));
151: addLogicProvider(new TransferableLP(rootplan, self, ldmf));
152: addLogicProvider(new DetailRequestLP(rootplan, self, glmFactory));
153: addLogicProvider(new OPlanWatcherLP(rootplan, ldmf));
154: */
155:
156: }
157:
158: }
|