001: /*
002: * <copyright>
003: *
004: * Copyright 2001-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.ldm;
028:
029: import java.util.List;
030:
031: import org.cougaar.core.component.ServiceBroker;
032: import org.cougaar.core.component.ServiceProvider;
033: import org.cougaar.core.domain.Factory;
034: import org.cougaar.core.mts.MessageAddress;
035: import org.cougaar.core.service.DomainService;
036: import org.cougaar.core.service.UIDServer;
037: import org.cougaar.planning.service.LDMService;
038: import org.cougaar.planning.service.PrototypeRegistryService;
039:
040: /** placeholder to clean up plugin->manager interactions **/
041: public class LDMServiceProvider implements ServiceProvider {
042: private LDMService ls;
043:
044: /*
045: public LDMServiceProvider(LDMServesPlugin lsp, PrototypeRegistryService prs, DomainService ds) {
046: // rather this was an assert!
047: if (lsp == null || prs == null || ds == null)
048: throw new IllegalArgumentException("LDMServiceProvider Constructor arguments must be non-null ("+
049: lsp+", "+prs+", "+ds+")");
050:
051: this.ls = new LDMServiceImpl(lsp,prs,ds);
052: }
053: */
054: public LDMServiceProvider(LDMService ls) {
055: this .ls = ls;
056: }
057:
058: public Object getService(ServiceBroker sb, Object requestor,
059: Class serviceClass) {
060: if (LDMService.class.isAssignableFrom(serviceClass)) {
061: return ls;
062: } else {
063: return null;
064: }
065: }
066:
067: public void releaseService(ServiceBroker sb, Object requestor,
068: Class serviceClass, Object service) {
069: }
070:
071: private static class LDMServiceImpl implements LDMService {
072: private LDMServesPlugin lsp;
073: private PrototypeRegistryService prs;
074: private DomainService ds;
075:
076: private LDMServiceImpl(LDMServesPlugin lsp,
077: PrototypeRegistryService prs, DomainService ds) {
078: this .lsp = lsp;
079: this .prs = prs;
080: this .ds = ds;
081: }
082:
083: public MessageAddress getMessageAddress() {
084: return lsp.getMessageAddress();
085: }
086:
087: public LDMServesPlugin getLDM() {
088: return lsp;
089: }
090:
091: public UIDServer getUIDServer() {
092: return lsp.getUIDServer();
093: }
094:
095: public PlanningFactory getFactory() {
096: return (PlanningFactory) getFactory("planning");
097: }
098:
099: public Factory getFactory(String s) {
100: return ds.getFactory(s);
101: }
102:
103: public Factory getFactory(Class cl) {
104: return ds.getFactory(cl);
105: }
106:
107: public List getFactories() {
108: return ds.getFactories();
109: }
110:
111: // standin API for LDMService called by PluginBinder for temporary support
112: public void addPrototypeProvider(PrototypeProvider plugin) {
113: prs.addPrototypeProvider(plugin);
114: }
115:
116: public void addPropertyProvider(PropertyProvider plugin) {
117: prs.addPropertyProvider(plugin);
118: }
119:
120: public void addLatePropertyProvider(LatePropertyProvider plugin) {
121: prs.addLatePropertyProvider(plugin);
122: }
123: }
124: }
|