X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=system%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fadapters%2FClassConfiguration.java;h=a4114175340495ca81740a6073851df7aed2aec7;hb=1a4d697bf8d5e387ef79f9b3473a53193fb46753;hp=3756bd3b7923fa52c00af73b3ebcfc97c0f27f94;hpb=9cd3686a90a0a75ef52ec190bcd445bc3a777e7e;p=utils
diff --git a/system/general/src/main/java/org/wamblee/system/adapters/ClassConfiguration.java b/system/general/src/main/java/org/wamblee/system/adapters/ClassConfiguration.java
index 3756bd3b..a4114175 100644
--- a/system/general/src/main/java/org/wamblee/system/adapters/ClassConfiguration.java
+++ b/system/general/src/main/java/org/wamblee/system/adapters/ClassConfiguration.java
@@ -15,34 +15,16 @@
*/
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.
- * In particular, it provides:
- *
- * - Selection of a constructor using explicit selection
- * {@link #select(Class...)} or using the most greedy constructor
- * {@link #greedy()}.
- *
- * -
- * Selection of methods to invoke to inject other objects into the object.
- *
- * - Selection of fields to set.
- *
- *
*
* @author Erik Brakkee
*
@@ -50,7 +32,8 @@ import org.wamblee.system.core.SystemAssemblyException;
public class ClassConfiguration {
private Class _class;
- private ConstructorConfiguration _constructorConfig;
+ private ConstructorConfiguration _constructorConfig;
+ private SetterConfiguration _setterConfig;
/**
* Constructs the configuration. By default no constructor is selected and
@@ -60,12 +43,17 @@ public class ClassConfiguration {
*/
public ClassConfiguration(Class aClass) {
_class = aClass;
- _constructorConfig = new ConstructorConfiguration(aClass);
+ _constructorConfig = new ConstructorConfiguration(aClass);
+ _setterConfig = new SetterConfiguration(aClass);
}
public ConstructorConfiguration getConstructorConfig() {
return _constructorConfig;
}
+
+ public SetterConfiguration getSetterConfiguration() {
+ return _setterConfig;
+ }
/**
* Creates the object in the given scope.
@@ -76,13 +64,25 @@ public class ClassConfiguration {
return _constructorConfig.create(aScope);
}
- public ProvidedInterface[] getProvidedInterfaces() {
- return new ProvidedInterface[] {
- new DefaultProvidedInterface("provided", _class)
- };
+ /**
+ * 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) {
+ _setterConfig.invoke(aScope, aObject);
+ }
+
+ public List getProvidedInterfaces() {
+ List result = new ArrayList();
+ result.add(new DefaultProvidedInterface("provided", _class));
+ return result;
}
- public RequiredInterface[] getRequiredInterface() {
- return _constructorConfig.getRequiredInterfaces().toArray(new RequiredInterface[0]);
+ public List getRequiredInterfaces() {
+ List result = new ArrayList();
+ result.addAll(_constructorConfig.getRequiredInterfaces());
+ result.addAll(_setterConfig.getRequiredInterfaces());
+ return result;
}
}