Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.struts2.conversion.TypeConverter;
import org.apache.struts2.inject.Container;
import org.apache.struts2.inject.Inject;
import org.apache.struts2.ognl.StrutsContext;
import org.apache.struts2.ognl.XWorkTypeConverterWrapper;
import ognl.OgnlContext;

Expand Down Expand Up @@ -78,8 +79,10 @@ public Object convertValue(Map<String, Object> context, Object target, Member me
public TypeConverter getTypeConverter( Map<String, Object> context ) {
ognl.TypeConverter converter = null;

if (context instanceof OgnlContext) {
converter = ((OgnlContext) context).getTypeConverter();
if (context instanceof StrutsContext strutsContext) {
converter = strutsContext.getTypeConverter();
} else if (context instanceof OgnlContext ognlContext) {
converter = ognlContext.getTypeConverter();
}

if (converter != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
*/
package org.apache.struts2.ognl;

import ognl.OgnlContext;
import org.apache.struts2.conversion.NullHandler;

import java.util.Map;

public class OgnlNullHandlerWrapper implements ognl.NullHandler {

private final NullHandler wrapped;
Expand All @@ -31,13 +30,13 @@ public OgnlNullHandlerWrapper(NullHandler target) {
}

@Override
public Object nullMethodResult(Map context, Object target,
String methodName, Object[] args) {
public Object nullMethodResult(OgnlContext context, Object target,
String methodName, Object[] args) {
return wrapped.nullMethodResult(context, target, methodName, args);
}

@Override
public Object nullPropertyValue(Map context, Object target, Object property) {
public Object nullPropertyValue(OgnlContext context, Object target, Object property) {
return wrapped.nullPropertyValue(context, target, property);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
package org.apache.struts2.ognl;

import org.apache.struts2.util.reflection.ReflectionContextFactory;
import ognl.Ognl;

import java.util.Map;

/**
* @deprecated since 6.8.0, to be removed, see {@link ReflectionContextFactory}
Expand All @@ -30,8 +27,8 @@
public class OgnlReflectionContextFactory implements ReflectionContextFactory {

@Override
public Map createDefaultContext(Object root) {
return Ognl.createDefaultContext(root);
public StrutsContext createDefaultContext(Object root) {
return StrutsContext.create(root, null, null, null);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,13 @@ public Field getField(Class inClass, String name) {
@Override
public Method getGetMethod(Class targetClass, String propertyName)
throws IntrospectionException, ReflectionException {
try {
return OgnlRuntime.getGetMethod(null, targetClass, propertyName);
} catch (OgnlException e) {
throw new ReflectionException(e);
}
return OgnlRuntime.getGetMethod(targetClass, propertyName);
}

@Override
public Method getSetMethod(Class targetClass, String propertyName)
throws IntrospectionException, ReflectionException {
try {
return OgnlRuntime.getSetMethod(null, targetClass, propertyName);
} catch (OgnlException e) {
throw new ReflectionException(e);
}
return OgnlRuntime.getSetMethod(null, targetClass, propertyName);
}

@Override
Expand All @@ -71,7 +63,7 @@ public void setProperties(Map<String, ?> props, Object o, Map<String, Object> co
}

@Override
public void setProperties(Map<String, ?> props, Object o, Map<String, Object> context, boolean throwPropertyExceptions) throws ReflectionException{
public void setProperties(Map<String, ?> props, Object o, Map<String, Object> context, boolean throwPropertyExceptions) throws ReflectionException {
ognlUtil.setProperties(props, o, context, throwPropertyExceptions);
}

Expand All @@ -82,7 +74,7 @@ public void setProperties(Map<String, ?> properties, Object o) {

@Override
public PropertyDescriptor getPropertyDescriptor(Class targetClass,
String propertyName) throws IntrospectionException,
String propertyName) throws IntrospectionException,
ReflectionException {
try {
return OgnlRuntime.getPropertyDescriptor(targetClass, propertyName);
Expand All @@ -93,7 +85,7 @@ public PropertyDescriptor getPropertyDescriptor(Class targetClass,

@Override
public void copy(Object from, Object to, Map<String, Object> context,
Collection<String> exclusions, Collection<String> inclusions) {
Collection<String> exclusions, Collection<String> inclusions) {
copy(from, to, context, exclusions, inclusions, null);
}

Expand Down Expand Up @@ -145,7 +137,7 @@ public Object getValue(String expression, Map<String, Object> context, Object ro

@Override
public void setValue(String expression, Map<String, Object> context, Object root,
Object value) throws ReflectionException {
Object value) throws ReflectionException {
try {
ognlUtil.setValue(expression, context, root, value);
} catch (OgnlException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
*/
package org.apache.struts2.ognl;

import ognl.OgnlContext;
import org.apache.struts2.conversion.TypeConverter;

import java.lang.reflect.Member;
import java.util.Map;

/**
* Wraps an XWork type conversion class for as an OGNL TypeConverter
Expand All @@ -38,7 +38,7 @@ public OgnlTypeConverterWrapper(TypeConverter converter) {
}

@Override
public Object convertValue(Map context, Object target, Member member, String propertyName, Object value, Class toType) {
public Object convertValue(OgnlContext context, Object target, Member member, String propertyName, Object value, Class<?> toType) {
return typeConverter.convertValue(context, target, member, propertyName, value, toType);
}

Expand Down
Loading