(no commit message)
[utils] / system / general / src / main / java / org / wamblee / system / adapters / ClassConfiguration.java
index cff3cd042db281fd63668084bb338dfa1256cce1..7ed7d8250d43e0ceb2e80da73911afda30e30a20 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2008 the original author or authors.
+ * Copyright 2005-2010 the original author or authors.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 package org.wamblee.system.adapters;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import org.wamblee.system.core.DefaultProvidedInterface;
 import org.wamblee.system.core.ProvidedInterface;
 import org.wamblee.system.core.RequiredInterface;
 import org.wamblee.system.core.Scope;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
- * The class configuration encapsulates the knowledge of how to wrap a class as a component.
+ * The class configuration encapsulates the knowledge of how to wrap a class as
+ * a component.
  * 
  * @author Erik Brakkee
- *
  */
 public class ClassConfiguration {
+    private Class clazz;
+
+    private ConstructorConfiguration constructorConfig;
+
+    private ObjectConfiguration objectConfig;
+
+    /**
+     * Constructs the configuration. By default no constructor is selected and
+     * one of {@link #select(Class...)} or {@link #greedy()} must be called.
+     * 
+     * @param aClass
+     *            Class to construct.
+     */
+    public ClassConfiguration(Class aClass) {
+        clazz = 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.
+     * 
+     * @param aScope
+     *            Scope containing required interfaces for this object.
+     * 
+     * @return object.
+     */
+    public Object create(Scope aScope) {
+        return constructorConfig.create(aScope);
+    }
+
+    /**
+     * Injects required interfaces through the setters
+     * 
+     * @param aScope
+     *            Scope in which injection takes place.
+     * @param aObject
+     *            Object to inject into.
+     */
+    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", clazz));
+
+        return result;
+    }
 
-       private Class _class; 
-       private ConstructorConfiguration _constructorConfig;
-       private SetterConfiguration _setterConfig; 
-       
-       /**
-        * Constructs the configuration. By default no constructor is selected and 
-        * one of {@link #select(Class...)} or 
-        * {@link #greedy()} must be called.  
-        * @param aClass Class to construct. 
-        */
-       public ClassConfiguration(Class aClass) {
-               _class = aClass; 
-               _constructorConfig = new ConstructorConfiguration(aClass);
-               _setterConfig = new SetterConfiguration(aClass);
-       }
-       
-       public ConstructorConfiguration getConstructorConfig() {
-               return _constructorConfig;
-       }
-       
-       public SetterConfiguration getSetterConfiguration() { 
-           return _setterConfig; 
-       }
+    public List<RequiredInterface> getRequiredInterfaces() {
+        List<RequiredInterface> result = new ArrayList<RequiredInterface>();
+        result.addAll(constructorConfig.getRequiredInterfaces());
+        result.addAll(objectConfig.getRequiredInterfaces());
 
-       /**
-        * Creates the object in the given scope. 
-        * @param aScope Scope containing required interfaces for this object. 
-        * @return object. 
-        */
-       public Object create(Scope 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) { 
-           _setterConfig.inject(aScope, aObject);
-       }
-       
-       public List<ProvidedInterface> getProvidedInterfaces() {
-           List<ProvidedInterface> result = new ArrayList<ProvidedInterface>();
-           result.add(new DefaultProvidedInterface("provided", _class));       
-           return result;
-       }
-       
-       public List<RequiredInterface> getRequiredInterfaces() { 
-           List<RequiredInterface> result = new ArrayList<RequiredInterface>();
-           result.addAll(_constructorConfig.getRequiredInterfaces());
-           result.addAll(_setterConfig.getRequiredInterfaces());
-           return result; 
-       }
+        return result;
+    }
 }