EMMA Coverage Report (generated Fri Sep 15 10:32:43 EDT 2006)
[all classes][edu.iu.uis.sit.portal]

COVERAGE SUMMARY FOR SOURCE FILE [SpringServiceLocator.java]

nameclass, %method, %block, %line, %
SpringServiceLocator.java0%   (0/1)0%   (0/11)0%   (0/70)0%   (0/23)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SpringServiceLocator0%   (0/1)0%   (0/11)0%   (0/70)0%   (0/23)
<static initializer> 0%   (0/1)0%   (0/3)0%   (0/1)
SpringServiceLocator (): void 0%   (0/1)0%   (0/3)0%   (0/1)
close (): void 0%   (0/1)0%   (0/7)0%   (0/3)
getAclService (): AclService 0%   (0/1)0%   (0/4)0%   (0/1)
getAppContext (): ApplicationContext 0%   (0/1)0%   (0/2)0%   (0/1)
getCacheService (): CacheService 0%   (0/1)0%   (0/4)0%   (0/1)
getPersonalizeService (): PersonalizeService 0%   (0/1)0%   (0/4)0%   (0/1)
getService (String): Object 0%   (0/1)0%   (0/22)0%   (0/6)
getUserService (): UserService 0%   (0/1)0%   (0/4)0%   (0/1)
initializeAppContexts (String): void 0%   (0/1)0%   (0/14)0%   (0/5)
setAppContext (ApplicationContext): void 0%   (0/1)0%   (0/3)0%   (0/2)

1/*
2 * Copyright (c) 2003, 2004, 2005, 2006 Trustees of Indiana University.
3 *
4 * Licensed under the Educational Community License Version 1.0 (the "License"); By obtaining,
5 * using and/or copying this Original Work, you agree that you have read, understand, and will
6 * comply with the terms and conditions of the Educational Community License.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
9 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
10 * AND NONINFRINGEMENT.
11 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
12 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
13 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14 */
15package edu.iu.uis.sit.portal;
16 
17import org.springframework.beans.factory.BeanFactory;
18import org.springframework.beans.factory.access.BeanFactoryLocator;
19import org.springframework.beans.factory.access.BeanFactoryReference;
20import org.springframework.beans.factory.access.SingletonBeanFactoryLocator;
21import org.springframework.context.ApplicationContext;
22import org.springframework.context.ConfigurableApplicationContext;
23 
24import edu.iu.uis.sit.portal.cache.service.CacheService;
25import edu.iu.uis.sit.portal.portlet.personalize.services.PersonalizeService;
26import edu.iu.uis.sit.portal.user.service.AclService;
27import edu.iu.uis.sit.portal.user.service.UserService;
28 
29public class SpringServiceLocator {
30 
31        private static ApplicationContext appContext;
32 
33        private static boolean initializationBegan = false;
34 
35        public static final String ACL_SRV = "myAclService";
36 
37        public static final String USER_SRV = "myUserService";
38 
39        public static final String PERSONALIZE_SRV = "myPersonalizeService";
40 
41        public static final String CACHE_SRV = "myCacheService";
42 
43        public static Object getService(String serviceName) {
44                if (appContext == null && !initializationBegan) {
45                        initializationBegan = true;
46                        initializeAppContexts("Spring.xml");
47                } else if (appContext == null && initializationBegan) {
48                        throw new RuntimeException("Spring not initialized properly.  Initialization has begun and the application context is null." + "Probably spring loaded bean is trying to use SpringServiceLocator before the application context is initialized.");
49                }
50 
51                return appContext.getBean(serviceName);
52        }
53 
54        public static void close() {
55                if (appContext instanceof ConfigurableApplicationContext) {
56                        ((ConfigurableApplicationContext) appContext).close();
57                }
58        }
59 
60        public static void setAppContext(ApplicationContext newAppContext) {
61                appContext = newAppContext;
62        }
63 
64        public static ApplicationContext getAppContext() {
65                return appContext;
66        }
67 
68        protected static void initializeAppContexts(String rootContextFile) {
69                BeanFactoryLocator bfLocator = SingletonBeanFactoryLocator.getInstance(rootContextFile);
70                BeanFactoryReference bfReference = bfLocator.useBeanFactory("appContext");
71                BeanFactory factory = bfReference.getFactory();
72                appContext = (ApplicationContext) factory;
73        }
74 
75        public static AclService getAclService() {
76                return (AclService) getService(ACL_SRV);
77        }
78 
79        public static UserService getUserService() {
80                return (UserService) getService(USER_SRV);
81        }
82 
83        public static PersonalizeService getPersonalizeService() {
84                return (PersonalizeService) getService(PERSONALIZE_SRV);
85        }
86 
87        public static CacheService getCacheService() {
88                return (CacheService) getService(CACHE_SRV);
89        }
90}

[all classes][edu.iu.uis.sit.portal]
EMMA 2.0.5312 (C) Vladimir Roubtsov