You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2011/11/02 00:09:31 UTC

svn commit: r1196358 - in /tapestry/tapestry5/trunk: tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ tapestry-core/src/main/java/org/apache/tapestry5/services/ tapestry-core/src/test/java/org/apache/tapestry5/internal/ tapestry-ioc/...

Author: hlship
Date: Tue Nov  1 23:09:30 2011
New Revision: 1196358

URL: http://svn.apache.org/viewvc?rev=1196358&view=rev
Log:
TAP5-1739: Continue culling dead code

Removed:
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassFab.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassFactory.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/FieldValueConduit.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/services/ClassFabUtilsTest.java
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ComponentLayer.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/TapestryInternalUtilsTest.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/TypeCoercerImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassFabUtils.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/CoercionTuple.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java
    tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/EntityManagerObjectProvider.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java?rev=1196358&r1=1196357&r2=1196358&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java Tue Nov  1 23:09:30 2011
@@ -14,10 +14,6 @@
 
 package org.apache.tapestry5.internal.services;
 
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.List;
-
 import org.apache.tapestry5.beaneditor.BeanModel;
 import org.apache.tapestry5.beaneditor.NonVisual;
 import org.apache.tapestry5.beaneditor.ReorderProperties;
@@ -28,16 +24,16 @@ import org.apache.tapestry5.ioc.Messages
 import org.apache.tapestry5.ioc.ObjectLocator;
 import org.apache.tapestry5.ioc.annotations.Primary;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
-import org.apache.tapestry5.ioc.services.ClassFactory;
-import org.apache.tapestry5.ioc.services.ClassPropertyAdapter;
-import org.apache.tapestry5.ioc.services.PropertyAccess;
-import org.apache.tapestry5.ioc.services.PropertyAdapter;
-import org.apache.tapestry5.ioc.services.TypeCoercer;
+import org.apache.tapestry5.ioc.services.*;
 import org.apache.tapestry5.services.BeanModelSource;
 import org.apache.tapestry5.services.ComponentLayer;
 import org.apache.tapestry5.services.DataTypeAnalyzer;
 import org.apache.tapestry5.services.PropertyConduitSource;
 
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.List;
+
 public class BeanModelSourceImpl implements BeanModelSource
 {
     private final TypeCoercer typeCoercer;
@@ -46,7 +42,7 @@ public class BeanModelSourceImpl impleme
 
     private final PropertyConduitSource propertyConduitSource;
 
-    private final ClassFactory classFactory;
+    private final PlasticProxyFactory proxyFactory;
 
     private final DataTypeAnalyzer dataTypeAnalyzer;
 
@@ -82,10 +78,8 @@ public class BeanModelSourceImpl impleme
     }
 
     /**
-     * @param classAdapter
-     *            defines the bean that contains the properties
-     * @param propertyNames
-     *            the initial set of property names, which will be rebuilt in the correct order
+     * @param classAdapter  defines the bean that contains the properties
+     * @param propertyNames the initial set of property names, which will be rebuilt in the correct order
      */
     private void orderProperties(ClassPropertyAdapter classAdapter, List<String> propertyNames)
     {
@@ -97,7 +91,7 @@ public class BeanModelSourceImpl impleme
 
             Method readMethod = pa.getReadMethod();
 
-            Location location = readMethod == null ? null : classFactory.getMethodLocation(readMethod);
+            Location location = readMethod == null ? null : proxyFactory.getMethodLocation(readMethod);
 
             int line = location == null ? -1 : location.getLine();
 
@@ -131,14 +125,16 @@ public class BeanModelSourceImpl impleme
     }
 
     public BeanModelSourceImpl(TypeCoercer typeCoercer, PropertyAccess propertyAccess,
-            PropertyConduitSource propertyConduitSource, @ComponentLayer
-            ClassFactory classFactory, @Primary
-            DataTypeAnalyzer dataTypeAnalyzer, ObjectLocator locator)
+                               PropertyConduitSource propertyConduitSource,
+                               @ComponentLayer
+                               PlasticProxyFactory proxyFactory,
+                               @Primary
+                               DataTypeAnalyzer dataTypeAnalyzer, ObjectLocator locator)
     {
         this.typeCoercer = typeCoercer;
         this.propertyAccess = propertyAccess;
         this.propertyConduitSource = propertyConduitSource;
-        this.classFactory = classFactory;
+        this.proxyFactory = proxyFactory;
         this.dataTypeAnalyzer = dataTypeAnalyzer;
         this.locator = locator;
     }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ComponentLayer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ComponentLayer.java?rev=1196358&r1=1196357&r2=1196358&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ComponentLayer.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ComponentLayer.java Tue Nov  1 23:09:30 2011
