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/04/21 19:20:06 UTC

svn commit: r531068 [6/7] - in /tapestry/tapestry5: tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/test/ tapestry-core/trunk/src/main/java/org/apache/tapestry/serv...

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=531068&r1=531067&r2=531068
==============================================================================
--- 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 Sat Apr 21 10:19:58 2007
@@ -81,159 +81,142 @@
         return findMethod(this, methodName);
     }
 
-    protected final Resource newResource()
+    /** Combines a series of lines by forming a string with a line separator after each line. */
+    protected final String join(String... lines)
     {
-        return newMock(Resource.class);
-    }
+        StringBuilder result = new StringBuilder();
 
-    protected final ServiceLocator newServiceLocator()
-    {
-        return newMock(ServiceLocator.class);
+        for (String line : lines)
+        {
+            result.append(line);
+            result.append("\n");
+        }
+
+        return result.toString();
     }
 
-    protected final ContributionDef newContributionDef()
+    protected final AnnotationProvider mockAnnotationProvider()
     {
-        return newMock(ContributionDef.class);
+        return newMock(AnnotationProvider.class);
     }
 
     @SuppressWarnings("unchecked")
-    protected final <T> OrderedConfiguration<T> newOrderedConfiguration()
+    protected final <T> Configuration<T> mockConfiguration()
     {
-        return newMock(OrderedConfiguration.class);
+        return newMock(Configuration.class);
     }
 
-    protected final void train_getServiceInterface(ServiceDef def, Class serviceInterface)
+    protected final ContributionDef mockContributionDef()
     {
-        expect(def.getServiceInterface()).andReturn(serviceInterface).atLeastOnce();
+        return newMock(ContributionDef.class);
     }
 
-    protected final void train_getServiceId(ServiceDef def, String serviceId)
+    protected final DecoratorDef mockDecoratorDef()
     {
-        expect(def.getServiceId()).andReturn(serviceId).atLeastOnce();
+        return newMock(DecoratorDef.class);
     }
 
-    protected final ServiceResources newServiceResources()
+    protected final Location mockLocation()
     {
-        return newMock(ServiceResources.class);
+        return newMock(Location.class);
     }
 
-    protected final ServiceDef newServiceDef()
+    protected final Log mockLog()
     {
-        return newMock(ServiceDef.class);
+        return newMock(Log.class);
     }
 
-    protected final void train_getServiceLog(ServiceResources resources, Log log)
+    @SuppressWarnings("unchecked")
+    protected final <K, V> MappedConfiguration<K, V> mockMappedConfiguration()
     {
-        expect(resources.getServiceLog()).andReturn(log).atLeastOnce();
-
+        return newMock(MappedConfiguration.class);
     }
 
-    protected final <T> void train_getService(ServiceLocator locator, String serviceId,
-            Class<T> serviceInterface, T service)
+    protected final MessageFormatter mockMessageFormatter()
     {
-        expect(locator.getService(serviceId, serviceInterface)).andReturn(service);
+        return newMock(MessageFormatter.class);
     }
 
-    protected final <T> void train_getService(ServiceLocator locator, Class<T> serviceInterface,
-            T service)
+    protected final Messages mockMessages()
     {
-        expect(locator.getService(serviceInterface)).andReturn(service);
+        return newMock(Messages.class);
     }
 
-    protected final void train_createObject(ObjectCreator creator, Object service)
+    protected final ModuleDef mockModuleDef()
     {
-        expect(creator.createObject()).andReturn(service);
+        return newMock(ModuleDef.class);
     }
 
-    protected final ObjectProvider newObjectProvider()
+    protected final ObjectCreator mockObjectCreator()
     {
-        return newMock(ObjectProvider.class);
-    }
-
-    protected final <T> void train_provide(ObjectProvider provider, Class<T> objectType,
-            AnnotationProvider annotationProvider, ServiceLocator locator, T object)
-    {
-        expect(provider.provide(objectType, annotationProvider, locator)).andReturn(
-                object);
+        return newMock(ObjectCreator.class);
     }
 
-    protected final ObjectCreator newObjectCreator()
+    protected final ObjectProvider mockObjectProvider()
     {
-        return newMock(ObjectCreator.class);
+        return newMock(ObjectProvider.class);
     }
 
-    protected final void train_getServiceInterface(ServiceResources resources,
-            Class serviceInterface)
+    @SuppressWarnings("unchecked")
+    protected final <T> OrderedConfiguration<T> mockOrderedConfiguration()
     {
-        expect(resources.getServiceInterface()).andReturn(serviceInterface).atLeastOnce();
+        return newMock(OrderedConfiguration.class);
     }
 
-    protected final void train_getServiceId(ServiceResources resources, String serviceId)
+    protected final Resource mockResource()
     {
-        expect(resources.getServiceId()).andReturn(serviceId).atLeastOnce();
-
+        return newMock(Resource.class);
     }
 
-    protected final void train_createInterceptor(ServiceDecorator decorator, Object coreObject,
-            Object interceptor)
+    /** Frequently used as a placeholder for an arbitrary service (but its nice and simple). */
+    protected final Runnable mockRunnable()
     {
-        expect(decorator.createInterceptor(coreObject)).andReturn(interceptor);
+        return newMock(Runnable.class);
     }
 
-    protected final ServiceBuilderResources newServiceBuilderResources()
+    protected final ServiceBuilderResources mockServiceBuilderResources()
     {
         return newMock(ServiceBuilderResources.class);
     }
 
-    protected final ServiceDecorator newServiceDecorator()
+    protected final ServiceDecorator mockServiceDecorator()
     {
         return newMock(ServiceDecorator.class);
     }
 
-    protected final void train_getLog(LogSource source, String serviceId, Log log)
+    protected final ServiceDef mockServiceDef()
     {
-        expect(source.getLog(serviceId)).andReturn(log).atLeastOnce();
+        return newMock(ServiceDef.class);
     }
 
-    /** Frequently used as a placeholder for an arbitrary service (but its nice and simple). */
-    protected final Runnable newRunnable()
+    protected final ServiceLocator mockServiceLocator()
     {
-        return newMock(Runnable.class);
+        return newMock(ServiceLocator.class);
     }
 
-    protected final ModuleDef newModuleDef()
+    protected final ServiceResources mockServiceResources()
     {
-        return newMock(ModuleDef.class);
+        return newMock(ServiceResources.class);
     }
 
-    protected final void train_matches(DecoratorDef decoratorDef, ServiceDef serviceDef,
-            boolean matches)
+    protected final SymbolSource mockSymbolSource()
     {
-        expect(decoratorDef.matches(serviceDef)).andReturn(matches);
+        return newMock(SymbolSource.class);
     }
 
-    protected final DecoratorDef newDecoratorDef()
+    protected final ThreadLocale mockThreadLocale()
     {
-        return newMock(DecoratorDef.class);
+        return newMock(ThreadLocale.class);
     }
 
-    protected final Location newLocation()
+    protected final TypeCoercer mockTypeCoercer()
     {
-        return newMock(Location.class);
+        return newMock(TypeCoercer.class);
     }
 
-    /** Combines a series of lines by forming a string with a line separator after each line. */
-    protected final String join(String... lines)
+    protected final void stub_contains(Messages messages, boolean contained)
     {
-        StringBuilder result = new StringBuilder();
-
-        for (String line : lines)
-        {
-            result.append(line);
-            result.append("\n");
-        }
-
-        return result.toString();
+        expect(messages.contains(isA(String.class))).andStubReturn(contained);
     }
 
     protected <S, T> void train_coerce(TypeCoercer coercer, S input, Class<T> expectedType,
@@ -242,21 +225,20 @@
         expect(coercer.coerce(input, expectedType)).andReturn(coercedValue);
     }
 
-    protected final TypeCoercer newTypeCoercer()
+    protected final void train_contains(Messages messages, String key, boolean result)
     {
-        return newMock(TypeCoercer.class);
+        expect(messages.contains(key)).andReturn(result).atLeastOnce();
     }
 
-    @SuppressWarnings("unchecked")
-    protected final <T> Configuration<T> newConfiguration()
+    protected final void train_createInterceptor(ServiceDecorator decorator, Object coreObject,
+            Object interceptor)
     {
-        return newMock(Configuration.class);
+        expect(decorator.createInterceptor(coreObject)).andReturn(interceptor);
     }
 
-    @SuppressWarnings("unchecked")
-    protected final <K, V> MappedConfiguration<K, V> newMappedConfiguration()
+    protected final void train_createObject(ObjectCreator creator, Object service)
     {
-        return newMock(MappedConfiguration.class);
+        expect(creator.createObject()).andReturn(service);
     }
 
     protected final void train_expandSymbols(SymbolSource source, String input)
@@ -270,90 +252,107 @@
         expect(source.expandSymbols(input)).andReturn(expanded);
     }
 
-    protected final SymbolSource newSymbolSource()
+    protected final void train_forFile(Resource resource, String relativePath, Resource file)
     {
-        return newMock(SymbolSource.class);
+        expect(resource.forFile(relativePath)).andReturn(file);
     }
 
