01: /*
02: * <copyright>
03: *
04: * Copyright 2002-2004 BBNT Solutions, LLC
05: * under sponsorship of the Defense Advanced Research Projects
06: * Agency (DARPA).
07: *
08: * You can redistribute this software and/or modify it under the
09: * terms of the Cougaar Open Source License as published on the
10: * Cougaar Open Source Website (www.cougaar.org).
11: *
12: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
16: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23: *
24: * </copyright>
25: */
26:
27: package org.cougaar.core.wp.resolver;
28:
29: import org.cougaar.core.agent.Agent; // inlined
30: import org.cougaar.core.component.ComponentDescription;
31: import org.cougaar.core.component.ComponentDescriptions;
32: import org.cougaar.core.component.ContainerSupport;
33: import org.cougaar.core.component.ServiceBroker;
34: import org.cougaar.core.component.ServiceRevokedListener;
35: import org.cougaar.core.mts.MessageAddress;
36: import org.cougaar.core.node.ComponentInitializerService;
37: import org.cougaar.core.service.AgentIdentificationService;
38: import org.cougaar.core.service.LoggingService;
39:
40: /**
41: * This component is an empty {@link
42: * org.cougaar.core.component.Container} for the white pages {@link
43: * Resolver} components.
44: */
45: public class ResolverContainer extends ContainerSupport {
46: public static final String INSERTION_POINT = Agent.INSERTION_POINT
47: + ".WPClient";
48:
49: private LoggingService logger;
50: private MessageAddress agentId;
51:
52: public void setLoggingService(LoggingService logger) {
53: this .logger = logger;
54: }
55:
56: public void setAgentIdentificationService(
57: AgentIdentificationService ais) {
58: if (ais != null) {
59: this .agentId = ais.getMessageAddress();
60: }
61: }
62:
63: protected String specifyContainmentPoint() {
64: return INSERTION_POINT;
65: }
66:
67: protected ComponentDescriptions findInitialComponentDescriptions() {
68: String cname = agentId.toString();
69: ServiceBroker sb = getServiceBroker();
70: ComponentInitializerService cis = (ComponentInitializerService) sb
71: .getService(this , ComponentInitializerService.class,
72: null);
73: try {
74: return new ComponentDescriptions(cis
75: .getComponentDescriptions(cname,
76: specifyContainmentPoint()));
77: } catch (ComponentInitializerService.InitializerException cise) {
78: if (logger.isInfoEnabled()) {
79: logger.info("\nUnable to add " + cname + "'s plugins ",
80: cise);
81: }
82: return null;
83: } finally {
84: sb.releaseService(this , ComponentInitializerService.class,
85: cis);
86: }
87: }
88: }
|