823b7c0d4951b53210c251292156db82e7cb8f87
[utils] / system / general / src / main / java / org / wamblee / system / adapters / DefaultContainer.java
1 /*
2  * Copyright 2008 the original author or authors.
3  * 
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
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
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.
15  */
16 package org.wamblee.system.adapters;
17
18 import org.wamblee.system.container.Container;
19 import org.wamblee.system.core.Component;
20 import org.wamblee.system.core.ProvidedInterface;
21 import org.wamblee.system.core.RequiredInterface;
22
23 public class DefaultContainer extends Container {
24
25     public DefaultContainer(String aName) {
26         super(aName);
27     }
28
29     @Override
30     public DefaultContainer addComponent(Component aComponent) {
31         super.addComponent(aComponent);
32         return this;
33     }
34     
35     public DefaultContainer addComponent(String aName, ClassConfiguration aConfiguration) {
36         return addComponent(new ClassAdapter(aName, aConfiguration));
37     }
38
39     public DefaultContainer addComponent(String aName, Object aObject, ObjectConfiguration aConfiguration) {
40         if ( !aConfiguration.appliesTo(aObject) ) { 
41             throw new IllegalArgumentException("Configuration '" + aConfiguration + "' does nto applu to '"  + 
42                     aObject + "'");
43         }
44         return addComponent(new ObjectAdapter(aName, aObject, aConfiguration));
45     }
46
47     
48     @Override
49     public DefaultContainer addRequiredInterface(RequiredInterface aRequired) {
50         super.addRequiredInterface(aRequired);
51         return this;
52     }
53
54     @Override
55     public DefaultContainer addProvidedInterface(ProvidedInterface aProvided) {
56         super.addProvidedInterface(aProvided);
57         return this;
58     }
59
60 }