01: /*
02: * <copyright>
03: *
04: * Copyright 1997-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.server;
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 container for the white pages server
42: * components.
43: */
44: public class ServerContainer extends ContainerSupport {
45: public static final String INSERTION_POINT = Agent.INSERTION_POINT
46: + ".WPServer";
47:
48: private LoggingService logger;
49: private MessageAddress agentId;
50:
51: public void setLoggingService(LoggingService logger) {
52: this .logger = logger;
53: }
54:
55: public void setAgentIdentificationService(
56: AgentIdentificationService ais) {
57: if (ais != null) {
58: this .agentId = ais.getMessageAddress();
59: }
60: }
61:
62: protected String specifyContainmentPoint() {
63: return INSERTION_POINT;
64: }
65:
66: protected ComponentDescriptions findInitialComponentDescriptions() {
67: String cname = agentId.toString();
68: ServiceBroker sb = getServiceBroker();
69: ComponentInitializerService cis = (ComponentInitializerService) sb
70: .getService(this , ComponentInitializerService.class,
71: null);
72: try {
73: return new ComponentDescriptions(cis
74: .getComponentDescriptions(cname,
75: specifyContainmentPoint()));
76: } catch (ComponentInitializerService.InitializerException cise) {
77: if (logger.isInfoEnabled()) {
78: logger.info("\nUnable to add " + cname + "'s plugins ",
79: cise);
80: }
81: return null;
82: } finally {
83: sb.releaseService(this , ComponentInitializerService.class,
84: cis);
85: }
86: }
87: }
|