Skip to content

Commit 0f61944

Browse files
authored
WW-5544 Marks ReflectionContextFactory as deprecated and uses ActionContext instead (#1254)
1 parent ca4e07c commit 0f61944

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

core/src/main/java/com/opensymphony/xwork2/ognl/OgnlReflectionContextFactory.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323

2424
import java.util.Map;
2525

26+
/**
27+
* @deprecated since 6.8.0, to be removed, see {@link ReflectionContextFactory}
28+
*/
29+
@Deprecated
2630
public class OgnlReflectionContextFactory implements ReflectionContextFactory {
2731

2832
public Map createDefaultContext(Object root) {

core/src/main/java/com/opensymphony/xwork2/util/reflection/ReflectionContextFactory.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020

2121
import java.util.Map;
2222

23+
/**
24+
* @deprecated since 6.8.0, avoid using this interface and any of its implementation, it's going to be removed soon
25+
*/
26+
@Deprecated
2327
public interface ReflectionContextFactory {
2428
/**
2529
* Creates and returns a new standard naming context for evaluating an OGNL

plugins/config-browser/src/main/java/org/apache/struts2/config_browser/ShowValidatorAction.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
package org.apache.struts2.config_browser;
2020

2121
import com.opensymphony.xwork2.inject.Inject;
22-
import com.opensymphony.xwork2.util.reflection.ReflectionContextFactory;
2322
import com.opensymphony.xwork2.util.reflection.ReflectionException;
2423
import com.opensymphony.xwork2.util.reflection.ReflectionProvider;
2524
import com.opensymphony.xwork2.validator.Validator;
2625
import org.apache.logging.log4j.LogManager;
2726
import org.apache.logging.log4j.Logger;
27+
import org.apache.struts2.ActionContext;
2828
import org.apache.struts2.interceptor.parameter.StrutsParameter;
2929

3030
import java.beans.BeanInfo;
@@ -49,19 +49,13 @@ public class ShowValidatorAction extends ListValidatorsAction {
4949
private Set<PropertyInfo> properties = Collections.emptySet();
5050
private int selected = 0;
5151

52-
ReflectionProvider reflectionProvider;
53-
ReflectionContextFactory reflectionContextFactory;
52+
private ReflectionProvider reflectionProvider;
5453

5554
@Inject
5655
public void setReflectionProvider(ReflectionProvider prov) {
5756
this.reflectionProvider = prov;
5857
}
5958

60-
@Inject
61-
public void setReflectionContextFactory(ReflectionContextFactory fac) {
62-
this.reflectionContextFactory = fac;
63-
}
64-
6559
public int getSelected() {
6660
return selected;
6761
}
@@ -85,7 +79,6 @@ public String execute() throws Exception {
8579
Validator validator = getSelectedValidator();
8680
properties = new TreeSet<>();
8781
try {
88-
Map<String, Object> context = reflectionContextFactory.createDefaultContext(validator);
8982
BeanInfo beanInfoFrom;
9083
try {
9184
beanInfoFrom = Introspector.getBeanInfo(validator.getClass(), Object.class);
@@ -97,6 +90,7 @@ public String execute() throws Exception {
9790

9891
PropertyDescriptor[] pds = beanInfoFrom.getPropertyDescriptors();
9992

93+
Map<String, Object> context = ActionContext.getContext().getContextMap();
10094
for (PropertyDescriptor pd : pds) {
10195
String name = pd.getName();
10296
Object value = null;
@@ -113,9 +107,9 @@ public String execute() throws Exception {
113107
}
114108
} catch (Exception e) {
115109
if (LOG.isWarnEnabled()) {
116-
LOG.warn("Unable to retrieve properties.", e);
110+
LOG.warn("Unable to retrieve properties.", e);
117111
}
118-
addActionError("Unable to retrieve properties: " + e.toString());
112+
addActionError("Unable to retrieve properties: " + e);
119113
}
120114

121115
if (hasErrors()) {

0 commit comments

Comments
 (0)