001
014
015 package com.liferay.portal.struts;
016
017 import com.liferay.portal.kernel.struts.BaseStrutsAction;
018 import com.liferay.portal.util.ClassLoaderUtil;
019
020 import javax.servlet.http.HttpServletRequest;
021 import javax.servlet.http.HttpServletResponse;
022
023 import org.apache.struts.action.Action;
024 import org.apache.struts.action.ActionForm;
025 import org.apache.struts.action.ActionForward;
026 import org.apache.struts.action.ActionMapping;
027
028
031 public class StrutsActionAdapter extends BaseStrutsAction {
032
033 public StrutsActionAdapter(
034 Action action, ActionMapping actionMapping, ActionForm actionForm) {
035
036 _action = action;
037 _actionMapping = actionMapping;
038 _actionForm = actionForm;
039 }
040
041 @Override
042 public String execute(
043 HttpServletRequest request, HttpServletResponse response)
044 throws Exception {
045
046 Thread currentThread = Thread.currentThread();
047
048 ClassLoader contextClassLoader = currentThread.getContextClassLoader();
049
050 currentThread.setContextClassLoader(
051 ClassLoaderUtil.getPortalClassLoader());
052
053 try {
054 ActionForward actionForward = _action.execute(
055 _actionMapping, _actionForm, request, response);
056
057 if (actionForward == null) {
058 return null;
059 }
060
061 return actionForward.getPath();
062 }
063 finally {
064 currentThread.setContextClassLoader(contextClassLoader);
065 }
066 }
067
068 private Action _action;
069 private ActionForm _actionForm;
070 private ActionMapping _actionMapping;
071
072 }