You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2013/03/26 09:35:52 UTC

svn commit: r1461014 - in /commons/proper/ognl/trunk/src: main/java/org/apache/commons/ognl/ test/java/org/apache/commons/ognl/

Author: lukaszlenart
Date: Tue Mar 26 08:35:51 2013
New Revision: 1461014

URL: http://svn.apache.org/r1461014
Log:
OGNL-232 Removes deprecated classes

Removed:
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/EvaluationPool.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ObjectArrayPool.java
Modified:
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTCtor.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTStaticMethod.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/OgnlContext.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/OgnlRuntime.java
    commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/SimpleNode.java
    commons/proper/ognl/trunk/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTCtor.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTCtor.java?rev=1461014&r1=1461013&r2=1461014&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTCtor.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTCtor.java Tue Mar 26 08:35:51 2013
@@ -79,75 +79,68 @@ public class ASTCtor
     {
         Object result, root = context.getRoot();
         int count = jjtGetNumChildren();
-        Object[] args = OgnlRuntime.getObjectArrayPool().create( count );
+        Object[] args = new Object[count];
 
-        try
+        for ( int i = 0; i < count; ++i )
         {
-            for ( int i = 0; i < count; ++i )
-            {
-                args[i] = children[i].getValue( context, root );
-            }
-            if ( isArray )
+            args[i] = children[i].getValue( context, root );
+        }
+        if ( isArray )
+        {
+            if ( args.length == 1 )
             {
-                if ( args.length == 1 )
+                try
                 {
-                    try
+                    Class componentClass = OgnlRuntime.classForName( context, className );
+                    List sourceList = null;
+                    int size;
+
+                    if ( args[0] instanceof List )
                     {
-                        Class componentClass = OgnlRuntime.classForName( context, className );
-                        List sourceList = null;
-                        int size;
+                        sourceList = (List) args[0];
+                        size = sourceList.size();
+                    }
+                    else
+                    {
+                        size = (int) OgnlOps.longValue( args[0] );
+                    }
+                    result = Array.newInstance( componentClass, size );
+                    if ( sourceList != null )
+                    {
+                        TypeConverter converter = context.getTypeConverter();
 
-                        if ( args[0] instanceof List )
-                        {
-                            sourceList = (List) args[0];
-                            size = sourceList.size();
-                        }
-                        else
-                        {
-                            size = (int) OgnlOps.longValue( args[0] );
-                        }
-                        result = Array.newInstance( componentClass, size );
-                        if ( sourceList != null )
+                        for ( int i = 0, icount = sourceList.size(); i < icount; i++ )
                         {
-                            TypeConverter converter = context.getTypeConverter();
+                            Object o = sourceList.get( i );
 
-                            for ( int i = 0, icount = sourceList.size(); i < icount; i++ )
+                            if ( ( o == null ) || componentClass.isInstance( o ) )
                             {
-                                Object o = sourceList.get( i );
-
-                                if ( ( o == null ) || componentClass.isInstance( o ) )
-                                {
-                                    Array.set( result, i, o );
-                                }
-                                else
-                                {
-                                    Array.set( result, i,
-                                               converter.convertValue( context, null, null, null, o, componentClass ) );
-                                }
+                                Array.set( result, i, o );
+                            }
+                            else
+                            {
+                                Array.set( result, i,
+                                           converter.convertValue( context, null, null, null, o, componentClass ) );
                             }
                         }
                     }
-                    catch ( ClassNotFoundException ex )
-                    {
-                        throw new OgnlException( "array component class '" + className + "' not found", ex );
-                    }
                 }
-                else
+                catch ( ClassNotFoundException ex )
                 {
-                    throw new OgnlException( "only expect array size or fixed initializer list" );
+                    throw new OgnlException( "array component class '" + className + "' not found", ex );
                 }
             }
             else
             {
-                result = OgnlRuntime.callConstructor( context, className, args );
+                throw new OgnlException( "only expect array size or fixed initializer list" );
             }
-
-            return result;
         }
-        finally
+        else
         {
-            OgnlRuntime.getObjectArrayPool().recycle( args );
+            result = OgnlRuntime.callConstructor( context, className, args );
         }
+
+        return result;
     }
 
 

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java?rev=1461014&r1=1461013&r2=1461014&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTMethod.java Tue Mar 26 08:35:51 2013
@@ -75,32 +75,24 @@ public class ASTMethod
     protected Object getValueBody( OgnlContext context, Object source )
         throws OgnlException
     {
-        Object[] args = OgnlRuntime.getObjectArrayPool().create( jjtGetNumChildren() );
+        Object[] args = new Object[jjtGetNumChildren()];
 
-        try
-        {
-            Object result, root = context.getRoot();
-
-            for ( int i = 0; i < args.length; ++i )
-            {
-                args[i] = children[i].getValue( context, root );
-            }
-
-            result = OgnlRuntime.callMethod( context, source, methodName, args );
+        Object result, root = context.getRoot();
 
-            if ( result == null )
-            {
-                NullHandler nullHandler = OgnlRuntime.getNullHandler( OgnlRuntime.getTargetClass( source ) );
-                result = nullHandler.nullMethodResult( context, source, methodName, args );
-            }
+        for ( int i = 0; i < args.length; ++i )
+        {
+            args[i] = children[i].getValue( context, root );
+        }
 
-            return result;
+        result = OgnlRuntime.callMethod( context, source, methodName, args );
 
-        }
-        finally
+        if ( result == null )
         {
-            OgnlRuntime.getObjectArrayPool().recycle( args );
+            NullHandler nullHandler = OgnlRuntime.getNullHandler( OgnlRuntime.getTargetClass( source ) );
+            result = nullHandler.nullMethodResult( context, source, methodName, args );
         }
+
+        return result;
     }
 
     public String getLastExpression()

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTStaticMethod.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTStaticMethod.java?rev=1461014&r1=1461013&r2=1461014&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTStaticMethod.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ASTStaticMethod.java Tue Mar 26 08:35:51 2013
@@ -61,23 +61,15 @@ public class ASTStaticMethod
     protected Object getValueBody( OgnlContext context, Object source )
         throws OgnlException
     {
-        ObjectArrayPool objectArrayPool = OgnlRuntime.getObjectArrayPool();
-        Object[] args = objectArrayPool.create( jjtGetNumChildren() );
+        Object[] args = new Object[jjtGetNumChildren()];
         Object root = context.getRoot();
 
-        try
+        for ( int i = 0, icount = args.length; i < icount; ++i )
         {
-            for ( int i = 0, icount = args.length; i < icount; ++i )
-            {
-                args[i] = children[i].getValue( context, root );
-            }
-
-            return OgnlRuntime.callStaticMethod( context, className, methodName, args );
-        }
-        finally
-        {
-            objectArrayPool.recycle( args );
+            args[i] = children[i].getValue( context, root );
         }
+
+        return OgnlRuntime.callStaticMethod( context, className, methodName, args );
     }
 
     public Class getGetterClass()

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/OgnlContext.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/OgnlContext.java?rev=1461014&r1=1461013&r2=1461014&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/OgnlContext.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/OgnlContext.java Tue Mar 26 08:35:51 2013
@@ -271,7 +271,6 @@ public class OgnlContext
      */
     public void recycleLastEvaluation()
     {
-        OgnlRuntime.getEvaluationPool().recycleAll( lastEvaluation );
         lastEvaluation = null;
     }
 

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/OgnlRuntime.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/OgnlRuntime.java?rev=1461014&r1=1461013&r2=1461014&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/OgnlRuntime.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/OgnlRuntime.java Tue Mar 26 08:35:51 2013
@@ -130,10 +130,6 @@ public class OgnlRuntime
 
     private static SecurityManager securityManager = System.getSecurityManager();
 
