[ 
https://issues.apache.org/jira/browse/WW-5217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17596983#comment-17596983
 ] 

Lukasz Lenart commented on WW-5217:
-----------------------------------

The simplest approach is to use on of factory methods 
{{Ognl.createDefaultContext(...)}}

> new OgnlContext() is removed
> ----------------------------
>
>                 Key: WW-5217
>                 URL: https://issues.apache.org/jira/browse/WW-5217
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Expression Language
>            Reporter: Alireza Fattahi
>            Priority: Major
>
> We used the OGNL in our classes as below
>  
> {code:java}
> OgnlExpression ognlExpression = new OgnlExpression(expressionString);
> ognlExpression.getValue(new OgnlContext(), rootObject);{code}
>  
> The OgnlExpression is a simple wrapper.
>  
>  
> {code:java}
> public class OgnlExpression{
>     private Object expression;
>     private static final Logger LOG = 
> LoggerFactory.getLogger(OgnlExpression.class);
>     public OgnlExpression( String expressionString )
>         throws OgnlException
>     {
>         super();
>         expression = Ognl.parseExpression( expressionString );
>     }
>     public Object getExpression()
>     {
>         return expression;
>     }
>     public Object getValue( OgnlContext context, Object rootObject )
>         throws OgnlException
>     {
>         LOG.debug("parse the expression with OGNL");
>         return Ognl.getValue( getExpression(), context, rootObject );
>     }
>     public void setValue( OgnlContext context, Object rootObject, Object 
> value )
>         throws OgnlException
>     {
>         Ognl.setValue(getExpression(), context, rootObject, value);
>     }
> {code}
>  
> After upgrade to version 6, the `new OgnlContext()` constructor seems to be 
> removed. I test the `new OgnlContext(null,null,null)` but got illegal 
> argument exception.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to