1
19
20 package com.liferay.portal.kernel.bean;
21
22 import com.liferay.portal.kernel.log.Log;
23 import com.liferay.portal.kernel.log.LogFactoryUtil;
24
25 import java.util.HashMap;
26 import java.util.Map;
27
28
34 public class PortletBeanLocatorUtil {
35
36 public static BeanLocator getBeanLocator(String servletContextName) {
37 return _beanLocators.get(servletContextName);
38 }
39
40 public static Object locate(String servletContextName, String name)
41 throws BeanLocatorException {
42
43 BeanLocator beanLocator = getBeanLocator(servletContextName);
44
45 if (beanLocator == null) {
46 _log.error("BeanLocator is null");
47
48 throw new BeanLocatorException("BeanLocator has not been set");
49 }
50 else {
51 return beanLocator.locate(name);
52 }
53 }
54
55 public static void setBeanLocator(
56 String servletContextName, BeanLocator beanLocator) {
57
58 if (_log.isDebugEnabled()) {
59 _log.debug("Setting BeanLocator " + beanLocator.hashCode());
60 }
61
62 _beanLocators.put(servletContextName, beanLocator);
63 }
64
65 private static Log _log =
66 LogFactoryUtil.getLog(PortletBeanLocatorUtil.class);
67
68 private static Map<String, BeanLocator> _beanLocators =
69 new HashMap<String, BeanLocator>();
70
71 }