* @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);
}
@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() {