You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2007/03/11 19:39:50 UTC

svn commit: r516982 - in /tapestry/tapestry5/tapestry-ioc/trunk/src: main/java/org/apache/tapestry/ioc/internal/ main/java/org/apache/tapestry/ioc/internal/util/ main/java/org/apache/tapestry/ioc/services/ site/apt/ test/java/org/apache/tapestry/ioc/in...

Author: hlship
Date: Sun Mar 11 11:39:49 2007
New Revision: 516982

URL: http://svn.apache.org/viewvc?view=rev&rev=516982
Log:
TAPESTRY-1341: Allow service builders named "build" and determine service id from the result type
Also, correct some documentation errors related to TAPESTRY-1339.

Added:
    tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/DefaultServiceIdModule.java
Modified:
    tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImpl.java
    tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/InterceptorStackBuilder.java
    tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/InternalUtils.java
    tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/TapestryIOCModule.java
    tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/case.apt
    tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/command.apt
    tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/configuration.apt
    tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/decorator.apt
    tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/module.apt
    tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/pipeline.apt
    tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/service.apt
    tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/shadow.apt
    tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/strategy.apt
    tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/symbols.apt
    tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImplTest.java
    tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/util/InternalUtilsTest.java

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImpl.java?view=diff&rev=516982&r1=516981&r2=516982
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/DefaultModuleDefImpl.java Sun Mar 11 11:39:49 2007
@@ -267,6 +267,11 @@
         // TODO: Methods named just "build"
         String serviceId = stripMethodPrefix(method, BUILD_METHOD_NAME_PREFIX);
 
+        // If the method name was just "build()", then work from the return type.
+
+        if (serviceId.equals(""))
+            serviceId = InternalUtils.lastTerm(method.getReturnType().getName());
+
         ServiceDef existing = _serviceDefs.get(serviceId);
         if (existing != null)
         {

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/InterceptorStackBuilder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/InterceptorStackBuilder.java?view=diff&rev=516982&r1=516981&r2=516982
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/InterceptorStackBuilder.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/InterceptorStackBuilder.java Sun Mar 11 11:39:49 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 2007 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.

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=516982&r1=516981&r2=516982
==============================================================================
--- 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 Sun Mar 11 11:39:49 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.
@@ -46,10 +46,6 @@
      */
     public static final String NAME_PREFIX = "_$";
 
-    private InternalUtils()
-    {
-    }
-
     /**
      * Converts a method to a user presentable string consisting of the containing class name, the
      * method name, and the short form of the parameter list (the class name of each parameter type,
@@ -375,5 +371,22 @@
     public static boolean containsSymbols(String input)
     {
         return input.contains("${");
+    }
+
+    /**
+     * Searches the string for the final period ('.') character and returns everything after that.
+     * The input string is generally a fully qualified class name, though tapestry-core also uses
+     * this method for the occasional property expression (which is also dot separated). Returns the
+     * input string unchanged if it does not contain a period character.
+     */
+    public static String lastTerm(String input)
+    {
+        Defense.notBlank(input, "input");
+
+        int dotx = input.lastIndexOf('.');
+
+        if (dotx < 0) return input;
+
+        return input.substring(dotx + 1);
     }
 }

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=516982&r1=516981&r2=516982
==============================================================================
--- 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 Sun Mar 11 11:39:49 2007
@@ -55,17 +55,23 @@
 {
     private final ClassFactory _classFactory;
 
+    private final PropertyAccess _propertyAccess;
+
     public TapestryIOCModule(@InjectService("ClassFactory")
-    ClassFactory classFactory)
+    ClassFactory classFactory,
+
+    @InjectService("PropertyAccess")
+    PropertyAccess propertyAccess)
     {
         _classFactory = classFactory;
+        _propertyAccess = propertyAccess;
     }
 
     /**
      * The LoggingDecorator service is used to decorate a service implementation so that it logs
      * method entry and exit (at level debug).
      */