@@ -15,20 +15,20 @@
 package org.apache.tapestry5.services;
 
 import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
 import static java.lang.annotation.ElementType.FIELD;
 import static java.lang.annotation.ElementType.PARAMETER;
-import java.lang.annotation.Retention;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import java.lang.annotation.Target;
 
 /**
  * Marker annotation used to identify a service from the component layer that conflicts, in terms of service interface,
- * with a service from elsewhere. In particular, this is used to disambiguate {@link
- * org.apache.tapestry5.ioc.services.ClassFactory} which has one implementation (marked with {@link
+ * with a service from elsewhere. In particular, this is used to disambiguate {@link org.apache.tapestry5.ioc.services.PlasticProxyFactory} which has one implementation (marked with {@link
  * org.apache.tapestry5.ioc.services.Builtin} and another with this annotation.
  */
 @Target(
-        { PARAMETER, FIELD })
+        {PARAMETER, FIELD})
 @Retention(RUNTIME)
 @Documented
 public @interface ComponentLayer

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=1196358&r1=1196357&r2=1196358&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java Tue Nov  1 23:09:30 2011
@@ -1459,24 +1459,6 @@ public final class TapestryModule
     }
 
     /**
-     * Returns a {@link org.apache.tapestry5.ioc.services.ClassFactory} that can
-     * be used to create extra classes around
-     * component classes. This ClassFactory will be cleared whenever an
-     * underlying component class is discovered to have
-     * changed. Use of this class factory implies that your code will become
-     * aware of this (if necessary) to discard any
-     * cached object (alas, this currently involves dipping into the internals
-     * side to register for the correct
-     * notifications). Failure to properly clean up can result in really nasty
-     * PermGen space memory leaks.
-     */
-    @Marker(ComponentLayer.class)
-    public ClassFactory buildComponentClassFactory(ComponentInstantiatorSource source)
-    {
-        return shadowBuilder.build(source, "classFactory", ClassFactory.class);
-    }
-
-    /**
      * Returns a {@link PlasticProxyFactory} that can be used to create extra classes around component classes. This
      * factory will be cleared whenever an underlying component class is discovered to have changed. Use of this
      * factory implies that your code will become aware of this (if necessary) to discard any cached object (alas,

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/TapestryInternalUtilsTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/TapestryInternalUtilsTest.java?rev=1196358&r1=1196357&r2=1196358&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/TapestryInternalUtilsTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/TapestryInternalUtilsTest.java Tue Nov  1 23:09:30 2011
@@ -20,13 +20,8 @@ import org.apache.tapestry5.internal.tes
 import org.apache.tapestry5.ioc.Messages;
 import org.apache.tapestry5.ioc.Resource;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
-import org.apache.tapestry5.ioc.services.ClassFactory;
-import org.apache.tapestry5.ioc.services.PropertyAccess;
 import org.apache.tapestry5.ioc.services.TypeCoercer;
 import org.apache.tapestry5.runtime.ComponentResourcesAware;
-import org.apache.tapestry5.services.BeanModelSource;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
@@ -35,28 +30,6 @@ import java.util.regex.Pattern;
 
 public class TapestryInternalUtilsTest extends InternalBaseTestCase
 {
-    private ClassFactory classFactory;
-
-    private PropertyAccess access;
-
-    private BeanModelSource beanModelSource;
-
-    @BeforeClass
-    public void setup()
-    {
-        classFactory = getService("ClassFactory", ClassFactory.class);
-        access = getService("PropertyAccess", PropertyAccess.class);
-        beanModelSource = getService(BeanModelSource.class);
-    }
-
-    @AfterClass
-    public void cleanup()
-    {
-        access = null;
-        classFactory = null;
-        beanModelSource = null;
-    }
-
     @Test(dataProvider = "to_user_presentable_data")
     public void to_user_presentable(String input, String expected)
     {
@@ -67,11 +40,11 @@ public class TapestryInternalUtilsTest e
     public Object[][] to_user_presentable_data()
     {
         return new Object[][]
-        {
-        { "hello", "Hello" },
-        { "userId", "User Id" },
-        { "useHTML", "Use HTML" },
-        { "underscored_name", "Underscored Name" }, };
+                {
+                        {"hello", "Hello"},
+                        {"userId", "User Id"},
+                        {"useHTML", "Use HTML"},
+                        {"underscored_name", "Underscored Name"},};
     }
 
     @Test
@@ -247,8 +220,7 @@ public class TapestryInternalUtilsTest e
         {
             TapestryInternalUtils.parseKeyValue(input);
             unreachable();
-        }
-        catch (IllegalArgumentException ex)
+        } catch (IllegalArgumentException ex)
         {
             assertEquals(ex.getMessage(), InternalMessages.badKeyValue(input));
         }
@@ -380,15 +352,15 @@ public class TapestryInternalUtilsTest e
     public Object[][] split_at_commas_data()
     {
         return new Object[][]
-        {
-        { "foo", new String[]
-        { "foo" } },
-        { "foo, bar", new String[]
-        { "foo", "bar" } },
-        { "  foo, \nbar\t\t", new String[]
-        { "foo", "bar" } },
-        { "", new String[0] },
-        { null, new String[0] } };
+                {
+                        {"foo", new String[]
+                                {"foo"}},
+                        {"foo, bar", new String[]
+                                {"foo", "bar"}},
+                        {"  foo, \nbar\t\t", new String[]
+                                {"foo", "bar"}},
+                        {"", new String[0]},
+                        {null, new String[0]}};
     }
 
     @Test(dataProvider = "split_at_commas_data")
@@ -402,10 +374,10 @@ public class TapestryInternalUtilsTest e
     public Object[][] to_base64_data()
     {
         return new Object[][]
-        {
-        { 0L, "AA" },
-        { 1L, "AQ" },
-        { 0xab54a98ceb1f0ad2L, "q1SpjOsfCtI" } };
+                {
+                        {0L, "AA"},
+                        {1L, "AQ"},
+                        {0xab54a98ceb1f0ad2L, "q1SpjOsfCtI"}};
     }
 
     @Test

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/TypeCoercerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/TypeCoercerImpl.java?rev=1196358&r1=1196357&r2=1196358&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/TypeCoercerImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/TypeCoercerImpl.java Tue Nov  1 23:09:30 2011
@@ -14,19 +14,10 @@
 
 package org.apache.tapestry5.ioc.internal.services;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.WeakHashMap;
-
 import org.apache.tapestry5.func.F;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.internal.util.InheritanceSearch;
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
-import org.apache.tapestry5.ioc.services.ClassFabUtils;
 import org.apache.tapestry5.ioc.services.Coercion;
 import org.apache.tapestry5.ioc.services.CoercionTuple;
 import org.apache.tapestry5.ioc.services.TypeCoercer;
@@ -34,6 +25,8 @@ import org.apache.tapestry5.ioc.util.Ava
 import org.apache.tapestry5.ioc.util.UnknownValueException;
 import org.apache.tapestry5.util.StringToEnumCoercion;
 
+import java.util.*;
+
 @SuppressWarnings("all")
 public class TypeCoercerImpl implements TypeCoercer
 {
@@ -73,8 +66,7 @@ public class TypeCoercerImpl implements 
             try
             {
                 return type.cast(c.coerce(input));
-            }
-            catch (Exception ex)
+            } catch (Exception ex)
             {
                 throw new RuntimeException(ServiceMessages.failedCoercion(input, type, c, ex), ex);
             }
@@ -139,7 +131,7 @@ public class TypeCoercerImpl implements 
     public Object coerce(Object input, Class targetType)
     {
         assert targetType != null;
-        Class effectiveTargetType = ClassFabUtils.getWrapperType(targetType);
+        Class effectiveTargetType = InternalUtils.getWrapperType(targetType);
 
         if (effectiveTargetType.isInstance(input))
             return input;
@@ -152,8 +144,8 @@ public class TypeCoercerImpl implements 
     {
         assert sourceType != null;
         assert targetType != null;
-        Class effectiveSourceType = ClassFabUtils.getWrapperType(sourceType);
-        Class effectiveTargetType = ClassFabUtils.getWrapperType(targetType);
+        Class effectiveSourceType = InternalUtils.getWrapperType(sourceType);
+        Class effectiveTargetType = InternalUtils.getWrapperType(targetType);
 
         if (effectiveTargetType.isAssignableFrom(effectiveSourceType))
             return NO_COERCION;
@@ -166,8 +158,8 @@ public class TypeCoercerImpl implements 
     {
         assert sourceType != null;
         assert targetType != null;
-        Class effectiveTargetType = ClassFabUtils.getWrapperType(targetType);
-        Class effectiveSourceType = ClassFabUtils.getWrapperType(sourceType);
+        Class effectiveTargetType = InternalUtils.getWrapperType(targetType);
+        Class effectiveSourceType = InternalUtils.getWrapperType(sourceType);
 
         // Is a coercion even necessary? Not if the target type is assignable from the
         // input value.
@@ -225,7 +217,7 @@ public class TypeCoercerImpl implements 
      * <p/>
      * This does create a good number of short lived temporary objects (the compound tuples), but that's what the GC is
      * really good at.
-     * 
+     *
      * @param sourceType
      * @param targetType
      * @return coercer from sourceType to targetType
@@ -281,9 +273,8 @@ public class TypeCoercerImpl implements 
      * Coercion from null is special; we match based on the target type and its not a spanning
      * search. In many cases, we
      * return a pass-thru that leaves the value as null.
-     * 
-     * @param targetType
-     *            desired type
+     *
+     * @param targetType desired type
      * @return the coercion
      */
     private Coercion searchForNullCoercion(Class targetType)
