org.apache.struts2.portlet.interceptor
public class: PortletAwareInterceptor [javadoc |
source]
java.lang.Object
com.opensymphony.xwork2.interceptor.AbstractInterceptor
org.apache.struts2.portlet.interceptor.PortletAwareInterceptor
All Implemented Interfaces:
PortletActionConstants, StrutsStatics
Method from org.apache.struts2.portlet.interceptor.PortletAwareInterceptor Summary: |
---|
intercept |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from org.apache.struts2.portlet.interceptor.PortletAwareInterceptor Detail: |
public String intercept(ActionInvocation invocation) throws Exception {
final Object action = invocation.getAction();
final ActionContext context = invocation.getInvocationContext();
if (action instanceof PortletRequestAware) {
PortletRequest request = (PortletRequest) context.get(REQUEST);
((PortletRequestAware) action).setPortletRequest(request);
}
if (action instanceof PortletResponseAware) {
PortletResponse response = (PortletResponse) context.get(RESPONSE);
((PortletResponseAware) action).setPortletResponse(response);
}
if (action instanceof PrincipalAware) {
PortletRequest request = (PortletRequest) context.get(REQUEST);
((PrincipalAware) action).setPrincipalProxy(new PortletPrincipalProxy(request));
}
if (action instanceof PortletContextAware) {
PortletContext portletContext = (PortletContext) context.get(STRUTS_PORTLET_CONTEXT);
((PortletContextAware) action).setPortletContext(portletContext);
}
if (action instanceof PortletConfigAware) {
PortletConfig portletConfig = (PortletConfig)context.get(PORTLET_CONFIG);
((PortletConfigAware) action).setPortletConfig(portletConfig);
}
if (action instanceof PortletPreferencesAware) {
PortletRequest request = (PortletRequest) context.get(REQUEST);
// Check if running in a servlet environment
if (request == null) {
LOG.warn("This portlet preferences implementation should only be used during development");
((PortletPreferencesAware)action).setPortletPreferences(new ServletPortletPreferences(ActionContext.getContext().getSession()));
} else {
((PortletPreferencesAware)action).setPortletPreferences(request.getPreferences());
}
}
return invocation.invoke();
}
Sets action properties based on the interfaces an action implements. Things like application properties,
parameters, session attributes, etc are set based on the implementing interface. |