| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.kuali.rice.kim.service; |
| 18 | |
|
| 19 | |
import org.apache.log4j.Logger; |
| 20 | |
import org.kuali.rice.core.api.config.module.RunMode; |
| 21 | |
import org.kuali.rice.core.api.config.property.ConfigContext; |
| 22 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
| 23 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
| 24 | |
import org.kuali.rice.kim.bo.KimType; |
| 25 | |
import org.kuali.rice.kim.service.support.KimTypeService; |
| 26 | |
import org.kuali.rice.kim.util.KimCommonUtils; |
| 27 | |
import org.kuali.rice.kim.util.KimConstants; |
| 28 | |
|
| 29 | |
import javax.xml.namespace.QName; |
| 30 | |
|
| 31 | 0 | public class KIMServiceLocatorWeb { |
| 32 | 0 | private static final Logger LOG = Logger.getLogger(KIMServiceLocatorWeb.class); |
| 33 | |
|
| 34 | |
public static final String KIM_RUN_MODE_PROPERTY = "kim.mode"; |
| 35 | |
public static final String KIM_TYPE_INFO_SERVICE = "kimTypeInfoService"; |
| 36 | |
|
| 37 | |
public static Object getService(String serviceName) { |
| 38 | 0 | return getBean(serviceName); |
| 39 | |
} |
| 40 | |
|
| 41 | |
public static Object getBean(String serviceName) { |
| 42 | 0 | if (LOG.isDebugEnabled()) { |
| 43 | 0 | LOG.debug("Fetching service " + serviceName); |
| 44 | |
} |
| 45 | 0 | return GlobalResourceLoader.getResourceLoader().getService( |
| 46 | |
(RunMode.REMOTE.equals(RunMode.valueOf(ConfigContext.getCurrentContextConfig().getProperty(KIM_RUN_MODE_PROPERTY)))) ? |
| 47 | |
new QName(KimConstants.KIM_MODULE_NAMESPACE, serviceName) : new QName(serviceName)); |
| 48 | |
} |
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
public static KimTypeService getKimTypeService(KimType kimType) { |
| 56 | 0 | if( kimType == null ) { |
| 57 | 0 | LOG.warn( "null KimType passed into getKimTypeService" ); |
| 58 | 0 | return null; |
| 59 | |
} |
| 60 | 0 | return getKimTypeService(KimCommonUtils.resolveKimTypeServiceName(kimType.getKimTypeServiceName())); |
| 61 | |
} |
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
public static KimTypeService getKimTypeService(QName kimTypeServiceName) { |
| 70 | 0 | if (kimTypeServiceName == null) { |
| 71 | 0 | throw new IllegalArgumentException("Invalid service name passed, value was null."); |
| 72 | |
} |
| 73 | |
try { |
| 74 | 0 | return (KimTypeService) GlobalResourceLoader.getService(kimTypeServiceName); |
| 75 | 0 | } catch (Exception exception) { |
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | 0 | LOG.error("Unable to find KIM type service with name: " + kimTypeServiceName, exception); |
| 81 | 0 | return null; |
| 82 | |
} |
| 83 | |
} |
| 84 | |
|
| 85 | |
public static KimTypeInfoService getTypeInfoService() { |
| 86 | 0 | return (KimTypeInfoService) getService(KIM_TYPE_INFO_SERVICE); |
| 87 | |
} |
| 88 | |
} |