Clover coverage report - JFox Service-Oriented Application Framework - 1.0-RC3 Coverage timestamp: 星期三 二月 15 2006 18:10:22 CST FRAMES NO FRAMES |
file stats: | LOC: | 137 |  | Methods: | 9
| NCLOC: | 43 |  | Classes: | 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
Source file | Conditionals | Statements | Methods | TOTAL
ServiceFactory.java | 100% | 60% | 55.6% | 61.9% |

1 |  |
     /**
2 |  |
      * @(#)ServiceFactory.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 org.huihoo.jfox.soaf.exception.ServiceConfigurationException;
28 |  |
     import org.picocontainer.PicoException;
29 |  |
     import org.picocontainer.PicoRegistrationException;
30 |  |
31 |  |
     /**
32 |  |
      * <p>
33 |  |
      * The ServiceFactory is a singleton wrapper on the service container instance.
34 |  |
      * </p>
35 |  |
      *
36 |  |
      * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
37 |  |
      * @version $Revision: 1.16 $ $Date: 2006/02/15 08:45:45 $
38 |  |
      * @version Revision: 1.0
39 |  |
      */
40 |  |
41 |  |
     public class ServiceFactory {
42 |  |
43 |  |
         private static ServiceFactory serviceFactory;
44 |  |
45 |  |
         private ServiceContainer serviceContainer = ServiceContainer.getInstance();
46 |  |
47 |  |
         private ManageableServiceContainer manageableServiceContainer = ManageableServiceContainer
48 |  |
                 .getInstance();
49 |  |
50 |  |
         /**
51 |  |
          * Singleton instance.
52 |  |
          */
53 | 108 |
         public static synchronized ServiceFactory getInstance() {
54 | 108 |
             if (serviceFactory == null) {
55 | 13 |
                 serviceFactory = new ServiceFactory();
56 |  |
             }
57 | 108 |
             return serviceFactory;
58 |  |
         }
59 |  |
60 |  |
         /**
61 |  |
          * Default Constructor.
62 |  |
          */
63 | 13 |
         public ServiceFactory() {
64 |  |
         }
65 |  |
66 |  |
         /**
67 |  |
          * Lookup service by serviceKey
68 |  |
          *
69 |  |
          * @param componentKey
70 |  |
          * @return Service Object
71 |  |
          */
72 | 1 |
         public synchronized Object getService(Object serviceKey)
73 |  |
                 throws PicoException, ServiceConfigurationException {
74 | 1 |
             return serviceContainer.getService(serviceKey);
75 |  |
         }
76 |  |
77 |  |
         /**
78 |  |
          * Lookup service by serviceType
79 |  |
          *
80 |  |
          * @param componentKey
81 |  |
          * @return Service Object
82 |  |
          */
83 | 195 |
         public synchronized Object getService(Class serviceType)
84 |  |
                 throws PicoException {
85 | 195 |
             return serviceContainer.getServiceOfType(serviceType);
86 |  |
         }
87 |  |
88 |  |
         /**
89 |  |
          * Unregister service.
90 |  |
          *
91 |  |
          * @param service
92 |  |
          */
93 | 1 |
         public void unRegisterService(Object service) {
94 | 1 |
             serviceContainer.unregisterComponent(service);
95 |  |
         }
96 |  |
97 |  |
         /**
98 |  |
          * Unregister service instance.
99 |  |
          *
100 |  |
          * @param serviceInstance
101 |  |
          */
102 | 0 |
         public void unRegisterServiceInstance(Object serviceInstance) {
103 | 0 |
             serviceContainer.unregisterComponentByInstance(serviceInstance);
104 |  |
         }
105 |  |
106 |  |
         /**
107 |  |
          * Register service implementation.
108 |  |
          *
109 |  |
          * @param service
110 |  |
          */
111 | 0 |
         public void registerService(Class serviceImpl)
112 |  |
                 throws PicoRegistrationException {
113 | 0 |
             serviceContainer.registerServiceImplementation(serviceImpl);
114 |  |
         }
115 |  |
116 |  |
         /**
117 |  |
          * Register service with service key.
118 |  |
          *
119 |  |
          * @param serviceKey
120 |  |
          * @param serviceImpl
121 |  |
          */
122 | 0 |
         public void registerService(Object serviceKey, Class serviceImpl)
123 |  |
                 throws PicoRegistrationException {
124 | 0 |
             serviceContainer.registerServiceImplementation(serviceKey, serviceImpl);
125 |  |
         }
126 |  |
127 |  |
         /**
128 |  |
          * Register service instance.
129 |  |
          *
130 |  |
          * @param serviceInstance
131 |  |
          */
132 | 0 |
         public void registerServiceInstance(Object serviceInstance)
133 |  |
                 throws PicoRegistrationException {
134 | 0 |
             serviceContainer.registerServiceInstance(serviceInstance);
135 |  |
         }
136 |  |
137 |  |
     }