X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fcore%2FAbstractComponent.java;h=d2cf69fe76f3b1039133debdc726ae88857a927d;hb=32a8562695029cf13d915bc7941a61fe07ff0005;hp=31e50ed58ad251bf90a1cd8afdffde7656aadf89;hpb=49e4054c52db618894cf85eab721aebcbb9c3bc1;p=utils diff --git a/system/general/src/main/java/org/wamblee/system/core/AbstractComponent.java b/system/general/src/main/java/org/wamblee/system/core/AbstractComponent.java index 31e50ed5..d2cf69fe 100644 --- a/system/general/src/main/java/org/wamblee/system/core/AbstractComponent.java +++ b/system/general/src/main/java/org/wamblee/system/core/AbstractComponent.java @@ -18,9 +18,7 @@ package org.wamblee.system.core; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.HashSet; import java.util.List; -import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -49,27 +47,40 @@ public abstract class AbstractComponent implements Component { * @param aRequired * Required services. */ - protected AbstractComponent(String aName, ProvidedInterface[] aProvided, - RequiredInterface[] aRequired) { + protected AbstractComponent(String aName, List aProvided, + List aRequired) { _remaining = new ThreadLocal>(); _context = null; _name = aName; - _provided = new ArrayList(); - _provided.addAll(Arrays.asList(aProvided)); - _required = new ArrayList(); - _required.addAll(Arrays.asList(aRequired)); + _provided = new ArrayList(aProvided); + _required = new ArrayList(aRequired); } + /** + * Constructs the subsystem. + * + * @param aName + * Name of the system. + * @param aProvided + * Provided services. + * @param aRequired + * Required services. + */ + protected AbstractComponent(String aName, ProvidedInterface[] aProvided, + RequiredInterface[] aRequired) { + this(aName, Arrays.asList(aProvided), Arrays.asList(aRequired)); + } + protected AbstractComponent(String aName) { this(aName, new ProvidedInterface[0], new RequiredInterface[0]); } - public AbstractComponent addProvidedInterface(ProvidedInterface aProvided) { + public AbstractComponent addProvidedInterface(ProvidedInterface aProvided) { _provided.add(aProvided); return this; } - public AbstractComponent addRequiredInterface(RequiredInterface aRequired) { + public AbstractComponent addRequiredInterface(RequiredInterface aRequired) { _required.add(aRequired); return this; } @@ -102,20 +113,20 @@ public abstract class AbstractComponent implements Component { } @Override - public final ProvidedInterfaces getProvidedInterfaces() { - return new ProvidedInterfaces(Collections.unmodifiableList(_provided)); + public final List getProvidedInterfaces() { + return Collections.unmodifiableList(_provided); } @Override - public final RequiredInterfaces getRequiredInterfaces() { - return new RequiredInterfaces(Collections.unmodifiableList(_required)); + public final List getRequiredInterfaces() { + return Collections.unmodifiableList(_required); } @Override public final Type start(Scope aScope) { LOG.info("Initialization starting '" + getQualifiedName() + "'"); List oldRemaining = _remaining.get(); - _remaining.set(new ArrayList(Arrays.asList(getProvidedInterfaces().toArray()))); + _remaining.set(new ArrayList(getProvidedInterfaces())); try { Type runtime = doStart(aScope); checkNotStartedInterfaces(); @@ -139,7 +150,7 @@ public abstract class AbstractComponent implements Component { /** * Must be implemented for initializing the subsystem. The implementation - * must call {@link #addService(Service)} for each service that is started. + * must call {@link #addInterface(ProvidedInterface, Object, Scope)} for each service that is started. * * @return Returns the runtime of the component. */