X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fadapters%2FClassConfiguration.java;h=bd5ccbb02bdf8f7dde32cc405c6c18cb93d67b58;hb=8de36ff0206c996baf3ee4adc3e2293b12ff5f39;hp=a686f88cec94cd57f187e3c3ca26eed80fa93a22;hpb=0d8d8f24656e585ee75558cfd6a4c661f8f14985;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 a686f88c..bd5ccbb0 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 @@ -1,12 +1,12 @@ /* * Copyright 2008 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. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,74 +15,84 @@ */ 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 _class; + + 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) { + _class = 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 getProvidedInterfaces() { + List result = new ArrayList(); + result.add(new DefaultProvidedInterface("provided", _class)); + + return result; + } - private Class _class; - 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) { - _class = aClass; - constructorConfig = new ConstructorConfiguration(aClass); - objectConfig = new ObjectConfiguration(aClass); - } - - public ConstructorConfiguration getConstructorConfig() { - return constructorConfig; - } - - public ObjectConfiguration getObjectConfig() { - return objectConfig; - } + public List getRequiredInterfaces() { + List result = new ArrayList(); + 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) { - objectConfig.inject(aScope, aObject); - } - - public List getProvidedInterfaces() { - List result = new ArrayList(); - result.add(new DefaultProvidedInterface("provided", _class)); - return result; - } - - public List getRequiredInterfaces() { - List result = new ArrayList(); - result.addAll(constructorConfig.getRequiredInterfaces()); - result.addAll(objectConfig.getRequiredInterfaces()); - return result; - } + return result; + } }