View Javadoc

1   /**
2    * Copyright 2005-2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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.kuali.rice.kim.api.services;
17  
18  import org.apache.log4j.Logger;
19  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
20  import org.kuali.rice.kim.api.identity.IdentityService;
21  import org.kuali.rice.kim.api.responsibility.ResponsibilityService;
22  import org.kuali.rice.kim.api.role.RoleService;
23  import org.kuali.rice.kim.api.type.KimTypeInfoService;
24  import org.kuali.rice.kim.api.permission.PermissionService;
25  import org.kuali.rice.kim.api.identity.PersonService;
26  
27  public class KimApiServiceLocator {
28      private static final Logger LOG = Logger.getLogger(KimApiServiceLocator.class);
29  
30      public static final String KIM_GROUP_SERVICE = "kimGroupService";
31      public static final String KIM_IDENTITY_SERVICE = "kimIdentityService";
32      public static final String KIM_PERMISSION_SERVICE = "kimPermissionService";
33      public static final String KIM_RESPONSIBILITY_SERVICE = "kimResponsibilityService";
34      public static final String KIM_ROLE_SERVICE = "kimRoleService";
35      public static final String KIM_PERSON_SERVICE = "personService";
36      public static final String KIM_TYPE_INFO_SERVICE = "kimTypeInfoService";
37  
38      static <T> T getService(String serviceName) {
39          return GlobalResourceLoader.<T>getService(serviceName);
40      }
41  
42      public static KimTypeInfoService getKimTypeInfoService() {
43          return getService(KIM_TYPE_INFO_SERVICE);
44      }
45  
46      public static PersonService getPersonService() {
47          if (LOG.isDebugEnabled()) {
48              LOG.debug("Fetching service " + KIM_PERSON_SERVICE);
49          }
50          return getService(KIM_PERSON_SERVICE);
51      }
52  
53      public static RoleService getRoleService() {
54          return getService(KIM_ROLE_SERVICE);
55      }
56      
57      public static org.kuali.rice.kim.api.group.GroupService getGroupService() {
58      	return getService(KIM_GROUP_SERVICE);
59      }
60      
61      public static IdentityService getIdentityService() {
62      	return getService(KIM_IDENTITY_SERVICE);
63      }
64      public static PermissionService getPermissionService() {
65      	return getService(KIM_PERMISSION_SERVICE);
66      }
67      public static ResponsibilityService getResponsibilityService() {
68      	return getService(KIM_RESPONSIBILITY_SERVICE);
69      }
70  }