You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2007/03/30 00:45:44 UTC

svn commit: r523862 [3/4] - in /tapestry/tapestry5: quickstart/trunk/src/main/resources/archetype-resources/ tapestry-component-report/trunk/ tapestry-core/trunk/src/main/java/org/apache/tapestry/ tapestry-core/trunk/src/main/java/org/apache/tapestry/a...

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/AliasManagerImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/AliasManagerImplTest.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/AliasManagerImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/AliasManagerImplTest.java Thu Mar 29 15:45:36 2007
@@ -14,8 +14,7 @@
 
 package org.apache.tapestry.internal.services;
 
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
-
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Map;
 
@@ -31,18 +30,22 @@
     public void no_conflict()
     {
         Log log = newLog();
+        Runnable r = newRunnable();
 
         replay();
 
-        Collection<AliasContribution> configuration = buildConfiguration();
+        AliasContribution[] contributions =
+        { AliasContribution.create(String.class, "FRED"),
+                AliasContribution.create(Runnable.class, r) };
+        Collection<AliasContribution> configuration = Arrays.asList(contributions);
 
         AliasManager manager = new AliasManagerImpl(log, configuration);
 
-        Map<String, Object> map = manager.getAliasesForMode("foo");
+        Map<Class, Object> map = manager.getAliasesForMode("foo");
 
         assertEquals(map.size(), 2);
-        assertEquals(map.get("fred"), "FRED");
-        assertEquals(map.get("barney"), "BARNEY");
+        assertEquals(map.get(String.class), "FRED");
+        assertSame(map.get(Runnable.class), r);
 
         verify();
     }
@@ -51,22 +54,26 @@
     public void first_entry_wins_on_conflict()
     {
         Log log = newLog();
+        Runnable r = newRunnable();
 
         log
-                .warn("Contribution FRED-CONFLICT (as 'fred') duplicates existing contribution FRED and has been ignored.");
+                .error("Contribution FRED-CONFLICT (for type java.lang.String) conflicts with existing contribution FRED and has been ignored.");
 
         replay();
 
-        Collection<AliasContribution> configuration = buildConfiguration();
-        configuration.add(new AliasContribution("fred", "FRED-CONFLICT"));
+        AliasContribution[] contributions =
+        { AliasContribution.create(String.class, "FRED"),
+                AliasContribution.create(String.class, "FRED-CONFLICT"),
+                AliasContribution.create(Runnable.class, r) };
+        Collection<AliasContribution> configuration = Arrays.asList(contributions);
 
         AliasManager manager = new AliasManagerImpl(log, configuration);
 
-        Map<String, Object> map = manager.getAliasesForMode("foo");
+        Map<Class, Object> map = manager.getAliasesForMode("foo");
 
         assertEquals(map.size(), 2);
-        assertEquals(map.get("fred"), "FRED");
-        assertEquals(map.get("barney"), "BARNEY");
+        assertEquals(map.get(String.class), "FRED");
+        assertSame(map.get(Runnable.class), r);
 
         verify();
     }
@@ -75,20 +82,23 @@
     public void contributions_to_other_modes_are_ignored()
     {
         Log log = newLog();
+        Runnable r = newRunnable();
 
         replay();
 
-        Collection<AliasContribution> configuration = buildConfiguration();
-
-        configuration.add(new AliasContribution("barney", "bar", "BARNEY2"));
+        AliasContribution[] contributions =
+        { AliasContribution.create(String.class, "FRED"),
+                AliasContribution.create(String.class, "bar", "FRED-NON-CONFLICT"),
+                AliasContribution.create(Runnable.class, r) };
+        Collection<AliasContribution> configuration = Arrays.asList(contributions);
 
         AliasManager manager = new AliasManagerImpl(log, configuration);
 
-        Map<String, Object> map = manager.getAliasesForMode("foo");
+        Map<Class, Object> map = manager.getAliasesForMode("foo");
 
         assertEquals(map.size(), 2);
-        assertEquals(map.get("fred"), "FRED");
-        assertEquals(map.get("barney"), "BARNEY");
+        assertEquals(map.get(String.class), "FRED");
+        assertSame(map.get(Runnable.class), r);
 
         verify();
     }
