*/
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:
- * <ul>
- * <li> Selection of a constructor using explicit selection
- * {@link #select(Class...)} or using the most greedy constructor
- * {@link #greedy()}.
- * </li>
- * <li>
- * Selection of methods to invoke to inject other objects into the object.
- * </li>
- * <li> Selection of fields to set.
- * </li>
- * </ul>
*
* @author Erik Brakkee
*
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
*/
public ClassConfiguration(Class aClass) {
_class = aClass;
- _constructorConfig = new ConstructorConfiguration(aClass);
+ _constructorConfig = new ConstructorConfiguration(aClass);
+ _objectConfig = new ObjectConfiguration(aClass);
}
public ConstructorConfiguration getConstructorConfig() {
return _constructorConfig;
}
+
+ public ObjectConfiguration getObjectConfig() {
+ return _objectConfig;
+ }
/**
* Creates the object in the given scope.
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) {
+ _objectConfig.inject(aScope, aObject);
+ }
+
+ 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;
}
}