added databasecomponent and now using Derby in the unit tests.
[utils] / system / general / src / main / java / org / wamblee / system / core / AbstractComponent.java
index 28bb6ff19b28b0f93988695525f672d9fec35bb5..04f0480125c36ff5737258b728b64461b3d3b11d 100644 (file)
@@ -112,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);
@@ -158,13 +159,18 @@ public abstract class AbstractComponent<Type> implements Component<Type> {
                        Object aService, Scope aScope) {
                LOG.info("Interface '" + getQualifiedName() + "."
                                + aDescriptor.getName() + "' started.");
-               _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");
+               }
                aScope.publishInterface(aDescriptor, aService);
        }
 
        @Override
        public void stop(Type aRuntime) {
+           LOG.info("Stopping initiated '" + getQualifiedName() + "'");
                doStop(aRuntime);
+               LOG.info("Stopping completed '" + getQualifiedName() + "'");
        }
 
        protected abstract void doStop(Type aRuntime);