1 /***
2 * @(#)ServiceContainer.java
3 *
4 * JFoxSOAF, Service-Oriented Application Framework
5 *
6 * Copyright(c) JFoxSOAF Team
7 *
8 * Licensed under the GNU LGPL, Version 2.1 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.gnu.org/copyleft/lesser.html
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 * For more information, please visit:
21 * http://www.jfox.cn/confluence/display/JFoxSOAF/Home
22 * http://www.huihoo.org/jfox/jfoxsoaf
23 */
24
25 package org.huihoo.jfox.soaf.container;
26
27 import java.util.List;
28
29 import org.picocontainer.ComponentAdapter;
30 import org.picocontainer.PicoContainer;
31 import org.picocontainer.PicoException;
32 import org.picocontainer.PicoRegistrationException;
33 import org.picocontainer.defaults.ComponentAdapterFactory;
34 import org.picocontainer.defaults.DefaultPicoContainer;
35
36 /***
37 * <p>
38 * The services container is a extension of DefaultPicoContainer.
39 * </p>
40 *
41 * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
42 * @version $Revision: 1.12 $ $Date: 2005/05/22 06:46:49 $
43 * @version Revision: 1.0
44 */
45
46 public class ServiceContainer extends DefaultPicoContainer {
47
48 private static ServiceContainer serviceContainer;
49
50 public static ServiceContainer getInstance() {
51 if (serviceContainer == null) {
52
53 serviceContainer = new ServiceContainer();
54 }
55 return serviceContainer;
56 }
57
58 /***
59 * Creates a new container with a custom ComponentAdapterFactory and a
60 * parent container.
61 *
62 * @param componentAdapterFactory
63 * @param parent
64 */
65 public ServiceContainer(ComponentAdapterFactory componentAdapterFactory,
66 PicoContainer parent) {
67 super(componentAdapterFactory, parent);
68 }
69
70 /***
71 * Creates a new container with a parent container.
72 *
73 * @param parent
74 */
75 public ServiceContainer(PicoContainer parent) {
76 super(parent);
77 }
78
79 /***
80 * Default Container.
81 *
82 * @param parent
83 */
84 public ServiceContainer() {
85 super();
86 }
87
88 /***
89 * @see org.picocontainer.MutablePicoContainer#registerComponentImplementation(java.lang.Object)
90 */
91 public ComponentAdapter registerServiceImplementation(Class serviceImpl)
92 throws PicoRegistrationException {
93 return super.registerComponentImplementation(serviceImpl);
94
95 }
96
97 /***
98 * @see org.picocontainer.defaults.DefaultPicoContainer#registerComponentImplementation(java.lang.Object,
99 * java.lang.Class, java.util.List)
100 */
101 public ComponentAdapter registerServiceImplementation(Object serviceKey,
102 Class serviceImpl, List parameters)
103 throws PicoRegistrationException {
104 return super.registerComponentImplementation(serviceKey, serviceImpl,
105 parameters);
106 }
107
108 /***
109 * @see org.picocontainer.MutablePicoContainer#registerComponentImplementation(java.lang.Object,
110 * java.lang.Class)
111 */
112 public ComponentAdapter registerServiceImplementation(Object serviceKey,
113 Class serviceImpl) throws PicoRegistrationException {
114 return super.registerComponentImplementation(serviceKey, serviceImpl);
115 }
116
117 /***
118 * @see org.picocontainer.MutablePicoContainer#registerComponentInstance(java.lang.Object,
119 * java.lang.Object)
120 */
121 public ComponentAdapter registerServiceInstance(Object serviceKey,
122 Object serviceInstance) throws PicoRegistrationException {
123 return super.registerComponentInstance(serviceKey, serviceInstance);
124 }
125
126 /***
127 * @see org.picocontainer.MutablePicoContainer#registerComponentInstance(java.lang.Object)
128 */
129 public ComponentAdapter registerServiceInstance(Object serviceInstance)
130 throws PicoRegistrationException {
131 return super.registerComponentInstance(serviceInstance);
132 }
133
134 /***
135 * @see org.picocontainer.PicoContainer#getComponentInstance(java.lang.Object)
136 */
137 public Object getService(Object serviceKey) throws PicoException {
138 return super.getComponentInstance(serviceKey);
139 }
140
141 /***
142 * @see org.picocontainer.PicoContainer#getComponentInstanceOfType(java.lang.Class)
143 */
144 public Object getServiceOfType(Class serviceType) {
145 return super.getComponentInstanceOfType(serviceType);
146 }
147
148 /***
149 * Unregister service.
150 *
151 * @param service
152 * @return ComponentAdapter
153 */
154 public ComponentAdapter unregisterService(Object service) {
155 return super.unregisterComponent(service);
156 }
157 }