001
014
015 package com.liferay.portal.kernel.spring.context;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.kernel.servlet.PortalClassLoaderServletContextListener;
020 import com.liferay.portal.kernel.util.PortalClassInvoker;
021 import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
022
023 import javax.servlet.ServletContext;
024 import javax.servlet.ServletContextListener;
025
026
029 public class PortletContextLoaderListener
030 extends PortalClassLoaderServletContextListener {
031
032 public static String getLockKey(ServletContext servletContext) {
033 return getLockKey(servletContext.getContextPath());
034 }
035
036 public static String getLockKey(String contextPath) {
037 try {
038 Object returnValue = PortalClassInvoker.invoke(
039 false, _CLASS_NAME, "getLockKey",
040 new String[] {String.class.getName()}, contextPath);
041
042 return String.valueOf(returnValue);
043 }
044 catch (Exception e) {
045 _log.error(e, e);
046
047 throw new IllegalStateException("Unable to get lock key", e);
048 }
049 }
050
051 @Override
052 protected ServletContextListener getInstance() throws Exception {
053 Class<?> clazz = Class.forName(
054 _CLASS_NAME, true, PortalClassLoaderUtil.getClassLoader());
055
056 return (ServletContextListener)clazz.newInstance();
057 }
058
059 private static final String _CLASS_NAME =
060 "com.liferay.portal.spring.context.PortletContextLoaderListener";
061
062 private static Log _log = LogFactoryUtil.getLog(
063 PortletContextLoaderListener.class.getName());
064
065 }