@@ -97,32 +107,24 @@
     public void mode_specific_contribution_overrides_general_contribution()
     {
         Log log = newLog();
+        Runnable r = newRunnable();
 
         replay();
 
-        Collection<AliasContribution> configuration = buildConfiguration();
-
-        configuration.add(new AliasContribution("fred", "foo", "FRED-OVERRIDE"));
+        AliasContribution[] contributions =
+        { AliasContribution.create(String.class, "FRED"),
+                AliasContribution.create(String.class, "bar", "FRED-NON-CONFLICT"),
+                AliasContribution.create(Runnable.class, r) };
+        Collection<AliasContribution> configuration = Arrays.asList(contributions);
 
         AliasManager manager = new AliasManagerImpl(log, configuration);
 
-        Map<String, Object> map = manager.getAliasesForMode("foo");
+        Map<Class, Object> map = manager.getAliasesForMode("BAR");
 
         assertEquals(map.size(), 2);
-        assertEquals(map.get("fred"), "FRED-OVERRIDE");
-        assertEquals(map.get("barney"), "BARNEY");
+        assertEquals(map.get(String.class), "FRED-NON-CONFLICT");
+        assertSame(map.get(Runnable.class), r);
 
         verify();
-
-    }
-
-    private Collection<AliasContribution> buildConfiguration()
-    {
-        Collection<AliasContribution> configuration = newList();
-
-        configuration.add(new AliasContribution("fred", "FRED"));
-        configuration.add(new AliasContribution("barney", "foo", "BARNEY"));
-
-        return configuration;
     }
 }

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/AssetInjectionProviderTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/AssetInjectionProviderTest.java?view=auto&rev=523862
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/AssetInjectionProviderTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/AssetInjectionProviderTest.java Thu Mar 29 15:45:36 2007
@@ -0,0 +1,92 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.services;
+
+import org.apache.tapestry.annotations.Path;
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.apache.tapestry.ioc.ServiceLocator;
+import org.apache.tapestry.ioc.services.SymbolSource;
+import org.apache.tapestry.model.MutableComponentModel;
+import org.apache.tapestry.services.AssetSource;
+import org.apache.tapestry.services.ClassTransformation;
+import org.apache.tapestry.services.InjectionProvider;
+import org.testng.annotations.Test;
+
+public class AssetInjectionProviderTest extends InternalBaseTestCase
+{
+    @Test
+    public void no_path_annotation()
+    {
+        SymbolSource symbolSource = newSymbolSource();
+        AssetSource assetSource = newAssetSource();
+        ServiceLocator locator = newServiceLocator();
+        ClassTransformation ct = newClassTransformation();
+        MutableComponentModel model = newMutableComponentModel();
+
+        String fieldName = "myField";
+        String fieldType = "java.lang.String";
+
+        train_getFieldAnnotation(ct, fieldName, Path.class, null);
+
+        replay();
+
+        InjectionProvider provider = new AssetInjectionProvider(symbolSource, assetSource);
+
+        assertFalse(provider.provideInjection(fieldName, fieldType, locator, ct, model));
+
+        verify();
+    }
+
+    @Test
+    public void path_annotation_present()
+    {
+        SymbolSource symbolSource = newSymbolSource();
+        AssetSource assetSource = newAssetSource();
+        ServiceLocator locator = newServiceLocator();
+        ClassTransformation ct = newClassTransformation();
+        MutableComponentModel model = newMutableComponentModel();
+        Path annotation = newPath();
+
+        String fieldName = "myField";
+        String fieldType = "java.lang.Object";
+        String value = "${foo}";
+        String expanded = "foo.gif";
+
+        train_getFieldAnnotation(ct, fieldName, Path.class, annotation);
+
+        train_value(annotation, value);
+        train_expandSymbols(symbolSource, value, expanded);
+
+        train_addInjectedField(ct, AssetSource.class, "assetSource", assetSource, "as");
+        train_getResourcesFieldName(ct, "rez");
+
+        // This only tests that the code is generated as expected (which is a bit brittle), it
+        // doesn't prove that the generated code actually works, but we have lots of integration
+        // tests for that.
+
+        ct
+                .extendConstructor("myField = (java.lang.Object) as.findAsset(rez.getBaseResource(), \"foo.gif\", rez.getLocale());");
+
+        ct.makeReadOnly(fieldName);
+
+        replay();
+
+        InjectionProvider provider = new AssetInjectionProvider(symbolSource, assetSource);
+
+        assertTrue(provider.provideInjection(fieldName, fieldType, locator, ct, model));
+
+        verify();
+    }
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/AssetObjectProviderTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/AssetObjectProviderTest.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/AssetObjectProviderTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/AssetObjectProviderTest.java Thu Mar 29 15:45:36 2007
@@ -14,43 +14,36 @@
 
 package org.apache.tapestry.internal.services;
 
-import java.math.BigDecimal;
-import java.util.Locale;
-
 import org.apache.tapestry.Asset;
+import org.apache.tapestry.annotations.Path;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.apache.tapestry.ioc.AnnotationProvider;
 import org.apache.tapestry.ioc.ObjectProvider;
-import org.apache.tapestry.ioc.Resource;
 import org.apache.tapestry.ioc.ServiceLocator;
-import org.apache.tapestry.ioc.services.ThreadLocale;
+import org.apache.tapestry.ioc.services.SymbolSource;
+import org.apache.tapestry.ioc.services.TypeCoercer;
 import org.apache.tapestry.services.AssetSource;
 import org.testng.annotations.Test;
 
 public class AssetObjectProviderTest extends InternalBaseTestCase
 {
+
     @Test
-    public void incorrect_object_type()
+    public void no_path_annotation()
     {
         AssetSource source = newAssetSource();
-        ThreadLocale threadLocale = newThreadLocale();
-        Resource root = newResource();
         ServiceLocator locator = newServiceLocator();
+        AnnotationProvider annotationProvider = newAnnotationProvider();
+        TypeCoercer typeCoercer = newTypeCoercer();
+        SymbolSource symbolSource = newSymbolSource();
+
+        train_getAnnotation(annotationProvider, Path.class, null);
 
         replay();
 
-        ObjectProvider provider = new AssetObjectProvider(source, threadLocale, root);
+        ObjectProvider provider = new AssetObjectProvider(source, typeCoercer, symbolSource);
 
-        try
-        {
-            provider.provide("foo/bar/baz.gif", BigDecimal.class, locator);
-            unreachable();
-        }
-        catch (RuntimeException ex)
-        {
-            assertEquals(
-                    ex.getMessage(),
-                    "Asset path \'foo/bar/baz.gif\' may not be assigned to type java.math.BigDecimal. Use type java.lang.Object or (preferrably) org.apache.tapestry.Asset.");
-        }
+        assertNull(provider.provide(Asset.class, annotationProvider, locator));
 
         verify();
     }
@@ -59,30 +52,29 @@
     public void normal_conversion()
     {
         AssetSource source = newAssetSource();
-        ThreadLocale threadLocale = newThreadLocale();
-        Resource root = newResource();
         ServiceLocator locator = newServiceLocator();
         Asset asset = newAsset();
-        Locale locale = Locale.GERMAN;
-        String path = "foo/bar/baz.gif";
-
-        train_getLocale(threadLocale, locale);
-        train_findAsset(source, root, path, locale, asset);
+        String path = "${foo}";
+        String expanded = "foo/bar/baz.gif";
+        AnnotationProvider annotationProvider = newAnnotationProvider();
+        TypeCoercer typeCoercer = newTypeCoercer();
+        Path pathAnnotation = newPath();
+        SymbolSource symbolSource = newSymbolSource();
+
+        train_getAnnotation(annotationProvider, Path.class, pathAnnotation);
+        train_value(pathAnnotation, path);
+        train_expandSymbols(symbolSource, path, expanded);
+        train_findAsset(source, null, expanded, null, asset);
+        train_coerce(typeCoercer, asset, Asset.class, asset);
 
         replay();
 
-        ObjectProvider provider = new AssetObjectProvider(source, threadLocale, root);
+        ObjectProvider provider = new AssetObjectProvider(source, typeCoercer, symbolSource);
 
-        Asset result = provider.provide(path, Asset.class, locator);
+        Asset result = provider.provide(Asset.class, annotationProvider, locator);
 
         assertSame(result, asset);
 
         verify();
-    }
-
-    private void train_findAsset(AssetSource source, Resource root, String path, Locale locale,
-            Asset asset)
-    {
-        expect(source.findAsset(root, path, locale)).andReturn(asset);
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/BeanModelSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/BeanModelSourceImplTest.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/BeanModelSourceImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/BeanModelSourceImplTest.java Thu Mar 29 15:45:36 2007
@@ -36,7 +36,7 @@
     @BeforeClass
     public void setup()
     {
-        _source = getObject("alias:BeanModelSource", BeanModelSource.class);
+        _source = getObject(BeanModelSource.class, null);
     }
 
     @AfterClass

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentEventImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentEventImplTest.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentEventImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ComponentEventImplTest.java Thu Mar 29 15:45:36 2007
@@ -30,7 +30,7 @@
     @BeforeClass
     public void setup_coercer()
     {
-        _coercer = getObject("alias:TypeCoercer", TypeCoercer.class);
+        _coercer = getObject(TypeCoercer.class, null);
     }
 
     @AfterClass

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/FieldValidatorDefaultSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/FieldValidatorDefaultSourceImplTest.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/FieldValidatorDefaultSourceImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/FieldValidatorDefaultSourceImplTest.java Thu Mar 29 15:45:36 2007
@@ -16,10 +16,10 @@
 
 import java.util.Locale;
 
-import org.apache.tapestry.AnnotationProvider;
 import org.apache.tapestry.Field;
 import org.apache.tapestry.FieldValidator;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.apache.tapestry.ioc.AnnotationProvider;
 import org.apache.tapestry.ioc.Messages;
 import org.apache.tapestry.services.FieldValidatorDefaultSource;
 import org.apache.tapestry.services.FieldValidatorSource;

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectBlockWorkerTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectBlockWorkerTest.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectBlockWorkerTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectBlockWorkerTest.java Thu Mar 29 15:45:36 2007
@@ -14,6 +14,7 @@
 
 package org.apache.tapestry.internal.services;
 
+import org.apache.tapestry.annotations.Id;
 import org.apache.tapestry.annotations.Inject;
 import org.apache.tapestry.model.MutableComponentModel;
 import org.apache.tapestry.services.ClassTransformation;
@@ -60,6 +61,11 @@
         verify();
     }
 
+    protected final Id newId()
+    {
+        return newMock(Id.class);
+    }
+
     /**
      * This doesn't prove anything; later there will be integration tests that prove that the
      * generated code is valid and works.
@@ -71,23 +77,33 @@
         MutableComponentModel model = newMutableComponentModel();
         Inject fredAnnotation = newInject();
         Inject barneyAnnotation = newInject();
+        Id barneyId = newId();
 
-        train_findFieldsOfType(ct, InjectBlockWorker.BLOCK_TYPE_NAME, "fred", "_barneyBlock");
+        String barneyFieldName = "_barneyBlock";
+        String fredFieldName = "fred";
+
+        train_findFieldsOfType(
+                ct,
+                InjectBlockWorker.BLOCK_TYPE_NAME,
+                fredFieldName,
+                barneyFieldName);
 
         train_getResourcesFieldName(ct, "rez");
 
-        train_getFieldAnnotation(ct, "fred", Inject.class, fredAnnotation);
+        train_getFieldAnnotation(ct, fredFieldName, Inject.class, fredAnnotation);
+
+        train_getFieldAnnotation(ct, fredFieldName, Id.class, null);
 
-        train_value(fredAnnotation, "");
+        ct.makeReadOnly(fredFieldName);
+        ct.claimField(fredFieldName, fredAnnotation);
 
-        ct.makeReadOnly("fred");
-        ct.claimField("fred", fredAnnotation);
+        train_getFieldAnnotation(ct, barneyFieldName, Inject.class, barneyAnnotation);
+        train_getFieldAnnotation(ct, barneyFieldName, Id.class, barneyId);
 
-        train_getFieldAnnotation(ct, "_barneyBlock", Inject.class, barneyAnnotation);
-        train_value(barneyAnnotation, "barney");
+        train_value(barneyId, "barney");
 
-        ct.makeReadOnly("_barneyBlock");
-        ct.claimField("_barneyBlock", barneyAnnotation);
+        ct.makeReadOnly(barneyFieldName);
+        ct.claimField(barneyFieldName, barneyAnnotation);
 
         train_extendMethod(
                 ct,

Copied: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectResourcesWorkerTest.java (from r519727, tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectAnonymousWorkerTest.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectResourcesWorkerTest.java?view=diff&rev=523862&p1=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectAnonymousWorkerTest.java&r1=519727&p2=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectResourcesWorkerTest.java&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectAnonymousWorkerTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectResourcesWorkerTest.java Thu Mar 29 15:45:36 2007
@@ -24,7 +24,7 @@
 import org.apache.tapestry.services.Request;
 import org.testng.annotations.Test;
 
-public class InjectAnonymousWorkerTest extends InternalBaseTestCase
+public class InjectResourcesWorkerTest extends InternalBaseTestCase
 {
     private static final String WEBREQUEST_CLASS_NAME = Request.class.getName();
 
@@ -48,7 +48,7 @@
 
         replay();
 
-        ComponentClassTransformWorker worker = new InjectAnonymousWorker(locator, ip);
+        ComponentClassTransformWorker worker = new InjectResourcesWorker(locator, ip);
 
         worker.transform(ct, model);
 
@@ -71,24 +71,13 @@
 
         train_provideInjection(ip, "myfield", WEBREQUEST_CLASS_NAME, locator, ct, model, false);
 
-        train_getClassName(ct, "foo.Baz");
-
         replay();
 
-        ComponentClassTransformWorker worker = new InjectAnonymousWorker(locator, ip);
+        ComponentClassTransformWorker worker = new InjectResourcesWorker(locator, ip);
+
+        // Does the work but doesn't claim the field, since there was no match.
 
-        try
-        {
-            worker.transform(ct, model);
-            unreachable();
-        }
-        catch (RuntimeException ex)
-        {
-            assertEquals(ex.getMessage(), ServicesMessages.noInjectionFound(
-                    "foo.Baz",
-                    "myfield",
-                    WEBREQUEST_CLASS_NAME));
-        }
+        worker.transform(ct, model);
 
         verify();
     }

Copied: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectWorkerTest.java (from r519727, tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectNamedWorkerTest.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectWorkerTest.java?view=diff&rev=523862&p1=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectNamedWorkerTest.java&r1=519727&p2=tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectWorkerTest.java&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectNamedWorkerTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/InjectWorkerTest.java Thu Mar 29 15:45:36 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -14,8 +14,12 @@
 
 package org.apache.tapestry.internal.services;
 
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.isA;
+
 import org.apache.tapestry.annotations.Inject;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.apache.tapestry.ioc.AnnotationProvider;
 import org.apache.tapestry.ioc.ObjectProvider;
 import org.apache.tapestry.ioc.ServiceLocator;
 import org.apache.tapestry.model.MutableComponentModel;
@@ -23,9 +27,8 @@
 import org.apache.tapestry.services.Request;
 import org.testng.annotations.Test;
 
-public class InjectNamedWorkerTest extends InternalBaseTestCase
+public class InjectWorkerTest extends InternalBaseTestCase
 {
-
     private static final String WEBREQUEST_CLASS_NAME = Request.class.getName();
 
     @Test
@@ -41,12 +44,11 @@
         train_findFieldsWithAnnotation(ct, Inject.class, "myfield");
         train_getFieldAnnotation(ct, "myfield", Inject.class, annotation);
 
-        train_value(annotation, "foo:Bar");
-
         train_getFieldType(ct, "myfield", WEBREQUEST_CLASS_NAME);
         train_toClass(ct, WEBREQUEST_CLASS_NAME, Request.class);
 
-        train_provide(provider, "foo:Bar", Request.class, locator, injected);
+        expect(provider.provide(eq(Request.class), isA(AnnotationProvider.class), eq(locator)))
+                .andReturn(injected);
 
         ct.injectField("myfield", injected);
 
@@ -54,9 +56,49 @@
 
         replay();
 
-        InjectNamedWorker worker = new InjectNamedWorker(provider, locator);
+        InjectWorker worker = new InjectWorker(provider, locator);
 
         worker.transform(ct, model);
+
+        verify();
+    }
+
+    @Test
+    public void provide_object_fails()
+    {
+        ObjectProvider provider = newObjectProvider();
+        ServiceLocator locator = newServiceLocator();
+        Inject annotation = newMock(Inject.class);
+        ClassTransformation ct = newClassTransformation();
+        MutableComponentModel model = newMutableComponentModel();
+        Throwable cause = new RuntimeException("Injection failed.");
+
+        train_findFieldsWithAnnotation(ct, Inject.class, "myfield");
+        train_getFieldAnnotation(ct, "myfield", Inject.class, annotation);
+
+        train_getFieldType(ct, "myfield", WEBREQUEST_CLASS_NAME);
+        train_toClass(ct, WEBREQUEST_CLASS_NAME, Request.class);
+
+        expect(provider.provide(eq(Request.class), isA(AnnotationProvider.class), eq(locator)))
+                .andThrow(cause);
+        train_getClassName(ct, "foo.pages.Bar");
+
+        replay();
+
+        InjectWorker worker = new InjectWorker(provider, locator);
+
+        try
+        {
+            worker.transform(ct, model);
+            unreachable();
+        }
+        catch (RuntimeException ex)
+        {
+            assertEquals(
+                    ex.getMessage(),
+                    "Error obtaining injected value for field foo.pages.Bar.myfield: Injection failed.");
+            assertSame(ex.getCause(), cause);
+        }
 
         verify();
     }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkFactoryImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkFactoryImplTest.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkFactoryImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/LinkFactoryImplTest.java Thu Mar 29 15:45:36 2007
@@ -49,7 +49,7 @@
     @BeforeClass
     public void setup()
     {
-        _typeCoercer = getObject("service:TypeCoercer", TypeCoercer.class);
+        _typeCoercer = getObject(TypeCoercer.class, null);
     }
 
     @AfterClass

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageRenderSupportImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageRenderSupportImplTest.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageRenderSupportImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PageRenderSupportImplTest.java Thu Mar 29 15:45:36 2007
@@ -17,9 +17,8 @@
 import org.apache.tapestry.Asset;
 import org.apache.tapestry.PageRenderSupport;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
-import org.apache.tapestry.ioc.Resource;
 import org.apache.tapestry.ioc.services.SymbolSource;
-import org.apache.tapestry.services.AssetFactory;
+import org.apache.tapestry.services.AssetSource;
 import org.testng.annotations.Test;
 
 public class PageRenderSupportImplTest extends InternalBaseTestCase
@@ -68,24 +67,19 @@
 
         DocumentScriptBuilder builder = newDocumentScriptBuilder();
         Asset asset = newAsset();
-        Resource root = newResource();
-        Resource file = newResource();
         SymbolSource source = newSymbolSource();
-        AssetFactory factory = newAssetFactory();
+        AssetSource assetSource = newAssetSource();
 
         train_expandSymbols(source, path, expanded);
 
-        train_getRootResource(factory, root);
-        train_forFile(root, expanded, file);
-
-        train_createAsset(factory, file, asset);
+        train_findAsset(assetSource, null, expanded, null, asset);
 
         train_toClientURL(asset, ASSET_URL);
         builder.addScriptLink(ASSET_URL);
 
         replay();
 
-        PageRenderSupport support = new PageRenderSupportImpl(builder, source, factory);
+        PageRenderSupport support = new PageRenderSupportImpl(builder, source, assetSource);
 
         support.addClasspathScriptLink(path);
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PropertyConduitSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PropertyConduitSourceImplTest.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PropertyConduitSourceImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/PropertyConduitSourceImplTest.java Thu Mar 29 15:45:36 2007
@@ -32,7 +32,7 @@
     @BeforeClass
     public void setup()
     {
-        _source = getObject("alias:PropertyConduitSource", PropertyConduitSource.class);
+        _source = getObject(PropertyConduitSource.class, null);
     }
 
     @AfterClass

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/services/AliasContributionTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/services/AliasContributionTest.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/services/AliasContributionTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/services/AliasContributionTest.java Thu Mar 29 15:45:36 2007
@@ -14,40 +14,54 @@
 
 package org.apache.tapestry.services;
 
-import org.apache.tapestry.ioc.test.TestBase;
+import org.apache.tapestry.test.TapestryTestCase;
 import org.testng.annotations.Test;
 
-public class AliasContributionTest extends TestBase
+public class AliasContributionTest extends TapestryTestCase
 {
     @Test
     public void default_for_mode()
     {
-        AliasContribution ic = new AliasContribution("fred", this);
+        Runnable r = newRunnable();
 
-        assertEquals("fred", ic.getName());
-        assertEquals("", ic.getMode());
-        assertSame(ic.getObject(), this);
+        replay();
+
+        AliasContribution contribution = AliasContribution.create(Runnable.class, r);
+
+        assertSame(contribution.getContributionType(), Runnable.class);
+        assertEquals(contribution.getMode(), "");
+        assertSame(contribution.getObject(), r);
+
+        verify();
     }
 
     @Test
     public void specific_mode()
     {
-        AliasContribution ic = new AliasContribution("fred", "mode", this);
+        Runnable r = newRunnable();
+
+        replay();
+
+        AliasContribution contribution = new AliasContribution<Runnable>(Runnable.class, "mode", r);
+
+        assertEquals(contribution.getContributionType(), Runnable.class);
+        assertEquals(contribution.getMode(), "mode");
+        assertSame(contribution.getObject(), r);
 
-        assertEquals("fred", ic.getName());
-        assertEquals("mode", ic.getMode());
-        assertSame(ic.getObject(), this);
+        verify();
     }
 
     @Test
     public void to_string()
     {
-        AliasContribution ic = new AliasContribution("fred", "FRED");
+        AliasContribution contribution = AliasContribution.create(String.class, "FRED");
 
-        assertEquals(ic.toString(), "<AliasContribution: fred FRED>");
+        assertEquals(contribution.toString(), "<AliasContribution: java.lang.String FRED>");
 
-        ic = new AliasContribution("fred", "servlet", "FRED");
+        contribution = new AliasContribution(String.class, "servlet", "FRED");
 
-        assertEquals(ic.toString(), "<AliasContribution: fred mode:servlet FRED>");
+        assertEquals(
+                contribution.toString(),
+                "<AliasContribution: java.lang.String mode:servlet FRED>");
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/log4j.properties?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/resources/log4j.properties (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/resources/log4j.properties Thu Mar 29 15:45:36 2007
@@ -23,9 +23,9 @@
 
 log4j.category.org.apache.tapestry.TapestryFilter=info
 log4j.category.org.apache.tapestry=error
-log4j.category.tapestry=error
-log4j.category.tapestry.ioc.ClassFactory=error
 
 log4j.category.app=info
 log4j.category.org.apache.tapestry.integration.app1=error
 log4j.category.org.apache.tapestry.corelib=error
+
+

Modified: tapestry/tapestry5/tapestry-hibernate/trunk/src/main/java/org/apache/tapestry/hibernate/HibernateModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-hibernate/trunk/src/main/java/org/apache/tapestry/hibernate/HibernateModule.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-hibernate/trunk/src/main/java/org/apache/tapestry/hibernate/HibernateModule.java (original)
+++ tapestry/tapestry5/tapestry-hibernate/trunk/src/main/java/org/apache/tapestry/hibernate/HibernateModule.java Thu Mar 29 15:45:36 2007
@@ -52,7 +52,7 @@
      * scanned for annotated entity classes.
      */
     public static void contributeHibernateSessionSource(Configuration<String> configuration,
-            @Inject("alias:ApplicationGlobals")
+            @Inject
             ApplicationGlobals globals)
     {
         configuration.add(globals.getApplicationRootPackage() + ".entities");
@@ -98,14 +98,14 @@
     }
 
     /**
-     * Contributes the "session" property (type {@link Session}), the Hibernate Session for the
-     * current request.
+     * Contributes the {@link #build(HibernateSessionManager, PropertyShadowBuilder) Session}
+     * service.
      */
     public static void contributeAlias(Configuration<AliasContribution> configuration,
 
     @InjectService("Session")
     Session session)
     {
-        configuration.add(new AliasContribution("session", session));
+        configuration.add(AliasContribution.create(Session.class, session));
     }
 }

Modified: tapestry/tapestry5/tapestry-hibernate/trunk/src/test/conf/testng.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-hibernate/trunk/src/test/conf/testng.xml?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-hibernate/trunk/src/test/conf/testng.xml (original)
+++ tapestry/tapestry5/tapestry-hibernate/trunk/src/test/conf/testng.xml Thu Mar 29 15:45:36 2007
@@ -1,18 +1,18 @@
 <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
 <!-- 
-  Copyright 2007 The Apache Software Foundation
-  
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-  
-  http://www.apache.org/licenses/LICENSE-2.0
-  
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
+   Copyright 2007 The Apache Software Foundation
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
 -->
 
 <suite name="Tapestry Hibernate Integration" parallel="false" thread-count="10" annotations="1.5" verbose="2">

Copied: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/AnnotationProvider.java (from r519727, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/AnnotationProvider.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/AnnotationProvider.java?view=diff&rev=523862&p1=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/AnnotationProvider.java&r1=519727&p2=tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/AnnotationProvider.java&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/AnnotationProvider.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/AnnotationProvider.java Thu Mar 29 15:45:36 2007
@@ -12,7 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry;
+package org.apache.tapestry.ioc;
 
 import java.lang.annotation.Annotation;
 

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/ObjectProvider.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/ObjectProvider.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/ObjectProvider.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/ObjectProvider.java Thu Mar 29 15:45:36 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -20,21 +20,12 @@
  * to a service within the Registry, object providers in different flavors are capable of vending,
  * or even creating, objects of disparate types from disparate sources.
  * <p>
- * Objects are located via an <em>object reference</em>, consisting of two parts:
- * <ul>
- * <li>An provider prefix, used to identify the specific implementation of ObjectProvider</li>
- * <li>An <em>expression</em>, interpreted by the provider.
- * </ul>
+ * Object providers are consulted in a strict order, and the first non-null result is taken.
  * <p>
- * The two values are separated by a colon.
+ * In many cases, an object provider searches for additional annotations on the element (usually a
+ * parameter, or perhaps a field) for which a value is required.
  * <p>
- * For example, "service:tapestry.ioc.ClassFactory" would consist of a prefix, "service" and an
- * expression "tapestry.ioc.ClassFactory". The expression would be mapped to the built in
- * "ClassFactory" service.
- * <p>
- * ObjectProviders exist to provide abstractions on top of the raw IoC services. Examples to follow,
- * especially "infrastructure:" which provides the ability to easily override services within a
- * Tapestry application.
+ * A default ObjectProvider uses {@link ServiceLocator#getService(Class)}.
  */
 public interface ObjectProvider
 {
@@ -44,17 +35,19 @@
      * contributor method, or service decorator method. The locator parameter provides access to the
      * services visible <em>to that context</em>.
      * 
-     * @param <T>
-     * @param expression
-     *            to be evaluated, to identify the object to return
      * @param objectType
      *            the expected object type
+     * @param annotationProvider
+     *            provides access to annotations (typically, the field or parameter to which an
+     *            injection-related annotation is attached); annotations on the field or parameter
+     *            may also be used when resolving the desired object
      * @param locator
      *            locator for the <em>context</em> in which the provider is being used
-     * @return the requested object
+     * @param <T>
+     * @return the requested object, or null if this object provider can not supply an object
      * @throws RuntimeException
      *             if the expression can not be evaluated, or the type of object identified is not
      *             assignable to the type specified by the objectType parameter
      */
-    <T> T provide(String expression, Class<T> objectType, ServiceLocator locator);
+    <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider, ServiceLocator locator);
 }

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/ServiceLocator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/ServiceLocator.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/ServiceLocator.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/ServiceLocator.java Thu Mar 29 15:45:36 2007
@@ -59,15 +59,15 @@
      * Obtains an object indirectly, using an {@link ObjectProvider} identified by the prefix of the
      * reference.
      * 
-     * @param <T>
-     * @param reference
-     *            a provider prefix, a colon, an expression meaningful to the provider (may contain
-     *            <em>symbols</em>, which will be expanded)
      * @param objectType
      *            the type of object to be returned
+     * @param annotationProvider
+     *            provides access to annotations on the field or parameter for which a value is to
+     *            be obtained, which may be utilized in selecting an appropriate object
+     * @param <T>
      * @return the requested object
      * @see ObjectProvider
      */
-    <T> T getObject(String reference, Class<T> objectType);
+    <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider);
 
 }

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/annotations/Inject.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/annotations/Inject.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/annotations/Inject.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/annotations/Inject.java Thu Mar 29 15:45:36 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -12,32 +12,26 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc.annotations;
-
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Injection based on an object reference. Whereas
- * {@link org.apache.tapestry.ioc.annotations.InjectService}'s value is always a service id, thsi
- * annotation is more flexible. The value is an object reference, which is used to select a
- * {@link org.apache.tapestry.ioc.ObjectProvider} that ultimately provides the value to be injected
- * via the annotated parameter.
- * <p>
- * There are several builtin providers, including "service". Thus this annotation with "service:Foo"
- * is identical to InjectService with value "Foo". In both cases, the visibility of services,
- * relative the module in which the injections take place, is honored.
- * 
- * 
- */
-@Target(PARAMETER)
-@Retention(RUNTIME)
-@Documented
-public @interface Inject {
-    /** Object reference identifying the object to be injected. */
-    String value();
-}
+package org.apache.tapestry.ioc.annotations;
+
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.apache.tapestry.ioc.ObjectProvider;
+
+/**
+ * Marker interface for a parameter whose value is determined at runtime as an injection. The value
+ * will be obtained from an {@link ObjectProvider} contributed into the MasterObjectProvider service
+ * implementation.
+ */
+@Target(PARAMETER)
+@Retention(RUNTIME)
+@Documented
+public @interface Inject
+{
+
+}

