mirror of
https://github.com/apache/struts.git
synced 2026-08-06 15:17:00 +00:00
Uses AbstractInterceptor instead of leaving init() and destroy() empty
This commit is contained in:
+2
-8
@@ -24,23 +24,17 @@ package org.apache.struts2.showcase.chat;
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.struts2.dispatcher.SessionMap;
|
||||
|
||||
public class ChatAuthenticationInterceptor implements Interceptor {
|
||||
public class ChatAuthenticationInterceptor extends AbstractInterceptor {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger LOG = LogManager.getLogger(ChatAuthenticationInterceptor.class);
|
||||
public static final String USER_SESSION_KEY = "chatUserSessionKey";
|
||||
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
public void init() {
|
||||
}
|
||||
|
||||
public String intercept(ActionInvocation invocation) throws Exception {
|
||||
|
||||
LOG.debug("Authenticating chat user");
|
||||
|
||||
@@ -23,7 +23,7 @@ package org.apache.struts2.showcase.chat;
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
@@ -32,7 +32,7 @@ import javax.servlet.http.HttpSession;
|
||||
/**
|
||||
* Authenticate showcase chat example, make sure everyone have a username.
|
||||
*/
|
||||
public class ChatInterceptor implements Interceptor {
|
||||
public class ChatInterceptor extends AbstractInterceptor {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(ChatInterceptor.class);
|
||||
|
||||
@@ -40,12 +40,6 @@ public class ChatInterceptor implements Interceptor {
|
||||
|
||||
public static final String CHAT_USER_SESSION_KEY = "ChatUserSessionKey";
|
||||
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
public void init() {
|
||||
}
|
||||
|
||||
public String intercept(ActionInvocation invocation) throws Exception {
|
||||
HttpSession session = (HttpSession) ActionContext.getContext().get(ActionContext.SESSION);
|
||||
User chatUser = (User) session.getAttribute(CHAT_USER_SESSION_KEY);
|
||||
|
||||
@@ -16,16 +16,15 @@
|
||||
package com.opensymphony.xwork2.mock;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
||||
import org.junit.Assert;
|
||||
|
||||
|
||||
/**
|
||||
* Mock for an {@link com.opensymphony.xwork2.interceptor.Interceptor}.
|
||||
*
|
||||
* @author Jason Carreira
|
||||
*/
|
||||
public class MockInterceptor implements Interceptor {
|
||||
public class MockInterceptor extends AbstractInterceptor {
|
||||
|
||||
private static final long serialVersionUID = 2692551676567227756L;
|
||||
|
||||
@@ -57,12 +56,6 @@ public class MockInterceptor implements Interceptor {
|
||||
return foo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to let an interceptor clean up any resources it has allocated.
|
||||
*/
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
@@ -101,13 +94,6 @@ public class MockInterceptor implements Interceptor {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after an Interceptor is created, but before any requests are processed using the intercept() methodName. This
|
||||
* gives the Interceptor a chance to initialize any needed resources.
|
||||
*/
|
||||
public void init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the Interceptor to do some processing on the request before and/or after the rest of the processing of the
|
||||
* request by the DefaultActionInvocation or to short-circuit the processing and just return a String return code.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.apache.struts2.interceptor;
|
||||
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.dispatcher.Parameter;
|
||||
@@ -12,7 +12,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class DateTextFieldInterceptor implements Interceptor {
|
||||
public class DateTextFieldInterceptor extends AbstractInterceptor {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(DateTextFieldInterceptor.class);
|
||||
|
||||
@@ -56,12 +56,6 @@ public class DateTextFieldInterceptor implements Interceptor {
|
||||
return values();
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
public void init() {
|
||||
}
|
||||
|
||||
public String intercept(ActionInvocation ai) throws Exception {
|
||||
HttpParameters parameters = ai.getInvocationContext().getParameters();
|
||||
|
||||
@@ -24,7 +24,7 @@ package org.apache.struts2.rest;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.ModelDriven;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.rest.handler.ContentTypeHandler;
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.io.InputStreamReader;
|
||||
/**
|
||||
* Uses the content handler to apply the request body to the action
|
||||
*/
|
||||
public class ContentTypeInterceptor implements Interceptor {
|
||||
public class ContentTypeInterceptor extends AbstractInterceptor {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
ContentTypeHandlerManager selector;
|
||||
@@ -45,10 +45,6 @@ public class ContentTypeInterceptor implements Interceptor {
|
||||
this.selector = sel;
|
||||
}
|
||||
|
||||
public void destroy() {}
|
||||
|
||||
public void init() {}
|
||||
|
||||
public String intercept(ActionInvocation invocation) throws Exception {
|
||||
HttpServletRequest request = ServletActionContext.getRequest();
|
||||
ContentTypeHandler handler = selector.getHandlerForRequest(request);
|
||||
|
||||
Reference in New Issue
Block a user