Now added support for ProvidedInterfaces in Container.
[utils] / system / general / src / main / java / org / wamblee / system / core / AbstractComponent.java
index b8e4e6be9b2f5276b041d44e9e61434c1c503ac0..6567e4e74067cf13f563e5e0f7f4ab6aa4cdc4be 100644 (file)
@@ -58,7 +58,21 @@ public abstract class AbstractComponent<Type> implements Component<Type> {
                _required = new ArrayList<RequiredInterface>();
                _required.addAll(Arrays.asList(aRequired));
        }
-
+       
+       protected AbstractComponent(String aName) {
+               this(aName, new ProvidedInterface[0], new RequiredInterface[0]);
+       }
+       
+       public AbstractComponent addProvidedInterface(ProvidedInterface aProvided) { 
+               _provided.add(aProvided);
+               return this; 
+       }
+       
+       public AbstractComponent addRequiredInterface(RequiredInterface aRequired) { 
+               _required.add(aRequired);
+               return this;
+       }
+       
        @Override
        public final String getName() {
                return _name;
@@ -72,6 +86,11 @@ public abstract class AbstractComponent<Type> implements Component<Type> {
                        _context = aContext + "." + _context;
                }
        }
+       
+       @Override
+       public String getContext() {
+               return _context;
+       }
 
        @Override
        public String getQualifiedName() {
@@ -93,12 +112,13 @@ public abstract class AbstractComponent<Type> implements Component<Type> {
 
        @Override
        public final Type start(Scope aScope) {
-               LOG.info("Initializing '" + getQualifiedName() + "'");
+               LOG.info("Initialization starting '" + getQualifiedName() + "'");
                List<ProvidedInterface> oldRemaining = _remaining.get();
                _remaining.set(new ArrayList<ProvidedInterface>(Arrays.asList(getProvidedInterfaces())));
                try {
                        Type runtime = doStart(aScope);
                        checkNotStartedInterfaces();
+                       LOG.info("Initialization finished '" + getQualifiedName() + "'");
                        return runtime;
                } finally {
                        _remaining.set(oldRemaining);
@@ -145,7 +165,9 @@ public abstract class AbstractComponent<Type> implements Component<Type> {
 
        @Override
        public void stop(Type aRuntime) {
+           LOG.info("Stopping initiated '" + getQualifiedName() + "'");
                doStop(aRuntime);
+               LOG.info("Stopping completed '" + getQualifiedName() + "'");
        }
 
        protected abstract void doStop(Type aRuntime);