@@ -325,7 +316,7 @@ public class TypeCoercerImpl implements 
      * Seeds the pool with the initial set of coercions for the given type.
      */
     private void seedQueue(Class sourceType, Class targetType, Set<CoercionTuple> consideredTuples,
-            LinkedList<CoercionTuple> queue)
+                           LinkedList<CoercionTuple> queue)
     {
         // Work from the source type up looking for tuples
 
@@ -354,23 +345,18 @@ public class TypeCoercerImpl implements 
      * Creates and adds to the pool a new set of coercions based on an intermediate tuple. Adds
      * compound coercion tuples
      * to the end of the queue.
-     * 
-     * @param sourceType
-     *            the source type of the coercion
-     * @param targetType
-     *            TODO
-     * @param intermediateTuple
-     *            a tuple that converts from the source type to some intermediate type (that is not
-     *            assignable to the target type)
-     * @param consideredTuples
-     *            set of tuples that have already been added to the pool (directly, or as a compound
-     *            coercion)
-     * @param queue
-     *            the work queue of tuples
+     *
+     * @param sourceType        the source type of the coercion
+     * @param targetType        TODO
+     * @param intermediateTuple a tuple that converts from the source type to some intermediate type (that is not
+     *                          assignable to the target type)
+     * @param consideredTuples  set of tuples that have already been added to the pool (directly, or as a compound
+     *                          coercion)
+     * @param queue             the work queue of tuples
      */
     @SuppressWarnings("unchecked")
     private void queueIntermediates(Class sourceType, Class targetType, CoercionTuple intermediateTuple,
-            Set<CoercionTuple> consideredTuples, LinkedList<CoercionTuple> queue)
+                                    Set<CoercionTuple> consideredTuples, LinkedList<CoercionTuple> queue)
     {
         Class intermediateType = intermediateTuple.getTargetType();
 
@@ -413,11 +399,9 @@ public class TypeCoercerImpl implements 
 
     /**
      * Returns a non-null list of the tuples from the source type.
-     * 
-     * @param sourceType
-     *            used to locate tuples
-     * @param targetType
-     *            used to add synthetic tuples
+     *
+     * @param sourceType used to locate tuples
+     * @param targetType used to add synthetic tuples
      * @return non-null list of tuples
      */
     private List<CoercionTuple> getTuples(Class sourceType, Class targetType)
@@ -433,7 +417,7 @@ public class TypeCoercerImpl implements 
         // memory leaks by retaining an instance). In any case, there are edge cases where we may create
         // the tuple unnecessarily (such as when an explicit string-to-enum coercion is part of the TypeCoercer
         // configuration), but on the whole, this is cheap at works.
-        
+
         if (sourceType == String.class && Enum.class.isAssignableFrom(targetType))
             tuples = extend(tuples, new CoercionTuple(sourceType, targetType, new StringToEnumCoercion(targetType)));
 

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java?rev=1196358&r1=1196357&r2=1196358&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java Tue Nov  1 23:09:30 2011
@@ -23,8 +23,6 @@ import org.apache.tapestry5.ioc.def.*;
 import org.apache.tapestry5.ioc.internal.NullAnnotationProvider;
 import org.apache.tapestry5.ioc.services.Coercion;
 import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
-import org.apache.tapestry5.plastic.MethodAdvice;
-import org.apache.tapestry5.plastic.MethodInvocation;
 import org.apache.tapestry5.plastic.PlasticUtils;
 import org.slf4j.Logger;
 
@@ -54,10 +52,6 @@ public class InternalUtils
     public static final boolean SERVICE_CLASS_RELOADING_ENABLED = Boolean.parseBoolean(System.getProperty(
             IOCConstants.SERVICE_CLASS_RELOADING_ENABLED, "true"));
 
-    /**
-     * Leading punctuation on member names that is stripped off to form a property name or new member name.
-     */
-    private static final String NAME_PREFIX = "_$";
 
     /**
      * Pattern used to eliminate leading and trailing underscores and dollar signs.
@@ -1558,4 +1552,17 @@ public class InternalUtils
         });
     }
 
+    public static Class getWrapperType(Class type)
+    {
+        // This is needed by TypeCoercer, which has its own rules about how to handler void.class (as a stand-in
+        // for null). Plastic treats Void as the wrapper for void.
+
+        if (type == void.class)
+        {
+            return type;
+        }
+
+        return PlasticUtils.toWrapperType(type);
+    }
+
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassFabUtils.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassFabUtils.java?rev=1196358&r1=1196357&r2=1196358&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassFabUtils.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassFabUtils.java Tue Nov  1 23:09:30 2011
@@ -18,44 +18,15 @@ import java.io.File;
 import java.lang.reflect.Method;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
-import org.apache.tapestry5.plastic.PlasticUtils;
 
 /**
  * Handy method useful when creating new classes using {@link org.apache.tapestry5.ioc.services.ClassFab}.
- * 
+ *
  * @deprecated Deprecated in Tapestry 5.3, to be removed in 5.4 with no replacement
  */
 @SuppressWarnings("all")
 public final class ClassFabUtils
 {
-    private static final AtomicLong UID_GENERATOR = new AtomicLong(System.currentTimeMillis());
-
-    public static String nextUID()
-    {
-        return Long.toHexString(UID_GENERATOR.getAndIncrement());
-    }
-
-    /**
-     * Generates a unique class name, which will be in the default package.
-     */
-    public static synchronized String generateClassName(String baseName)
-    {
-        return "$" + baseName + "_" + nextUID();
-    }
-
-    /**
-     * Returns a class name derived from the provided interfaceClass. The package part of the interface name is stripped
-     * out, and the result passed to {@link #generateClassName(String)}.
-     */
-    public static String generateClassName(Class interfaceClass)
-    {
-        return generateClassName(interfaceClass.getSimpleName());
-    }
-
     /**
      * Returns true if the method is the standard toString() method. Very few interfaces will ever include this method
      * as part of the interface, but we have to be sure.
@@ -71,175 +42,10 @@ public final class ClassFabUtils
         return method.getReturnType().equals(String.class);
     }
 
-    public static Class getPrimitiveType(String primitiveTypeName)
-    {
-        return PRIMITIVE_TYPE_NAME_TO_PRIMITIVE_INFO.get(primitiveTypeName).primitiveType;
-    }
-
-    private static class PrimitiveInfo
-    {
-        private final Class primitiveType;
-
-        private final String typeCode;
-
-        private final Class wrapperType;
-
-        private final String unwrapMethod;
-
-        public PrimitiveInfo(Class primitiveType, String typeCode, Class wrapperType, String unwrapMethod)
-        {
-            this.primitiveType = primitiveType;
-            this.typeCode = typeCode;
-            this.wrapperType = wrapperType;
-            this.unwrapMethod = unwrapMethod;
-        }
-    }
-
-    private static final Map<String, PrimitiveInfo> PRIMITIVE_TYPE_NAME_TO_PRIMITIVE_INFO = CollectionFactory.newMap();
-    private static final Map<Class, PrimitiveInfo> WRAPPER_TYPE_TO_PRIMITIVE_INFO = CollectionFactory.newMap();
-
-    static
-    {
-        add(boolean.class, "Z", Boolean.class, "booleanValue");
-        add(short.class, "S", Short.class, "shortValue");
-        add(int.class, "I", Integer.class, "intValue");
-        add(long.class, "J", Long.class, "longValue");
-        add(float.class, "F", Float.class, "floatValue");
-        add(double.class, "D", Double.class, "doubleValue");
-        add(char.class, "C", Character.class, "charValue");
-        add(byte.class, "B", Byte.class, "byteValue");
-    }
-
-    private static void add(Class primitiveType, String typeCode, Class wrapperType, String unwrapMethod)
-    {
-        PrimitiveInfo info = new PrimitiveInfo(primitiveType, typeCode, wrapperType, unwrapMethod);
-
-        PRIMITIVE_TYPE_NAME_TO_PRIMITIVE_INFO.put(primitiveType.getName(), info);
-
-        WRAPPER_TYPE_TO_PRIMITIVE_INFO.put(wrapperType, info);
-    }
-
-    /**
-     * Translates types from standard Java format to Java VM format. For example, java.util.Locale remains
-     * java.util.Locale, but int[][] is translated to [[I and java.lang.Object[] to [Ljava.lang.Object;
-     */
-    public static String toJVMBinaryName(String type)
-    {
-        // if it is not an array, just return the type itself
-        if (!type.endsWith("[]"))
-            return type;
-
-        // if it is an array, convert it to JavaVM-style format
-        StringBuilder buffer = new StringBuilder();
-
-        while (type.endsWith("[]"))
-        {
-            buffer.append("[");
-            type = type.substring(0, type.length() - 2);
-        }
-
-        PrimitiveInfo pi = PRIMITIVE_TYPE_NAME_TO_PRIMITIVE_INFO.get(type);
-
-        if (pi != null)
-        {
-            buffer.append(pi.typeCode);
-        }
-        else
-        {
-            buffer.append("L");
-            buffer.append(type);
-            buffer.append(";");
-        }
-
-        return buffer.toString();
-    }
-
-    /**
-     * Given a wrapper type, determines the corresponding primitive type.
-     */
-    public static Class getPrimitiveType(Class wrapperType)
-    {
-        return WRAPPER_TYPE_TO_PRIMITIVE_INFO.get(wrapperType).primitiveType;
-    }
-
-    /**
-     * Returns the wrapper type for an input type; for most types, this is the type. For primitive types, it is the
-     * corresponding wrapper type.
-     * 
-     * @param type
-     *            type to check
-     * @return type or corresponding wrapper type
-     */
-    public static Class getWrapperType(Class type)
-    {
-        PrimitiveInfo info = PRIMITIVE_TYPE_NAME_TO_PRIMITIVE_INFO.get(type.getName());
-
-        return info == null ? type : info.wrapperType;
-    }
-
-    /**
-     * Takes a reference and casts it to the desired type. If the desired type is a primitive type, then the reference
-     * is cast to the correct wrapper type and a call to the correct unwrapper method is added. The end result is code
-     * that can be assigned to a field or parameter of the desired type (even if desired type is a primitive).
-     * 
-     * @param reference
-     *            to be cast
-     * @param desiredType
-     *            desired object or primitive type
-     * @return Javassist code to peform the cast
-     */
-    public static String castReference(String reference, String desiredType)
-    {
-        if (isPrimitiveType(desiredType))
-        {
-            PrimitiveInfo info = PRIMITIVE_TYPE_NAME_TO_PRIMITIVE_INFO.get(desiredType);
-
-            return String.format("((%s)%s).%s()", info.wrapperType.getName(), reference, info.unwrapMethod);
-        }
-
-        return String.format("(%s)%s", desiredType, reference);
-    }
-
-    /**
-     * Given a primitive type, finds the unwrap method of the corresponding wrapper type.
-     * 
-     * @param primitiveType
-     * @return method name
-     */
-    public static String getUnwrapMethodName(Class primitiveType)
-    {
-        return PRIMITIVE_TYPE_NAME_TO_PRIMITIVE_INFO.get(primitiveType.getName()).unwrapMethod;
-    }
-
-    /**
-     * Given a type name, determines if that is the name of a primitive type.
-     */
-    public static boolean isPrimitiveType(String typeName)
-    {
-        return PRIMITIVE_TYPE_NAME_TO_PRIMITIVE_INFO.containsKey(typeName);
-    }
-
-    /**
-     * Converts a Class to a JVM type code (the way class information is expressed in a class file).
-     */
-    public static String getTypeCode(Class type)
-    {
-        if (type.equals(void.class))
-            return "V";
-
-        if (type.isPrimitive())
-            return PRIMITIVE_TYPE_NAME_TO_PRIMITIVE_INFO.get(type.getName()).typeCode;
-
-        if (type.isArray())
-            return "[" + getTypeCode(type.getComponentType());
-
-        return "L" + type.getName().replace('.', '/') + ";";
-    }
-
     /**
      * Given a Class instance, convert the name into a path that can be used to locate
      * the underlying class file on the classpath.
-     * 
+     *
      * @since 5.2.0
      */
     public static String getPathForClass(Class clazz)
@@ -251,7 +57,7 @@ public final class ClassFabUtils
 
     /**
      * Given a fully qualified class name, converts to a path on the classpath.
-     * 
+     *
      * @since 5.2.0
      */
     public static String getPathForClassNamed(String className)
@@ -259,9 +65,10 @@ public final class ClassFabUtils
         return className.replace('.', '/') + ".class";
     }
 
+
     /**
      * Converts a URL with protocol "file" to a File instance.
-     * 
+     *
      * @since 5.2.0
      */
     public static File toFileFromFileProtocolURL(URL url)
@@ -276,8 +83,7 @@ public final class ClassFabUtils
         try
         {
             return new File(url.toURI());
-        }
-        catch (URISyntaxException ex)
+        } catch (URISyntaxException ex)
         {
             return new File(url.getPath());
         }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/CoercionTuple.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/CoercionTuple.java?rev=1196358&r1=1196357&r2=1196358&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/CoercionTuple.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/CoercionTuple.java Tue Nov  1 23:09:30 2011
