001
014
015 package com.liferay.portal.server.capabilities;
016
017 import com.liferay.portal.kernel.util.ReflectionUtil;
018
019 import java.lang.reflect.Field;
020
021 import javax.servlet.ServletContext;
022
023
027 public class TomcatServerCapabilities implements ServerCapabilities {
028
029 public void determine(ServletContext servletContext) throws Exception {
030 determineSupportsHotDeploy(servletContext);
031 }
032
033 public boolean isSupportsHotDeploy() {
034 return _supportsHotDeploy;
035 }
036
037 protected void determineSupportsHotDeploy(ServletContext servletContext)
038 throws Exception {
039
040
041
042 Class<?> applicationContextFacadeClass = servletContext.getClass();
043
044 Field contextField1 = ReflectionUtil.getDeclaredField(
045 applicationContextFacadeClass, "context");
046
047 Object contextValue1 = contextField1.get(servletContext);
048
049
050
051 Class<?> applicationContextClass = contextField1.getType();
052
053 Field contextField2 = ReflectionUtil.getDeclaredField(
054 applicationContextClass, "context");
055
056 Object contextValue2 = contextField2.get(contextValue1);
057
058
059
060 Class<?> standardContextClass = contextField2.getType();
061
062
063
064 Class<?> containerBaseClass = standardContextClass.getSuperclass();
065
066 Field parentField = ReflectionUtil.getDeclaredField(
067 containerBaseClass, "parent");
068
069 Object parentValue = parentField.get(contextValue2);
070
071 Field autoDeployField = ReflectionUtil.getDeclaredField(
072 parentValue.getClass(), "autoDeploy");
073
074 Boolean autoDeployValue = (Boolean)autoDeployField.get(parentValue);
075
076 _supportsHotDeploy = autoDeployValue;
077 }
078
079 private boolean _supportsHotDeploy;
080
081 }