-    private static final EvaluationPool evaluationPool = new EvaluationPool();
-
-    private static final ObjectArrayPool objectArrayPool = new ObjectArrayPool();
-
     /**
      * Expression compiler used by {@link Ognl#compileExpression(OgnlContext, Object, String)} calls.
      */
@@ -386,7 +382,7 @@ public class OgnlRuntime
         }
         else
         {
-            array = getObjectArrayPool().create( size );
+            array = new Object[size];
             for ( int i = 0; i < size; i++ )
             {
                 array[i] = list.get( i );
@@ -918,7 +914,7 @@ public class OgnlRuntime
         throws MethodFailedException
     {
         Throwable cause = null;
-        Object[] actualArgs = objectArrayPool.create( args.length );
+        Object[] actualArgs = new Object[args.length];
 
         try
         {
@@ -1008,10 +1004,6 @@ public class OgnlRuntime
         {
             cause = e.getTargetException();
         }
-        finally
-        {
-            objectArrayPool.recycle( actualArgs );
-        }
 
         throw new MethodFailedException( source, methodName, cause );
     }
@@ -1084,9 +1076,8 @@ public class OgnlRuntime
             }
             if ( ctor == null )
             {
-                actualArgs = objectArrayPool.create( args.length );
-                if ( ( ctor = getConvertedConstructorAndArgs( context, target, constructors, args, actualArgs ) )
-                    == null )
+                actualArgs = new Object[args.length];
+                if ( ( ctor = getConvertedConstructorAndArgs( context, target, constructors, args, actualArgs ) ) == null )
                 {
                     throw new NoSuchMethodException();
                 }
@@ -1117,13 +1108,6 @@ public class OgnlRuntime
         {
             cause = e;
         }
-        finally
-        {
-            if ( actualArgs != args )
-            {
-                objectArrayPool.recycle( actualArgs );
-            }
-        }
 
         throw new MethodFailedException( className, "new", cause );
     }
@@ -1203,17 +1187,9 @@ public class OgnlRuntime
         {
             if ( method != null )
             {
-                Object[] args = objectArrayPool.create( value );
-
-                try
-                {
-                    callAppropriateMethod( context, target, target, method.getName(), propertyName,
-                                           Collections.nCopies( 1, method ), args );
-                }
-                finally
-                {
-                    objectArrayPool.recycle( args );
-                }
+                Object[] args = new Object[]{ value };
+                callAppropriateMethod( context, target, target, method.getName(), propertyName,
+                                       Collections.nCopies( 1, method ), args );
             }
             else
             {
@@ -1753,7 +1729,7 @@ public class OgnlRuntime
     public static Object getIndexedProperty( OgnlContext context, Object source, String name, Object index )
         throws OgnlException
     {
-        Object[] args = objectArrayPool.create( index );
+        Object[] args = new Object[] { index };
 
         try
         {
@@ -1787,16 +1763,12 @@ public class OgnlRuntime
         {
             throw new OgnlException( "getting indexed property descriptor for '" + name + "'", ex );
         }
-        finally
-        {
-            objectArrayPool.recycle( args );
-        }
     }
 
     public static void setIndexedProperty( OgnlContext context, Object source, String name, Object index, Object value )
         throws OgnlException
     {
-        Object[] args = objectArrayPool.create( index, value );
+        Object[] args = new Object[] { index, value };
 
         try
         {
@@ -1830,20 +1802,6 @@ public class OgnlRuntime
         {
             throw new OgnlException( "getting indexed property descriptor for '" + name + "'", ex );
         }
-        finally
-        {
-            objectArrayPool.recycle( args );
-        }
-    }
-
-    public static EvaluationPool getEvaluationPool()
-    {
-        return evaluationPool;
-    }
-
-    public static ObjectArrayPool getObjectArrayPool()
-    {
-        return objectArrayPool;
     }
 
     /**

Modified: commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/SimpleNode.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/SimpleNode.java?rev=1461014&r1=1461013&r2=1461014&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/SimpleNode.java (original)
+++ commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/SimpleNode.java Tue Mar 26 08:35:51 2013
@@ -235,9 +235,8 @@ public abstract class SimpleNode
         if ( context.getTraceEvaluations() )
         {
 
-            EvaluationPool pool = OgnlRuntime.getEvaluationPool();
             Throwable evalException = null;
-            Evaluation evaluation = pool.create( this, source );
+            Evaluation evaluation = new Evaluation( this, source );
 
             context.pushEvaluation( evaluation );
             try
@@ -263,11 +262,6 @@ public abstract class SimpleNode
                 {
                     eval.setException( evalException );
                 }
-                if ( ( evalException == null ) && ( context.getRootEvaluation() == null )
-                    && !context.getKeepLastEvaluation() )
-                {
-                    pool.recycleAll( eval );
-                }
             }
         }
         else
@@ -290,9 +284,8 @@ public abstract class SimpleNode
     {
         if ( context.getTraceEvaluations() )
         {
-            EvaluationPool pool = OgnlRuntime.getEvaluationPool();
             Throwable evalException = null;
-            Evaluation evaluation = pool.create( this, target, true );
+            Evaluation evaluation = new Evaluation( this, target, true );
 
             context.pushEvaluation( evaluation );
             try
@@ -318,11 +311,6 @@ public abstract class SimpleNode
                 {
                     eval.setException( evalException );
                 }
-                if ( ( evalException == null ) && ( context.getRootEvaluation() == null )
-                    && !context.getKeepLastEvaluation() )
-                {
-                    pool.recycleAll( eval );
-                }
             }
         }
         else

Modified: commons/proper/ognl/trunk/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java
URL: http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java?rev=1461014&r1=1461013&r2=1461014&view=diff
==============================================================================
--- commons/proper/ognl/trunk/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java (original)
+++ commons/proper/ognl/trunk/src/test/java/org/apache/commons/ognl/TestOgnlRuntime.java Tue Mar 26 08:35:51 2013
@@ -220,7 +220,7 @@ public class TestOgnlRuntime
 
         GameGenericObject argument = new GameGenericObject();
 
-        Object[] args = OgnlRuntime.getObjectArrayPool().create( 2 );
+        Object[] args = new Object[2];
         args[0] = argument;
 
         assertEquals( "Halo 3", OgnlRuntime.callMethod( context, service, "getFullMessageFor", args ) );