-    public LoggingDecorator buildLoggingDecorator(@InjectService("ExceptionTracker")
+    public LoggingDecorator build(@InjectService("ExceptionTracker")
     ExceptionTracker exceptionTracker)
     {
         return new LoggingDecoratorImpl(_classFactory, exceptionTracker);
@@ -76,8 +82,7 @@
      * and "primitive") but additional ones are accessed via this service (and its mapped
      * configuration).
      */
-    public static ServiceLifecycleSource buildServiceLifecycleSource(
-            final Map<String, ServiceLifecycle> configuration)
+    public static ServiceLifecycleSource build(final Map<String, ServiceLifecycle> configuration)
     {
         return new ServiceLifecycleSource()
         {
@@ -127,16 +132,15 @@
     /**
      * Builder that creates a shadow, a projection of a property of some other object.
      */
-    public PropertyShadowBuilder buildPropertyShadowBuilder(@InjectService("PropertyAccess")
-    PropertyAccess propertyAccess)
+    public PropertyShadowBuilder buildPropertyShadowBuilder()
     {
-        return new PropertyShadowBuilderImpl(_classFactory, propertyAccess);
+        return new PropertyShadowBuilderImpl(_classFactory, _propertyAccess);
     }
 
     /**
      * Builder that creates a filter pipeline around a simple service interface.
      */
-    public PipelineBuilder buildPipelineBuilder(@InjectService("DefaultImplementationBuilder")
+    public PipelineBuilder build(@InjectService("DefaultImplementationBuilder")
     DefaultImplementationBuilder builder)
     {
         return new PipelineBuilderImpl(_classFactory, builder);
@@ -181,16 +185,15 @@
         return new ExceptionTrackerImpl();
     }
 
-    public static ExceptionAnalyzer buildExceptionAnalyzer(@InjectService("PropertyAccess")
-    PropertyAccess access)
+    public ExceptionAnalyzer buildExceptionAnalyzer()
     {
-        return new ExceptionAnalyzerImpl(access);
+        return new ExceptionAnalyzerImpl(_propertyAccess);
     }
 
     /**
      * Returns the service that can coerce between different types.
      */
-    public static TypeCoercer buildTypeCoercer(Collection<CoercionTuple> configuration)
+    public static TypeCoercer build(Collection<CoercionTuple> configuration)
     {
         return new TypeCoercerImpl(configuration);
     }
@@ -426,7 +429,7 @@
         return new ThreadLocaleImpl();
     }
 
-    public static SymbolSource buildSymbolSource(List<SymbolProvider> configuration)
+    public static SymbolSource build(List<SymbolProvider> configuration)
     {
         return new SymbolSourceImpl(configuration);
     }

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/case.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/case.apt?view=diff&rev=516982&r1=516981&r2=516982
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/case.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/case.apt Sun Mar 11 11:39:49 2007
@@ -7,9 +7,7 @@
   Ever get frustrated because you typed the right thing with the wrong case and your system blew up?  We do.
   
   Tapestry IOC attempts to be case insensitive for all the main constructs:
-  
-  * Module ids.
-  
+   
   * Service ids.
   
   * Object provider prefixes.
@@ -18,7 +16,7 @@
   
   []
   
-  Thus, <<<getService("fBaz", Baz.class)>>> is preferred, but <<<getService("BAZ", Baz.class)>>> (or any variation thereof) will work just exactly as well.  This also extends to other naming conventions,
+  Thus, <<<getService("Baz", Baz.class)>>> is preferred, but <<<getService("BAZ", Baz.class)>>> (or any variation thereof) will work just exactly as well.  This also extends to other naming conventions,
   such as <<<contributeFoo>>> methods. It also applies to values inside annotations.
   
   Just case is ignored --

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=516982&r1=516981&r2=516982
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/command.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/command.apt Sun Mar 11 11:39:49 2007
@@ -54,7 +54,7 @@
   We can just let the ChainBuilder service create that object.
   
 +----+
-  public static MyChainService buildMyChainService(List<MyChainService> commands,
+  public static MyChainService build(List<MyChainService> commands,
     @InjectService("ChainBuilder")
     ChainBuilder chainBuilder)
   {

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/configuration.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/configuration.apt?view=diff&rev=516982&r1=516981&r2=516982
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/configuration.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/configuration.apt Sun Mar 11 11:39:49 2007
@@ -40,8 +40,7 @@
   "contribute":
   
 +------+
-  @Contribute("FileServicerDispatcher")
-  public static void contributeFileServicers(MappedConfiguration<String,FileServicer> configuration)
+  public static void contributeFileServicerDispatcher(MappedConfiguration<String,FileServicer> configuration)
   {
     configuration.add("txt", new TextFileServicer());
     configuration.add("pdf", new PDFFileServicer());
@@ -51,8 +50,7 @@
   Like service builder and service decorator methods, we can inject services if we like:
   
 +------+
-  @Contribute("FileServicerDispatcher")
-  public static void contributeFileServicers(MappedConfiguration<String,FileServicer> configuration,
+  public static void contributFileServicerDispatcher(MappedConfiguration<String,FileServicer> configuration,
   
     @InjectService("TextFileServicer") FileServicer textFileServicer,
     
@@ -67,7 +65,7 @@
   service configuration:
   
 +------+
-   public static void contributeFileServicers(MappedConfiguration<String,FileServicer> configuration)
+   public static void contributeFileServicerDispatcher(MappedConfiguration<String,FileServicer> configuration)
   {
     configuration.add("doc", new WordFileServicer());
     configuration.add("ppt", new PowerPointFileServicer());

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=516982&r1=516981&r2=516982
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/decorator.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/decorator.apt Sun Mar 11 11:39:49 2007
@@ -61,7 +61,7 @@
 
 public class MyAppModule
 {
-  public static Indexer buildIndexer()
+  public static Indexer build()
   {
     return new IndexerImpl();
   }
@@ -115,7 +115,7 @@
 
 public class MyAppModule
 {
-  public static Indexer buildIndexer(Class serviceInterface, Log serviceLog,
+  public static Indexer build(Class serviceInterface, Log serviceLog,
     @InjectService("LoggingDecorator")
     LoggingInterceptorFactory decorator)
   {

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=516982&r1=516981&r2=516982
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/module.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/module.apt Sun Mar 11 11:39:49 2007
@@ -18,7 +18,7 @@
 
 public class MyAppModule
 {
-  public static Indexer buildIndexer()
+  public static Indexer build()
   {
     return new IndexerImpl();
   }
@@ -26,13 +26,28 @@
 +-----------------------------------------------------------------------------------+
 
   Any public method (static or instance) whose name starts with "build" is a service builder method, implicitly
-  defining a service within the module.  Here we're defining a service around
+  defining a service within the module. 
+  
+  
+  Here we're defining a service around
   the Indexer service interface (presumably also in the org.example.myapp.services
   package).
-
-  The service's unique id is derived from the method name.
-  Here "build" was stripped off of "buildIndexer", leaving "Indexer".  This id is how
-  other services will refer to the Indexer service.  Tapestry IoC is case insensitive; later we can
+  
+  
+  Every service has a unique id, used to identify it throughout the Registry of services (the Registry
+  is the combined sum of all services from all modules). If you don't provide an explicit service id,
+  as in this example, the service id  is drawn from the return type; this service has an id of "Indexer".
+  
+  
+  You can give a service an explicit id by adding it to the method name:  buildIndexer().  This is useful
+  when you do not want the service id to match the service interface name (for example, when you have different
+  services that implement the same interface), or when you need to avoid name collisions on the 
+  method name (Java allows only a single method with a given name and set of parameters, even if the return
+  types are differenty, so if you have two different service builder methods that take the same parameters,
+  you should give them explicit service ids in the method name).
+  
+  
+  Tapestry IoC is {{{case.html}case insensitive}}; later we can
   refer to this service as "indexer" or "INDEXER" or any variation thereof, and connect to
   this service.
   
@@ -72,7 +87,7 @@
     _fileSystem = fileSystem;
   }
   
-  public Indexer buildIndexer()
+  public Indexer build()
   {
     IndexerImpl indexer = new IndexerImpl(_fileSystem);
       

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/pipeline.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/pipeline.apt?view=diff&rev=516982&r1=516981&r2=516982
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/pipeline.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/pipeline.apt Sun Mar 11 11:39:49 2007
@@ -72,7 +72,7 @@
   must be provided.  The bridges and the terminator implement the service interface.
   
 +-----+
-  public static StringTransformService buildStringTransform(
+  public static StringTransformService build(
     @InjectService("PipelineBuilder")
     PipelineBuilder builder,
     List<StringTransformFilter> configuration,

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=516982&r1=516981&r2=516982
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/service.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/service.apt Sun Mar 11 11:39:49 2007
@@ -22,7 +22,7 @@
 
 public class MyAppModule
 {
-  public static Indexer buildIndexer()
+  public static Indexer build()
   {
     return new IndexerImpl();
   }
@@ -32,7 +32,16 @@
   Here the service interface is Indexer (presumably inside the org.example.myapp.services package,
   since there isn't an import).  Tapestry IoC doesn't know about the IndexerImpl class (the
   service implementation of the Indexer service), but it does know 
-  about the buildIndexer() method.
+  about the build() method.
+  
+  That's one of the great innovations of Tapestry IoC: we don't try to encapsulate in XML or annotations
+  all the different ways possible to create a service; those things are best expressed in Java code.
+  For a simple case (as here), it would be hard for external configuration (again, in XML or Java annotations)
+  to be shorter than "new IndexerImpl()".
+  
+  For more complex and realistic scenarios, such as injecting dependencies via the constructor, or
+  doing more interest work (such as registering the newly created service for events published by some other service),
+  the Java code is simply the most direct, flexible, extensible and readable approach.
   
 {Injecting Dependencies} with @InjectService
 
@@ -41,7 +50,7 @@
   when it executes, and a FileSystem to access files and store indexes.
   
 +-----------------------------------------------------------------------------------+
-  public static Indexer buildIndexer(@InjectService("JobScheduler")
+  public static Indexer build(@InjectService("JobScheduler")
     JobScheduler scheduler, 
     
     @InjectService("FileSystem")
@@ -82,7 +91,7 @@
   as:
     
 +-----------------------------------------------------------------------------------+
-  public static Indexer buildIndexer(@Inject("service:JobScheduler")
+  public static Indexer build(@Inject("service:JobScheduler")
     JobScheduler scheduler, @Inject("service:FileSystem")
     FileSystem fileSystem)
   {
@@ -199,7 +208,7 @@
   Example:
   
 +-----------------------------------------------------------------------------------+
-  public static Indexer buildIndexer(String serviceId, Log serviceLog, 
+  public static Indexer build(String serviceId, Log serviceLog, 
   
     @InjectService("JobScheduler")
     JobScheduler scheduler, 
@@ -247,7 +256,7 @@
   Example:
   
 +-----------------------------------------------------------------------------------+
-  public static Indexer buildIndexer(JobScheduler scheduler, FileSystem fileSystem)
+  public static Indexer build(JobScheduler scheduler, FileSystem fileSystem)
   {
     IndexerImpl indexer = new IndexerImpl(fileSystem);
       
@@ -292,7 +301,7 @@
   With Tapestry IoC, this is not even considered a special case:
   
 +-----------------------------------------------------------------------------------+
-  public static Indexer buildIndexer(JobScheduler scheduler, FileSystem fileSystem)
+  public static Indexer build(JobScheduler scheduler, FileSystem fileSystem)
   {
     IndexerImpl indexer = new IndexerImpl(fileSystem);
   
@@ -301,7 +310,7 @@
     return indexer;
   }
     
-  public static buildFileSystem(Indexer indexer)
+  public static build(Indexer indexer)
   {
     return new FileSystemImpl(indexer);
   }  

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=516982&r1=516981&r2=516982
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/shadow.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/shadow.apt Sun Mar 11 11:39:49 2007
@@ -10,7 +10,7 @@
   
   Effectively, it is used to allow a property of another service to be exposed as its own service.
   
-  For example, the tapestry module provides a WebRequest property as a shadow of the RequestGlobals
+  For example, the tapestry-core module provides a WebRequest property as a shadow of the RequestGlobals
   service's request property:
   
 +----+
@@ -41,9 +41,13 @@
 Non-Reflective
 
   When the shadow is created, reflection is used to translate the property name to a method name.
-  At runtime, reflection is not used.  A typical method is implemented is (approximately):
+  This information is used to build a new class (at runtime) that is instantiated as the service implementation.
+  
+  A typical method is implemented as (approximately):
   
 +----+
+private RequestGlobals _source;
+
 public String getParameter(String name)
 {
   return _source.getRequest().getParameter(name);
@@ -51,6 +55,7 @@
 +----+
 
   That is, the shadow implementation holds onto the target object (in the above example,
-  the RequestGlobals service) and invokes a method on it directly, not using reflection.
+  the RequestGlobals service) and invokes a method on it directly, not using reflection, no differently
+  than you would if you wrote the code yourself.
   
   

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/strategy.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/strategy.apt?view=diff&rev=516982&r1=516981&r2=516982
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/strategy.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/strategy.apt Sun Mar 11 11:39:49 2007
@@ -42,7 +42,7 @@
   You conver the configuration into a StrategyRegistry, and use that to build the final service:
   
 +---+
-  public static MyStrategyService buildMyStrategyService(Map<Class, MyStrategyService> configuration,
+  public static MyStrategyService build(Map<Class, MyStrategyService> configuration,
     @InjectService("StrategyBuilder")
     StrategyBuilder builder)
   {

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=516982&r1=516981&r2=516982
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/symbols.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/symbols.apt Sun Mar 11 11:39:49 2007
@@ -18,7 +18,7 @@
   For example:
   
 +----+
-  public static MyService buildMyService(@Inject("${some-reference}") CollaboratorA collabA,
+  public static MyService build(@Inject("${some-reference}") CollaboratorA collabA,
       @InjectService("${some-service-id}") CollaboratorB collabB)
   {
     return . . . ;

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=516982&r1=516981&r2=516982
==============================================================================
--- 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 Sun Mar 11 11:39:49 2007
@@ -78,7 +78,24 @@
         assertEquals(dd.toString(), className + ".decorateLogging(Class, Object)");
 
         verify();
+    }
 
+    @Test
+    public void default_service_id_from_return_type()
+    {
+        Log log = newLog();
+
+        replay();
+
+        ModuleDef def = new DefaultModuleDefImpl(DefaultServiceIdModule.class, log);
+
+        assertEquals(def.getServiceIds().size(), 1);
+
+        ServiceDef sd = def.getServiceDef("FieService");
+
+        assertEquals(sd.getServiceId(), "FieService");
+
+        verify();
     }
 
     /** Two different methods both claim to build the same service. */

Added: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/DefaultServiceIdModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/DefaultServiceIdModule.java?view=auto&rev=516982
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/DefaultServiceIdModule.java (added)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/DefaultServiceIdModule.java Sun Mar 11 11:39:49 2007
@@ -0,0 +1,23 @@
+// 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;
+
+public class DefaultServiceIdModule
+{
+    public FieService build()
+    {
+        return null;
+    }
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/util/InternalUtilsTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/util/InternalUtilsTest.java?view=diff&rev=516982&r1=516981&r2=516982
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/util/InternalUtilsTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/util/InternalUtilsTest.java Sun Mar 11 11:39:49 2007
@@ -278,4 +278,13 @@
         }
     }
 
+    @Test
+    public void last_term()
+    {
+        String input = "SimpleInput";
+
+        assertSame(InternalUtils.lastTerm(input), input);
+
+        assertEquals(InternalUtils.lastTerm("fie.fie.foe.fum"), "fum");
+    }
 }