(no commit message)
[utils] / system / general / src / main / java / org / wamblee / system / core / AbstractComponent.java
index d86277d880a16068c33dfa0d00f73a2b7487eae4..9bad650d23cb47d42da9cb29dec850b166aafcff 100644 (file)
@@ -124,7 +124,7 @@ public abstract class AbstractComponent implements Component {
         * @param aService
         *            Service.
         */
-       protected final void addService(
+       protected final void addInterface(
                        ProvidedInterface aDescriptor, Object aService) {
                LOG.info("Interface '" + getQualifiedName() + "." + aDescriptor.getName() + "' started.");
                _running.add(aDescriptor);
@@ -132,17 +132,35 @@ public abstract class AbstractComponent implements Component {
        }
 
        @Override
-       public ProvidedInterface[] getRunningServices() {
+       public ProvidedInterface[] getRunningInterfaces() {
                return _running.toArray(new ProvidedInterface[0]);
        }
        
        @Override
        public void stop() {
-               doStop();       
+               doStop();
+               if ( _running.size() > 0 ) { 
+                       // programming error.
+                       throw new RuntimeException(getQualifiedName() + ": still services running after the stop call.");
+               }
                _status = Status.STOPPED;
        }
        
-       protected abstract void doStop(); 
+       protected abstract void doStop();
+       
+       /**
+        * Implementations must call this method to indicate that a running service has
+        * been stopped.
+        * 
+        * @param aService
+        *            Service.
+        */
+       protected final void removeInterface(
+                       ProvidedInterface aDescriptor) {
+               LOG.info("Interface '" + getQualifiedName() + "." + aDescriptor.getName() + "' stopped.");
+               _running.remove(aDescriptor);
+               aDescriptor.publish(null);
+       }
 
        @Override
        public String toString() {