mirror of
https://github.com/apache/struts.git
synced 2026-08-07 15:46:57 +00:00
WW-4173 Passes current ActionInvocation to allow based disabling interceptor on it
This commit is contained in:
@@ -248,11 +248,11 @@ public class DefaultActionInvocation implements ActionInvocation {
|
||||
if (interceptor instanceof WithLazyParams) {
|
||||
interceptor = lazyParamInjector.injectParams(interceptor, interceptorMapping.getParams(), invocationContext);
|
||||
}
|
||||
if (interceptor.isDisabled()) {
|
||||
if (interceptor.isDisabled(this)) {
|
||||
LOG.debug("Interceptor: {} is disabled, skipping to next", interceptor.getClass().getSimpleName());
|
||||
resultCode = this.invoke();
|
||||
} else {
|
||||
resultCode = interceptor.intercept(DefaultActionInvocation.this);
|
||||
resultCode = interceptor.intercept(this);
|
||||
}
|
||||
} else {
|
||||
resultCode = invokeActionOnly();
|
||||
|
||||
@@ -49,7 +49,7 @@ public abstract class AbstractInterceptor implements Interceptor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
public boolean isDisabled(ActionInvocation invocation) {
|
||||
return this.disabled;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,8 +222,9 @@ public interface Interceptor extends Serializable {
|
||||
/**
|
||||
* Allows to disable processing a given interceptor
|
||||
*
|
||||
* @param invocation current {@link ActionInvocation} to determine if the interceptor should be executed
|
||||
* @return true if the given interceptor should be skipped
|
||||
* @since 6.1.0
|
||||
*/
|
||||
boolean isDisabled();
|
||||
boolean isDisabled(ActionInvocation invocation);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class CoepInterceptor extends AbstractInterceptor implements PreResultLis
|
||||
|
||||
@Override
|
||||
public String intercept(ActionInvocation invocation) throws Exception {
|
||||
if (this.isDisabled()) {
|
||||
if (this.isDisabled(invocation)) {
|
||||
LOG.trace("COEP interceptor has been disabled");
|
||||
} else {
|
||||
invocation.addPreResultListener(this);
|
||||
@@ -61,7 +61,7 @@ public class CoepInterceptor extends AbstractInterceptor implements PreResultLis
|
||||
|
||||
@Override
|
||||
public void beforeResult(ActionInvocation invocation, String resultCode) {
|
||||
if (this.isDisabled()) {
|
||||
if (this.isDisabled(invocation)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class CoopInterceptor extends AbstractInterceptor implements PreResultLis
|
||||
|
||||
@Override
|
||||
public String intercept(ActionInvocation invocation) throws Exception {
|
||||
if (this.isDisabled()) {
|
||||
if (this.isDisabled(invocation)) {
|
||||
LOG.trace("COOP interceptor has been disabled");
|
||||
} else {
|
||||
invocation.addPreResultListener(this);
|
||||
@@ -63,7 +63,7 @@ public class CoopInterceptor extends AbstractInterceptor implements PreResultLis
|
||||
|
||||
@Override
|
||||
public void beforeResult(ActionInvocation invocation, String resultCode) {
|
||||
if (this.isDisabled()) {
|
||||
if (this.isDisabled(invocation)) {
|
||||
return;
|
||||
}
|
||||
HttpServletRequest request = invocation.getInvocationContext().getServletRequest();
|
||||
|
||||
@@ -62,7 +62,7 @@ public class FetchMetadataInterceptor extends AbstractInterceptor {
|
||||
|
||||
@Override
|
||||
public String intercept(ActionInvocation invocation) throws Exception {
|
||||
if (this.isDisabled()) {
|
||||
if (this.isDisabled(invocation)) {
|
||||
LOG.trace("Fetch Metadata interceptor has been disabled");
|
||||
return invocation.invoke();
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public final class CspInterceptor extends AbstractInterceptor implements PreResu
|
||||
|
||||
@Override
|
||||
public String intercept(ActionInvocation invocation) throws Exception {
|
||||
if (this.isDisabled()) {
|
||||
if (this.isDisabled(invocation)) {
|
||||
LOG.trace("CSP interceptor has been disabled");
|
||||
} else {
|
||||
invocation.addPreResultListener(this);
|
||||
@@ -56,7 +56,7 @@ public final class CspInterceptor extends AbstractInterceptor implements PreResu
|
||||
}
|
||||
|
||||
public void beforeResult(ActionInvocation invocation, String resultCode) {
|
||||
if (this.isDisabled()) {
|
||||
if (this.isDisabled(invocation)) {
|
||||
return;
|
||||
}
|
||||
HttpServletRequest request = invocation.getInvocationContext().getServletRequest();
|
||||
|
||||
Reference in New Issue
Block a user