-    protected final ThreadLocale newThreadLocale()
+    protected final void train_forLocale(Resource base, Locale locale, Resource resource)
     {
-        return newMock(ThreadLocale.class);
+        expect(base.forLocale(locale)).andReturn(resource);
     }
 
-    protected final Messages newMessages()
+    /** Have to put the result before the varargs. */
+    protected void train_format(MessageFormatter formatter, String result, Object... arguments)
     {
-        return newMock(Messages.class);
+        expect(formatter.format(arguments)).andReturn(result);
     }
 
-    protected final void train_toURL(Resource resource, URL url)
+    protected final void train_get(Messages messages, String key, String message)
     {
-        expect(resource.toURL()).andReturn(url).atLeastOnce();
+        expect(messages.get(key)).andReturn(message).atLeastOnce();
     }
 
-    protected final void train_getPath(Resource r, String path)
+    protected final void train_getLocale(ThreadLocale threadLocale, Locale locale)
     {
-        expect(r.getPath()).andReturn(path).atLeastOnce();
+        expect(threadLocale.getLocale()).andReturn(locale);
     }
 
-    protected final void train_getLocale(ThreadLocale threadLocale, Locale locale)
+    protected final void train_getLog(LogSource source, String serviceId, Log log)
     {
-        expect(threadLocale.getLocale()).andReturn(locale);
+        expect(source.getLog(serviceId)).andReturn(log).atLeastOnce();
     }
 
-    protected final Log newLog()
+    protected final void train_getMessageFormatter(Messages messages, String key,
+            MessageFormatter formatter)
     {
-        return newMock(Log.class);
+        expect(messages.getFormatter(key)).andReturn(formatter).atLeastOnce();
     }
 
-    protected final void train_isDebugEnabled(Log log, boolean debugEnabled)
+    protected final void train_getPath(Resource r, String path)
     {
-        expect(log.isDebugEnabled()).andReturn(debugEnabled);
+        expect(r.getPath()).andReturn(path).atLeastOnce();
     }
 
-    protected final void train_contains(Messages messages, String key, boolean result)
+    protected final <T> void train_getService(ServiceLocator locator, Class<T> serviceInterface,
+            T service)
     {
-        expect(messages.contains(key)).andReturn(result).atLeastOnce();
+        expect(locator.getService(serviceInterface)).andReturn(service);
     }
 
-    protected final void train_getMessageFormatter(Messages messages, String key,
-            MessageFormatter formatter)
+    protected final <T> void train_getService(ServiceLocator locator, String serviceId,
+            Class<T> serviceInterface, T service)
     {
-        expect(messages.getFormatter(key)).andReturn(formatter).atLeastOnce();
+        expect(locator.getService(serviceId, serviceInterface)).andReturn(service);
     }
 
-    protected final MessageFormatter newMessageFormatter()
+    protected final void train_getServiceId(ServiceDef def, String serviceId)
     {
-        return newMock(MessageFormatter.class);
+        expect(def.getServiceId()).andReturn(serviceId).atLeastOnce();
     }
 
-    /** Have to put the result before the varargs. */
-    protected void train_format(MessageFormatter formatter, String result, Object... arguments)
+    protected final void train_getServiceId(ServiceResources resources, String serviceId)
     {
-        expect(formatter.format(arguments)).andReturn(result);
+        expect(resources.getServiceId()).andReturn(serviceId).atLeastOnce();
+
     }
 
-    protected final void train_get(Messages messages, String key, String message)
+    protected final void train_getServiceInterface(ServiceDef def, Class serviceInterface)
     {
-        expect(messages.get(key)).andReturn(message).atLeastOnce();
+        expect(def.getServiceInterface()).andReturn(serviceInterface).atLeastOnce();
     }
 
-    protected final void stub_contains(Messages messages, boolean contained)
+    protected final void train_getServiceInterface(ServiceResources resources,
+            Class serviceInterface)
     {
-        expect(messages.contains(isA(String.class))).andStubReturn(contained);
+        expect(resources.getServiceInterface()).andReturn(serviceInterface).atLeastOnce();
     }
 
-    protected final void train_forFile(Resource resource, String relativePath, Resource file)
+    protected final void train_getServiceLog(ServiceResources resources, Log log)
     {
-        expect(resource.forFile(relativePath)).andReturn(file);
+        expect(resources.getServiceLog()).andReturn(log).atLeastOnce();
+
     }
 
-    protected final void train_forLocale(Resource base, Locale locale, Resource resource)
+    protected final void train_isDebugEnabled(Log log, boolean debugEnabled)
     {
-        expect(base.forLocale(locale)).andReturn(resource);
+        expect(log.isDebugEnabled()).andReturn(debugEnabled);
     }
 
-    protected final AnnotationProvider newAnnotationProvider()
+    protected final void train_matches(DecoratorDef decoratorDef, ServiceDef serviceDef,
+            boolean matches)
     {
-        return newMock(AnnotationProvider.class);
+        expect(decoratorDef.matches(serviceDef)).andReturn(matches);
+    }
+
+    protected final <T> void train_provide(ObjectProvider provider, Class<T> objectType,
+            AnnotationProvider annotationProvider, ServiceLocator locator, T object)
+    {
+        expect(provider.provide(objectType, annotationProvider, locator)).andReturn(object);
+    }
+
+    protected final void train_toURL(Resource resource, URL url)
+    {
+        expect(resource.toURL()).andReturn(url).atLeastOnce();
     }
 }

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=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/module.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/module.apt Sat Apr 21 10:19:58 2007
@@ -98,12 +98,7 @@
   private final JobScheduler _scheduler;
   private final FileSystem _fileSystem;
   
-  public MyModule(
-    @InjectService("JobScheduler")
-    JobScheduler scheduler, 
-    
-    @InjectService("FileSystem")
-    FileSystem fileSystem)
+  public MyModule(JobScheduler scheduler, FileSystem fileSystem)
   {
     _scheduler = scheduler;
     _fileSystem = fileSystem;
@@ -124,9 +119,18 @@
   methods are not static, the MyModule class will be instantiated so that the methods may be
   invoked. The constructor receives two common dependencies, which are stored into instance
   fields that may later be used inside service builder methods such as buildIndexer().
+  
+  This approach is far from required; all the builder methods of your module can be static if you wish.
+  It is used when you have many common dependencies and wish to avoid defining those
+  dependencies as parameters to multiple methods.
 
-  In addition to injecting dependencies with the @InjectService and @Inject annotations,
-  you may also inject a number of <module> resources:
+  Tapestry IoC automatically resolves the parameter type (JobScheduler and FileSystem, in the example)
+  to the corresponding services that implement that type. When there's more than one
+  service that implements the service interface, you'll get an error (but additional annotations
+  and configuration can be used to ensure the correct service injected).
+ 
+  For modules, there are two additional parameter types that are used to refer to <resources> that
+  can be provided to the module instance (rather than <services> which may be injected).    
       
   * org.apache.commons.logging.Log: log for the module (derived from the module's class name)
    
@@ -199,7 +203,7 @@
 SubModule Annotation
 
   Often, you will have several different modules working together that should all be loaded
-  as a unit. They will, of course, have individual, unique ids.
+  as a unit. 
   
   One approach is to update the module ids into the manifest, as shown in the previous extension.
   

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=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/provider.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/provider.apt Sat Apr 21 10:19:58 2007
@@ -4,31 +4,38 @@
 
 Object Providers
 
-  The
-  {{{apidocs/org/apache/tapestry/ioc/annotations/Inject.html}@Inject annotation}}
-  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.
+  When you don't provide the {{{../apidocs/org/apache/tapestry/annotations/InjectService.html}InjectService}} annotation
+  on a parameter (to a service builder method or constructor), Tapestry will
+  resolve the parameter automatically.
+  
+  This is called <object injection>, rather than <service injection>, because the value that will ultimately
+  be injected is not necessarilly a service; it may be some aribrary object.
+  
+  If this sounds vague, its because there is not just one
+  {{{../apidocs/org/apache/tapestry/ioc/ObjectProvider.html}ObjectProvider}}; there's a whole set of them,
+  forming a {{{command.html}chain of command}}.  The commands in the chain may provide an object
+  based on the parameter type, or based on additional annotations on the parameter.
+  
+  There are two built-in object providers:
+  
+  * Check for {{{apidocs/org/apache/tapestry/ioc/annotations/Value.html}Value}} annotation
+  
+  * Check for a <unique> service in the Registry whose service interface matches the parameter type
+  
+  []
   
   Usually, the @Inject annotation is supplemented by an additional annotation which
   triggers a specific  ObjectProvider to provide the value.
   
-@Value Annotation
+@Value Annotation Provider
 
-  The {{{apidocs/org/apache/tapestry/ioc/annotations/Value.html}@Value annotation}}
+  The Value annotation
   allows a literal value to be injected.  When combined with 
   {{{symbols.html}symbols}}, they 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)
+  public MyService build(@Value("${max-seconds}") long maxSeconds)
   {
     return new MyServiceImpl(maxSeconds);
   }
@@ -38,6 +45,16 @@
   The value is supplied as a symbol, with a factory default that may be overwritten
   with an application default. 
   
