Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WW-3714 Deprecate and repackage common APIs part 4 #1083

Merged
merged 6 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions core/src/main/java/com/opensymphony/xwork2/ActionContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ private ActionContext(org.apache.struts2.ActionContext actualContext) {
super(actualContext.getContextMap());
}

static ActionContext adapt(org.apache.struts2.ActionContext actualContext) {
public static ActionContext adapt(org.apache.struts2.ActionContext actualContext) {
if (actualContext instanceof ActionContext) {
return (ActionContext) actualContext;
}
return actualContext != null ? new ActionContext(actualContext) : null;
}

Expand Down Expand Up @@ -163,15 +166,19 @@ public Map<String, Object> getSession() {
return super.getSession();
}

@Override
public ActionContext withValueStack(ValueStack valueStack) {
return withValueStack((org.apache.struts2.util.ValueStack) valueStack);
}

@Override
public ActionContext withValueStack(org.apache.struts2.util.ValueStack valueStack) {
super.withValueStack(valueStack);
return this;
}

@Override
public ValueStack getValueStack() {
return super.getValueStack();
return ValueStack.adapt(super.getValueStack());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,24 @@
@Deprecated
public interface ActionEventListener extends org.apache.struts2.ActionEventListener {

@Override
default Object prepare(Object action, org.apache.struts2.util.ValueStack stack) {
return prepare(action, ValueStack.adapt(stack));
}

@Override
default String handleException(Throwable t, org.apache.struts2.util.ValueStack stack) {
return handleException(t, ValueStack.adapt(stack));
}

Object prepare(Object action, ValueStack stack);

String handleException(Throwable t, ValueStack stack);

static ActionEventListener adapt(org.apache.struts2.ActionEventListener actualListener) {
if (actualListener instanceof ActionEventListener) {
return (ActionEventListener) actualListener;
}
return actualListener != null ? new LegacyAdapter(actualListener) : null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public interface ActionInvocation extends org.apache.struts2.ActionInvocation {
@Override
ActionProxy getProxy();

@Override
ValueStack getStack();

@Override
default void addPreResultListener(org.apache.struts2.interceptor.PreResultListener listener) {
addPreResultListener(PreResultListener.adapt(listener));
Expand All @@ -60,6 +63,9 @@ default void init(org.apache.struts2.ActionProxy proxy) {
void init(ActionProxy proxy);

static ActionInvocation adapt(org.apache.struts2.ActionInvocation actualInvocation) {
if (actualInvocation instanceof ActionInvocation) {
return (ActionInvocation) actualInvocation;
}
return actualInvocation != null ? new LegacyAdapter(actualInvocation) : null;
}

Expand Down Expand Up @@ -108,7 +114,7 @@ public void setResultCode(String resultCode) {

@Override
public ValueStack getStack() {
return adaptee.getStack();
return ValueStack.adapt(adaptee.getStack());
}

@Override
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/com/opensymphony/xwork2/ActionProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public interface ActionProxy extends org.apache.struts2.ActionProxy {
ActionInvocation getInvocation();

static ActionProxy adapt(org.apache.struts2.ActionProxy actualProxy) {
if (actualProxy instanceof ActionProxy) {
return (ActionProxy) actualProxy;
}
return actualProxy != null ? new LegacyAdapter(actualProxy) : null;
}

Expand Down
16 changes: 3 additions & 13 deletions core/src/main/java/com/opensymphony/xwork2/ModelDriven.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,8 @@
package com.opensymphony.xwork2;

/**
* ModelDriven Actions provide a model object to be pushed onto the ValueStack
* in addition to the Action itself, allowing a FormBean type approach like Struts.
*
* @author Jason Carreira
* @deprecated since 6.7.0, use {@link org.apache.struts2.ModelDriven} instead.
*/
public interface ModelDriven<T> {

/**
* Gets the model to be pushed onto the ValueStack instead of the Action itself.
*
* @return the model
*/
T getModel();

@Deprecated
public interface ModelDriven<T> extends org.apache.struts2.ModelDriven<T> {
}
17 changes: 3 additions & 14 deletions core/src/main/java/com/opensymphony/xwork2/Preparable.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,8 @@
package com.opensymphony.xwork2;

/**
* Preparable Actions will have their <code>prepare()</code> method called if the {@link com.opensymphony.xwork2.interceptor.PrepareInterceptor}
* is applied to the ActionConfig.
*
* @author Jason Carreira
* @see com.opensymphony.xwork2.interceptor.PrepareInterceptor
* @deprecated since 6.7.0, use {@link org.apache.struts2.Preparable} instead.
*/
public interface Preparable {

/**
* This method is called to allow the action to prepare itself.
*
* @throws Exception thrown if a system level exception occurs.
*/
void prepare() throws Exception;

@Deprecated
public interface Preparable extends org.apache.struts2.Preparable {
}
3 changes: 3 additions & 0 deletions core/src/main/java/com/opensymphony/xwork2/Result.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ default void execute(org.apache.struts2.ActionInvocation invocation) throws Exce
void execute(ActionInvocation invocation) throws Exception;

static Result adapt(org.apache.struts2.Result actualResult) {
if (actualResult instanceof Result) {
return (Result) actualResult;
}
return actualResult != null ? new LegacyAdapter(actualResult) : null;
}

Expand Down
7 changes: 3 additions & 4 deletions core/src/main/java/com/opensymphony/xwork2/Unchainable.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
package com.opensymphony.xwork2;

/**
* Simple marker interface to indicate an object should <b>not</b> have its properties copied during chaining.
*
* @see com.opensymphony.xwork2.interceptor.ChainingInterceptor
* @deprecated since 6.7.0, use {@link org.apache.struts2.Unchainable} instead.
*/
public interface Unchainable {
@Deprecated
public interface Unchainable extends org.apache.struts2.Unchainable {
}
15 changes: 3 additions & 12 deletions core/src/main/java/com/opensymphony/xwork2/Validateable.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,8 @@
package com.opensymphony.xwork2;

/**
* Provides an interface in which a call for a validation check can be done.
*
* @author Jason Carreira
* @see ActionSupport
* @see com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor
* @deprecated since 6.7.0, use {@link org.apache.struts2.Validateable} instead.
*/
public interface Validateable {

/**
* Performs validation.
*/
void validate();

@Deprecated
public interface Validateable extends org.apache.struts2.Validateable {
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,22 @@

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.LocalizedTextProvider;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.security.AcceptedPatternsChecker;
import com.opensymphony.xwork2.security.ExcludedPatternsChecker;
import com.opensymphony.xwork2.util.ClearableValueStack;
import com.opensymphony.xwork2.util.Evaluated;
import com.opensymphony.xwork2.LocalizedTextProvider;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.ValueStackFactory;
import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.dispatcher.HttpParameters;
import org.apache.struts2.dispatcher.Parameter;
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.interceptor.ValidationAware;

import java.util.Map;

Expand Down Expand Up @@ -108,7 +109,7 @@ public class AliasInterceptor extends AbstractInterceptor {
@Inject(StrutsConstants.STRUTS_DEVMODE)
public void setDevMode(String mode) {
this.devMode = Boolean.parseBoolean(mode);
}
}

@Inject
public void setValueStackFactory(ValueStackFactory valueStackFactory) {
Expand Down Expand Up @@ -225,7 +226,7 @@ public void setAliasesKey(String aliasesKey) {
LOG.debug("invalid alias expression: {}", aliasesKey);
}
}

return invocation.invoke();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,23 @@
import com.opensymphony.xwork2.ActionChainResult;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.Result;
import com.opensymphony.xwork2.Unchainable;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ProxyUtil;
import com.opensymphony.xwork2.util.CompoundRoot;
import com.opensymphony.xwork2.util.ProxyUtil;
import com.opensymphony.xwork2.util.TextParseUtil;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.Unchainable;

import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.struts2.interceptor.ValidationAware;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import org.apache.commons.lang3.reflect.MethodUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.interceptor.ValidationAware;
import org.apache.struts2.interceptor.ValidationErrorAware;
import org.apache.struts2.interceptor.ValidationWorkflowAware;

/**
* <!-- START SNIPPET: description -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
package com.opensymphony.xwork2.interceptor;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.util.CompoundRoot;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.ModelDriven;

/**
* <!-- START SNIPPET: description -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ default void beforeResult(org.apache.struts2.ActionInvocation invocation, String
void beforeResult(ActionInvocation invocation, String resultCode);

static PreResultListener adapt(org.apache.struts2.interceptor.PreResultListener actualListener) {
if (actualListener instanceof PreResultListener) {
return (PreResultListener) actualListener;
}
return actualListener != null ? new LegacyAdapter(actualListener) : null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
package com.opensymphony.xwork2.interceptor;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.Preparable;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.struts2.Preparable;

import java.lang.reflect.InvocationTargetException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,8 @@
import com.opensymphony.xwork2.ModelDriven;

/**
* Adds the ability to set a model, probably retrieved from a given state.
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.ScopedModelDriven} instead.
*/
public interface ScopedModelDriven<T> extends ModelDriven<T> {

/**
* @param model sets the model
*/
void setModel(T model);

/**
* Sets the key under which the model is stored
* @param key The model key
*/
void setScopeKey(String key);

/**
* @return the key under which the model is stored
*/
String getScopeKey();
@Deprecated
public interface ScopedModelDriven<T> extends org.apache.struts2.interceptor.ScopedModelDriven<T>, ModelDriven<T> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.inject.Inject;
import org.apache.struts2.StrutsException;
import org.apache.struts2.interceptor.ScopedModelDriven;

import java.lang.reflect.Method;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.LocalizedTextProvider;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.config.entities.Parameterizable;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ClearableValueStack;
import com.opensymphony.xwork2.LocalizedTextProvider;
import com.opensymphony.xwork2.util.TextParseUtil;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.ValueStackFactory;
Expand All @@ -34,6 +34,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.dispatcher.HttpParameters;
import org.apache.struts2.interceptor.ValidationAware;

import java.util.Collections;
import java.util.Map;
Expand Down
Loading