Added: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/annotations/Value.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/annotations/Value.java?view=auto&rev=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/annotations/Value.java (added)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/annotations/Value.java Thu Mar 29 15:45:36 2007
@@ -0,0 +1,41 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.ioc.annotations;
+
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.apache.tapestry.ioc.services.SymbolSource;
+import org.apache.tapestry.ioc.services.TypeCoercer;
+
+/**
+ * Used in conjunction with {@link Inject} to inject a literal value, rather than a service. Symbols
+ * in the value are expanded and the resulting string is coerced to the desired type.
+ * 
+ * @see SymbolSource
+ * @see TypeCoercer
+ */
+@Target(PARAMETER)
+@Retention(RUNTIME)
+@Documented
+public @interface Value
+{
+    /** The value to be coerced and injected. */
+    String value();
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/IOCInternalTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/IOCInternalTestCase.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/IOCInternalTestCase.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/IOCInternalTestCase.java Thu Mar 29 15:45:36 2007
@@ -19,6 +19,7 @@
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.tapestry.ioc.AnnotationProvider;
 import org.apache.tapestry.ioc.Registry;
 import org.apache.tapestry.ioc.RegistryBuilder;
 import org.apache.tapestry.ioc.ServiceDecorator;
@@ -66,9 +67,9 @@
         return _classFactory;
     }
 