@@ -14,6 +14,7 @@
 
 package org.apache.tapestry5.ioc.services;
 
+import org.apache.tapestry5.ioc.internal.util.InternalUtils;
 import org.apache.tapestry5.plastic.PlasticUtils;
 
 /**
@@ -115,8 +116,8 @@ public final class CoercionTuple<S, T>
         assert targetType != null;
         assert coercion != null;
 
-        this.sourceType = ClassFabUtils.getWrapperType(sourceType);
-        this.targetType = ClassFabUtils.getWrapperType(targetType);
+        this.sourceType = InternalUtils.getWrapperType(sourceType);
+        this.targetType = InternalUtils.getWrapperType(targetType);
         this.coercion = wrap ? new CoercionWrapper<S, T>(coercion) : coercion;
     }
 

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java?rev=1196358&r1=1196357&r2=1196358&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java Tue Nov  1 23:09:30 2011
@@ -19,7 +19,6 @@ import org.apache.tapestry5.ioc.Registry
 import org.apache.tapestry5.ioc.RegistryBuilder;
 import org.apache.tapestry5.ioc.ServiceDecorator;
 import org.apache.tapestry5.ioc.def.ServiceDef3;
-import org.apache.tapestry5.ioc.services.ClassFactory;
 import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
 import org.apache.tapestry5.ioc.test.IOCTestCase;
 import org.testng.annotations.AfterMethod;
@@ -36,8 +35,6 @@ public class IOCInternalTestCase extends
 {
     private static Registry registry;
 
-    private static ClassFactory classFactory;
-
     private static PlasticProxyFactory proxyFactory;
 
     @AfterMethod
@@ -46,11 +43,6 @@ public class IOCInternalTestCase extends
         registry.cleanupThread();
     }
 
-    public final ClassFactory getClassFactory()
-    {
-        return classFactory;
-    }
-
     public final PlasticProxyFactory getProxyFactory()
     {
         return proxyFactory;
@@ -100,7 +92,6 @@ public class IOCInternalTestCase extends
 
         registry.performRegistryStartup();
 
-        classFactory = registry.getService(ClassFactory.class);
         proxyFactory = registry.getService(PlasticProxyFactory.class);
 
     }
@@ -116,7 +107,6 @@ public class IOCInternalTestCase extends
         registry.shutdown();
 
         registry = null;
-        classFactory = null;
     }
 
     protected final InternalRegistry mockInternalRegistry()

Modified: tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/EntityManagerObjectProvider.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/EntityManagerObjectProvider.java?rev=1196358&r1=1196357&r2=1196358&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/EntityManagerObjectProvider.java (original)
+++ tapestry/tapestry5/trunk/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/EntityManagerObjectProvider.java Tue Nov  1 23:09:30 2011
@@ -14,26 +14,23 @@
 
 package org.apache.tapestry5.internal.jpa;
 
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-
 import org.apache.tapestry5.ioc.AnnotationProvider;
 import org.apache.tapestry5.ioc.ObjectCreator;
 import org.apache.tapestry5.ioc.ObjectLocator;
 import org.apache.tapestry5.ioc.ObjectProvider;
-import org.apache.tapestry5.ioc.services.ClassFactory;
+import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
 import org.apache.tapestry5.jpa.EntityManagerManager;
 
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
 public class EntityManagerObjectProvider implements ObjectProvider
 {
 
     private EntityManager proxy;
 
-    /**
-     * {@inheritDoc}
-     */
     public <T> T provide(final Class<T> objectType, final AnnotationProvider annotationProvider,
-            final ObjectLocator locator)
+                         final ObjectLocator locator)
     {
         if (objectType.equals(EntityManager.class))
             return objectType.cast(getOrCreateProxy(annotationProvider, locator));
@@ -46,13 +43,13 @@ public class EntityManagerObjectProvider
     {
         if (proxy == null)
         {
-            final ClassFactory classFactory = objectLocator.getService("ClassFactory",
-                    ClassFactory.class);
+            final PlasticProxyFactory proxyFactory = objectLocator.getService("PlasticProxyFactory",
+                    PlasticProxyFactory.class);
 
-             final PersistenceContext annotation = annotationProvider
-                            .getAnnotation(PersistenceContext.class);
+            final PersistenceContext annotation = annotationProvider
+                    .getAnnotation(PersistenceContext.class);
 
-            proxy = classFactory.createProxy(EntityManager.class, new ObjectCreator()
+            proxy = proxyFactory.createProxy(EntityManager.class, new ObjectCreator()
             {
                 public Object createObject()
                 {