Huge refactoring.
[utils] / system / general / src / main / java / org / wamblee / system / core / ProvidedInterface.java
index 349197d0f2b8a450ee39ea5e21a6c4dfc10f2ffa..fe7f7d26a73483907d0102b29050c86455f8d55c 100644 (file)
@@ -19,6 +19,7 @@ import java.util.Collection;
 
 /**
  * Represents an interface provided by a component.
+ * Different component objects should never share ProvidedInterface instances!
  *  
  * @author Erik Brakkee
  */
@@ -37,14 +38,24 @@ public interface ProvidedInterface {
        Class[] getInterfaceTypes();
        
        /**
-        * Publish an implementation of the interface. 
-        * @param aImplementation
+        * Sets a unique id of the provided interface to identify it within a given scope.
+        * Will be called by the container as part of calling {@link #publish(Object, Scope)}. 
+        * @param aId Unique id. 
         */
-       void publish(Object aImplementation); 
-       
+       void setUniqueId(String aId);
+
+       /**
+        * Gets the unique if of the provided interface. This is set by the container
+        * using {@link #setUniqueId(String)}.  
+        */
+       String getUniqueId();
+
        /**
-        * Gets the implementation. 
-        * @return Implementation or null if not started. 
+        * Publishes an implementation of the interface. The implementation must 
+        * call {@link Scope#publishInterface(ProvidedInterface, Object)} to publish the
+        * interface implementation in a given scope.  
+        * @param aImplementation Implementation to publish. 
+        * @param aScope Scope in which to publish the implementation. 
         */
-       Object getImplementation(); 
+       void publish(Object aImplementation, Scope aScope);
 }