2 * Copyright 2008 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.wamblee.system.adapters;
18 import org.wamblee.system.core.DefaultProvidedInterface;
19 import org.wamblee.system.core.ProvidedInterface;
20 import org.wamblee.system.core.RequiredInterface;
21 import org.wamblee.system.core.Scope;
23 import java.util.ArrayList;
24 import java.util.List;
28 * The class configuration encapsulates the knowledge of how to wrap a
29 * class as a component.
31 * @author Erik Brakkee
33 public class ClassConfiguration {
42 private ConstructorConfiguration constructorConfig;
47 private ObjectConfiguration objectConfig;
50 * Constructs the configuration. By default no constructor is selected and
51 * one of {@link #select(Class...)} or
52 * {@link #greedy()} must be called.
53 * @param aClass Class to construct.
55 public ClassConfiguration(Class aClass) {
57 constructorConfig = new ConstructorConfiguration(aClass);
58 objectConfig = new ObjectConfiguration(aClass);
64 * @return DOCUMENT ME!
66 public ConstructorConfiguration getConstructorConfig() {
67 return constructorConfig;
73 * @return DOCUMENT ME!
75 public ObjectConfiguration getObjectConfig() {
80 * Creates the object in the given scope.
82 * @param aScope Scope containing required interfaces for this object.
86 public Object create(Scope aScope) {
87 return constructorConfig.create(aScope);
91 * Injects required interfaces through the setters
93 * @param aScope Scope in which injection takes place.
94 * @param aObject Object to inject into.
96 public void inject(Scope aScope, Object aObject) {
97 objectConfig.inject(aScope, aObject);
103 * @return DOCUMENT ME!
105 public List<ProvidedInterface> getProvidedInterfaces() {
106 List<ProvidedInterface> result = new ArrayList<ProvidedInterface>();
107 result.add(new DefaultProvidedInterface("provided", _class));
115 * @return DOCUMENT ME!
117 public List<RequiredInterface> getRequiredInterfaces() {
118 List<RequiredInterface> result = new ArrayList<RequiredInterface>();
119 result.addAll(constructorConfig.getRequiredInterfaces());
120 result.addAll(objectConfig.getRequiredInterfaces());