001
014
015 package com.liferay.util.bean;
016
017 import com.liferay.portal.kernel.bean.BeanLocator;
018 import com.liferay.portal.kernel.bean.BeanLocatorException;
019 import com.liferay.portal.kernel.log.Log;
020 import com.liferay.portal.kernel.log.LogFactoryUtil;
021
022
025 public class PortletBeanLocatorUtil {
026
027 public static BeanLocator getBeanLocator() {
028 return _beanLocator;
029 }
030
031 public static Object locate(String name) throws BeanLocatorException {
032 if (_beanLocator == null) {
033 _log.error("BeanLocator is null");
034
035 throw new BeanLocatorException("BeanLocator has not been set");
036 }
037 else {
038 return _beanLocator.locate(name);
039 }
040 }
041
042 public static void setBeanLocator(BeanLocator beanLocator) {
043 if (_log.isDebugEnabled()) {
044 if (beanLocator != null) {
045 _log.debug("Setting BeanLocator " + beanLocator.hashCode());
046 }
047 else {
048 _log.debug("Setting BeanLocator null");
049 }
050 }
051
052 _beanLocator = beanLocator;
053 }
054
055 private static Log _log = LogFactoryUtil.getLog(
056 PortletBeanLocatorUtil.class);
057
058 private static BeanLocator _beanLocator;
059
060 }