X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fcore%2FAbstractComponent.java;h=579fd27435907d4ee9c0db8466fb1bb12db71270;hb=0d8d8f24656e585ee75558cfd6a4c661f8f14985;hp=d2cf69fe76f3b1039133debdc726ae88857a927d;hpb=da48a523c81e59fe0eac34e43d12937396161f25;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 d2cf69fe..579fd274 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 @@ -30,12 +30,12 @@ public abstract class AbstractComponent implements Component { private static final Log LOG = LogFactory.getLog(AbstractComponent.class); - private ThreadLocal> _remaining; + private ThreadLocal> remaining; - private String _context; - private String _name; - private List _provided; - private List _required; + private String context; + private String name; + private List provided; + private List required; /** * Constructs the subsystem. @@ -49,11 +49,11 @@ public abstract class AbstractComponent implements Component { */ protected AbstractComponent(String aName, List aProvided, List aRequired) { - _remaining = new ThreadLocal>(); - _context = null; - _name = aName; - _provided = new ArrayList(aProvided); - _required = new ArrayList(aRequired); + remaining = new ThreadLocal>(); + context = null; + name = aName; + provided = new ArrayList(aProvided); + required = new ArrayList(aRequired); } /** @@ -76,71 +76,71 @@ public abstract class AbstractComponent implements Component { } public AbstractComponent addProvidedInterface(ProvidedInterface aProvided) { - _provided.add(aProvided); + provided.add(aProvided); return this; } public AbstractComponent addRequiredInterface(RequiredInterface aRequired) { - _required.add(aRequired); + required.add(aRequired); return this; } @Override public final String getName() { - return _name; + return name; } @Override public void addContext(String aContext) { - if (_context == null) { - _context = aContext; + if (context == null) { + context = aContext; } else { - _context = aContext + "." + _context; + context = aContext + "." + context; } } @Override public String getContext() { - return _context; + return context; } @Override public String getQualifiedName() { - if (_context == null) { + if (context == null) { return getName(); } - return _context + "." + getName(); + return context + "." + getName(); } @Override public final List getProvidedInterfaces() { - return Collections.unmodifiableList(_provided); + return Collections.unmodifiableList(provided); } @Override public final List getRequiredInterfaces() { - return Collections.unmodifiableList(_required); + return Collections.unmodifiableList(required); } @Override public final Type start(Scope aScope) { LOG.info("Initialization starting '" + getQualifiedName() + "'"); - List oldRemaining = _remaining.get(); - _remaining.set(new ArrayList(getProvidedInterfaces())); + List oldRemaining = remaining.get(); + remaining.set(new ArrayList(getProvidedInterfaces())); try { Type runtime = doStart(aScope); checkNotStartedInterfaces(); LOG.info("Initialization finished '" + getQualifiedName() + "'"); return runtime; } finally { - _remaining.set(oldRemaining); + remaining.set(oldRemaining); } } private void checkNotStartedInterfaces() { - if (_remaining.get().size() > 0) { + if (remaining.get().size() > 0) { String notProvided = ""; - for (ProvidedInterface provided : _remaining.get()) { + for (ProvidedInterface provided : remaining.get()) { notProvided += "\nComponent " + getQualifiedName() + " did not start interface " + provided; } @@ -171,7 +171,7 @@ public abstract class AbstractComponent implements Component { Object aService, Scope aScope) { LOG.info("Interface '" + getQualifiedName() + "." + aDescriptor.getName() + "' started."); - if ( !_remaining.get().remove(aDescriptor) ) { + if ( !remaining.get().remove(aDescriptor) ) { throw new SystemAssemblyException("Component '" + getQualifiedName() + "' started an unexpected interface '" + aDescriptor + "' that was not registerd as a provided interface before"); }