Huge refactoring.
[utils] / system / general / src / main / java / org / wamblee / system / core / Component.java
index ff80ee693acdcba8f70443cf4bb704ba4821a2d5..d14eb08a2364891205aef8647b47446e8df66f0a 100644 (file)
@@ -17,11 +17,19 @@ package org.wamblee.system.core;
 
 /**
  * A component represents a part of a system that requires a 
- * number of interfaces and provides a number of interfaces. 
+ * number of interfaces and provides a number of interfaces.
+ * 
+ * The component interface provides the meta-data for a component. 
+ * After calling {@link #start(Scope)}, an actual runtime representation of the
+ * component can be created which is independent of this component. 
+ * As a special case, the runtime representation may be identical to the 
+ * component instance but in general it is not. This allows a component to be 
+ * used as a factory for creating objects. 
+ * 
  *
  * @author Erik Brakkee
  */
-public interface Component {
+public interface Component<Type> {
        
        /**
         * Gets the name of the subsystem.
@@ -56,22 +64,18 @@ public interface Component {
 
        
        /**
-        * Initialises the subsytem by starting all the services that
-        * it described as provided. 
-        */
-       void start();
-       
-       /**
-        * Gets the list of running services in the subsystem. 
-        * 
-        * This method may only be called after the
-        * {@link #initialize(String, Service[])} has been called. 
-        * @return
+        * Initialises the subsystem by starting all the services that
+        * it described as provided.
+        * @param aScope Scope with external interface implementations that are available. The component 
+        *  implementation can either oublish itself in this scope or it can decide to
+        *  create a new scope with the scope passed in as a parent. 
+        * @return Gets an object representing the runtime of the component.  
         */
-       ProvidedInterface[] getRunningInterfaces();
+       Type start(Scope aScope);
        
        /**
-        * Stops a subsystem. 
+        * Stops a component. 
+        * @param aRuntime THe runtime part of the component.  
         */
-       void stop(); 
+       void stop(Type aRuntime); 
 }