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.mts.base;
028:
029: import org.cougaar.core.component.ParameterizedComponent;
030: import org.cougaar.core.component.ServiceBroker;
031: import org.cougaar.core.service.LoggingService;
032: import org.cougaar.core.service.ThreadService;
033: import org.cougaar.mts.std.AspectSupport;
034:
035: /**
036: * Root class of Components of the MTS.
037: */
038: abstract public class BoundComponent extends ParameterizedComponent {
039:
040: private MessageTransportRegistryService registry;
041: private NameSupport nameSupport;
042: private AspectSupport aspectSupport;
043: private ServiceBroker sb;
044:
045: protected LoggingService loggingService;
046: protected ThreadService threadService;
047:
048: protected BoundComponent() {
049:
050: }
051:
052: public void load() {
053: super .load();
054: getLoggingService();
055: getThreadService();
056: getRegistry();
057: getNameSupport();
058: getAspectSupport();
059: }
060:
061: protected MessageTransportRegistryService getRegistry() {
062: if (registry == null) {
063: ServiceBroker sb = getServiceBroker();
064: registry = (MessageTransportRegistryService) sb.getService(
065: this , MessageTransportRegistryService.class, null);
066: }
067: return registry;
068: }
069:
070: protected NameSupport getNameSupport() {
071: if (nameSupport == null) {
072: ServiceBroker sb = getServiceBroker();
073: nameSupport = (NameSupport) sb.getService(this ,
074: NameSupport.class, null);
075: }
076: return nameSupport;
077: }
078:
079: protected AspectSupport getAspectSupport() {
080: if (aspectSupport == null) {
081: ServiceBroker sb = getServiceBroker();
082: aspectSupport = (AspectSupport) sb.getService(this ,
083: AspectSupport.class, null);
084: }
085: return aspectSupport;
086: }
087:
088: protected LoggingService getLoggingService() {
089: if (loggingService == null) {
090: ServiceBroker sb = getServiceBroker();
091: loggingService = (LoggingService) sb.getService(this ,
092: LoggingService.class, null);
093: }
094: return loggingService;
095: }
096:
097: protected ThreadService getThreadService() {
098: if (threadService == null) {
099: ServiceBroker sb = getServiceBroker();
100: threadService = (ThreadService) sb.getService(this ,
101: ThreadService.class, null);
102: }
103: return threadService;
104: }
105:
106: public final void setServiceBroker(ServiceBroker sb) {
107: this .sb = sb;
108: }
109:
110: public ServiceBroker getServiceBroker() {
111: return sb;
112: }
113:
114: }
|