-    public final <T> T getObject(String reference, Class<T> objectType)
+    public final <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider)
     {
-        return _registry.getObject(reference, objectType);
+        return _registry.getObject(objectType, annotationProvider);
     }
 
     public final <T> T getService(Class<T> serviceInterface)

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/InternalRegistry.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/InternalRegistry.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/InternalRegistry.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/InternalRegistry.java Thu Mar 29 15:45:36 2007
@@ -19,6 +19,7 @@
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
+import org.apache.tapestry.ioc.AnnotationProvider;
 import org.apache.tapestry.ioc.ObjectProvider;
 import org.apache.tapestry.ioc.Registry;
 import org.apache.tapestry.ioc.ServiceDecorator;
@@ -140,15 +141,17 @@
     /**
      * Provides an object by delegating to the {@link ObjectProvider MasterObjectProvider} service.
      * 
-     * @param reference
-     *            A string used to identify the objecty to be provided
      * @param objectType
      *            the expected type of object
+     * @param annotationProvider
+     *            provides access to annotations on the field or parameter for which an injected
+     *            value is to be obtained
      * @param locator
      *            identifies what services are visible in the context
-     * @see ObjectProvider#provide(String, Class, ServiceLocator)
+     * @see ObjectProvider#provide(Class, AnnotationProvider, ServiceLocator)
      */
