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

svn commit: r516840 [3/4] - in /tapestry/tapestry5/tapestry-ioc/trunk: .settings/ src/main/java/org/apache/tapestry/ioc/ src/main/java/org/apache/tapestry/ioc/annotations/ src/main/java/org/apache/tapestry/ioc/def/ src/main/java/org/apache/tapestry/ioc...

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=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/service.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/service.apt Sat Mar 10 18:00:22 2007
@@ -20,7 +20,6 @@
 
 import org.apache.tapestry.ioc.annotations.Id;
 
-@Id("myapp")
 public class MyAppModule
 {
   public static Indexer buildIndexer()
@@ -31,7 +30,7 @@
 +-----------------------------------------------------------------------------------+
 
   Here the service interface is Indexer (presumably inside the org.example.myapp.services package,
-  since there isn't an import).  Tapestry doesn't know about the IndexerImpl class (the
+  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.
   
@@ -43,7 +42,9 @@
   
 +-----------------------------------------------------------------------------------+
   public static Indexer buildIndexer(@InjectService("JobScheduler")
-    JobScheduler scheduler, @InjectService("FileSystem")
+    JobScheduler scheduler, 
+    
+    @InjectService("FileSystem")
     FileSystem fileSystem)
   {
     IndexerImpl indexer = new IndexerImpl(fileSystem);
@@ -55,9 +56,8 @@
 +-----------------------------------------------------------------------------------+
 
   Here we've annotated the parameters of the service builder method to identify what
-  service to inject for that parameter.  We used unqualified ids ... these are the names
-  of other services within the <same module>: there will be a buildJobScheduler()
-  and a buildFileSystem() service builder methods as well.
+  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.
   
   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
@@ -65,9 +65,6 @@
   interceptors and its dependencies, are ready to go. Again, this is done in a 
   thread-safe manner.   
   
-  If we used fully qualified service ids, such as "org.examples.myapps.jobs.JobScheduler",
-  then we can access services from some other module entirely.
-  
   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
@@ -97,17 +94,6 @@
   }
 +-----------------------------------------------------------------------------------+
   
-Defining Visibility
-
-  Normally, a service can be referenced from any other module, simply by providing a
-  fully qualified service id.
-  
-  In some cases, it is desirable to mark a service a private, in which case, it is only
-  visible within the same module.
-  
-  The {{{apidocs/org/apache/tapestry/ioc/annotations/Private.html}@Private annotation}} can
-  be attached to a service builder method to indicate that the service in question is private.
-  
 Defining Service Lifecycle
 
   Each service has a <lifecycle> that controls when the service implementation is instantiated.
@@ -133,6 +119,12 @@
   As the first method is invoked, the service builder method is invoked, then any service
   decorations occur.  This construction process occurs only once.
   
+  You should be aware when writing services that your code must be thread safe; any service
+  you define could be invoked simulataneously by multiple threads. This is rarely an issue
+  in practice, since most services take input, use local variables, and invoke methods on other services,
+  without making use of non-final instance variables.  The few instance variables
+  in a service implementation are usually references to other Tapestry IoC services.
+  
 * perthread
 
   The perthread service lifecycle exists primarily to help multi-threaded servlet applications,
@@ -189,7 +181,7 @@
   In addition to injecting services, Tapestry will key off of the parameter type to allow
   other things to be injected.
   
-  * java.lang.String: fully qualified service id for the service being created
+  * java.lang.String: unique id for the service
     
   * org.apache.commons.logging.Log: to which service logging can occur
   
@@ -207,8 +199,12 @@
   Example:
   
 +-----------------------------------------------------------------------------------+
-  public static Indexer buildIndexer(String serviceId, Log serviceLog, @InjectService("JobScheduler")
-    JobScheduler scheduler, @InjectService("FileSystem")
+  public static Indexer buildIndexer(String serviceId, Log serviceLog, 
+  
+    @InjectService("JobScheduler")
+    JobScheduler scheduler, 
+    
+    @InjectService("FileSystem")
     FileSystem fileSystem)
   {
     IndexerImpl indexer = new IndexerImpl(serviceLog, fileSystem);
@@ -227,6 +223,9 @@
   id of service dependencies is known at build time), it is easier
   to use the @InjectService annotation.
   
+  The Log's name (used when configuring logging settings for the service) consists of
+  the module class name and the service id seperated by a period, i.e. "org.example.myapp.MyModule.Indexer".
+  
 Automatic Dependency Resolution
 
   When injecting another service, you may choose to not provide the @InjectService annotation.
@@ -235,12 +234,12 @@
   from the parameter type).  If it finds exactly one match, then the corresponding service will be
   injected.
   
-  If it finds more than one match, that's an error.  
+  If there are no matches, or multiple matches, then a runtime exception is thrown.
   
   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 implementation and break your injections.
+  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.
@@ -269,18 +268,19 @@
   in the
   {{{apidocs/org/apache/tapestry/ioc/services/TapestryIOCModule.html}TapestryIOCModule}} class.
   
-*----------------------------------+-----------------------------------------------------------------------------------------+
-| <<Service Id>>                   | <<Service Interface>>                                                                   |
-*----------------------------------+-----------------------------------------------------------------------------------------+
-| tapestry.ioc.ClassFactory        | {{{apidocs/org/apache/tapestry/ioc/services/ClassFactory.html}ClassFactory}}         |
-*----------------------------------+-----------------------------------------------------------------------------------------+
-| tapestry.ioc.LogSource           | {{{apidocs/org/apache/tapestry/ioc/LogSource.html}LogSource}}                        |
-*----------------------------------+-----------------------------------------------------------------------------------------+
-| tapestry.ioc.RegistryShutdownHub | {{{apidocs/org/apache/tapestry/ioc/RegistryShutdownHub.html}RegistryShutdownHub}}    |
-*----------------------------------+-----------------------------------------------------------------------------------------+
-| tapestry.ioc.ThreadCleanupHub    | {{{apidocs/org/apache/tapestry/ioc/services/ThreadCleanupHub.html}ThreadCleanupHub}} |
-*----------------------------------+-----------------------------------------------------------------------------------------+
+*---------------------+-----------------------------------------------------------------------------------------+
+| <<Service Id>>      | <<Service Interface>>                                                                   |
+*---------------------+-----------------------------------------------------------------------------------------+
+| ClassFactory        | {{{apidocs/org/apache/tapestry/ioc/services/ClassFactory.html}ClassFactory}}            |
+*---------------------+-----------------------------------------------------------------------------------------+
+| LogSource           | {{{apidocs/org/apache/tapestry/ioc/LogSource.html}LogSource}}                           |
+*---------------------+-----------------------------------------------------------------------------------------+
+| RegistryShutdownHub | {{{apidocs/org/apache/tapestry/ioc/RegistryShutdownHub.html}RegistryShutdownHub}}       |
+*---------------------+-----------------------------------------------------------------------------------------+
+| ThreadCleanupHub    | {{{apidocs/org/apache/tapestry/ioc/services/ThreadCleanupHub.html}ThreadCleanupHub}}    |
+*---------------------+-----------------------------------------------------------------------------------------+
 
+  Consult the JavaDoc for each of these services to identify under what circumstances you'll need to use them.
   
 Mutually Dependant Services
 

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=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/strategy.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/strategy.apt Sat Mar 10 18:00:22 2007
@@ -17,7 +17,7 @@
   
   As a special case, the value null is search for as if it was an instance of the class void.
     
-  The {{{apidocs/org/apache/tapestry/ioc/services/StrategyBuilder.html}tapestry.ioc.StrategyBuilder}} service creates a service implementation around a strategy registry.
+  The {{{apidocs/org/apache/tapestry/ioc/services/StrategyBuilder.html}StrategyBuilder}} service creates a service implementation around a strategy registry.
   
 +---+
 public interface StrategyBuilder
@@ -43,7 +43,7 @@
   
 +---+
   public static MyStrategyService buildMyStrategyService(Map<Class, MyStrategyService> configuration,
-    @InjectService("tapestry.ioc.StrategyBuilder")
+    @InjectService("StrategyBuilder")
     StrategyBuilder builder)
   {
      StategyRegistry<MyStrategyService> registry = StrategyRegistry.newInstance(MyStrategyService.class, configuration);

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=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/symbols.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/symbols.apt Sat Mar 10 18:00:22 2007
@@ -18,16 +18,16 @@
   For example:
   
 +----+
-  public static MyService buildMyService(@Inject("${mymodule.some-reference}") CollaboratorA collabA,
-      @InjectService("${mymodule.some-service-id}") CollaboratorB collabB)
+  public static MyService buildMyService(@Inject("${some-reference}") CollaboratorA collabA,
+      @InjectService("${some-service-id}") CollaboratorB collabB)
   {
     return . . . ;
   }
 +---+
 
-  Here, the first symbol is <<<mymodule.some-reference>>> whose value should be an
+  Here, the first symbol is <<<some-reference>>> whose value should be an
   {{{provider.html}object reference}} such as <<<service:CollaboratorA>>>.  The second symbol,
-  <<<mymodule.some-service-id>>> is just a service id, such as <<<CollaboratorB>>>.
+  <<<some-service-id>>> is just a service id, such as <<<CollaboratorB>>>.
      
   Although not shown here, it is possible to use multple symbols inside the string, or mix literal text with
   symbols.
@@ -58,8 +58,7 @@
   From the previous example:
   
 +----+
-  @Contribute("tapestry.ioc.ApplicationDefaults")
-  public void contributeDefaults(MappedConfiguration<String, String> configuration)
+  public void contributeApplicationDefaults(MappedConfiguration<String, String> configuration)
   {
     configuration.add("mymodule.some-reference", "service:CollaboratorA");
     configuration.add("mymodule.some-service-id", "CollaboratorB");
@@ -81,8 +80,7 @@
   
   
 +----+
-  @Contribute("tapestry.ioc.FactoryDefaults")
-  public void contributeDefaults(MappedConfiguration<String, String> configuration)
+  public void contributeFactoryDefaults(MappedConfiguration<String, String> configuration)
   {
       configuration.add("report.url", "http://${report.host}:${report.port}/${report.path}");
       configuration.add("report.host", "www.myreportsite.com");
@@ -99,8 +97,7 @@
   illegal:
   
 +----+
-  @Contribute("tapestry.ioc.ApplicationDefaults")
-  public void contributeOverrides(MappedConfiguration<String, String> configuration)
+  public void contributeApplicationDefaults(MappedConfiguration<String, String> configuration)
   {
       configuration.add("report.path", "${report.url}/report.cgi");
   }

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/BarneyModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/BarneyModule.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/BarneyModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/BarneyModule.java Sat Mar 10 18:00:22 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,110 +12,105 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc;
-
+package org.apache.tapestry.ioc;
+
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.tapestry.ioc.annotations.Contribute;
-import org.apache.tapestry.ioc.annotations.Id;
-import org.apache.tapestry.ioc.annotations.Match;
-import org.apache.tapestry.ioc.annotations.Order;
-
-/**
- * Module used to demonstrate decorator ordering.
- */
-
-@Id("barney")
-public class BarneyModule
-{
-    @Match("fred.*")
-    @Order("after:fred.Beta")
-    public Object decorateGamma(Object delegate, DecoratorList list)
-    {
-        list.add("gamma");
-
-        return null;
-    }
-
-    public Sizer buildSizer(final Map<Class, Sizer> configuration)
-    {
-        return new Sizer()
-        {
-            public int size(Object object)
-            {
-                if (object == null)
-                    return 0;
-
-                Sizer sizer = configuration.get(object.getClass());
-
-                if (sizer != null)
-                    return sizer.size(object);
-
-                return 1;
-            }
-
-        };
-    }
-
-    public void contributeSizer(MappedConfiguration<Class, Sizer> configuration)
-    {
-        Sizer listSizer = new Sizer()
-        {
-            public int size(Object object)
-            {
-                List list = (List) object;
-
-                return list.size();
-            }
-        };
-
-        Sizer mapSizer = new Sizer()
-        {
-            public int size(Object object)
-            {
-                Map map = (Map) object;
-
-                return map.size();
-            }
-        };
-
-        // Have to work on concrete class, rather than type, until we move the StrategyFactory
-        // over from HiveMind.
-
-        configuration.add(ArrayList.class, listSizer);
-        configuration.add(HashMap.class, mapSizer);
-    }
-
-    /**
-     * Put DecoratorList in module barney, where so it won't accidentally be decorated (which
-     * recusively builds the service, and is caught as a failure).
-     */
-    public DecoratorList buildDecoratorList()
-    {
-        return new DecoratorList()
-        {
-            private List<String> _names = newList();
-
-            public void add(String name)
-            {
-                _names.add(name);
-            }
-
-            public List<String> getNames()
-            {
-                return _names;
-            }
-        };
-    }
-
-    @Contribute("fred.UnorderedNames")
-    public void contributeGamma(Configuration<String> configuration)
-    {
-        configuration.add("Gamma");
-    }
-}
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tapestry.ioc.annotations.Match;
+import org.apache.tapestry.ioc.annotations.Order;
+
+/**
+ * Module used to demonstrate decorator ordering.
+ */
+
+public class BarneyModule
+{
+    @Match(
+    { "UnorderedNames", "Fred", "PrivateFredAlias" })
+    @Order("after:Beta")
+    public Object decorateGamma(Object delegate, DecoratorList list)
+    {
+        list.add("gamma");
+
+        return null;
+    }
+
+    public Sizer buildSizer(final Map<Class, Sizer> configuration)
+    {
+        return new Sizer()
+        {
+            public int size(Object object)
+            {
+                if (object == null) return 0;
+
+                Sizer sizer = configuration.get(object.getClass());
+
+                if (sizer != null) return sizer.size(object);
+
+                return 1;
+            }
+
+        };
+    }
+
+    public void contributeSizer(MappedConfiguration<Class, Sizer> configuration)
+    {
+        Sizer listSizer = new Sizer()
+        {
+            public int size(Object object)
+            {
+                List list = (List) object;
+
+                return list.size();
+            }
+        };
+
+        Sizer mapSizer = new Sizer()
+        {
+            public int size(Object object)
+            {
+                Map map = (Map) object;
+
+                return map.size();
+            }
+        };
+
+        // Have to work on concrete class, rather than type, until we move the StrategyFactory
+        // over from HiveMind.
+
+        configuration.add(ArrayList.class, listSizer);
+        configuration.add(HashMap.class, mapSizer);
+    }
+
+    /**
+     * Put DecoratorList in module barney, where so it won't accidentally be decorated (which
+     * recusively builds the service, and is caught as a failure).
+     */
+    public DecoratorList buildDecoratorList()
+    {
+        return new DecoratorList()
+        {
+            private List<String> _names = newList();
+
+            public void add(String name)
+            {
+                _names.add(name);
+            }
+
+            public List<String> getNames()
+            {
+                return _names;
+            }
+        };
+    }
+
+    public void contributeUnorderedNames(Configuration<String> configuration)
+    {
+        configuration.add("Gamma");
+    }
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/EagerLoadModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/EagerLoadModule.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/EagerLoadModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/EagerLoadModule.java Sat Mar 10 18:00:22 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,26 +12,22 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc;
-
-import org.apache.tapestry.ioc.annotations.EagerLoad;
-import org.apache.tapestry.ioc.annotations.Id;
-
-/**
- * Used to test service eager loading.
- * 
- * 
- */
-@Id("ioc.eager")
-public class EagerLoadModule
-{
-    public static boolean _eagerLoadDidHappen = false;
-
-    @EagerLoad
-    public StringHolder buildStringHolder()
-    {
-        _eagerLoadDidHappen = true;
-
-        return new StringHolderImpl();
-    }
-}
+package org.apache.tapestry.ioc;
+
+import org.apache.tapestry.ioc.annotations.EagerLoad;
+
+/**
+ * Used to test service eager loading.
+ */
+public class EagerLoadModule
+{
+    public static boolean _eagerLoadDidHappen = false;
+
+    @EagerLoad
+    public StringHolder buildStringHolder()
+    {
+        _eagerLoadDidHappen = true;
+
+        return new StringHolderImpl();
+    }
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/FredModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/FredModule.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/FredModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/FredModule.java Sat Mar 10 18:00:22 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,143 +12,97 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc;
-
+package org.apache.tapestry.ioc;
+
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.tapestry.ioc.annotations.Contribute;
-import org.apache.tapestry.ioc.annotations.Id;
-import org.apache.tapestry.ioc.annotations.InjectService;
-import org.apache.tapestry.ioc.annotations.Match;
-import org.apache.tapestry.ioc.annotations.Order;
-import org.apache.tapestry.ioc.annotations.Private;
-
-/**
- * Module used to demonstrate decorator ordering.
- * 
- * 
- */
-@Id("fred")
-public class FredModule
-{
-
-    /**
-     * Doesn't matter what the service does, we just want to verify that the decorators are invoked
-     * in the order we expect.
-     */
-    public Runnable buildFred()
-    {
-        return new Runnable()
-        {
-            public void run()
-            {
-            }
-        };
-    }
-
-    @Private
-    public Runnable buildPrivateFred()
-    {
-        return buildFred();
-    }
-
-    /** A public alias of a private service. */
-    public Runnable buildPrivateFredAlias(@InjectService("PrivateFred")
-    Runnable privateFred)
-    {
-        return privateFred;
-    }
-
-    @Match("fred.*")
-    @Order("before:Beta")
-    public Object decorateAlpha(Object delegate, DecoratorList list)
-    {
-        list.add("alpha");
-
-        return null;
-    }
-
-    @Match("fred.*")
-    public Object decorateBeta(Object delegate, DecoratorList list)
-    {
-        list.add("beta");
-
-        return null;
-    }
-
-    public NameListHolder buildUnorderedNames(Collection<String> configuration)
-    {
-        final List<String> sorted = newList(configuration);
-
-        Collections.sort(sorted);
-
-        return new NameListHolder()
-        {
-
-            public List<String> getNames()
-            {
-                return sorted;
-            }
-
-        };
-    }
-
-    public NameListHolder buildOrderedNames(final List<String> configuration)
-    {
-        return new NameListHolder()
-        {
-
-            public List<String> getNames()
-            {
-                return configuration;
-            }
-
-        };
-    }
-
-    public void contributeOrderedNames(OrderedConfiguration<String> configuration)
-    {
-        // Order "FRED" after "BARNEY"
-
-        configuration.add("fred", "FRED", "after:barney");
-        configuration.add("barney", "BARNEY");
-    }
-
-    public void contributeUnorderedNames(Configuration<String> configuration)
-    {
-        configuration.add("UnorderedNames");
-    }
-
-    @Contribute("UnorderedNames")
-    public void contributeBeta(Configuration<String> configuration)
-    {
-        configuration.add("Beta");
-    }
-
-    @Private
-    public NameListHolder buildPrivateUnorderedNames(final Collection<String> configuration)
-    {
-        return buildUnorderedNames(configuration);
-    }
-
-    public void contributePrivateUnorderedNames(Configuration<String> configuration)
-    {
-        configuration.add("PrivateUnorderedNames");
-    }
-
-    @Contribute("PrivateUnorderedNames")
-    public void contributeOmega(Configuration<String> configuration)
-    {
-        configuration.add("Omega");
-    }
-
-    public NameListHolder buildPrivateUnorderedNamesAlias(@InjectService("PrivateUnorderedNames")
-    NameListHolder privateService)
-    {
-        return privateService;
-    }
-}
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.tapestry.ioc.annotations.Match;
+import org.apache.tapestry.ioc.annotations.Order;
+
+/**
+ * Module used to demonstrate decorator ordering.
+ */
+public class FredModule
+{
+
+    /**
+     * Doesn't matter what the service does, we just want to verify that the decorators are invoked
+     * in the order we expect.
+     */
+    public Runnable buildFred()
+    {
+        return new Runnable()
+        {
+            public void run()
+            {
+            }
+        };
+    }
+
+    @Match(
+    { "UnorderedNames", "Fred" })
+    @Order("before:Beta")
+    public Object decorateAlpha(Object delegate, DecoratorList list)
+    {
+        list.add("alpha");
+
+        return null;
+    }
+
+    @Match(
+    { "UnorderedNames", "Fred" })
+    public Object decorateBeta(Object delegate, DecoratorList list)
+    {
+        list.add("beta");
+
+        return null;
+    }
+
+    public NameListHolder buildUnorderedNames(Collection<String> configuration)
+    {
+        final List<String> sorted = newList(configuration);
+
+        Collections.sort(sorted);
+
+        return new NameListHolder()
+        {
+
+            public List<String> getNames()
+            {
+                return sorted;
+            }
+
+        };
+    }
+
+    public NameListHolder buildOrderedNames(final List<String> configuration)
+    {
+        return new NameListHolder()
+        {
+
+            public List<String> getNames()
+            {
+                return configuration;
+            }
+
+        };
+    }
+
+    public void contributeOrderedNames(OrderedConfiguration<String> configuration)
+    {
+        // Order "FRED" after "BARNEY"
+
+        configuration.add("fred", "FRED", "after:barney");
+        configuration.add("barney", "BARNEY");
+    }
+
+    public void contributeUnorderedNames(Configuration<String> configuration)
+    {
+        configuration.add("UnorderedNames");
+        configuration.add("Beta");
+    }
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/IndirectionModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/IndirectionModule.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/IndirectionModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/IndirectionModule.java Sat Mar 10 18:00:22 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -14,12 +14,9 @@
 
 package org.apache.tapestry.ioc;
 
-import org.apache.tapestry.ioc.annotations.Contribute;
-import org.apache.tapestry.ioc.annotations.Id;
 import org.apache.tapestry.ioc.annotations.Inject;
 import org.apache.tapestry.ioc.annotations.InjectService;
 
-@Id("indirection")
 public class IndirectionModule
 {
     public Indirection buildInner()
@@ -57,14 +54,13 @@
         };
     }
 
-    @Contribute("tapestry.ioc.FactoryDefaults")
-    public void contributeDefaults(MappedConfiguration<String, String> configuration)
+    public void contributeFactoryDefaults(MappedConfiguration<String, String> configuration)
     {
         // You tend to want to use the fully qualified service id, since you can't tell under which
         // context the
         // symbols will be expanded.
 
-        configuration.add("indirection.inner", "indirection.Inner");
-        configuration.add("indirection.object-inner", "service:indirection.Inner");
+        configuration.add("indirection.inner", "Inner");
+        configuration.add("indirection.object-inner", "service:Inner");
     }
 }

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/InjectLiteralModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/InjectLiteralModule.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/InjectLiteralModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/InjectLiteralModule.java Sat Mar 10 18:00:22 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -14,11 +14,8 @@
 
 package org.apache.tapestry.ioc;
 
-import org.apache.tapestry.ioc.annotations.Contribute;
-import org.apache.tapestry.ioc.annotations.Id;
 import org.apache.tapestry.ioc.annotations.Inject;
 
-@Id("inject.literal")
 public class InjectLiteralModule
 {
     public static IntHolder buildIntHolder(@Inject("${value}")
@@ -27,8 +24,7 @@
         return new IntHolderImpl(value);
     }
 
-    @Contribute("tapestry.ioc.FactoryDefaults")
-    public static void contributeDefaults(MappedConfiguration<String, String> configuration)
+    public static void contributeFactoryDefaults(MappedConfiguration<String, String> configuration)
     {
         configuration.add("value", "42");
     }

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java Sat Mar 10 18:00:22 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.
@@ -36,6 +36,23 @@
     }
 
     @Test
+    public void duplicate_service_names_are_failure()
+    {
+        try
+        {
+            buildRegistry(FredModule.class, DuplicateFredModule.class);
+            unreachable();
+        }
+        catch (RuntimeException ex)
+        {
+            assertTrue(ex.getMessage().startsWith("Service id 'Fred' has already been defined by"));
+
+            // Can't check the entire message, because we can't guarantee what order the modules
+            // will be processed in.
+        }
+    }
+
+    @Test
     public void static_builder_method_does_not_instantiate_builder()
     {
         StaticModule.setInstantiated(false);
@@ -43,7 +60,7 @@
 
         Registry r = buildRegistry(StaticModule.class);
 
-        Runnable fred = r.getService("static.Fred", Runnable.class);
+        Runnable fred = r.getService("Fred", Runnable.class);
 
         fred.run();
 
@@ -59,7 +76,7 @@
 
         Registry r = buildRegistry(StaticModule.class);
 
-        Runnable fred = r.getService("static.Barney", Runnable.class);
+        Runnable fred = r.getService("Barney", Runnable.class);
 
         fred.run();
 
@@ -74,7 +91,7 @@
 
         Registry r = buildRegistry(StaticModule.class);
 
-        NameListHolder holder = r.getService("static.Names", NameListHolder.class);
+        NameListHolder holder = r.getService("Names", NameListHolder.class);
 
         List<String> names = holder.getNames();
 
@@ -88,7 +105,7 @@
     {
         Registry r = buildRegistry();
 
-        Runnable service = r.getService("fred.Fred", Runnable.class);
+        Runnable service = r.getService("Fred", Runnable.class);
 
         service.run();
 
@@ -103,12 +120,12 @@
         {
             assertEquals(
                     ex.getMessage(),
-                    "Proxy for service fred.Fred is no longer active because the IOC Registry has been shut down.");
+                    "Proxy for service Fred is no longer active because the IOC Registry has been shut down.");
         }
 
         // Show that toString() still works, even for a shutdown proxy.
 
-        assertEquals(service.toString(), "<Proxy for fred.Fred(java.lang.Runnable)>");
+        assertEquals(service.toString(), "<Proxy for Fred(java.lang.Runnable)>");
     }
 
     /**
@@ -120,7 +137,7 @@
     {
         Registry r = buildRegistry();
 
-        Runnable service = r.getService("fred.Fred", Runnable.class);
+        Runnable service = r.getService("Fred", Runnable.class);
 
         // Force creation
 
@@ -133,37 +150,12 @@
         assertEquals(names, Arrays.asList("gamma", "beta", "alpha"));
     }
 
-    /**
-     * Along the way, we are demonstrating that decorators can target multiple services within a
-     * module, and can target services in other modules. The main point, though, is the difference
-     * between a private and a public service in terms of decoration.
-     */
-    @Test
-    public void private_service_decorator_order()
-    {
-        Registry r = buildRegistry();
-
-        Runnable service = r.getService("fred.PrivateFredAlias", Runnable.class);
-
-        // Force creation
-
-        service.run();
-
-        List<String> names = r.getService(DecoratorList.class).getNames();
-
-        // The trick here is that the public service (PrivateFredAlias) was decorated first with the
-        // full set (the same as the previous test), then the private service (PrivateFred) was
-        // decorated just with decorators from module fred.
-
-        assertEquals(names, Arrays.asList("gamma", "beta", "alpha", "beta", "alpha"));
-    }
-
     @Test
     public void public_service_unordered_configuration()
     {
         Registry r = buildRegistry();
 
-        NameListHolder service = r.getService("fred.UnorderedNames", NameListHolder.class);
+        NameListHolder service = r.getService("UnorderedNames", NameListHolder.class);
 
         List<String> names = service.getNames();
 
@@ -180,7 +172,7 @@
     {
         Registry r = buildRegistry();
 
-        NameListHolder service = r.getService("fred.OrderedNames", NameListHolder.class);
+        NameListHolder service = r.getService("OrderedNames", NameListHolder.class);
 
         List<String> names = service.getNames();
 
@@ -194,7 +186,7 @@
     {
         Registry r = buildRegistry();
 
-        Sizer sizer = r.getService("barney.Sizer", Sizer.class);
+        Sizer sizer = r.getService("Sizer", Sizer.class);
 
         assertEquals(sizer.size(null), 0);
 
@@ -219,34 +211,20 @@
     }
 
     @Test
-    public void private_service_unordered_configuration()
-    {
-        Registry r = buildRegistry();
-
-        NameListHolder service = r.getService(
-                "fred.PrivateUnorderedNamesAlias",
-                NameListHolder.class);
-
-        List<String> names = service.getNames();
-
-        assertEquals(names, Arrays.asList("Omega", "PrivateUnorderedNames"));
-    }
-
-    @Test
     public void unknown_lifecycle()
     {
         Registry r = buildRegistry(UnknownLifecycleModule.class);
 
         try
         {
-            r.getService("ioc.test.UnknownLifecycle", Runnable.class);
+            r.getService("UnknownLifecycle", Runnable.class);
             unreachable();
         }
         catch (Exception ex)
         {
             assertEquals(
                     ex.getMessage(),
-                    "Error building service proxy for service 'ioc.test.UnknownLifecycle' "
+                    "Error building service proxy for service 'UnknownLifecycle' "
                             + "(at org.apache.tapestry.ioc.UnknownLifecycleModule.buildUnknownLifecycle()): "
                             + "Unknown service lifecycle 'magic'.");
         }
@@ -315,28 +293,13 @@
     }
 
     @Test
-    public void use_of_service_object_provider_prefix()
-    {
-        Registry r = buildRegistry(ServiceObjectProviderModule.class);
-
-        StringTransformer st = r.getObject(
-                "service:ioc.test.PublicTransformer",
-                StringTransformer.class);
-
-        // The PublicTransform gets the PrivateTransformer via
-        // an @Inject.
-
-        assertEquals(st.transform("fred"), "FRED");
-    }
-
-    @Test
     public void recursive_module_construction_is_caught()
     {
         Registry r = buildRegistry(RecursiveConstructorModule.class);
 
         try
         {
-            Runnable runnable = r.getService("recursive.Runnable", Runnable.class);
+            Runnable runnable = r.getService("Runnable", Runnable.class);
 
             // We can get the proxy, but invoking a method causes
             // the module to be instantiated ... but that also invokes a method on
@@ -372,7 +335,7 @@
     {
         Registry r = buildRegistry(IndirectionModule.class);
 
-        Indirection outer = r.getService("indirection.Outer", Indirection.class);
+        Indirection outer = r.getService("Outer", Indirection.class);
 
         assertEquals(outer.getName(), "OUTER[INNER]");
     }
@@ -382,7 +345,7 @@
     {
         Registry r = buildRegistry(IndirectionModule.class);
 
-        Indirection outer = r.getService("indirection.Outer2", Indirection.class);
+        Indirection outer = r.getService("Outer2", Indirection.class);
 
         assertEquals(outer.getName(), "OUTER2[INNER]");
     }
@@ -422,8 +385,8 @@
     {
         Registry r = buildRegistry(FredModule.class);
 
-        Runnable fred = r.getService("fred.Fred", Runnable.class);
+        Runnable fred = r.getService("Fred", Runnable.class);
 
-        assertSame(r.getService("FRED.FRED", Runnable.class), fred);
+        assertSame(r.getService("FRED", Runnable.class), fred);
     }
 }

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/MasterModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/MasterModule.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/MasterModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/MasterModule.java Sat Mar 10 18:00:22 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,20 +12,16 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc;
-
-import org.apache.tapestry.ioc.annotations.Id;
-import org.apache.tapestry.ioc.annotations.SubModule;
-
-/**
- * Used by {@link org.apache.tapestry.ioc.RegistryBuilderTest}.
- * 
- * 
- */
-@Id("master")
-@SubModule(
-{ FredModule.class, BarneyModule.class })
-public final class MasterModule
-{
-
-}
+package org.apache.tapestry.ioc;
+
+import org.apache.tapestry.ioc.annotations.SubModule;
+
+/**
+ * Used by {@link org.apache.tapestry.ioc.RegistryBuilderTest}.
+ */
+@SubModule(
+{ FredModule.class, BarneyModule.class })
+public final class MasterModule
+{
+
+}

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=516840&r1=516839&r2=516840
==============================================================================
--- 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 Mar 10 18:00:22 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,17 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc;
-
-import org.apache.tapestry.ioc.annotations.Id;
-import org.apache.tapestry.ioc.annotations.Lifecycle;
-
-@Id("ioc.test")
-public class PerThreadModule
-{
-    @Lifecycle("perthread")
-    public StringHolder buildStringHolder()
-    {
-        return new StringHolderImpl();
-    }
-}
+package org.apache.tapestry.ioc;
+
+import org.apache.tapestry.ioc.annotations.Lifecycle;
+
+public class PerThreadModule
+{
+    @Lifecycle("perthread")
+    public StringHolder buildStringHolder()
+    {
+        return new StringHolderImpl();
+    }
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RecursiveConstructorModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RecursiveConstructorModule.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RecursiveConstructorModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RecursiveConstructorModule.java Sat Mar 10 18:00:22 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,36 +12,32 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc;
-
-import org.apache.tapestry.ioc.annotations.Id;
-import org.apache.tapestry.ioc.annotations.InjectService;
-
-/**
- * Used by {@link org.apache.tapestry.ioc.IntegrationTest}.
- * 
- * 
- */
-@Id("recursive")
-public class RecursiveConstructorModule
-{
-
-    public RecursiveConstructorModule(@InjectService("Runnable")
-    Runnable r)
-    {
-        // Invoking a method on the service proxy is going to cause a recursive attempt to
-        // instantiate the module. Hilarity ensues.
-
-        r.run();
-    }
-
-    public Runnable buildRunnable()
-    {
-        return new Runnable()
-        {
-            public void run()
-            {
-            }
-        };
-    }
-}
+package org.apache.tapestry.ioc;
+
+import org.apache.tapestry.ioc.annotations.InjectService;
+
+/**
+ * Used by {@link org.apache.tapestry.ioc.IntegrationTest}.
+ */
+public class RecursiveConstructorModule
+{
+
+    public RecursiveConstructorModule(@InjectService("Runnable")
+    Runnable r)
+    {
+        // Invoking a method on the service proxy is going to cause a recursive attempt to
+        // instantiate the module. Hilarity ensues.
+
+        r.run();
+    }
+
+    public Runnable buildRunnable()
+    {
+        return new Runnable()
+        {
+            public void run()
+            {
+            }
+        };
+    }
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderOverrideTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderOverrideTest.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderOverrideTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderOverrideTest.java Sat Mar 10 18:00:22 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,119 +12,120 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc;
-
-import org.apache.tapestry.ioc.annotations.Id;
-import org.apache.tapestry.ioc.annotations.InjectService;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-@Test
-public class RegistryBuilderOverrideTest extends Assert
-{
-    private RegistryBuilder builder;
-
-    private Registry registry;
-
-    public interface Transformer<T>
-    {
-        T transform(T input);
-    }
-
-    public static class IdentifyTransformer<T> implements Transformer<T>
-    {
-        public T transform(T input)
-        {
-            return input;
-        }
-    }
-
-    public static class UppercaseTransformer implements Transformer<String>
-    {
-        public String transform(String input)
-        {
-            return input.toUpperCase();
-        }
-    }
-
-    @Id("test")
-    public static class TestModule
-    {
-        public static Transformer buildService1()
-        {
-            return new IdentifyTransformer<String>();
-        }
-
-        public static Transformer buildService2()
-        {
-            return new IdentifyTransformer<String>();
-        }
-
-        // Just a proxy for Service2.
-        public static Transformer buildService3(@InjectService("Service2")
-        Transformer s2)
-        {
-            return s2;
-        }
-    }
-
-    @BeforeMethod
-    public void before()
-    {
-        builder = new RegistryBuilder();
-        builder.add(TestModule.class);
-    }
-
-    @AfterMethod
-    public void after()
-    {
-        if (registry != null)
-        {
-            registry.shutdown();
-        }
-    }
-
-    @Test
-    public void service_override()
-    {
-        builder.addServiceOverride("test.Service2", new UppercaseTransformer());
-        registry = builder.build();
-        @SuppressWarnings("unchecked")
-        Transformer<String> s1 = registry.getService("test.Service1", Transformer.class);
-        assertEquals(s1.transform("a"), "a");
-        @SuppressWarnings("unchecked")
-        Transformer<String> s2 = registry.getService("test.Service2", Transformer.class);
-        assertEquals(s2.transform("a"), "A");
-    }
-
-    @Test
-    public void overidden_service_injected_into_other_service()
-    {
-        builder.addServiceOverride("test.Service2", new UppercaseTransformer());
-        registry = builder.build();
-        @SuppressWarnings("unchecked")
-        Transformer<String> s3 = registry.getService("test.Service3", Transformer.class);
-        assertEquals(s3.transform("a"), "A");
-    }
-
-    @Test
-    public void overridden_service_with_incorrect_interface_causes_exception()
-    {
-        builder = new RegistryBuilder();
-        builder.add(TestModule.class);
-        builder.addServiceOverride("test.Service2", "bad impl");
-        registry = builder.build();
-        try
-        {
-            registry.getService("test.Service2", Transformer.class);
-        }
-        catch (RuntimeException e)
-        {
-            String errorMsg = e.getMessage();
-            assertTrue(errorMsg.contains("String"));
-            assertTrue(errorMsg.contains("Transformer"));
-        }
-    }
-}
+package org.apache.tapestry.ioc;
+
+import org.apache.tapestry.ioc.annotations.InjectService;
+import org.apache.tapestry.ioc.test.TestBase;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+@Test
+public class RegistryBuilderOverrideTest extends TestBase
+{
+    private RegistryBuilder builder;
+
+    private Registry registry;
+
+    public interface Transformer<T>
+    {
+        T transform(T input);
+    }
+
+    public static class IdentifyTransformer<T> implements Transformer<T>
+    {
+        public T transform(T input)
+        {
+            return input;
+        }
+    }
+
+    public static class UppercaseTransformer implements Transformer<String>
+    {
+        public String transform(String input)
+        {
+            return input.toUpperCase();
+        }
+    }
+
+    public static class TestModule
+    {
+        public static Transformer buildService1()
+        {
+            return new IdentifyTransformer<String>();
+        }
+
+        public static Transformer buildService2()
+        {
+            return new IdentifyTransformer<String>();
+        }
+
+        // Just a proxy for Service2.
+        public static Transformer buildService3(@InjectService("Service2")
+        Transformer s2)
+        {
+            return s2;
+        }
+    }
+
+    @BeforeMethod
+    public void before()
+    {
+        builder = new RegistryBuilder();
+        builder.add(TestModule.class);
+    }
+
+    @AfterMethod
+    public void after()
+    {
+        if (registry != null)
+        {
+            registry.shutdown();
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void service_override()
+    {
+        builder.addServiceOverride("Service2", new UppercaseTransformer());
+        registry = builder.build();
+        Transformer<String> s1 = registry.getService("Service1", Transformer.class);
+        assertEquals(s1.transform("a"), "a");
+
+        Transformer<String> s2 = registry.getService("Service2", Transformer.class);
+        assertEquals(s2.transform("a"), "A");
+    }
+
+    @Test
+    public void overidden_service_injected_into_other_service()
+    {
+        builder.addServiceOverride("Service2", new UppercaseTransformer());
+        registry = builder.build();
+        @SuppressWarnings("unchecked")
+        Transformer<String> s3 = registry.getService("Service3", Transformer.class);
+
+        assertEquals(s3.transform("a"), "A");
+    }
+
+    @Test
+    public void overridden_service_with_incorrect_interface_causes_exception()
+    {
+        builder = new RegistryBuilder();
+        builder.add(TestModule.class);
+        builder.addServiceOverride("Service2", "bad impl");
+        registry = builder.build();
+        try
+        {
+            registry.getService("Service2", Transformer.class);
+
+            unreachable();
+        }
+        catch (RuntimeException e)
+        {
+            String errorMsg = e.getMessage();
+            assertTrue(errorMsg.contains("String"));
+            assertTrue(errorMsg.contains("Transformer"));
+        }
+    }
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTest.java Sat Mar 10 18:00:22 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.
@@ -35,7 +35,7 @@
         // Borrowed from IntegrationTest, this will only work if both FredModule and BarneyModule
         // are loaded.
 
-        NameListHolder service = r.getService("fred.UnorderedNames", NameListHolder.class);
+        NameListHolder service = r.getService("UnorderedNames", NameListHolder.class);
 
         List<String> names = service.getNames();
 
@@ -67,8 +67,6 @@
         // This proves that the IOC works, the service builder method was invoked, that the
         // ClassFactory service was accessed and used.
 
-        assertEquals(
-                service.toString(),
-                "<Proxy for ioc.test.Square(org.apache.tapestry.ioc.Square)>");
+        assertEquals(service.toString(), "<Proxy for Square(org.apache.tapestry.ioc.Square)>");
     }
 }

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTestModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTestModule.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTestModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/RegistryBuilderTestModule.java Sat Mar 10 18:00:22 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,22 +12,19 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc;
-
-import org.apache.tapestry.ioc.annotations.Id;
-
-@Id("ioc.test")
-public class RegistryBuilderTestModule
-{
-    /** Arbitrary interface and service name. */
-    public Square buildSquare()
-    {
-        return new Square()
-        {
-            public long square(long input)
-            {
-                return input * input;
-            }
-        };
-    }
-}
+package org.apache.tapestry.ioc;
+
+public class RegistryBuilderTestModule
+{
+    /** Arbitrary interface and service name. */
+    public Square buildSquare()
+    {
+        return new Square()
+        {
+            public long square(long input)
+            {
+                return input * input;
+            }
+        };
+    }
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/StaticModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/StaticModule.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/StaticModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/StaticModule.java Sat Mar 10 18:00:22 2007
@@ -18,13 +18,8 @@
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.tapestry.ioc.annotations.Id;
 import org.apache.tapestry.ioc.internal.util.CollectionFactory;
 
-/**
- * 
- */
-@Id("static")
 public class StaticModule
 {
     private static boolean _instantiated;

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/UnknownLifecycleModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/UnknownLifecycleModule.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/UnknownLifecycleModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/UnknownLifecycleModule.java Sat Mar 10 18:00:22 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,20 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc;
-
-import org.apache.tapestry.ioc.annotations.Id;
-import org.apache.tapestry.ioc.annotations.Lifecycle;
-
-/**
- * 
- */
-@Id("ioc.test")
-public class UnknownLifecycleModule
-{
-    @Lifecycle("magic")
-    public Runnable buildUnknownLifecycle()
-    {
-        return null;
-    }
-}
+package org.apache.tapestry.ioc;
+
+import org.apache.tapestry.ioc.annotations.Lifecycle;
+
+public class UnknownLifecycleModule
+{
+    @Lifecycle("magic")
+    public Runnable buildUnknownLifecycle()
+    {
+        return null;
+    }
+}

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=516840&r1=516839&r2=516840
==============================================================================
--- 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 Mar 10 18:00:22 2007
@@ -17,7 +17,6 @@
 import static org.apache.tapestry.ioc.internal.IOCMessages.buildMethodConflict;
 
 import java.lang.reflect.Method;
-import java.math.BigDecimal;
 import java.util.Set;
 
 import org.apache.commons.logging.Log;
@@ -28,44 +27,11 @@
 import org.apache.tapestry.ioc.def.ServiceDef;
 import org.apache.tapestry.ioc.internal.util.InternalUtils;
 import org.apache.tapestry.ioc.test.IOCTestCase;
-import org.testng.Assert;
 import org.testng.annotations.Test;
 
 public class DefaultModuleDefImplTest extends IOCTestCase
 {
     @Test
-    public void module_builder_without_id()
-    {
-        Log log = newLog();
-
-        replay();
-
-        // BigDecimal is arbitrary, any class would do.
-
-        ModuleDef md = new DefaultModuleDefImpl(BigDecimal.class, log);
-
-        Assert.assertEquals("java.math", md.getModuleId());
-
-        verify();
-    }
-
-    @Test
-    public void module_builder_with_id()
-    {
-        Log log = newLog();
-
-        replay();
-
-        // BigDecimal is arbitrary, any class would do.
-
-        ModuleDef md = new DefaultModuleDefImpl(ModuleBuilderWithId.class, log);
-
-        Assert.assertEquals("tapestry.ioc", md.getModuleId());
-
-        verify();
-    }
-
-    @Test
     public void simple_module() throws Exception
     {
         String className = SimpleModule.class.getName();
@@ -78,37 +44,26 @@
 
         ModuleDef md = new DefaultModuleDefImpl(SimpleModule.class, log);
 
-        assertEquals(md.toString(), "ModuleDef[" + className + " ioc.Barney, ioc.Fred, ioc.Wilma]");
+        assertEquals(md.toString(), "ModuleDef[" + className + " Barney, Fred, Wilma]");
 
         Set<String> ids = md.getServiceIds();
 
         assertEquals(ids.size(), 3);
-        assertTrue(ids.contains("ioc.Fred"));
-        assertTrue(ids.contains("ioc.Barney"));
-        assertTrue(ids.contains("ioc.Wilma"));
+        assertTrue(ids.contains("Fred"));
+        assertTrue(ids.contains("Barney"));
+        assertTrue(ids.contains("Wilma"));
 
-        ServiceDef sd = md.getServiceDef("ioc.Fred");
+        ServiceDef sd = md.getServiceDef("Fred");
 
-        assertEquals(sd.getServiceId(), "ioc.Fred");
+        assertEquals(sd.getServiceId(), "Fred");
 
         assertEquals(sd.getServiceInterface(), FieService.class);
 
         assertEquals(sd.toString(), className + ".buildFred()");
         assertEquals(sd.getServiceLifeycle(), IOCConstants.DEFAULT_LIFECYCLE);
-        assertEquals(sd.isPrivate(), false);
         assertEquals(sd.isEagerLoad(), false);
 
-        sd = md.getServiceDef("ioc.Barney");
-
-        assertEquals(sd.getServiceId(), "ioc.Barney");
-
-        assertEquals(sd.getServiceInterface(), FoeService.class);
-
-        assertEquals(sd.toString(), className + ".buildBarney()");
-        assertEquals(sd.getServiceLifeycle(), "threaded");
-        assertEquals(sd.isPrivate(), true);
-
-        sd = md.getServiceDef("ioc.Wilma");
+        sd = md.getServiceDef("Wilma");
         assertEquals(sd.isEagerLoad(), true);
 
         // Now the decorator method.
@@ -119,7 +74,7 @@
 
         DecoratorDef dd = defs.iterator().next();
 
-        assertEquals(dd.getDecoratorId(), "ioc.Logging");
+        assertEquals(dd.getDecoratorId(), "Logging");
         assertEquals(dd.toString(), className + ".decorateLogging(Class, Object)");
 
         verify();
@@ -147,11 +102,11 @@
         Set<String> ids = md.getServiceIds();
 
         assertEquals(ids.size(), 1);
-        assertTrue(ids.contains("ioc.Fred"));
+        assertTrue(ids.contains("Fred"));
 
-        ServiceDef sd = md.getServiceDef("ioc.Fred");
+        ServiceDef sd = md.getServiceDef("Fred");
 
-        assertEquals(sd.getServiceId(), "ioc.Fred");
+        assertEquals(sd.getServiceId(), "Fred");
 
         assertEquals(sd.getServiceInterface(), FieService.class);
 
@@ -240,29 +195,7 @@
     @Test
     public void contribution_without_annotation()
     {
-        attemptConfigurationMethod(
-                SimpleModule.class,
-                "ioc.Barney",
-                "contributeBarney(Configuration)");
-    }
-
-    @Test
-    public void contribution_with_annotation()
-    {
-        attemptConfigurationMethod(
-                ConfigurationWithContributeAnnotationModule.class,
-                "ioc.test.Fred",
-                "contributeSomething(Configuration)");
-
-    }
-
-    @Test
-    public void contribution_with_annotation_to_other_module()
-    {
-        attemptConfigurationMethod(
-                ConfigurationWithAnnotationOtherModule.class,
-                "some.module.Wilma",
-                "contributeOtherModule(Configuration)");
+        attemptConfigurationMethod(SimpleModule.class, "Barney", "contributeBarney(Configuration)");
     }
 
     @Test
@@ -270,7 +203,7 @@
     {
         attemptConfigurationMethod(
                 OrderedConfigurationModule.class,
-                "ioc.test.Ordered",
+                "Ordered",
                 "contributeOrdered(OrderedConfiguration)");
     }
 
@@ -279,7 +212,7 @@
     {
         attemptConfigurationMethod(
                 MappedConfigurationModule.class,
-                "ioc.test.Mapped",
+                "Mapped",
                 "contributeMapped(MappedConfiguration)");
     }
 

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ExtraPublicConstructorsModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ExtraPublicConstructorsModule.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ExtraPublicConstructorsModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ExtraPublicConstructorsModule.java Sat Mar 10 18:00:22 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,34 +12,29 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc.internal;
-
-import org.apache.tapestry.ioc.annotations.Id;
-import org.apache.tapestry.ioc.annotations.InjectService;
-import org.apache.tapestry.ioc.services.ClassFactory;
-
-/**
- * Used by {@link org.apache.tapestry.ioc.internal.ModuleImplTest}.
- * 
- * 
- */
-@Id("extra.public")
-public class ExtraPublicConstructorsModule
-{
-
-    public ExtraPublicConstructorsModule()
-    {
-
-    }
-
-    /**
-     * Should be the first constructor, the one that gets invoked. I'm worried that different
-     * compilers or JVMs will order the constructors differently.
-     */
-
-    public ExtraPublicConstructorsModule(@InjectService("tapestry.ioc.ClassFactory")
-    ClassFactory factory)
-    {
-
-    }
-}
+package org.apache.tapestry.ioc.internal;
+
+import org.apache.tapestry.ioc.annotations.InjectService;
+import org.apache.tapestry.ioc.services.ClassFactory;
+
+/**
+ * Used by {@link org.apache.tapestry.ioc.internal.ModuleImplTest}.
+ */
+public class ExtraPublicConstructorsModule
+{
+
+    public ExtraPublicConstructorsModule()
+    {
+
+    }
+
+    /**
+     * Should be the first constructor, the one that gets invoked. I'm worried that different
+     * compilers or JVMs will order the constructors differently.
+     */
+    public ExtraPublicConstructorsModule(@InjectService("ClassFactory")
+    ClassFactory factory)
+    {
+
+    }
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/MappedConfigurationModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/MappedConfigurationModule.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/MappedConfigurationModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/MappedConfigurationModule.java Sat Mar 10 18:00:22 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,21 +12,17 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc.internal;
-
-import org.apache.tapestry.ioc.MappedConfiguration;
-import org.apache.tapestry.ioc.annotations.Id;
-
-/**
- * Used by {@link org.apache.tapestry.ioc.internal.DefaultModuleDefImpl}.
- * 
- * 
- */
-@Id("ioc.test")
-public class MappedConfigurationModule
-{
-    public void contributeMapped(MappedConfiguration configuration)
-    {
-
-    }
-}
+package org.apache.tapestry.ioc.internal;
+
+import org.apache.tapestry.ioc.MappedConfiguration;
+
+/**
+ * Used by {@link org.apache.tapestry.ioc.internal.DefaultModuleDefImpl}.
+ */
+public class MappedConfigurationModule
+{
+    public void contributeMapped(MappedConfiguration configuration)
+    {
+
+    }
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ModuleBuilderWithId.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ModuleBuilderWithId.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ModuleBuilderWithId.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ModuleBuilderWithId.java Sat Mar 10 18:00:22 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,17 +12,12 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc.internal;
-
-import org.apache.tapestry.ioc.annotations.Id;
-
-/**
- * Used by {@link org.apache.tapestry.ioc.internal.DefaultModuleDefImplTest}.
- * 
- * 
- */
-@Id("tapestry.ioc")
-public class ModuleBuilderWithId
-{
-
-}
+package org.apache.tapestry.ioc.internal;
+
+/**
+ * Used by {@link org.apache.tapestry.ioc.internal.DefaultModuleDefImplTest}.
+ */
+public class ModuleBuilderWithId
+{
+
+}

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=516840&r1=516839&r2=516840
==============================================================================
--- 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 Mar 10 18:00:22 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.
@@ -45,10 +45,10 @@
 
         Module module = new ModuleImpl(registry, moduleDef, log);
 
-        train_getLog(registry, "ioc.test.Upcase", log);
+        expect(registry.logForService("Upcase")).andReturn(log);
 
         train_isDebugEnabled(log, true);
-        log.debug("Creating service 'ioc.test.Upcase'.");
+        log.debug("Creating service 'Upcase'.");
 
         train_getLifecycle(registry, "singleton", new SingletonServiceLifecycle());
 
@@ -62,7 +62,7 @@
 
         replay();
 
-        UpcaseService service = module.getService("ioc.test.Upcase", UpcaseService.class, module);
+        UpcaseService service = module.getService("Upcase", UpcaseService.class);
 
         assertEquals(service.upcase("hello"), "HELLO");
 
@@ -76,70 +76,6 @@
     }
 
     @Test
-    public void get_service_by_id_private()
-    {
-        InternalRegistry registry = newInternalRegistry();
-        Log log = newLog();
-        ClassFactory factory = new ClassFactoryImpl();
-
-        ModuleDef moduleDef = new DefaultModuleDefImpl(ModuleImplTestModule.class, log);
-
-        Module module = new ModuleImpl(registry, moduleDef, log);
-
-        train_getLog(registry, "ioc.test.PrivateUpcase", log);
-
-        train_isDebugEnabled(log, false);
-
-        train_getLifecycle(registry, "singleton", new SingletonServiceLifecycle());
-
-        train_newClass(registry, factory, UpcaseService.class);
-
-        registry.addRegistryShutdownListener(isA(RegistryShutdownListener.class));
-
-        train_isDebugEnabled(log, false);
-
-        train_findDecoratorsForService(registry);
-
-        replay();
-
-        UpcaseService service = module.getService(
-                "ioc.test.PrivateUpcase",
-                UpcaseService.class,
-                module);
-
-        assertEquals(service.upcase("hello"), "HELLO");
-
-        verify();
-    }
-
-    @Test
-    public void get_service_by_id_private_wrong_module()
-    {
-        InternalRegistry registry = newInternalRegistry();
-        Log log = newLog();
-
-        ModuleDef moduleDef = new DefaultModuleDefImpl(ModuleImplTestModule.class, log);
-
-        Module module = new ModuleImpl(registry, moduleDef, log);
-
-        replay();
-
-        try
-        {
-            module.getService("ioc.test.PrivateUpcase", UpcaseService.class, null);
-            unreachable();
-        }
-        catch (RuntimeException ex)
-        {
-            assertEquals(
-                    ex.getMessage(),
-                    "Service 'ioc.test.PrivateUpcase' is private, and may not be referenced outside of its containing module.");
-        }
-
-        verify();
-    }
-
-    @Test
     public void find_service_ids_for_interface()
     {
         InternalRegistry registry = newInternalRegistry();
@@ -151,15 +87,11 @@
 
         replay();
 
-        Collection<String> ids = module.findServiceIdsForInterface(UpcaseService.class, module);
+        Collection<String> ids = module.findServiceIdsForInterface(FieService.class);
 
         assertEquals(ids.size(), 2);
-        assertTrue(ids.contains("ioc.test.Upcase"));
-        assertTrue(ids.contains("ioc.test.PrivateUpcase"));
-
-        ids = module.findServiceIdsForInterface(UpcaseService.class, null);
-        assertEquals(ids.size(), 1);
-        assertTrue(ids.contains("ioc.test.Upcase"));
+        assertTrue(ids.contains("Fie"));
+        assertTrue(ids.contains("OtherFie"));
 
         verify();
     }
@@ -197,24 +129,6 @@
     }
 
     @Test
-    public void get_module_id()
-    {
-        InternalRegistry registry = newInternalRegistry();
-        Log log = newLog();
-        ModuleDef def = newModuleDef();
-
-        train_getModuleId(def, "foo.bar");
-
-        replay();
-
-        Module module = new ModuleImpl(registry, def, log);
-
-        assertEquals(module.getModuleId(), "foo.bar");
-
-        verify();
-    }
-
-    @Test
     public void no_public_constructor_on_module_builder_class()
     {
         InternalRegistry registry = newInternalRegistry();
@@ -234,7 +148,7 @@
         {
             assertEquals(
                     ex.getMessage(),
-                    "Module builder for module 'private' (class org.apache.tapestry.ioc.internal.PrivateConstructorModule) "
+                    "Module builder class org.apache.tapestry.ioc.internal.PrivateConstructorModule "
                             + "does not contain any public constructors.");
         }
 
@@ -253,9 +167,9 @@
 
         log.warn(contains("contains more than one public constructor"));
 
-        train_expandSymbols(registry, "tapestry.ioc.ClassFactory", "tapestry.ioc.ClassFactory");
+        train_expandSymbols(registry, "ClassFactory", "ClassFactory");
 
-        train_getService(registry, "tapestry.ioc.ClassFactory", ClassFactory.class, module, factory);
+        train_getService(registry, "ClassFactory", ClassFactory.class, factory);
 
         replay();
 
@@ -289,11 +203,11 @@
         assertEquals(us.upcase("hello"), "HELLO");
         assertEquals(
                 us.toString(),
-                "<Proxy for ioc.test.Upcase(org.apache.tapestry.ioc.internal.UpcaseService)>");
+                "<Proxy for Upcase(org.apache.tapestry.ioc.internal.UpcaseService)>");
 
         ToStringService ts = registry.getService(ToStringService.class);
 
-        assertEquals(ts.toString(), "<ToStringService: ioc.test.ToString>");
+        assertEquals(ts.toString(), "<ToStringService: ToString>");
     }
 
     @Test
@@ -301,7 +215,7 @@
     {
         Registry registry = buildRegistry();
 
-        FoeService foe = registry.getService("ioc.test.RecursiveFoe", FoeService.class);
+        FoeService foe = registry.getService("RecursiveFoe", FoeService.class);
 
         try
         {

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ModuleImplTestModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ModuleImplTestModule.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ModuleImplTestModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/ModuleImplTestModule.java Sat Mar 10 18:00:22 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,56 +12,50 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc.internal;
-
-import org.apache.tapestry.ioc.annotations.Id;
-import org.apache.tapestry.ioc.annotations.InjectService;
-import org.apache.tapestry.ioc.annotations.Private;
-
-/**
- * Module builder used by {@link ModuleImplTest}.
- * 
- * 
- */
-@Id("ioc.test")
-public class ModuleImplTestModule
-{
-    public UpcaseService buildUpcase()
-    {
-        return new UpcaseServiceImpl();
-    }
-
-    @Private
-    public UpcaseService buildPrivateUpcase()
-    {
-        return new UpcaseServiceImpl();
-    }
-
-    public ToStringService buildToString(final String serviceId)
-    {
-        return new ToStringService()
-        {
-            @Override
-            public String toString()
-            {
-                return "<ToStringService: " + serviceId + ">";
-            }
-        };
-    }
-
-    public FieService buildFie()
-    {
-        return null;
-    }
-
-    public FoeService buildRecursiveFoe(@InjectService("ioc.test.RecursiveFoe")
-    FoeService self)
-    {
-        // While constructing self, we invoke a method on self.
-
-        self.foe();
-
-        return null;
-    }
-
-}
+package org.apache.tapestry.ioc.internal;
+
+import org.apache.tapestry.ioc.annotations.InjectService;
+
+/**
+ * Module builder used by {@link ModuleImplTest}.
+ */
+public class ModuleImplTestModule
+{
+    public UpcaseService buildUpcase()
+    {
+        return new UpcaseServiceImpl();
+    }
+
+    public FieService buildOtherFie()
+    {
+        return null;
+    }
+
+    public ToStringService buildToString(final String serviceId)
+    {
+        return new ToStringService()
+        {
+            @Override
+            public String toString()
+            {
+                return "<ToStringService: " + serviceId + ">";
+            }
+        };
+    }
+
+    public FieService buildFie()
+    {
+        return null;
+    }
+
+    public FoeService buildRecursiveFoe(@InjectService("RecursiveFoe")
+    FoeService self)
+    {
+        // While constructing self, we invoke a method on self.
+
+        self.foe();
+
+        return null;
+    }
+
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/NoUsableContributionParameterModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/NoUsableContributionParameterModule.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/NoUsableContributionParameterModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/NoUsableContributionParameterModule.java Sat Mar 10 18:00:22 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,22 +12,18 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc.internal;
-
-import org.apache.tapestry.ioc.annotations.Id;
-import org.apache.tapestry.ioc.annotations.InjectService;
-
-/**
- * Used by {@link org.apache.tapestry.ioc.internal.DefaultModuleDefImpl}.
- * 
- * 
- */
-@Id("ioc.test")
-public class NoUsableContributionParameterModule
-{
-    public void contributeNoParameter(@InjectService("foo.Bar")
-    UpcaseService service)
-    {
-
-    }
-}
+package org.apache.tapestry.ioc.internal;
+
+import org.apache.tapestry.ioc.annotations.InjectService;
+
+/**
+ * Used by {@link org.apache.tapestry.ioc.internal.DefaultModuleDefImpl}.
+ */
+public class NoUsableContributionParameterModule
+{
+    public void contributeNoParameter(@InjectService("foo.Bar")
+    UpcaseService service)
+    {
+
+    }
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/OneShotServiceCreatorTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/OneShotServiceCreatorTest.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/OneShotServiceCreatorTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/OneShotServiceCreatorTest.java Sat Mar 10 18:00:22 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.
@@ -33,7 +33,7 @@
         ObjectCreator delegate = newObjectCreator();
         Object service = new Object();
 
-        ServiceDef def = new ServiceDefImpl("foo.Bar", "singleton", method, false, false);
+        ServiceDef def = new ServiceDefImpl("foo.Bar", "singleton", method, false);
 
         train_createObject(delegate, service);
 
@@ -70,7 +70,7 @@
         ObjectCreator delegate = newObjectCreator();
         Object service = new Object();
 
-        ServiceDef def = new ServiceDefImpl("foo.Bar", "singleton", method, false, false);
+        ServiceDef def = new ServiceDefImpl("foo.Bar", "singleton", method, false);
 
         expect(delegate.createObject()).andThrow(failure);
 

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/OrderedConfigurationModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/OrderedConfigurationModule.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/OrderedConfigurationModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/OrderedConfigurationModule.java Sat Mar 10 18:00:22 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,21 +12,17 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc.internal;
-
-import org.apache.tapestry.ioc.OrderedConfiguration;
-import org.apache.tapestry.ioc.annotations.Id;
-
-/**
- * Used by {@link org.apache.tapestry.ioc.internal.DefaultModuleDefImpl}.
- * 
- * 
- */
-@Id("ioc.test")
-public class OrderedConfigurationModule
-{
-    public void contributeOrdered(OrderedConfiguration configuration)
-    {
-
-    }
-}
+package org.apache.tapestry.ioc.internal;
+
+import org.apache.tapestry.ioc.OrderedConfiguration;
+
+/**
+ * Used by {@link org.apache.tapestry.ioc.internal.DefaultModuleDefImpl}.
+ */
+public class OrderedConfigurationModule
+{
+    public void contributeOrdered(OrderedConfiguration configuration)
+    {
+
+    }
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/PrivateConstructorModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/PrivateConstructorModule.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/PrivateConstructorModule.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/PrivateConstructorModule.java Sat Mar 10 18:00:22 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,19 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc.internal;
-
-import org.apache.tapestry.ioc.annotations.Id;
-
-/**
- * Used by {@link org.apache.tapestry.ioc.internal.ModuleImplTest}.
- * 
- * 
- */
-@Id("private")
-public class PrivateConstructorModule
-{
-    private PrivateConstructorModule()
-    {
-    }
-}
+package org.apache.tapestry.ioc.internal;
+
+
+/**
+ * Used by {@link org.apache.tapestry.ioc.internal.ModuleImplTest}.
+ */
+public class PrivateConstructorModule
+{
+    private PrivateConstructorModule()
+    {
+    }
+}