tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r1150523 - in /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5: internal/services/DefaultInjectionProvider.java services/TapestryModule.java
Date Sun, 24 Jul 2011 23:05:15 GMT
Author: hlship
Date: Sun Jul 24 23:05:14 2011
New Revision: 1150523

URL: http://svn.apache.org/viewvc?rev=1150523&view=rev
Log:
TAP5-1508: Record DefaultInjectionProvider to InjectionProvider2

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultInjectionProvider.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultInjectionProvider.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultInjectionProvider.java?rev=1150523&r1=1150522&r2=1150523&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultInjectionProvider.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultInjectionProvider.java
Sun Jul 24 23:05:14 2011
@@ -14,37 +14,42 @@
 
 package org.apache.tapestry5.internal.services;
 
+import org.apache.tapestry5.ioc.AnnotationProvider;
 import org.apache.tapestry5.ioc.Messages;
 import org.apache.tapestry5.ioc.ObjectLocator;
 import org.apache.tapestry5.ioc.services.MasterObjectProvider;
 import org.apache.tapestry5.model.MutableComponentModel;
-import org.apache.tapestry5.services.ClassTransformation;
-import org.apache.tapestry5.services.InjectionProvider;
-import org.apache.tapestry5.services.TransformField;
+import org.apache.tapestry5.plastic.PlasticField;
+import org.apache.tapestry5.services.transform.InjectionProvider2;
+
+import java.lang.annotation.Annotation;
 
 /**
  * Worker for the {@link org.apache.tapestry5.ioc.annotations.Inject} annotation that delegates
out to the master
  * {@link org.apache.tapestry5.ioc.services.MasterObjectProvider} to access the value. This
worker must be scheduled
  * after certain other workers, such as {@link BlockInjectionProvider} (which is keyed off
a combination of type and
  * the Inject annotation).
- * 
+ *
  * @see org.apache.tapestry5.ioc.services.MasterObjectProvider
  */
-public class DefaultInjectionProvider implements InjectionProvider
+public class DefaultInjectionProvider implements InjectionProvider2
 {
     private final MasterObjectProvider masterObjectProvider;
 
     private final ObjectLocator locator;
 
-    public DefaultInjectionProvider(MasterObjectProvider masterObjectProvider, ObjectLocator
locator)
+    private final ComponentClassCache classCache;
+
+    private final static String MESSAGES_TYPE = Messages.class.getName();
+
+    public DefaultInjectionProvider(MasterObjectProvider masterObjectProvider, ObjectLocator
locator, ComponentClassCache classCache)
     {
         this.masterObjectProvider = masterObjectProvider;
         this.locator = locator;
+        this.classCache = classCache;
     }
 
-    @SuppressWarnings("unchecked")
-    public boolean provideInjection(String fieldName, Class fieldType, ObjectLocator locator,
-            final ClassTransformation transformation, MutableComponentModel componentModel)
+    public boolean provideInjection(final PlasticField field, ObjectLocator locator, MutableComponentModel
componentModel)
     {
         // I hate special cases, but we have a conflict between the ObjectProvider contributed
so as to inject
         // the global application messages into services, and the injection of per-component
Messages into components.
@@ -52,12 +57,20 @@ public class DefaultInjectionProvider im
         // to inject the wrong Messages (the global application messages, not the component
messages) ... so we
         // make a special check here.
 
-        if (fieldType.equals(Messages.class))
+        if (field.getTypeName().equals(MESSAGES_TYPE))
+        {
             return false;
+        }
 
-        TransformField field = transformation.getField(fieldName);
+        Class fieldType = classCache.forName(field.getTypeName());
 
-        Object injectionValue = masterObjectProvider.provide(fieldType, field, this.locator,
false);
+        Object injectionValue = masterObjectProvider.provide(fieldType, new AnnotationProvider()
+        {
+            public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
+            {
+                return field.getAnnotation(annotationClass);
+            }
+        }, this.locator, false);
 
         // Null means that no ObjectProvider could provide the value. We have set up the
chain of
         // command so that InjectResources can give it a try next. Later, we'll try to match
against

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=1150523&r1=1150522&r2=1150523&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
Sun Jul 24 23:05:14 2011
@@ -745,6 +745,8 @@ public final class TapestryModule
 
     /**
      * <dl>
+     * <dt>Default</dt>
+     * <dd>based on {@link MasterObjectProvider}</dd>
      * <dt>Named</dt> <dd>Handles fields with the {@link javax.inject.Named}
annotation</dd>
      * <dt>Block</dt>
      * <dd>injects fields of type {@link Block}</dd>
@@ -762,33 +764,16 @@ public final class TapestryModule
 
                                                          AssetSource assetSource)
     {
-        configuration.addInstance("Named", InjectNamedProvider.class, "before:Default");
-        configuration.add("Block", new BlockInjectionProvider(), "before:Default");
-        configuration.add("CommonResources", new CommonResourcesInjectionProvider(), "after:Default");
-        configuration.add("Asset", new AssetInjectionProvider(symbolSource, assetSource),
"before:Default");
+        configuration.addInstance("Named", InjectNamedProvider.class);
+        configuration.add("Block", new BlockInjectionProvider());
+        configuration.add("Asset", new AssetInjectionProvider(symbolSource, assetSource));
+
+        configuration.addInstance("Default", DefaultInjectionProvider.class);
+
+        configuration.add("CommonResources", new CommonResourcesInjectionProvider());
         // This needs to be the last one, since it matches against services
         // and might blow up if there is no match.
         configuration.addInstance("Service", ServiceInjectionProvider.class, "after:*");
-
-    }
-
-    /**
-     * Contributes the base set of injection providers:
-     * <dl>
-     * <dt>Default</dt>
-     * <dd>based on {@link MasterObjectProvider}</dd>
-     * <dt>ComponentResources</dt>
-     * <dd>give component access to its resources</dd>
-     * </dl>
-     */
-    @Contribute(InjectionProvider2.class)
-    public static void provideOldStyleInjectionProvider(OrderedConfiguration<InjectionProvider>
configuration,
-
-                                                        MasterObjectProvider masterObjectProvider,
-
-                                                        ObjectLocator locator)
-    {
-        configuration.add("Default", new DefaultInjectionProvider(masterObjectProvider, locator));
     }
 
     /**



Mime
View raw message