Skip to content

Commit

Permalink
WW-3714 Shortcut adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
kusalk committed Oct 17, 2024
1 parent 1042a62 commit d057ca3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/src/main/java/com/opensymphony/xwork2/ActionContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ private ActionContext(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
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ default String handleException(Throwable t, org.apache.struts2.util.ValueStack s
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 @@ -63,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
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
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
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 @@ -32,6 +32,9 @@ public interface ValueStack extends org.apache.struts2.util.ValueStack {
ActionContext getActionContext();

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

Expand Down

0 comments on commit d057ca3

Please sign in to comment.