+Service Provider
+
+  This is always that last object provider checked.
+  
+  A <single> service must exist whose service interface matches the parameter type.  This is <not> an exact match: a search is made for any and all
+  services whose service interface is a super class of the parameter type.  
+  
+  An exception is thrown if there are no matches, or if there are multiple matches.
+
+  
 Alias Object Provider
 
   The {{{http://tapestry.apache.org/tapestry5/tapestry-core/}tapestry-core}} module
@@ -49,7 +66,7 @@
 Defining New Providers
 
   New providers can be specified by contributing to the
-  tapestry.ioc.MasterObjectProvider service's configuration.  The configuration
+  MasterObjectProvider service's configuration.  The configuration
   is mapped, with the keys being the provider prefix, and the values
   being the object provider implementation.
   
@@ -68,9 +85,4 @@
   Of course, this is a simplified example. In a real scenario, the provider is most likely
   a service with its own dependencies.      
   
-  
-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 Value and InjectService
-  annotations support the use of {{{symbols.html}symbols}}.
\ No newline at end of file
+  
\ No newline at end of file

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=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/service.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/service.apt Sat Apr 21 10:19:58 2007
@@ -94,25 +94,33 @@
 
   Here, the service id is "FileSystemIndexer" not "Indexer".
   
-  For autobuilt services, the service id can be specified when the service is bount:
+  For autobuilt services, the service id can be specified when the service is bound:
   
 +---+
   binder.bind(Indexer.class, IndexerImpl.class).withId("FileSystemIndexer");
 +---+
   
-  
-{Injecting Dependencies} with @InjectService
+{Injecting Dependencies}
 
   It's pretty unlikely  that your service will be able to operate in a total vacuum. It will
-  have other dependencies.  For example, let's say the Indexer needs a JobScheduler to control
+  have other dependencies.  
+  
+  Dependencies are provided to a service in one of three ways:
+  
+  * As parameters to the service builder method
+  
+  * As parameters to the service implementation class' constructor (for autobuilt services)
+  
+  * As parameters passed to the constructor of the service's module builder (cached inside instance variables)
+  
+  []
+   
+  
+  For example, let's say the Indexer needs a JobScheduler to control
   when it executes, and a FileSystem to access files and store indexes.
   
 +-----------------------------------------------------------------------------------+
-  public static Indexer build(@InjectService("JobScheduler")
-    JobScheduler scheduler, 
-    
-    @InjectService("FileSystem")
-    FileSystem fileSystem)
+  public static Indexer build(JobScheduler scheduler, FileSystem fileSystem)
   {
     IndexerImpl indexer = new IndexerImpl(fileSystem);
       
@@ -123,8 +131,7 @@
 +-----------------------------------------------------------------------------------+
 
   Here we've annotated the parameters of the service builder method to identify what
-  service to inject for that parameter.  It doesn't matter in which module
-  these services are defined, and whether the service builder methods are static or instance.
+  service to inject for that parameter.  
   
   Note that we don't invoke those service builder methods ... we just "advertise" that we need
   the named services.  Tapestry IoC will provide the necessary proxies and, when we start to
@@ -132,6 +139,29 @@
   interceptors and its dependencies, are ready to go. Again, this is done in a 
   thread-safe manner.   
   
+  What happens if there is more than one service that implements the JobScheduler interface, or
+  the FileSystem interface?  You'll see a runtime exception, because Tapestry is unable to resolve
+  it down to a <single> service. At this point, it is necessary to <disambiguate> the link between
+  the service interface and <one> service.  One approach is to use
+  the 
+  {{{../apidocs/org/apache/tapestry/annotations/InjectService.html}InjectService}} annotation:
+  
+  
++-----------------------------------------------------------------------------------+
+  public static Indexer build(@InjectService("JobScheduler")
+    JobScheduler scheduler, 
+    
+    @InjectService("FileSystem")
+    FileSystem fileSystem)
+  {
+    IndexerImpl indexer = new IndexerImpl(fileSystem);
+      
+    scheduler.scheduleDailyJob(indexer);
+      
+    return indexer;
+  }
++-----------------------------------------------------------------------------------+  
+  
   If you find yourself injecting the same dependencies into multiple service builder 
   (or service decorator) methods, you can 
   {{{module.html#Caching Services}cache dependency injections}} in your module, by defining
@@ -327,13 +357,8 @@
   Example:
   
 +-----------------------------------------------------------------------------------+
-  public static Indexer build(String serviceId, Log serviceLog, 
-  
-    @InjectService("JobScheduler")
-    JobScheduler scheduler, 
-    
-    @InjectService("FileSystem")
-    FileSystem fileSystem)
+  public static Indexer build(String serviceId, Log serviceLog,  
+     JobScheduler scheduler, FileSystem fileSystem)
   {
     IndexerImpl indexer = new IndexerImpl(serviceLog, fileSystem);
       
@@ -357,54 +382,51 @@
   This works the exact same way with autobuilt services, except that the parameters of the service
   implementation constructor are considered, rather than the parameters of the service
   builder method.
-  
-  
-Automatic Dependency Resolution
 
-  When injecting another service, you may choose to not provide the @InjectService annotation.
-  
-  Tapestry will search the registry for a service that implements the <exact> service interface (determined
-  from the parameter type).  If it finds exactly one match, then the corresponding service will be
-  injected.
+  The @InjectService annotation takes precendence over these resources.
   
-  If there are no matches, or multiple matches, then a runtime exception is thrown.
+  If the @InjectService annotation is not present, and the parameter type does not exactly match
+  a resource type, then {{{provider.html}object injection}} occurs.   Object injection will find the correct
+  object to inject based on a number of (extensible) factors, including the parameter type and any additional annotations
+  on the parameter.
   
-  Obviously, this is only useful when you can be sure that there's only one service in the entire registry
-  that implements the service interface.  When you are building a framework for others to use, you should
-  not use this feature ... it's all too likely that some end-user application will create a second service
-  with the same service interface and break your injections.
-  
-  On the other hand, if you are using Tapestry IoC as part of an application, then you can save yourself
-  a small amount of effort and maintenance by letting Tapestry automatically identify dependencies.
-  
-  Example:
+  Every once and a while, you'll have a conflict between a resource type and an object injection.  For example,
+  the following does not work as expected:
   
 +-----------------------------------------------------------------------------------+
-  public static Indexer build(JobScheduler scheduler, FileSystem fileSystem)
+  public static Indexer build(String serviceId, Log serviceLog,  
+     JobScheduler scheduler, FileSystem fileSystem,
+     @Value("${index-alerts-email}")
+     String alertEmail)
   {
-    IndexerImpl indexer = new IndexerImpl(fileSystem);
-      
-    scheduler.scheduleDailyJob(indexer);
+    IndexerImpl indexer = new IndexerImpl(serviceLog, fileSystem, alertEmail);
       
+    scheduler.scheduleDailyJob(serviceId, indexer);
+
     return indexer;
   }
-+-----------------------------------------------------------------------------------+  
++-----------------------------------------------------------------------------------+    
 
-  Assuming that JobScheduler and FileSystem are unique service interfaces, the above will work.
-  It is not necessary that Indexer, JobScheduler and FileSystem be in the same
-  module.
+  It doesn't work because type String always gets the service id, as a resource (as with the serviceId parameter).
+  In order to get this to work, we need to turn off the resource injection for the alertEmail parameter.
+  That's what the {{{../apidocs/org/apache/tapestry/annotations/Inject.html}Inject}} annotation does:
   
-  Again, this works identically whether it is a service builder method, or an autobuilt service's constructor.
-
-Injecting Objects
++-----------------------------------------------------------------------------------+
+  public static Indexer build(String serviceId, Log serviceLog,  
+     JobScheduler scheduler, FileSystem fileSystem,
+     @Inject @Value("${index-alerts-email}")
+     String alertEmail)
+  {
+    IndexerImpl indexer = new IndexerImpl(serviceLog, fileSystem, alertEmail);
+      
+    scheduler.scheduleDailyJob(serviceId, indexer);
 
-  Another option is to inject <objects>, not <services>.  
+    return indexer;
+  }
++-----------------------------------------------------------------------------------+      
   
-  This is accomplished using the
-  {{{apidocs/org/apache/tapestry/ioc/annotations/Inject.html}Inject}} annotation.   The object
-  that gets injected is defined by an
-  {{{provider.html}object provider}}, and is based on the type of the parameter, and potentially
-  other annotations on the parameter.
+  Here, the alertEmail parameter will recieve the configured alerts email (see
+  {{{symbols.html}the symbols documentation}} for more about this syntax) rather than the service id.
   
 Builtin Services
 

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/site.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/site.xml?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/site.xml (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/site.xml Sat Apr 21 10:19:58 2007
@@ -60,6 +60,9 @@
             <item name="Starting the Registry" href="run.html"/>
             <item name="Object Providers" href="provider.html"/>
             <item name="Ordering" href="order.html"/>
+        </menu>
+        
+        <menu name="Service Builders">
             <item name="Chain Of Command" href="command.html"/>
             <item name="Strategy" href="strategy.html"/>
             <item name="Pipeline" href="pipeline.html"/>

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/PerThreadModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/PerThreadModule.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/PerThreadModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/PerThreadModule.java Sat Apr 21 10:19:58 2007
@@ -14,11 +14,13 @@
 
 package org.apache.tapestry.ioc;
 
+import static org.apache.tapestry.ioc.IOCConstants.PERTHREAD_SCOPE;
+
 import org.apache.tapestry.ioc.annotations.Scope;
 
 public class PerThreadModule
 {
-    @Scope("perthread")
+    @Scope(PERTHREAD_SCOPE)
     public StringHolder buildStringHolder()
     {
         return new StringHolderImpl();

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ContributionDefImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ContributionDefImplTest.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ContributionDefImplTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ContributionDefImplTest.java Sat Apr 21 10:19:58 2007
@@ -14,8 +14,12 @@
 
 package org.apache.tapestry.ioc.internal;
 
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.isA;
+
 import java.lang.reflect.Method;
 
+import org.apache.tapestry.ioc.AnnotationProvider;
 import org.apache.tapestry.ioc.Configuration;
 import org.apache.tapestry.ioc.MappedConfiguration;
 import org.apache.tapestry.ioc.ModuleBuilderSource;
@@ -40,8 +44,8 @@
     public void unordered_contribution()
     {
         _toContribute = new Object();
-        Configuration configuration = newConfiguration();
-        ServiceLocator locator = newServiceLocator();
+        Configuration configuration = mockConfiguration();
+        ServiceLocator locator = mockServiceLocator();
 
         configuration.add(_toContribute);
 
@@ -59,9 +63,9 @@
     @Test
     public void unordered_collection_with_service_lookup()
     {
-        Configuration configuration = newConfiguration();
-        ServiceLocator locator = newServiceLocator();
-        UpcaseService service = newUpcaseService();
+        Configuration configuration = mockConfiguration();
+        ServiceLocator locator = mockServiceLocator();
+        UpcaseService service = mockUpcaseService();
 
         train_getService(locator, "zip.Zap", UpcaseService.class, service);
 
@@ -80,12 +84,13 @@
     @Test
     public void unordered_collection_with_incorrect_configuration_parameter()
     {
-        Configuration configuration = newConfiguration();
-        ServiceLocator locator = newServiceLocator();
+        Configuration configuration = mockConfiguration();
+        ServiceLocator locator = mockServiceLocator();
 
         Throwable t = new RuntimeException("Missing service.");
 
-        expect(locator.getService(MappedConfiguration.class)).andThrow(t);
+        expect(locator.getObject(eq(MappedConfiguration.class), isA(AnnotationProvider.class)))
+                .andThrow(t);
 
         replay();
 
@@ -114,9 +119,9 @@
     @Test
     public void ordered_collection_with_service_lookup()
     {
-        OrderedConfiguration configuration = newOrderedConfiguration();
-        ServiceLocator locator = newServiceLocator();
-        UpcaseService service = newUpcaseService();
+        OrderedConfiguration configuration = mockOrderedConfiguration();
+        ServiceLocator locator = mockServiceLocator();
+        UpcaseService service = mockUpcaseService();
 
         train_getService(locator, "zip.Zap", UpcaseService.class, service);
 
@@ -136,9 +141,9 @@
     @Test
     public void mapped_collection_with_service_lookup()
     {
-        MappedConfiguration configuration = newMappedConfiguration();
-        ServiceLocator locator = newServiceLocator();
-        UpcaseService service = newUpcaseService();
+        MappedConfiguration configuration = mockMappedConfiguration();
+        ServiceLocator locator = mockServiceLocator();
+        UpcaseService service = mockUpcaseService();
 
         train_getService(locator, "zip.Zap", UpcaseService.class, service);
 
@@ -154,7 +159,7 @@
         verify();
     }
 
-    private UpcaseService newUpcaseService()
+    private UpcaseService mockUpcaseService()
     {
         return newMock(UpcaseService.class);
     }

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImplTest.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImplTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImplTest.java Sat Apr 21 10:19:58 2007
@@ -60,7 +60,7 @@
     {
         String className = SimpleModule.class.getName();
 
-        Log log = newLog();
+        Log log = mockLog();
 
         replay();
 
@@ -107,7 +107,7 @@
     @Test
     public void default_service_id_from_return_type()
     {
-        Log log = newLog();
+        Log log = mockLog();
 
         replay();
 
@@ -132,7 +132,7 @@
         String expectedMethod = InternalUtils.asString(ServiceIdConflictMethodModule.class
                 .getMethod("buildFred", Object.class), _classFactory);
 
-        Log log = newLog();
+        Log log = mockLog();
 
         log.warn(buildMethodConflict(conflictMethodString, expectedMethod), null);
 
@@ -168,7 +168,7 @@
     {
         Method m = VoidBuilderMethodModule.class.getMethod("buildNull");
 
-        Log log = newLog();
+        Log log = mockLog();
 
         log.warn(IOCMessages.buildMethodWrongReturnType(m), null);
 
@@ -192,7 +192,7 @@
     {
         Method m = moduleClass.getMethod(methodName, Object.class);
 
-        Log log = newLog();
+        Log log = mockLog();
 
         log.warn(IOCMessages.decoratorMethodWrongReturnType(m), null);
 
@@ -223,7 +223,7 @@
         Class moduleClass = NoDelegateDecoratorMethodModule.class;
         Method m = moduleClass.getMethod("decorateNoDelegate");
 
-        Log log = newLog();
+        Log log = mockLog();
 
         log.warn(IOCMessages.decoratorMethodNeedsDelegateParameter(m), null);
 
@@ -263,7 +263,7 @@
     private void attemptConfigurationMethod(Class moduleClass, String expectedServiceId,
             String expectedMethodSignature)
     {
-        Log log = newLog();
+        Log log = mockLog();
 
         replay();
 
@@ -293,7 +293,7 @@
         Class moduleClass = TooManyContributionParametersModule.class;
         Method m = findMethod(moduleClass, "contributeTooMany");
 
-        Log log = newLog();
+        Log log = mockLog();
         log.warn(IOCMessages.tooManyContributionParameters(m));
 
         replay();
@@ -311,7 +311,7 @@
         Class moduleClass = NoUsableContributionParameterModule.class;
         Method m = findMethod(moduleClass, "contributeNoParameter");
 
-        Log log = newLog();
+        Log log = mockLog();
         log.warn(IOCMessages.noContributionParameter(m));
 
         replay();
@@ -326,7 +326,7 @@
     @Test
     public void simple_binder_method()
     {
-        Log log = newLog();
+        Log log = mockLog();
 
         replay();
 
@@ -345,7 +345,7 @@
     @Test
     public void bind_service_with_all_options()
     {
-        Log log = newLog();
+        Log log = mockLog();
 
         replay();
 
@@ -364,7 +364,7 @@
     @Test
     public void attempt_to_bind_a_service_with_no_public_constructor()
     {
-        Log log = newLog();
+        Log log = mockLog();
 
         replay();
 
@@ -386,7 +386,7 @@
     @Test
     public void instance_method_bind_is_ignored()
     {
-        Log log = newLog();
+        Log log = mockLog();
 
         log.error(and(
                 contains(NonStaticBindMethodModule.class.getName()),
@@ -406,8 +406,8 @@
     @Test
     public void multiple_constructors_on_autobuild_service_implementation()
     {
-        Log log = newLog();
-        ServiceBuilderResources resources = newServiceBuilderResources();
+        Log log = mockLog();
+        ServiceBuilderResources resources = mockServiceBuilderResources();
 
         train_isDebugEnabled(log, true);
 
@@ -447,7 +447,7 @@
     @Test
     public void exception_from_inside_bind_method()
     {
-        Log log = newLog();
+        Log log = mockLog();
 
         replay();
 
@@ -471,7 +471,7 @@
     @Test
     public void autoload_service_is_eager_load_via_annotation()
     {
-        Log log = newLog();
+        Log log = mockLog();
 
         replay();
 

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/InterceptorStackBuilderTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/InterceptorStackBuilderTest.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/InterceptorStackBuilderTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/InterceptorStackBuilderTest.java Sat Apr 21 10:19:58 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.
@@ -30,8 +30,8 @@
     @Test
     public void no_decorators()
     {
-        ObjectCreator core = newObjectCreator();
-        Module module = newModule();
+        ObjectCreator core = mockObjectCreator();
+        Module module = mockModule();
         Object coreObject = new Object();
         List<ServiceDecorator> decorators = newList();
 
@@ -53,10 +53,10 @@
     @Test
     public void decorator_returns_null_interceptor()
     {
-        ObjectCreator core = newObjectCreator();
-        Module module = newModule();
+        ObjectCreator core = mockObjectCreator();
+        Module module = mockModule();
         Object coreObject = new Object();
-        ServiceDecorator decorator = newServiceDecorator();
+        ServiceDecorator decorator = mockServiceDecorator();
 
         List<ServiceDecorator> decorators = asList(decorator);
 
@@ -80,13 +80,13 @@
     @Test
     public void decorator_orderering()
     {
-        ObjectCreator core = newObjectCreator();
-        Module module = newModule();
+        ObjectCreator core = mockObjectCreator();
+        Module module = mockModule();
         Object coreObject = new Object();
         Object interceptor1 = new Object();
         Object interceptor2 = new Object();
-        ServiceDecorator decorator1 = newServiceDecorator();
-        ServiceDecorator decorator2 = newServiceDecorator();
+        ServiceDecorator decorator1 = mockServiceDecorator();
+        ServiceDecorator decorator2 = mockServiceDecorator();
 
         List<ServiceDecorator> decorators = asList(decorator1, decorator2);
 

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ModuleImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ModuleImplTest.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ModuleImplTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ModuleImplTest.java Sat Apr 21 10:19:58 2007
@@ -37,8 +37,8 @@
     @Test
     public void get_service_by_id_exists()
     {
-        InternalRegistry registry = newInternalRegistry();
-        Log log = newLog();
+        InternalRegistry registry = mockInternalRegistry();
+        Log log = mockLog();
         ClassFactory factory = new ClassFactoryImpl();
 
         ModuleDef moduleDef = new DefaultModuleDefImpl(ModuleImplTestModule.class, log,
@@ -79,8 +79,8 @@
     @Test
     public void find_service_ids_for_interface()
     {
-        InternalRegistry registry = newInternalRegistry();
-        Log log = newLog();
+        InternalRegistry registry = mockInternalRegistry();
+        Log log = mockLog();
 
         ModuleDef moduleDef = new DefaultModuleDefImpl(ModuleImplTestModule.class, log, null);
 
@@ -101,14 +101,14 @@
     @Test
     public void find_decorator_defs_for_service()
     {
-        InternalRegistry registry = newInternalRegistry();
-        ServiceDef serviceDef = newServiceDef();
-        DecoratorDef def1 = newDecoratorDef();
-        DecoratorDef def2 = newDecoratorDef();
+        InternalRegistry registry = mockInternalRegistry();
+        ServiceDef serviceDef = mockServiceDef();
+        DecoratorDef def1 = mockDecoratorDef();
+        DecoratorDef def2 = mockDecoratorDef();
         Set<DecoratorDef> rawDefs = newMock(Set.class);
-        Log log = newLog();
+        Log log = mockLog();
 
-        ModuleDef moduleDef = newModuleDef();
+        ModuleDef moduleDef = mockModuleDef();
 
         expect(moduleDef.getDecoratorDefs()).andReturn(rawDefs);
 
@@ -132,8 +132,8 @@
     @Test
     public void no_public_constructor_on_module_builder_class()
     {
-        InternalRegistry registry = newInternalRegistry();
-        Log log = newLog();
+        InternalRegistry registry = mockInternalRegistry();
+        Log log = mockLog();
         ModuleDef def = new DefaultModuleDefImpl(PrivateConstructorModule.class, log, null);
 
         replay();
@@ -160,8 +160,8 @@
     @Test
     public void too_many_public_constructors_on_module_builder_class()
     {
-        InternalRegistry registry = newInternalRegistry();
-        Log log = newLog();
+        InternalRegistry registry = mockInternalRegistry();
+        Log log = mockLog();
         ModuleDef def = new DefaultModuleDefImpl(ExtraPublicConstructorsModule.class, log, null);
         ClassFactory factory = newMock(ClassFactory.class);
         Module module = new ModuleImpl(registry, def, log);

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/RecursiveServiceCreationCheckWrapperTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/RecursiveServiceCreationCheckWrapperTest.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/RecursiveServiceCreationCheckWrapperTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/RecursiveServiceCreationCheckWrapperTest.java Sat Apr 21 10:19:58 2007
@@ -27,9 +27,9 @@
     @Test
     public void ensure_only_called_once() throws Exception
     {
-        Log log = newLog();
-        ObjectCreatorSource source = newObjectCreatorSource();
-        ObjectCreator delegate = newObjectCreator();
+        Log log = mockLog();
+        ObjectCreatorSource source = mockObjectCreatorSource();
+        ObjectCreator delegate = mockObjectCreator();
         Object service = new Object();
 
         ServiceDef def = new ServiceDefImpl(Runnable.class, "Bar", "singleton", false, source);
@@ -65,9 +65,9 @@
     public void reporting_of_construction_failure() throws Exception
     {
         RuntimeException failure = new RuntimeException("Just cranky.");
-        Log log = newLog();
-        ObjectCreatorSource source = newObjectCreatorSource();
-        ObjectCreator delegate = newObjectCreator();
+        Log log = mockLog();
+        ObjectCreatorSource source = mockObjectCreatorSource();
+        ObjectCreator delegate = mockObjectCreator();
         Object service = new Object();
 
         ServiceDef def = new ServiceDefImpl(Runnable.class, "Bar", "singleton", false, source);

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ServiceBuilderMethodFixture.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ServiceBuilderMethodFixture.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ServiceBuilderMethodFixture.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ServiceBuilderMethodFixture.java Sat Apr 21 10:19:58 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,99 +12,110 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.tapestry.ioc.ServiceResources;
-import org.apache.tapestry.ioc.annotations.InjectService;
-import org.testng.Assert;
-
-/**
- * Used by {@link org.apache.tapestry.ioc.internal.ServiceBuilderMethodInvokerTest}.
- * 
- * 
- */
-public class ServiceBuilderMethodFixture extends Assert
-{
-    FieService _fie;
-
-    String _expectedServiceId;
-
-    ServiceResources _expectedServiceResources;
-
-    Class _expectedServiceInterface;
-
-    Log _expectedLog;
-
-    FoeService _expectedFoe;
-
-    Object _expectedConfiguration;
-
-    public FieService buildWithUnorderedConfiguration(Collection<Runnable> configuration)
-    {
-        assertSame(configuration, _expectedConfiguration);
-
-        return _fie;
-    }
-
-    public FieService buildWithOrderedConfiguration(List<Runnable> configuration)
-    {
-        assertSame(configuration, _expectedConfiguration);
-
-        return _fie;
-    }
-
-    public void methodWithParameterizedList(List<Runnable> list)
-    {
-    }
-
-    public void methodWithList(List list)
-    {
-    }
-
-    public void methodWithWildcardList(List<? super ArrayList> list)
-    {
-
-    }
-
-    public FieService build_noargs()
-    {
-        return _fie;
-    }
-
-    public FieService build_injected(@InjectService("Foe")
-    FoeService foe)
-    {
-        assertSame(_expectedFoe, foe);
-
-        return _fie;
-    }
-
-    public FieService build_auto(FoeService foe)
-    {
-        assertSame(_expectedFoe, foe);
-
-        return _fie;
-    }
-
-    public FieService build_fail()
-    {
-        throw new RuntimeException("Method failed.");
-    }
-
-    public FieService build_args(String serviceId, ServiceResources resources,
-            Class serviceInterface, Log log)
-    {
-        assertEquals(serviceId, _expectedServiceId);
-        assertSame(resources, _expectedServiceResources);
-        assertSame(serviceInterface, _expectedServiceInterface);
-        assertSame(log, _expectedLog);
-
-        return _fie;
-    }
-
-}
+package org.apache.tapestry.ioc.internal;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.tapestry.ioc.ServiceResources;
+import org.apache.tapestry.ioc.annotations.Inject;
+import org.apache.tapestry.ioc.annotations.InjectService;
+import org.apache.tapestry.ioc.annotations.Value;
+import org.testng.Assert;
+
+/**
+ * Used by {@link org.apache.tapestry.ioc.internal.ServiceBuilderMethodInvokerTest}.
+ */
+public class ServiceBuilderMethodFixture extends Assert
+{
+    FieService _fie;
+
+    String _expectedServiceId;
+
+    ServiceResources _expectedServiceResources;
+
+    Class _expectedServiceInterface;
+
+    Log _expectedLog;
+
+    FoeService _expectedFoe;
+
+    Object _expectedConfiguration;
+
+    String _expectedString;
+
+    public FieService buildWithUnorderedConfiguration(Collection<Runnable> configuration)
+    {
+        assertSame(configuration, _expectedConfiguration);
+
+        return _fie;
+    }
+
+    public FieService buildWithOrderedConfiguration(List<Runnable> configuration)
+    {
+        assertSame(configuration, _expectedConfiguration);
+
+        return _fie;
+    }
+
+    public void methodWithParameterizedList(List<Runnable> list)
+    {
+    }
+
+    public void methodWithList(List list)
+    {
+    }
+
+    public void methodWithWildcardList(List<? super ArrayList> list)
+    {
+
+    }
+
+    public FieService build_noargs()
+    {
+        return _fie;
+    }
+
+    public FieService build_injected(@InjectService("Foe")
+    FoeService foe)
+    {
+        assertSame(_expectedFoe, foe);
+
+        return _fie;
+    }
+
+    public FieService build_auto(FoeService foe)
+    {
+        assertSame(_expectedFoe, foe);
+
+        return _fie;
+    }
+
+    public FieService build_fail()
+    {
+        throw new RuntimeException("Method failed.");
+    }
+
+    public FieService build_args(String serviceId, ServiceResources resources,
+            Class serviceInterface, Log log)
+    {
+        assertEquals(serviceId, _expectedServiceId);
+        assertSame(resources, _expectedServiceResources);
+        assertSame(serviceInterface, _expectedServiceInterface);
+        assertSame(log, _expectedLog);
+
+        return _fie;
+    }
+
+    public FieService build_with_forced_injection(@Inject
+    @Value("Injected")
+    String string)
+    {
+        assertEquals(string, _expectedString);
+
+        return _fie;
+    }
+
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ServiceBuilderMethodInvokerTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ServiceBuilderMethodInvokerTest.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ServiceBuilderMethodInvokerTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ServiceBuilderMethodInvokerTest.java Sat Apr 21 10:19:58 2007
@@ -14,7 +14,9 @@
 
 package org.apache.tapestry.ioc.internal;
 
-import static org.apache.tapestry.ioc.internal.ServiceBuilderMethodInvoker.findParameterizedTypeFromGenericType;
+import static org.apache.tapestry.ioc.internal.AbstractServiceCreator.findParameterizedTypeFromGenericType;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.isA;
 
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
@@ -22,9 +24,10 @@
 import java.util.List;
 
 import org.apache.commons.logging.Log;
+import org.apache.tapestry.ioc.AnnotationProvider;
 import org.apache.tapestry.ioc.ObjectCreator;
 import org.apache.tapestry.ioc.ServiceBuilderResources;
-import org.apache.tapestry.ioc.internal.util.InternalUtils;
+import org.easymock.EasyMock;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
@@ -38,10 +41,10 @@
     public void noargs_method()
     {
         ServiceBuilderMethodFixture fixture = new ServiceBuilderMethodFixture();
-        ServiceBuilderResources resources = newServiceBuilderResources();
-        Log log = newLog();
+        ServiceBuilderResources resources = mockServiceBuilderResources();
+        Log log = mockLog();
 
-        fixture._fie = newFieService();
+        fixture._fie = mockFieService();
 
         trainForConstructor(resources, log);
 
@@ -75,16 +78,16 @@
     {
         ServiceBuilderMethodFixture fixture = new ServiceBuilderMethodFixture();
         Method method = findMethod(fixture, "build_args");
-        ServiceBuilderResources resources = newServiceBuilderResources();
+        ServiceBuilderResources resources = mockServiceBuilderResources();
 
-        Log log = newLog();
+        Log log = mockLog();
 
         fixture._expectedServiceId = SERVICE_ID;
         fixture._expectedServiceInterface = FieService.class;
         fixture._expectedServiceResources = resources;
         fixture._expectedLog = log;
 
-        fixture._fie = newFieService();
+        fixture._fie = mockFieService();
 
         trainForConstructor(resources, log);
 
@@ -106,13 +109,50 @@
     }
 
     @Test
+    public void inject_annotation_bypasses_resources()
+    {
+        ServiceBuilderMethodFixture fixture = new ServiceBuilderMethodFixture();
+        Method method = findMethod(fixture, "build_with_forced_injection");
+        ServiceBuilderResources resources = mockServiceBuilderResources();
+
+        Log log = mockLog();
+
+        fixture._expectedString = "Injected";
+
+        fixture._fie = mockFieService();
+
+        trainForConstructor(resources, log);
+
+        train_getModuleBuilder(resources, fixture);
+
+        train_isDebugEnabled(log, true);
+
+        log.debug(IOCMessages.invokingMethod(CREATOR_DESCRIPTION));
+
+        // This simulates what the real stack does when it sees @Value("Injected")
+
+        expect(resources.getObject(eq(String.class), isA(AnnotationProvider.class))).andReturn(
+                "Injected");
+
+        replay();
+
+        ObjectCreator sc = new ServiceBuilderMethodInvoker(resources, CREATOR_DESCRIPTION, method);
+
+        Object actual = sc.createObject();
+
+        assertSame(actual, fixture._fie);
+
+        verify();
+    }
+
+    @Test
     public void injected_service_method()
     {
         ServiceBuilderMethodFixture fixture = new ServiceBuilderMethodFixture();
-        ServiceBuilderResources resources = newServiceBuilderResources();
-        Log log = newLog();
+        ServiceBuilderResources resources = mockServiceBuilderResources();
+        Log log = mockLog();
 
-        fixture._fie = newFieService();
+        fixture._fie = mockFieService();
         fixture._expectedFoe = newFoe();
 
         trainForConstructor(resources, log);
@@ -140,10 +180,10 @@
     public void injected_ordered_collection()
     {
         ServiceBuilderMethodFixture fixture = new ServiceBuilderMethodFixture();
-        ServiceBuilderResources resources = newServiceBuilderResources();
-        Log log = newLog();
+        ServiceBuilderResources resources = mockServiceBuilderResources();
+        Log log = mockLog();
 
-        fixture._fie = newFieService();
+        fixture._fie = mockFieService();
         List<Runnable> result = newMock(List.class);
         fixture._expectedConfiguration = result;
 
@@ -173,10 +213,10 @@
     public void injected_unordered_collection()
     {
         ServiceBuilderMethodFixture fixture = new ServiceBuilderMethodFixture();
-        ServiceBuilderResources resources = newServiceBuilderResources();
-        Log log = newLog();
+        ServiceBuilderResources resources = mockServiceBuilderResources();
+        Log log = mockLog();
 
-        fixture._fie = newFieService();
+        fixture._fie = mockFieService();
         Collection<Runnable> result = newMock(Collection.class);
         fixture._expectedConfiguration = result;
 
@@ -202,15 +242,15 @@
 
     private FoeService newFoe()
     {
-        return newFoeService();
+        return mockFoeService();
     }
 
     @Test
     public void builder_method_returns_null()
     {
         ServiceBuilderMethodFixture fixture = new ServiceBuilderMethodFixture();
-        ServiceBuilderResources resources = newServiceBuilderResources();
-        Log log = newLog();
+        ServiceBuilderResources resources = mockServiceBuilderResources();
+        Log log = mockLog();
 
         Method method = findMethod(fixture, "build_noargs");
 
@@ -242,8 +282,8 @@
     public void builder_method_failed()
     {
         ServiceBuilderMethodFixture fixture = new ServiceBuilderMethodFixture();
-        ServiceBuilderResources resources = newServiceBuilderResources();
-        Log log = newLog();
+        ServiceBuilderResources resources = mockServiceBuilderResources();
+        Log log = mockLog();
 
         Method method = findMethod(fixture, "build_fail");
 
@@ -281,17 +321,18 @@
         ServiceBuilderMethodFixture fixture = new ServiceBuilderMethodFixture();
         Method method = findMethod(fixture, "build_auto");
 
-        ServiceBuilderResources resources = newServiceBuilderResources();
-        Log log = newLog();
+        ServiceBuilderResources resources = mockServiceBuilderResources();
+        Log log = mockLog();
 
-        fixture._fie = newFieService();
-        fixture._expectedFoe = newFoeService();
+        fixture._fie = mockFieService();
+        fixture._expectedFoe = mockFoeService();
 
         trainForConstructor(resources, log);
 
         train_getModuleBuilder(resources, fixture);
 
-        train_getService(resources, FoeService.class, fixture._expectedFoe);
+        expect(resources.getObject(eq(FoeService.class), isA(AnnotationProvider.class))).andReturn(
+                fixture._expectedFoe);
 
         train_isDebugEnabled(log, false);
 
@@ -355,12 +396,12 @@
         }
     }
 
-    private FoeService newFoeService()
+    private FoeService mockFoeService()
     {
         return newMock(FoeService.class);
     }
 
-    private FieService newFieService()
+    private FieService mockFieService()
     {
         return newMock(FieService.class);
     }

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ServiceDecoratorImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ServiceDecoratorImplTest.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ServiceDecoratorImplTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ServiceDecoratorImplTest.java Sat Apr 21 10:19:58 2007
@@ -48,10 +48,10 @@
         ServiceDecoratorFixture fixture = new ServiceDecoratorFixture();
         Method m = findMethod(fixture, "decoratorReturnsInterceptor");
 
-        ServiceResources resources = newServiceResources();
-        Log log = newLog();
-        fixture._expectedDelegate = newFieService();
-        fixture._interceptorToReturn = newFieService();
+        ServiceResources resources = mockServiceResources();
+        Log log = mockLog();
+        fixture._expectedDelegate = mockFieService();
+        fixture._interceptorToReturn = mockFieService();
         ModuleBuilderSource source = newSource(fixture);
 
         trainForConstructor(resources, log);
@@ -80,9 +80,9 @@
     {
         ServiceDecoratorFixture fixture = new ServiceDecoratorFixture();
         ModuleBuilderSource source = newSource(fixture);
-        ServiceResources resources = newServiceResources();
-        Log log = newLog();
-        Object delegate = newFieService();
+        ServiceResources resources = mockServiceResources();
+        Log log = mockLog();
+        Object delegate = mockFieService();
 
         trainForConstructor(resources, log);
 
@@ -107,9 +107,9 @@
     {
         ServiceDecoratorFixture fixture = new ServiceDecoratorFixture();
         ModuleBuilderSource source = newSource(fixture);
-        ServiceResources resources = newServiceResources();
-        Log log = newLog();
-        fixture._expectedDelegate = newFieService();
+        ServiceResources resources = mockServiceResources();
+        Log log = mockLog();
+        fixture._expectedDelegate = mockFieService();
         fixture._interceptorToReturn = newMock(FoeService.class);
 
         Method m = findMethod(fixture, "decoratorUntyped");
@@ -141,9 +141,9 @@
     {
         ServiceDecoratorFixture fixture = new ServiceDecoratorFixture();
         ModuleBuilderSource source = newSource(fixture);
-        ServiceResources resources = newServiceResources();
-        Log log = newLog();
-        Object delegate = newFieService();
+        ServiceResources resources = mockServiceResources();
+        Log log = mockLog();
+        Object delegate = mockFieService();
         fixture._exception = new RuntimeException("Ouch!");
 
         trainForConstructor(resources, log);
@@ -175,7 +175,7 @@
         verify();
     }
 
-    private FieService newFieService()
+    private FieService mockFieService()
     {
         return newMock(FieService.class);
     }

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/SingletonServiceLifecycleTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/SingletonServiceLifecycleTest.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/SingletonServiceLifecycleTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/SingletonServiceLifecycleTest.java Sat Apr 21 10:19:58 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.
@@ -24,8 +24,8 @@
     @Test
     public void test()
     {
-        ServiceResources resources = newServiceResources();
-        ObjectCreator creator = newObjectCreator();
+        ServiceResources resources = mockServiceResources();
+        ObjectCreator creator = mockObjectCreator();
         Object expected = new Object();
 
         train_createObject(creator, expected);

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ValidatingConfigurationWrapperTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ValidatingConfigurationWrapperTest.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ValidatingConfigurationWrapperTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ValidatingConfigurationWrapperTest.java Sat Apr 21 10:19:58 2007
@@ -25,10 +25,10 @@
     @Test
     public void valid_contribution()
     {
-        ContributionDef def = newContributionDef();
-        Log log = newLog();
-        Configuration configuration = newConfiguration();
-        Runnable value = newRunnable();
+        ContributionDef def = mockContributionDef();
+        Log log = mockLog();
+        Configuration configuration = mockConfiguration();
+        Runnable value = mockRunnable();
 
         configuration.add(value);
 
@@ -46,8 +46,8 @@
     @Test
     public void null_contribution()
     {
-        Log log = newLog();
-        Configuration configuration = newConfiguration();
+        Log log = mockLog();
+        Configuration configuration = mockConfiguration();
         ContributionDef def = new ContributionDefImpl("Bar", findMethod("contributeUnorderedNull"),
                 getClassFactory());
 
@@ -67,8 +67,8 @@
     @Test
     public void wrong_type_of_contribution()
     {
-        Log log = newLog();
-        Configuration configuration = newConfiguration();
+        Log log = mockLog();
+        Configuration configuration = mockConfiguration();
         ContributionDef def = new ContributionDefImpl("Bar", findMethod("contributeUnorderedNull"),
                 getClassFactory());
 

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ValidatingMappedConfigurationWrapperTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ValidatingMappedConfigurationWrapperTest.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ValidatingMappedConfigurationWrapperTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ValidatingMappedConfigurationWrapperTest.java Sat Apr 21 10:19:58 2007
@@ -31,13 +31,13 @@
     @Test
     public void proper_key_and_value()
     {
-        ContributionDef def = newContributionDef();
-        Log log = newLog();
+        ContributionDef def = mockContributionDef();
+        Log log = mockLog();
         Map<Class, ContributionDef> keyToContribution = newMap();
-        MappedConfiguration<Class, Runnable> delegate = newMappedConfiguration();
+        MappedConfiguration<Class, Runnable> delegate = mockMappedConfiguration();
 
         Class key = Integer.class;
-        Runnable value = newRunnable();
+        Runnable value = mockRunnable();
 
         delegate.add(key, value);
 
@@ -58,15 +58,15 @@
     {
         ContributionDef def1 = newContributionDef("contributionPlaceholder1");
         ContributionDef def2 = newContributionDef("contributionPlaceholder2");
-        Log log = newLog();
+        Log log = mockLog();
         Map<Class, ContributionDef> keyToContribution = newMap();
 
         keyToContribution.put(Integer.class, def1);
 
-        MappedConfiguration<Class, Runnable> delegate = newMappedConfiguration();
+        MappedConfiguration<Class, Runnable> delegate = mockMappedConfiguration();
 
         Class key = Integer.class;
-        Runnable value = newRunnable();
+        Runnable value = mockRunnable();
 
         log.warn(IOCMessages.contributionDuplicateKey(SERVICE_ID, def2, def1));
 
@@ -86,10 +86,10 @@
     public void null_key()
     {
         ContributionDef def = newContributionDef("contributionPlaceholder1");
-        Log log = newLog();
+        Log log = mockLog();
         Map<Class, ContributionDef> keyToContribution = newMap();
-        MappedConfiguration<Class, Runnable> delegate = newMappedConfiguration();
-        Runnable value = newRunnable();
+        MappedConfiguration<Class, Runnable> delegate = mockMappedConfiguration();
+        Runnable value = mockRunnable();
 
         log.warn(IOCMessages.contributionKeyWasNull(SERVICE_ID, def));
 
@@ -108,10 +108,10 @@
     public void wrong_key_type()
     {
         ContributionDef def = newContributionDef("contributionPlaceholder1");
-        Log log = newLog();
+        Log log = mockLog();
         Map<?, ContributionDef> keyToContribution = newMap();
-        MappedConfiguration delegate = newMappedConfiguration();
-        Runnable value = newRunnable();
+        MappedConfiguration delegate = mockMappedConfiguration();
+        Runnable value = mockRunnable();
 
         log.warn(IOCMessages.contributionWrongKeyType(SERVICE_ID, def, String.class, Class.class));
 
@@ -130,9 +130,9 @@
     public void wrong_value_type()
     {
         ContributionDef def = newContributionDef("contributionPlaceholder1");
-        Log log = newLog();
+        Log log = mockLog();
         Map<?, ContributionDef> keyToContribution = newMap();
-        MappedConfiguration delegate = newMappedConfiguration();
+        MappedConfiguration delegate = mockMappedConfiguration();
 
         log.warn(IOCMessages.contributionWrongValueType(
                 SERVICE_ID,
@@ -154,9 +154,9 @@
     public void null_value()
     {
         ContributionDef def = newContributionDef("contributionPlaceholder1");
-        Log log = newLog();
+        Log log = mockLog();
         Map<Class, ContributionDef> keyToContribution = newMap();
-        MappedConfiguration<Class, Runnable> delegate = newMappedConfiguration();
+        MappedConfiguration<Class, Runnable> delegate = mockMappedConfiguration();
 
         log.warn(IOCMessages.contributionWasNull(SERVICE_ID, def));
 

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ValidatingOrderedConfigurationWrapperTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ValidatingOrderedConfigurationWrapperTest.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ValidatingOrderedConfigurationWrapperTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ValidatingOrderedConfigurationWrapperTest.java Sat Apr 21 10:19:58 2007
@@ -26,10 +26,10 @@
     @Test
     public void valid_type_long_form()
     {
-        ContributionDef def = newContributionDef();
-        Log log = newLog();
-        OrderedConfiguration<Runnable> configuration = newOrderedConfiguration();
-        Runnable contribution = newRunnable();
+        ContributionDef def = mockContributionDef();
+        Log log = mockLog();
+        OrderedConfiguration<Runnable> configuration = mockOrderedConfiguration();
+        Runnable contribution = mockRunnable();
 
         configuration.add("id", contribution, "after:pre", "before:post");
 
@@ -46,10 +46,10 @@
     @Test
     public void valid_type_short_form()
     {
-        ContributionDef def = newContributionDef();
-        Log log = newLog();
-        OrderedConfiguration<Runnable> configuration = newOrderedConfiguration();
-        Runnable contribution = newRunnable();
+        ContributionDef def = mockContributionDef();
+        Log log = mockLog();
+        OrderedConfiguration<Runnable> configuration = mockOrderedConfiguration();
+        Runnable contribution = mockRunnable();
 
         configuration.add("id", contribution);
 
@@ -66,9 +66,9 @@
     @Test
     public void null_object_passed_through()
     {
-        ContributionDef def = newContributionDef();
-        Log log = newLog();
-        OrderedConfiguration<Runnable> configuration = newOrderedConfiguration();
+        ContributionDef def = mockContributionDef();
+        Log log = mockLog();
+        OrderedConfiguration<Runnable> configuration = mockOrderedConfiguration();
 
         configuration.add("id", null);
 
@@ -89,8 +89,8 @@
         Method method = findMethod("contributeBarneyService");
 
         ContributionDef def = new ContributionDefImpl("Service", method, getClassFactory());
-        Log log = newLog();
-        OrderedConfiguration<Runnable> configuration = newOrderedConfiguration();
+        Log log = mockLog();
+        OrderedConfiguration<Runnable> configuration = mockOrderedConfiguration();
 
         log.warn(IOCMessages.contributionWrongValueType(
                 "Service",

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/BridgeBuilderTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/BridgeBuilderTest.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/BridgeBuilderTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/BridgeBuilderTest.java Sat Apr 21 10:19:58 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.
@@ -28,7 +28,7 @@
     @Test
     public void standard_interface_and_filter()
     {
-        Log log = newLog();
+        Log log = mockLog();
 
         replay();
 
@@ -71,7 +71,7 @@
     @Test
     public void toString_part_of_service_interface()
     {
-        Log log = newLog();
+        Log log = mockLog();
 
         replay();
 
@@ -105,7 +105,7 @@
     @Test
     public void service_interface_method_not_matched_in_filter_interface()
     {
-        Log log = newLog();
+        Log log = mockLog();
         ExtraServiceMethod next = newMock(ExtraServiceMethod.class);
         Serializable filter = newMock(Serializable.class);
 
@@ -139,7 +139,7 @@
     @Test
     public void filter_interface_contains_extra_methods()
     {
-        Log log = newLog();
+        Log log = mockLog();
         Serializable next = newMock(Serializable.class);
         ExtraFilterMethod filter = newMock(ExtraFilterMethod.class);
 
@@ -163,7 +163,7 @@
     @Test
     public void service_parameter_in_middle_of_filter_method()
     {
-        Log log = newLog();
+        Log log = mockLog();
 
         replay();
 

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/ChainBuilderImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/ChainBuilderImplTest.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/ChainBuilderImplTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/ChainBuilderImplTest.java Sat Apr 21 10:19:58 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.
@@ -29,8 +29,8 @@
     @Test
     public void simple_void_method()
     {
-        Runnable r1 = newRunnable();
-        Runnable r2 = newRunnable();
+        Runnable r1 = mockRunnable();
+        Runnable r2 = mockRunnable();
 
         // Training:
 
@@ -51,8 +51,8 @@
     @Test
     public void int_method()
     {
-        ChainCommand c1 = newChainCommand();
-        ChainCommand c2 = newChainCommand();
+        ChainCommand c1 = mockChainCommand();
+        ChainCommand c2 = mockChainCommand();
 
         expect(c1.workInt(7)).andReturn(0);
 
@@ -70,8 +70,8 @@
     @Test
     public void int_method_shortcircuits()
     {
-        ChainCommand c1 = newChainCommand();
-        ChainCommand c2 = newChainCommand();
+        ChainCommand c1 = mockChainCommand();
+        ChainCommand c2 = mockChainCommand();
 
         expect(c1.workInt(7)).andReturn(88);
 
@@ -87,8 +87,8 @@
     @Test
     public void boolean_method()
     {
-        ChainCommand c1 = newChainCommand();
-        ChainCommand c2 = newChainCommand();
+        ChainCommand c1 = mockChainCommand();
+        ChainCommand c2 = mockChainCommand();
 
         train_workBoolean(c1, true, false);
         train_workBoolean(c2, true, true);
@@ -110,8 +110,8 @@
     @Test
     public void string_method()
     {
-        ChainCommand c1 = newChainCommand();
-        ChainCommand c2 = newChainCommand();
+        ChainCommand c1 = mockChainCommand();
+        ChainCommand c2 = mockChainCommand();
 
         expect(c1.workString("fred")).andReturn(null);
 
@@ -130,8 +130,8 @@
     @Test
     public void double_method()
     {
-        ChainCommand c1 = newChainCommand();
-        ChainCommand c2 = newChainCommand();
+        ChainCommand c1 = mockChainCommand();
+        ChainCommand c2 = mockChainCommand();
 
         expect(c1.workDouble(1.2d)).andReturn(0d);
 
@@ -146,7 +146,7 @@
         verify();
     }
 
-    private ChainCommand newChainCommand()
+    private ChainCommand mockChainCommand()
     {
         return newMock(ChainCommand.class);
     }
@@ -154,8 +154,8 @@
     @Test
     public void fabricated_classes_are_reused()
     {
-        Runnable r1 = newRunnable();
-        Runnable r2 = newRunnable();
+        Runnable r1 = mockRunnable();
+        Runnable r2 = mockRunnable();
 
         Runnable chain1 = build(Runnable.class, r1);
         Runnable chain2 = build(Runnable.class, r2);

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/ExceptionAnalyzerImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/ExceptionAnalyzerImplTest.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/ExceptionAnalyzerImplTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/ExceptionAnalyzerImplTest.java Sat Apr 21 10:19:58 2007
@@ -65,7 +65,7 @@
     @Test
     public void exception_properties()
     {
-        Location l = newLocation();
+        Location l = mockLocation();
 
         replay();
 
@@ -130,7 +130,7 @@
     @Test
     public void middle_exception_retained_due_to_extra_property()
     {
-        Location l = newLocation();
+        Location l = mockLocation();
 
         replay();
 

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/LoggingDecoratorImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/LoggingDecoratorImplTest.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/LoggingDecoratorImplTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/LoggingDecoratorImplTest.java Sat Apr 21 10:19:58 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.
@@ -51,8 +51,8 @@
     @Test
     public void void_method()
     {
-        Log log = newLog();
-        Runnable delegate = newRunnable();
+        Log log = mockLog();
+        Runnable delegate = mockRunnable();
 
         train_isDebugEnabled(log, true);
         log.debug("[ENTER] run()");
@@ -84,8 +84,8 @@
     public void method_throws_runtime_exception()
     {
         Throwable t = new RuntimeException("From delegate.");
-        Log log = newLog();
-        Runnable delegate = newRunnable();
+        Log log = mockLog();
+        Runnable delegate = mockRunnable();
 
         train_isDebugEnabled(log, true);
         log.debug("[ENTER] run()");
@@ -119,7 +119,7 @@
     public void method_throws_checked_exception() throws Exception
     {
         Throwable t = new SAXParseException("From delegate.", null);
-        Log log = newLog();
+        Log log = mockLog();
         ExceptionService delegate = newMock(ExceptionService.class);
 
         train_isDebugEnabled(log, true);
@@ -153,7 +153,7 @@
     @Test
     public void object_parameter_and_return_type()
     {
-        Log log = newLog();
+        Log log = mockLog();
         UpcaseService delegate = new UpcaseService()
         {
             public String upcase(String input)
@@ -180,7 +180,7 @@
     @Test
     public void primitive_parameter_and_return_type()
     {
-        Log log = newLog();
+        Log log = mockLog();
         AdderService delegate = new AdderService()
         {
             public long add(long operand1, long operand2)
@@ -207,7 +207,7 @@
     @Test
     public void to_string_method_in_service_interface_is_delegated()
     {
-        Log log = newLog();
+        Log log = mockLog();
         ToStringService delegate = new ToStringService()
         {
             @Override

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/PipelineBuilderImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/PipelineBuilderImplTest.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/PipelineBuilderImplTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/PipelineBuilderImplTest.java Sat Apr 21 10:19:58 2007
@@ -56,7 +56,7 @@
     @Test
     public void pipeline_with_filters()
     {
-        Log log = newLog();
+        Log log = mockLog();
 
         replay();
 
@@ -109,7 +109,7 @@
     @Test
     public void pipeline_without_filters_is_terminator()
     {
-        Log log = newLog();
+        Log log = mockLog();
         StandardService terminator = newMock(StandardService.class);
 
         replay();
@@ -131,7 +131,7 @@
     @Test
     public void pipeline_with_default_terminator()
     {
-        Log log = newLog();
+        Log log = mockLog();
 
         replay();
 

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/RegistryShutdownHubImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/RegistryShutdownHubImplTest.java?view=diff&rev=531068&r1=531067&r2=531068
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/RegistryShutdownHubImplTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/services/RegistryShutdownHubImplTest.java Sat Apr 21 10:19:58 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.
@@ -28,9 +28,9 @@
     @Test
     public void add_and_notify()
     {
-        RegistryShutdownListener l1 = newListener();
-        RegistryShutdownListener l2 = newListener();
-        Log log = newLog();
+        RegistryShutdownListener l1 = mockListener();
+        RegistryShutdownListener l2 = mockListener();
+        Log log = mockLog();
 
         l1.registryDidShutdown();
         l2.registryDidShutdown();
@@ -54,11 +54,11 @@
     @Test
     public void notification_error()
     {
-        RegistryShutdownListener l1 = newListener();
-        RegistryShutdownListener l2 = newListener();
-        RegistryShutdownListener l3 = newListener();
+        RegistryShutdownListener l1 = mockListener();
+        RegistryShutdownListener l2 = mockListener();
+        RegistryShutdownListener l3 = mockListener();
 
-        Log log = newLog();
+        Log log = mockLog();
 
         Throwable t = new RuntimeException("Shutdown failure.");
 
@@ -83,7 +83,7 @@
         verify();
     }
 
-    private RegistryShutdownListener newListener()
+    private RegistryShutdownListener mockListener()
     {
         return newMock(RegistryShutdownListener.class);
     }