--- /dev/null
+/**\r
+ * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.\r
+ *\r
+ * This library is free software; you can redistribute it and/or modify it under\r
+ * the terms of the GNU Lesser General Public License as published by the Free\r
+ * Software Foundation; either version 2.1 of the License, or (at your option)\r
+ * any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful, but WITHOUT\r
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more\r
+ * details.\r
+ */\r
+\r
+package com.liferay.portal.kernel.bean;\r
+\r
+import com.liferay.portal.kernel.log.Log;\r
+import com.liferay.portal.kernel.log.LogFactoryUtil;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+/**\r
+ * @author Brian Wing Shun Chan\r
+ */\r
+public class PortletBeanLocatorUtil {\r
+\r
+ public static BeanLocator getBeanLocator(String servletContextName) {\r
+ return _beanLocators.get(servletContextName);\r
+ }\r
+\r
+ public static Object locate(String servletContextName, String name)\r
+ throws BeanLocatorException {\r
+\r
+ BeanLocator beanLocator = getBeanLocator(servletContextName);\r
+\r
+ if (beanLocator == null) {\r
+ _log.error(\r
+ "BeanLocator is null for servlet context " +\r
+ servletContextName);\r
+ \r
+ System.out.println();\r
+ System.out.println("*******************************************************");\r
+ System.out.println("PORTLET " + servletContextName + " NEED TO BE DEPLOYED");\r
+ System.out.println("*******************************************************");\r
+ System.out.println();\r
+ \r
+ throw new BeanLocatorException(\r
+ "BeanLocator has not been set for servlet context " +\r
+ servletContextName);\r
+ }\r
+ else {\r
+ return beanLocator.locate(name);\r
+ }\r
+ }\r
+\r
+ public static void setBeanLocator(\r
+ String servletContextName, BeanLocator beanLocator) {\r
+\r
+ if (_log.isDebugEnabled()) {\r
+ if (beanLocator != null) {\r
+ _log.debug(\r
+ "Setting BeanLocator " + beanLocator.hashCode() +\r
+ " for servlet context " + servletContextName);\r
+ }\r
+ else {\r
+ _log.debug(\r
+ "Removing BeanLocator for servlet context " +\r
+ servletContextName);\r
+ }\r
+ }\r
+\r
+ _beanLocators.put(servletContextName, beanLocator);\r
+ }\r
+\r
+ private static Log _log = LogFactoryUtil.getLog(\r
+ PortletBeanLocatorUtil.class);\r
+\r
+ private static Map<String, BeanLocator> _beanLocators =\r
+ new HashMap<String, BeanLocator>();\r
+\r
+}
\ No newline at end of file