-    <T> T getObject(String reference, Class<T> objectType, ServiceLocator locator);
+    <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider,
+            ServiceLocator locator);
 
     /**
      * Given an input string that <em>may</em> contain symbols, returns the string with any and

Added: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/NullAnnotationProvider.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/NullAnnotationProvider.java?view=auto&rev=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/NullAnnotationProvider.java (added)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/NullAnnotationProvider.java Thu Mar 29 15:45:36 2007
@@ -0,0 +1,33 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.ioc.internal;
+
+import java.lang.annotation.Annotation;
+
+import org.apache.tapestry.ioc.AnnotationProvider;
+
+/**
+ * A null implementation of {@link AnnotationProvider}, used when there is not appropriate source
+ * of annotations.
+ */
+public class NullAnnotationProvider implements AnnotationProvider
+{
+    /** Always returns null. */
+    public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
+    {
+        return null;
+    }
+
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/RegistryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/RegistryImpl.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/RegistryImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/RegistryImpl.java Thu Mar 29 15:45:36 2007
@@ -25,6 +25,7 @@
 import java.util.Set;
 
 import org.apache.commons.logging.Log;
+import org.apache.tapestry.ioc.AnnotationProvider;
 import org.apache.tapestry.ioc.Configuration;
 import org.apache.tapestry.ioc.IOCConstants;
 import org.apache.tapestry.ioc.LogSource;
@@ -564,7 +565,8 @@
         return _classFactory.newClass(serviceInterface);
     }
 
-    public <T> T getObject(String reference, Class<T> objectType, ServiceLocator locator)
+    public <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider,
+            ServiceLocator locator)
     {
         _lock.check();
 
@@ -572,15 +574,14 @@
                 IOCConstants.MASTER_OBJECT_PROVIDER_SERVICE_ID,
                 ObjectProvider.class);
 
-        return masterProvider.provide(reference, objectType, locator);
+        return masterProvider.provide(objectType, annotationProvider, locator);
     }
 
-    public <T> T getObject(String reference, Class<T> objectType)
+    public <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider)
     {
         _lock.check();
 
-        // Concerened about this causing potential endless loops.
-        return getObject(reference, objectType, this);
+        return getObject(objectType, new NullAnnotationProvider(), this);
     }
 
     public void addRegistryShutdownListener(RegistryShutdownListener listener)

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/RegistryWrapper.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/RegistryWrapper.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/RegistryWrapper.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/RegistryWrapper.java Thu Mar 29 15:45:36 2007
@@ -14,6 +14,7 @@
 
 package org.apache.tapestry.ioc.internal;
 
+import org.apache.tapestry.ioc.AnnotationProvider;
 import org.apache.tapestry.ioc.Registry;
 import org.apache.tapestry.ioc.ServiceLocator;
 
@@ -40,9 +41,9 @@
         _registry.shutdown();
     }
 
-    public <T> T getObject(String reference, Class<T> objectType)
+    public <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider)
     {
-        return _registry.getObject(reference, objectType);
+        return _registry.getObject(objectType, null);
     }
 
     public <T> T getService(String serviceId, Class<T> serviceInterface)

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ServiceLocatorImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ServiceLocatorImpl.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ServiceLocatorImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ServiceLocatorImpl.java Thu Mar 29 15:45:36 2007
@@ -14,6 +14,7 @@
 
 package org.apache.tapestry.ioc.internal;
 
