tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r961460 - /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/EnvironmentalWorker.java
Date Wed, 07 Jul 2010 18:27:56 GMT
Author: hlship
Date: Wed Jul  7 18:27:55 2010
New Revision: 961460

URL: http://svn.apache.org/viewvc?rev=961460&view=rev
Log:
TAP5-1197: Change EnvironmentalWorker to no longer use EnvironmentalAccess, as those would
have to be stored in the PerThreadManager anyway, negating the advantage.

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/EnvironmentalWorker.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/EnvironmentalWorker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/EnvironmentalWorker.java?rev=961460&r1=961459&r2=961460&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/EnvironmentalWorker.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/EnvironmentalWorker.java
Wed Jul  7 18:27:55 2010
@@ -16,27 +16,25 @@ package org.apache.tapestry5.internal.tr
 
 import org.apache.tapestry5.ComponentResources;
 import org.apache.tapestry5.annotations.Environmental;
-import org.apache.tapestry5.ioc.services.Builtin;
-import org.apache.tapestry5.ioc.services.ClassFactory;
+import org.apache.tapestry5.internal.services.ComponentClassCache;
 import org.apache.tapestry5.ioc.services.FieldValueConduit;
 import org.apache.tapestry5.model.MutableComponentModel;
-import org.apache.tapestry5.runtime.PageLifecycleAdapter;
 import org.apache.tapestry5.services.ClassTransformation;
 import org.apache.tapestry5.services.ComponentClassTransformWorker;
 import org.apache.tapestry5.services.ComponentValueProvider;
 import org.apache.tapestry5.services.Environment;
-import org.apache.tapestry5.services.EnvironmentalAccess;
 import org.apache.tapestry5.services.TransformField;
 
 /**
  * Obtains a value from the {@link Environment} service based on the field type. This is
triggered by the presence of
  * the {@link Environmental} annotation.
  */
+@SuppressWarnings("rawtypes")
 public class EnvironmentalWorker implements ComponentClassTransformWorker
 {
     private final Environment environment;
 
-    private final ClassLoader classLoader;
+    private final ComponentClassCache classCache;
 
     @SuppressWarnings("unchecked")
     private final class EnvironmentalConduit extends ReadOnlyFieldValueConduit
@@ -45,41 +43,26 @@ public class EnvironmentalWorker impleme
 
         private final boolean required;
 
-        private EnvironmentalAccess access;
-
-        private EnvironmentalConduit(ComponentResources resources, String fieldName,
-                final Class environmentalType, boolean required)
+        private EnvironmentalConduit(ComponentResources resources, String fieldName, final
Class environmentalType,
+                boolean required)
         {
             super(resources, fieldName);
 
             this.environmentalType = environmentalType;
             this.required = required;
-
-            resources.addPageLifecycleListener(new PageLifecycleAdapter()
-            {
-                @Override
-                public void containingPageDidDetach()
-                {
-                    access = null;
-                }
-            });
         }
 
         public Object get()
         {
-            if (access == null)
-                access = environment.getAccess(environmentalType);
-
-            return required ? access.peekRequired() : access.peek();
+            return required ? environment.peekRequired(environmentalType) : environment.peek(environmentalType);
         }
     }
 
-    public EnvironmentalWorker(Environment environment, @Builtin
-    ClassFactory servicesLayerClassFactory)
+    public EnvironmentalWorker(Environment environment, ComponentClassCache classCache)
     {
         this.environment = environment;
 
-        classLoader = servicesLayerClassFactory.getClassLoader();
+        this.classCache = classCache;
     }
 
     public void transform(ClassTransformation transformation, MutableComponentModel model)
@@ -98,7 +81,7 @@ public class EnvironmentalWorker impleme
 
         final String fieldName = field.getName();
 
-        final Class fieldType = toClass(field.getType());
+        final Class fieldType = classCache.forName(field.getType());
 
         final boolean required = annotation.value();
 
@@ -113,15 +96,4 @@ public class EnvironmentalWorker impleme
         field.replaceAccess(provider);
     }
 
-    private Class toClass(String typeName)
-    {
-        try
-        {
-            return classLoader.loadClass(typeName);
-        }
-        catch (ClassNotFoundException ex)
-        {
-            throw new RuntimeException(ex);
-        }
-    }
 }



Mime
View raw message