updated coding rules.
[utils] / system / general / src / main / java / org / wamblee / system / adapters / ClassConfiguration.java
index 8a898110acbf79b83d1890774a8f5d3e44ac6b45..a686f88cec94cd57f187e3c3ca26eed80fa93a22 100644 (file)
  */
 package org.wamblee.system.adapters;
 
-import java.lang.reflect.Constructor;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
-import org.wamblee.collections.CollectionFilter;
-import org.wamblee.conditions.Condition;
 import org.wamblee.system.core.DefaultProvidedInterface;
-import org.wamblee.system.core.DefaultRequiredInterface;
 import org.wamblee.system.core.ProvidedInterface;
 import org.wamblee.system.core.RequiredInterface;
 import org.wamblee.system.core.Scope;
-import org.wamblee.system.core.SystemAssemblyException;
 
 /**
  * The class configuration encapsulates the knowledge of how to wrap a class as a component.
@@ -38,7 +32,8 @@ import org.wamblee.system.core.SystemAssemblyException;
 public class ClassConfiguration {
 
        private Class _class; 
-       private ConstructorConfiguration _constructorConfig; 
+       private ConstructorConfiguration constructorConfig;
+       private ObjectConfiguration objectConfig; 
        
        /**
         * Constructs the configuration. By default no constructor is selected and 
@@ -48,11 +43,16 @@ public class ClassConfiguration {
         */
        public ClassConfiguration(Class aClass) {
                _class = aClass; 
-               _constructorConfig = new ConstructorConfiguration(aClass);  
+               constructorConfig = new ConstructorConfiguration(aClass);
+               objectConfig = new ObjectConfiguration(aClass);
        }
        
        public ConstructorConfiguration getConstructorConfig() {
-               return _constructorConfig;
+               return constructorConfig;
+       }
+       
+       public ObjectConfiguration getObjectConfig() { 
+           return objectConfig; 
        }
 
        /**
@@ -61,16 +61,28 @@ public class ClassConfiguration {
         * @return object. 
         */
        public Object create(Scope aScope) {
-               return _constructorConfig.create(aScope);
+               return constructorConfig.create(aScope);
+       }
+       
+       /**
+        * Injects required interfaces through the setters 
+        * @param aObject Object to inject into. 
+        * @param aScope Scope in which injection takes place. 
+        */
+       public void inject(Scope aScope, Object aObject) { 
+           objectConfig.inject(aScope, aObject);
        }
        
-       public ProvidedInterface[] getProvidedInterfaces() { 
-               return new ProvidedInterface[] { 
-                       new DefaultProvidedInterface("provided", _class)        
-               };
+       public List<ProvidedInterface> getProvidedInterfaces() {
+           List<ProvidedInterface> result = new ArrayList<ProvidedInterface>();
+           result.add(new DefaultProvidedInterface("provided", _class));       
+           return result;
        }
        
-       public RequiredInterface[] getRequiredInterface() { 
-               return _constructorConfig.getRequiredInterfaces().toArray(new RequiredInterface[0]);
+       public List<RequiredInterface> getRequiredInterfaces() { 
+           List<RequiredInterface> result = new ArrayList<RequiredInterface>();
+           result.addAll(constructorConfig.getRequiredInterfaces());
+           result.addAll(objectConfig.getRequiredInterfaces());
+           return result; 
        }
 }