+import org.apache.tapestry.ioc.AnnotationProvider;
 import org.apache.tapestry.ioc.ServiceLocator;
 
 /**
@@ -44,9 +45,9 @@
         return _registry.getService(serviceInterface);
     }
 
-    public <T> T getObject(String reference, Class<T> objectType)
+    public <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider)
     {
-        return _registry.getObject(reference, objectType, this);
+        return _registry.getObject(objectType, annotationProvider, this);
     }
 
     protected InternalRegistry getRegistry()

Added: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ValueObjectProvider.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ValueObjectProvider.java?view=auto&rev=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ValueObjectProvider.java (added)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ValueObjectProvider.java Thu Mar 29 15:45:36 2007
@@ -0,0 +1,49 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.ioc.internal.services;
+
+import org.apache.tapestry.ioc.AnnotationProvider;
+import org.apache.tapestry.ioc.ObjectProvider;
+import org.apache.tapestry.ioc.ServiceLocator;
+import org.apache.tapestry.ioc.annotations.Value;
+import org.apache.tapestry.ioc.services.SymbolSource;
+import org.apache.tapestry.ioc.services.TypeCoercer;
+
+public class ValueObjectProvider implements ObjectProvider
+{
+    private final SymbolSource _symbolSource;
+
+    private final TypeCoercer _typeCoercer;
+
+    public ValueObjectProvider(final SymbolSource symbolSource, final TypeCoercer typeCoercer)
+    {
+        _symbolSource = symbolSource;
+        _typeCoercer = typeCoercer;
+    }
+
+    public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider,
+            ServiceLocator locator)
+    {
+        Value annotation = annotationProvider.getAnnotation(Value.class);
+
+        if (annotation == null) return null;
+
+        String value = annotation.value();
+        String expanded = _symbolSource.expandSymbols(value);
+        T coerced = _typeCoercer.coerce(expanded, objectType);
+
+        return coerced;
+    }
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/InternalUtils.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/InternalUtils.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/InternalUtils.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/InternalUtils.java Thu Mar 29 15:45:36 2007
@@ -28,6 +28,7 @@
 import java.util.ListIterator;
 import java.util.Map;
 
+import org.apache.tapestry.ioc.AnnotationProvider;
 import org.apache.tapestry.ioc.Locatable;
 import org.apache.tapestry.ioc.Location;
 import org.apache.tapestry.ioc.ServiceLocator;
@@ -179,10 +180,19 @@
 
     @SuppressWarnings("unchecked")
     private static Object calculateParameterValue(Class parameterType,
-            Annotation[] parameterAnnotations, ServiceLocator locator,
+            final Annotation[] parameterAnnotations, ServiceLocator locator,
             Map<Class, Object> parameterDefaults)
     {
-        InjectService is = findAnnotation(parameterAnnotations, InjectService.class);
+        AnnotationProvider provider = new AnnotationProvider()
+        {
+            public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
+            {
+                return findAnnotation(parameterAnnotations, annotationClass);
+            }
+
+        };
+
+        InjectService is = provider.getAnnotation(InjectService.class);
 
         if (is != null)
         {
@@ -191,14 +201,9 @@
             return locator.getService(serviceId, parameterType);
         }
 
-        Inject i = findAnnotation(parameterAnnotations, Inject.class);
+        Inject i = provider.getAnnotation(Inject.class);
 
-        if (i != null)
-        {
-            String reference = i.value();
-
-            return locator.getObject(reference, parameterType);
-        }
+        if (i != null) { return locator.getObject(parameterType, provider); }
 
         // See if we have any "pre-determined" parameter type to object mappings
 

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java Thu Mar 29 15:45:36 2007
@@ -22,30 +22,32 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.tapestry.ioc.AnnotationProvider;
 import org.apache.tapestry.ioc.Configuration;
 import org.apache.tapestry.ioc.MappedConfiguration;
 import org.apache.tapestry.ioc.ObjectProvider;
 import org.apache.tapestry.ioc.OrderedConfiguration;
 import org.apache.tapestry.ioc.ServiceLifecycle;
+import org.apache.tapestry.ioc.ServiceLocator;
 import org.apache.tapestry.ioc.annotations.InjectService;
 import org.apache.tapestry.ioc.annotations.Lifecycle;
+import org.apache.tapestry.ioc.annotations.Value;
 import org.apache.tapestry.ioc.internal.services.ChainBuilderImpl;
 import org.apache.tapestry.ioc.internal.services.DefaultImplementationBuilderImpl;
 import org.apache.tapestry.ioc.internal.services.ExceptionAnalyzerImpl;
 import org.apache.tapestry.ioc.internal.services.ExceptionTrackerImpl;
 import org.apache.tapestry.ioc.internal.services.LoggingDecoratorImpl;
 import org.apache.tapestry.ioc.internal.services.MapSymbolProvider;
-import org.apache.tapestry.ioc.internal.services.MasterObjectProvider;
 import org.apache.tapestry.ioc.internal.services.PerThreadServiceLifecycle;
 import org.apache.tapestry.ioc.internal.services.PipelineBuilderImpl;
 import org.apache.tapestry.ioc.internal.services.PropertyAccessImpl;
 import org.apache.tapestry.ioc.internal.services.PropertyShadowBuilderImpl;
-import org.apache.tapestry.ioc.internal.services.ServiceObjectProvider;
 import org.apache.tapestry.ioc.internal.services.StrategyBuilderImpl;
 import org.apache.tapestry.ioc.internal.services.SymbolSourceImpl;
 import org.apache.tapestry.ioc.internal.services.SystemPropertiesSymbolProvider;
 import org.apache.tapestry.ioc.internal.services.ThreadLocaleImpl;
 import org.apache.tapestry.ioc.internal.services.TypeCoercerImpl;
+import org.apache.tapestry.ioc.internal.services.ValueObjectProvider;
 import org.apache.tapestry.ioc.util.StrategyRegistry;
 
 /**
@@ -157,25 +159,48 @@
     /**
      * The master {@link ObjectProvider} is responsible for identifying a particular ObjectProvider
      * by its prefix, and delegating to that instance.
-     * 
-     * @param configuration
-     *            map of ObjectProviders, keyed on prefix
      */
-    public static ObjectProvider buildMasterObjectProvider(
-            Map<String, ObjectProvider> configuration, @InjectService("SymbolSource")
-            SymbolSource symbolSource, @InjectService("TypeCoercer")
-            TypeCoercer typeCoercer)
+    public ObjectProvider buildMasterObjectProvider(List<ObjectProvider> configuration,
+            @InjectService("ChainBuilder")
+            ChainBuilder chainBuilder)
     {
-        return new MasterObjectProvider(configuration, symbolSource, typeCoercer);
+        return chainBuilder.build(ObjectProvider.class, configuration);
     }
 
     /**
-     * Contributes the "service:" object provider.
+     * Contributes "DefaultProvider", ordered last, that delegates to
+     * {@link ServiceLocator#getService(Class)}.
+     * <p>
+     * Contributes "Value", which injects values (not services) triggered by the {@link Value}
+     * annotation.
      */
     public static void contributeMasterObjectProvider(
-            MappedConfiguration<String, ObjectProvider> configuration)
+            OrderedConfiguration<ObjectProvider> configuration,
+
+            @InjectService("ValueObjectProvider")
+            ObjectProvider valueObjectProvider)
+    {
+        ObjectProvider defaultProvider = new ObjectProvider()
+        {
+
+            public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider,
+                    ServiceLocator locator)
+            {
+                return locator.getService(objectType);
+            }
+        };
+
+        configuration.add("DefaultProvider", defaultProvider, "after:*");
+        configuration.add("Value", valueObjectProvider);
+    }
+
+    public static ObjectProvider buildValueObjectProvider(@InjectService("TypeCoercer")
+    TypeCoercer typeCoercer,
+
+    @InjectService("SymbolSource")
+    SymbolSource symbolSource)
     {
-        configuration.add("service", new ServiceObjectProvider());
+        return new ValueObjectProvider(symbolSource, typeCoercer);
     }
 
     /** Used by the {@link org.apache.tapestry.ioc.services.LoggingDecorator} service. */

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java Thu Mar 29 15:45:36 2007
@@ -21,6 +21,7 @@
 import java.util.Locale;
 
 import org.apache.commons.logging.Log;
