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/07/25 01:04:49 UTC
svn commit: r1150521 - in
/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5:
internal/services/ServiceInjectionProvider.java services/TapestryModule.java
Author: hlship
Date: Sun Jul 24 23:04:49 2011
New Revision: 1150521
URL: http://svn.apache.org/viewvc?rev=1150521&view=rev
Log:
TAP5-1508: Record ServiceInjectionProvider to InjectionProvider2
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServiceInjectionProvider.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/ServiceInjectionProvider.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServiceInjectionProvider.java?rev=1150521&r1=1150520&r2=1150521&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServiceInjectionProvider.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ServiceInjectionProvider.java Sun Jul 24 23:04:49 2011
@@ -17,31 +17,34 @@ package org.apache.tapestry5.internal.se
import org.apache.tapestry5.ioc.ObjectLocator;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.model.MutableComponentModel;
-import org.apache.tapestry5.services.ClassTransformation;
-import org.apache.tapestry5.services.InjectionProvider;
+import org.apache.tapestry5.plastic.PlasticField;
+import org.apache.tapestry5.services.transform.InjectionProvider2;
/**
* A very late worker related to the {@link Inject} annotation that, when all other forms of injection have failed,
* matches the field type to a service interface.
*/
-public class ServiceInjectionProvider implements InjectionProvider
+public class ServiceInjectionProvider implements InjectionProvider2
{
private final ObjectLocator locator;
- public ServiceInjectionProvider(ObjectLocator locator)
+ private final ComponentClassCache classCache;
+
+ public ServiceInjectionProvider(ObjectLocator locator, ComponentClassCache classCache)
{
this.locator = locator;
+ this.classCache = classCache;
}
- @SuppressWarnings("unchecked")
- public boolean provideInjection(String fieldName, Class fieldType, ObjectLocator locator,
- ClassTransformation transformation, MutableComponentModel componentModel)
+ public boolean provideInjection(PlasticField field, ObjectLocator locator, MutableComponentModel componentModel)
{
+ Class fieldType = classCache.forName(field.getTypeName());
+
Object inject = this.locator.getService(fieldType);
assert inject != null;
- transformation.getField(fieldName).inject(inject);
+ field.inject(inject);
// If we make it this far without an exception, then we were successful
// and should claim the field.
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=1150521&r1=1150520&r2=1150521&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:04:49 2011
@@ -752,6 +752,9 @@ public final class TapestryModule
* <dd>Access to properties of resources (log, messages, etc.)</dd>
* <dt>Asset</dt>
* <dd>injection of assets (triggered via {@link Path} annotation), with the path relative to the component class</dd>
+ * <dt>Service</dt>
+ * <dd>Ordered last, for use when Inject is present and nothing else works, matches field type against Tapestry IoC
+ * services</dd>
* </dl>
*/
@Contribute(InjectionProvider2.class)
@@ -763,6 +766,10 @@ public final class TapestryModule
configuration.add("Block", new BlockInjectionProvider(), "before:Default");
configuration.add("CommonResources", new CommonResourcesInjectionProvider(), "after:Default");
configuration.add("Asset", new AssetInjectionProvider(symbolSource, assetSource), "before:Default");
+ // 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:*");
+
}
/**
@@ -772,9 +779,6 @@ public final class TapestryModule
* <dd>based on {@link MasterObjectProvider}</dd>
* <dt>ComponentResources</dt>
* <dd>give component access to its resources</dd>
- * <dt>Service</dt>
- * <dd>ordered last, for use when Inject is present and nothing else works, matches field type against Tapestry IoC
- * services</dd>
* </dl>
*/
@Contribute(InjectionProvider2.class)
@@ -788,9 +792,6 @@ public final class TapestryModule
configuration.add("ComponentResources", new ComponentResourcesInjectionProvider());
- // This needs to be the last one, since it matches against services
- // and might blow up if there is no match.
- configuration.add("Service", new ServiceInjectionProvider(locator), "after:*");
}
/**