X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsystem%2FAbstractComponent.java;h=3b4725835155e3cfc558fd370967e3fd4467ebd2;hb=66cabd44d9f89e5f07cd04190ac0566dfcb26731;hp=074e3ab0fe408a3e111f569b7a77d1df76bf0c23;hpb=6a914dcbd1c89027eafae6021af4199a636e4e48;p=utils diff --git a/system/general/src/main/java/org/wamblee/system/AbstractComponent.java b/system/general/src/main/java/org/wamblee/system/AbstractComponent.java index 074e3ab0..3b472583 100644 --- a/system/general/src/main/java/org/wamblee/system/AbstractComponent.java +++ b/system/general/src/main/java/org/wamblee/system/AbstractComponent.java @@ -1,3 +1,18 @@ +/* + * Copyright 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.wamblee.system; import java.util.ArrayList; @@ -16,7 +31,8 @@ public abstract class AbstractComponent implements Component { private static final Log LOG = LogFactory.getLog(AbstractComponent.class); - private Status _status; + private Status _status; + private String _context; private String _name; private List _provided; private List _required; @@ -35,6 +51,7 @@ public abstract class AbstractComponent implements Component { protected AbstractComponent(String aName, ProvidedInterface[] aProvided, RequiredInterface[] aRequired) { _status = Status.NOT_STARTED; + _context = null; _name = aName; _provided = new ArrayList(); _provided.addAll(Arrays.asList(aProvided)); @@ -52,6 +69,14 @@ public abstract class AbstractComponent implements Component { public final String getName() { return _name; } + + @Override + public String getQualifiedName() { + if ( _context == null ) { + return getName(); + } + return _context + "." + getName(); + } @Override public final ProvidedInterface[] getProvidedServices() { @@ -66,8 +91,15 @@ public abstract class AbstractComponent implements Component { @Override public final void start(String aContext) { LOG.info("Initializing '" + aContext + "." + _name + "'"); + _context = aContext; doStart(aContext + "." + getName()); _status = Status.RUNNING; + if ( _running.size() != _provided.size()) { + List remaining = + new ArrayList(_provided); + remaining.removeAll(_running); + throw new SystemAssemblyException(aContext + "." + getName() + ": not all services were started, missing " + remaining); + } } /**