+import org.apache.tapestry.ioc.AnnotationProvider;
 import org.apache.tapestry.ioc.Configuration;
 import org.apache.tapestry.ioc.Location;
 import org.apache.tapestry.ioc.LogSource;
@@ -149,10 +150,11 @@
         return newMock(ObjectProvider.class);
     }
 
-    protected final <T> void train_provide(ObjectProvider provider, String expression,
-            Class<T> objectType, ServiceLocator locator, T object)
+    protected final <T> void train_provide(ObjectProvider provider, Class<T> objectType,
+            AnnotationProvider annotationProvider, ServiceLocator locator, T object)
     {
-        expect(provider.provide(expression, objectType, locator)).andReturn(object);
+        expect(provider.provide(objectType, annotationProvider, locator)).andReturn(
+                object);
     }
 
     protected final ObjectCreator newObjectCreator()
@@ -348,5 +350,10 @@
     protected final void train_forLocale(Resource base, Locale locale, Resource resource)
     {
         expect(base.forLocale(locale)).andReturn(resource);
+    }
+
+    protected final AnnotationProvider newAnnotationProvider()
+    {
+        return newMock(AnnotationProvider.class);
     }
 }

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/coerce.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/coerce.apt?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/coerce.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/coerce.apt Thu Mar 29 15:45:36 2007
@@ -8,11 +8,11 @@
   of a different type with similar content: a common example is coercing a string into an integer or a double.
   
   Although these types of coercions happens more inside
