Huge refactoring.
[utils] / system / general / src / main / java / org / wamblee / system / core / DefaultProvidedInterface.java
index 60c111ed1ecfd14c699924b0f2fb10b8476af2ce..90c230dcc9bf23493fcba2dd629f14c7c880e665 100644 (file)
@@ -26,20 +26,20 @@ public class DefaultProvidedInterface implements ProvidedInterface {
        
        private String _name; 
        private Class[] _interfaces;
-       private Object _implementation
+       private String _uniqueId
        
        /**
         * Constructs the descriptor. 
         * @param aInterface Type of service. 
         */
        public DefaultProvidedInterface(String aName, Class aInterface) {
-               _name = aName; 
-               _interfaces = new Class[] { aInterface };  
+               this(aName, new Class[] { aInterface }); 
        }
        
        public DefaultProvidedInterface(String aName, Class[] aInterfaces) {
                _name = aName; 
-               _interfaces = Arrays.copyOf(aInterfaces, aInterfaces.length);  
+               _interfaces = Arrays.copyOf(aInterfaces, aInterfaces.length);
+               _uniqueId = null; 
        }
 
        @Override
@@ -51,40 +51,20 @@ public class DefaultProvidedInterface implements ProvidedInterface {
        public Class[] getInterfaceTypes() {
                return _interfaces;
        }
-       
+
        @Override
-       public void publish(Object aImplementation) {
-               _implementation = aImplementation;      
+       public void setUniqueId(String aId) {
+               _uniqueId = aId;        
        }
        
        @Override
-       public Object getImplementation() {
-               return _implementation; 
+       public String getUniqueId() {
+               return _uniqueId;
        }
        
        @Override
-       public boolean equals(Object obj) {
-               if ( !(obj instanceof DefaultProvidedInterface)) { 
-                       return false; 
-               }
-               DefaultProvidedInterface descr = (DefaultProvidedInterface)obj;
-               if ( _interfaces.length != descr._interfaces.length ) { 
-                       return false; 
-               }
-               String[] interfaces1 = new String[_interfaces.length];
-               String[] interfaces2 = new String[_interfaces.length];
-               for (int i = 0; i < _interfaces.length; i++) {  
-                       interfaces1[i] = _interfaces[i].getName();
-                       interfaces2[i] = descr._interfaces[i].getName();
-               }
-               Arrays.sort(interfaces1);
-               Arrays.sort(interfaces2);
-               return Arrays.equals(interfaces1, interfaces2);
-       }
-
-       @Override
-       public int hashCode() {
-               return _interfaces.hashCode(); 
+       public void publish(Object aImplementation, Scope aScope) {
+               aScope.publishInterface(this, aImplementation);
        }
        
        @Override