setterconfiguration now by default does not add all the setters.
[utils] / system / general / src / main / java / org / wamblee / system / adapters / DefaultContainer.java
index c54206ea23ca3e8dd1f72b543958cda254511676..823b7c0d4951b53210c251292156db82e7cb8f87 100644 (file)
@@ -15,8 +15,8 @@
  */
 package org.wamblee.system.adapters;
 
+import org.wamblee.system.container.Container;
 import org.wamblee.system.core.Component;
-import org.wamblee.system.core.Container;
 import org.wamblee.system.core.ProvidedInterface;
 import org.wamblee.system.core.RequiredInterface;
 
@@ -31,16 +31,20 @@ public class DefaultContainer extends Container {
         super.addComponent(aComponent);
         return this;
     }
-
-    public DefaultContainer addComponent(String aName, Class aClass) {
-        return addComponent(new ClassAdapter(aName, new ClassConfiguration(
-                aClass)));
-    }
     
     public DefaultContainer addComponent(String aName, ClassConfiguration aConfiguration) {
         return addComponent(new ClassAdapter(aName, aConfiguration));
     }
 
+    public DefaultContainer addComponent(String aName, Object aObject, ObjectConfiguration aConfiguration) {
+        if ( !aConfiguration.appliesTo(aObject) ) { 
+            throw new IllegalArgumentException("Configuration '" + aConfiguration + "' does nto applu to '"  + 
+                    aObject + "'");
+        }
+        return addComponent(new ObjectAdapter(aName, aObject, aConfiguration));
+    }
+
+    
     @Override
     public DefaultContainer addRequiredInterface(RequiredInterface aRequired) {
         super.addRequiredInterface(aRequired);