-  tapestry-core (inlcuding coercions of {{{http://tapestry.apache.org/tapestry5/tapestry-core/guide/coercion.html}parameters}}), this
+  tapestry-core (inlcuding coercions of {{{http://tapestry.apache.org/tapestry5/tapestry-core/guide/coercion.html}component parameters}}), this
   may also happen inside tapestry-ioc, such as when injecting a value, rather than a service, into a builder method.
   
   Like everything else in Tapestry, type coercions are extensible.  At the root is the
-  {{{apidocs/org/apache/tapestry/ioc/services/TypeCoercer.html}tapestry.ioc.TypeCoercer}} service. Its configuration consists
+  {{{apidocs/org/apache/tapestry/ioc/services/TypeCoercer.html}TypeCoercer}} service. Its configuration consists
   of a number of 
   {{{apidocs/org/apache/tapestry/ioc/services/CoercionTuple.html}CoercionTuple}}s.  Each tuple defines how to coerce from one type to another.
   The initial set of coercions is focused primarily on coercions between different numeric types:
@@ -41,7 +41,7 @@
   inform the TypeCoercer about this coercion.
   
 +---+    
-   public void contributeTypeCoercer(Configuration<CoercionTuple> configuration)
+   public static void contributeTypeCoercer(Configuration<CoercionTuple> configuration)
    {
      Coercion<BigDecimal, Money> coercion = new Coercion<BigDecimal, Money>()
      {

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/command.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/command.apt?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/command.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/command.apt Thu Mar 29 15:45:36 2007
@@ -24,8 +24,8 @@
   
   This is a useful pattern because it makes it very easy to <extend> a given process,
   simply by providing new commands and specifying where they fit into the overall
-  process. Most of chain of command is combined with an ordered 
-  {{{configuration.html}configuration}} to define what the command are (and in what
+  process. Most often chain of command is combined with an ordered 
+  {{{configuration.html}configuration}} to define what the list of commands are (and in what
   order they should execute).
   
 ChainBuilder Service
@@ -50,7 +50,7 @@
   particular interface and a particular list of commands implementing that interface.  
   
   This can be used inside a service builder method.  Nothing says a service builder method
-  just has to just instantiate a class; it is only required to return an appropriate object.
+  just has to  instantiate a class; it is only required to return an appropriate object.
   We can just let the ChainBuilder service create that object.
   
 +----+
@@ -63,7 +63,7 @@
 +----+
 
   Here, the behavior of the MyChainService is defined by its configuration: an ordered
-  list of MyChainService commands that are contributed by many modules.
+  list of MyChainService commands that are contributed by one or more modules.
   
   Internally, the ChainBuilder creates a new class that implements the service interface.
   The list of commands is converted into an array, which is used inside the service implementation

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/decorator.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/decorator.apt?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/decorator.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/decorator.apt Thu Mar 29 15:45:36 2007
@@ -160,7 +160,7 @@
   As elsewhere, matching is case insensitive.
 
 
-  Thus, <<<@Match("*")>>> is dangerous, because it will match every (public) service in every
+  Thus, <<<@Match("*")>>> is dangerous, because it will match every service in every
   module.  
   
   <Note: It is not possible to decorate the services of the TapestryIOCModule.>

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/module.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/module.apt?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/module.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/module.apt Thu Mar 29 15:45:36 2007
@@ -77,10 +77,10 @@
   private final FileSystem _fileSystem;
   
   public MyModule(
-    @Inject("service:JobScheduler")
+    @InjectService("JobScheduler")
     JobScheduler scheduler, 
     
-    @Inject("service:FileSystem")
+    @InjectService("FileSystem")
     FileSystem fileSystem)
   {
     _scheduler = scheduler;
@@ -125,11 +125,7 @@
   defined within the same module from the module builder's constructor,
   then the service implementation will be needed. Creating service implementations
   requires the module builder instance ... that's a recursive reference. 
-  
-  Another common example would be using @Inject("alias:<property>") when the module being constructed
-  contributes into the Alias service's configuration. Here, to resolve the contribution, Tapestry
-  needs an instance of the module builder class even as it is trying to invoke the module builder's constructor.
-  
+    
   Tapestry detects these scenarios and throws a runtime exception to prevent an endless loop.
     
 {Autoloading modules}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/provider.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/provider.apt?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/provider.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/provider.apt Thu Mar 29 15:45:36 2007
@@ -6,35 +6,39 @@
 
   The
   {{{apidocs/org/apache/tapestry/ioc/annotations/Inject.html}@Inject annotation}}
-  is a flexible way to inject dependencies into a service. With this annotation
-  the value to be injected is not identified by a service id <per se>. Instead
-  the annotation's value is an <<object reference>>: a combination of a
-  <<provider prefix>> and an <<expression>> (separated by a colon). 
-  
-  The provider prefix
-  maps to a particular instance of
-  {{{apidocs/org/apache/tapestry/ioc/ObjectProvider.html}ObjectProvider}}, which
-  understands the expression.
-  
-  In practice, @InjectService("Foo") and @Inject("service:Foo") work identically,
-  Here, the provider prefix is "service" and the expression (interprested as a service id)
-  is "Foo".
-  
-* service provider
-
-  As outlined above, the service provider interprets the expression as
-  a service id.
-  
-* alias provider
-
-  The tapestry module (provided by the {{{http://tapestry.apache.org/tapestry5/tapestry-core/}tapestry-core library}}) provides the
-  {{{http://tapestry.apache.org/tapestry5/tapestry-core/guide/alias.html}alias}} object provider, which exists to allow
-  for various forms of service overrides.
-    
-* default provider  
+  is a flexible way to inject dependencies into a service. By placing this annotation
+  on a parameter of a service builder method, Tapestry will automatically
+  locate the correct object or service.
+  
+  In fact, there is not just one ObjectProvider, there's a whole set of them,
+  forming a {{{command.html}chain of command}}.  
+  
+  The default ObjectProvider will search for a service that matches the type
+  of the parameter annotated with the @Inject annotation ... which isn't that useful,
+  because Tapestry 5 IoC would do that even if the annotation was not present.
+  
+  Usually, the @Inject annotation is supplemented by an additional annotation which
+  triggers a specific  ObjectProvider to provide the value.
+  
+@Value Annotation
+
+  The {{{apidocs/org/apache/tapestry/ioc/annotations/Value.html}@Value annotation}}
+  allows a literal value to be injected.  When combined with 
+  {{{symbols.html}symbols}}, the represent a way for parts of the overall service
+  network to be spot-configured.  For example:
+  
++----+
+  public MyService build(@Inject @Value("${max-seconds}") long maxSeconds)
+  {
+    return new MyServiceImpl(maxSeconds);
+  }
++----+
+
+  Here, the MyService service requires a configuration of a number of seconds.
+  The value is supplied as a symbol, with a factory default that may be overwritten
+  with an application default. 
+  
   
-  If the string does not contain a prefix, then the value is treated as a literal string.
-  It will be {{{coerce.html}coerced}} to the proper type (such as int or long).
   
 Defining New Providers
 
@@ -46,12 +50,15 @@
   Example:
   
 +-----+
-  public void contributeMasterObjectProvider(MappedConfiguration<String,ObjectProvider> configuration)
+  public void contributeMasterObjectProvider(OrderedConfiguration<ObjectProvider> configuration)
   {
-    configuration.add("myprefix", new MyObjectProvider());
+    configuration.add("MyObject", new MyObjectProvider());
   }
 +-----+
 
+  This establishes a name for the object provider (useful if the exact order of execution of the
+  provider, relative to other providers, is relevant). 
+
   Of course, this is a simplified example. In a real scenario, the provider is most likely
   a service with its own dependencies.      
   
@@ -59,5 +66,5 @@
 Providers and Symbols
 
   It is occasionally useful to add a level of indirection, to allow control over exactly
-  what service (or other object) is injected.  Both the Inject and InjectService
+  what service (or other object) is injected.  Both the Value and InjectService
   annotations support the use of {{{symbols.html}symbols}}.

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/run.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/run.apt?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/run.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/run.apt Thu Mar 29 15:45:36 2007
@@ -32,7 +32,7 @@
   
   Using this approach, you will form a Registry containing
   the builtin services from the
-  {{{apidocs/org/apache/tapestry/ioc/services/TapestryIoCModule.html}tapestry.ioc module}}, plus
+  {{{apidocs/org/apache/tapestry/ioc/services/TapestryIoCModule.html}Tapestry IoC module}}, plus
   the modules you explicitly list.
   
 Building the Default Registry

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/service.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/service.apt?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/service.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/service.apt Thu Mar 29 15:45:36 2007
@@ -78,31 +78,7 @@
   (or service decorator) methods, you can 
   {{{module.html#Caching Services}cache dependency injections}} in your module, by defining
   a constructor.  This reduces duplication in your module.
-  
-Injecting Dependencies with @Inject
-
-  A second approach to injection uses the more general purpose
-  {{{apidocs/org/apache/tapestry/ioc/annotations/Inject.html}@Inject annotation}}.
-  
-  @Inject doesn't specify a service id <em>per se</em>.  With inject, you provide
-  an {{{provider.html}object reference}}.  Different prefixes on the reference
-  are interpreted in different ways.  The "service" prefix works identically
-  to the @InjectService annotation, so the previous example can be rewritten
-  as:
     
-+-----------------------------------------------------------------------------------+
-  public static Indexer build(@Inject("service:JobScheduler")
-    JobScheduler scheduler, @Inject("service:FileSystem")
-    FileSystem fileSystem)
-  {
-    IndexerImpl indexer = new IndexerImpl(fileSystem);
-      
-    scheduler.scheduleDailyJob(indexer);
-      
-    return indexer;
-  }
-+-----------------------------------------------------------------------------------+
-  
 Defining Service Lifecycle
 
   Each service has a <lifecycle> that controls when the service implementation is instantiated.
@@ -176,7 +152,7 @@
   
   This feature is used when a service manages a resource, such as a thread, that needs to be created
   as soon as the application starts up.  Another common example is a service that listens for events produced
-  by a second service; the first service may need to be created, and start listing, before any of its
+  by a second service; the first service may need to be created, and start listening, before any of its
   service methods are invoked (which would normally trigger the instantiation of the service).
   
   Many services may be annotated with @EagerLoad; the order in which services are created is not defined. 
@@ -272,7 +248,7 @@
   
 Builtin Services
 
-  A few services within the tapestry.ioc module are "builtin"; there is no 
+  A few services within the Tapestry IOC Module are "builtin"; there is no 
   service builder method
   in the
   {{{apidocs/org/apache/tapestry/ioc/services/TapestryIOCModule.html}TapestryIOCModule}} class.

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/shadow.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/shadow.apt?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/shadow.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/shadow.apt Thu Mar 29 15:45:36 2007
@@ -5,7 +5,7 @@
 Shadow Services
 
   The 
-  {{{apidocs/org/apache/tapestry/ioc/services/PropertyShadowBuilder.html}tapestry.ioc.PropertyShadowBuilder}}
+  {{{apidocs/org/apache/tapestry/ioc/services/PropertyShadowBuilder.html}PropertyShadowBuilder}}
   service is used to build a special, delegating kind of service implementation.
   
   Effectively, it is used to allow a property of another service to be exposed as its own service.
@@ -14,7 +14,7 @@
   service's request property:
   
 +----+
-public WebRequest buildWebRequest()
+public WebRequest build()
 {
   return _shadowBuilder.build(_requestGlobals, "request", WebRequest.class);
 }
@@ -23,7 +23,7 @@
   This can be thought of as similar to:
   
 +----+
-public WebRequest buildWebRequest()
+public WebRequest build()
 {
   return _requestGlobals.getRequest();
 }

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/symbols.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/symbols.apt?view=diff&rev=523862&r1=523861&r2=523862
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/symbols.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/symbols.apt Thu Mar 29 15:45:36 2007
@@ -11,23 +11,22 @@
   name is segmented with periods.
   
   These symbols are used inside the 
-  {{{apidocs/org/apache/tapestry/ioc/annoations/Inject.html}Inject}} and
+  {{{apidocs/org/apache/tapestry/ioc/annoations/Value.html}Value}} and
   {{{apidocs/org/apache/tapestry/ioc/annoations/InjectService.html}InjectService}}
-  annoations.
+  annotations.
   
   For example:
   
 +----+
-  public static MyService build(@Inject("${some-reference}") CollaboratorA collabA,
-      @InjectService("${some-service-id}") CollaboratorB collabB)
+  public static MyService build(
+      @InjectService("${some-service-id}") Collaborator collab)
   {
     return . . . ;
   }
 +---+
 
-  Here, the first symbol is <<<some-reference>>> whose value should be an
-  {{{provider.html}object reference}} such as <<<service:CollaboratorA>>>.  The second symbol,
-  <<<some-service-id>>> is just a service id, such as <<<CollaboratorB>>>.
+  Here, the symbol,
+  <<<some-service-id>>> is  a service id, such as <<<WackyCollaborator>>>.
      
   Although not shown here, it is possible to use multple symbols inside the string, or mix literal text with
   symbols.
@@ -53,15 +52,14 @@
 * ApplicationDefaults
 
   Values not found as System Properties are searched for in the ApplicationDefaults.  This
-  service, tapestry.ioc.ApplicationDefaults may be configured using a mapped configuration to provide values.
+  service, ApplicationDefaults, may be configured using a mapped configuration to provide values.
   
   From the previous example:
   
 +----+
   public void contributeApplicationDefaults(MappedConfiguration<String, String> configuration)
   {
-    configuration.add("mymodule.some-reference", "service:CollaboratorA");
-    configuration.add("mymodule.some-service-id", "CollaboratorB");
+    configuration.add("some-service-id", "WackyCollaborator");
   }
 +----+
   
@@ -91,7 +89,8 @@
   
   The ordinary default for <<<report.url>>> will be <<<http://www.myreportsite.com:80/report.cgi>>>.
   
-  However, this can be changed by making an overriding contribution to the tapestry.ioc.ApplicationDefaults configuration.  
+  However, this can be changed by making an overriding contribution to the ApplicationDefaults service
+  configuration.  
   
   Tapestry checks that no symbol is directly or indirectly dependent on itself.  For example, the following contribution is
   illegal: