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 [2/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/main/java/org/apache/tapestry/ioc/internal/RegistryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/RegistryImpl.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/RegistryImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/RegistryImpl.java Sat Mar 10 18:00:22 2007
@@ -18,7 +18,6 @@
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
 
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -28,7 +27,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.tapestry.ioc.Configuration;
 import org.apache.tapestry.ioc.IOCConstants;
-import org.apache.tapestry.ioc.IOCUtilities;
 import org.apache.tapestry.ioc.LogSource;
 import org.apache.tapestry.ioc.MappedConfiguration;
 import org.apache.tapestry.ioc.ObjectProvider;
@@ -56,23 +54,24 @@
 import org.apache.tapestry.ioc.services.RegistryShutdownListener;
 import org.apache.tapestry.ioc.services.ServiceLifecycleSource;
 import org.apache.tapestry.ioc.services.SymbolSource;
+import org.apache.tapestry.ioc.services.TapestryIOCModule;
 import org.apache.tapestry.ioc.services.ThreadCleanupHub;
 
 public class RegistryImpl implements Registry, InternalRegistry
 {
-    private static final String SYMBOL_SOURCE_SERVICE_ID = "tapestry.ioc.SymbolSource";
+    private static final String SYMBOL_SOURCE_SERVICE_ID = "SymbolSource";
 
-    private static final String REGISTRY_SHUTDOWN_HUB_SERVICE_ID = "tapestry.ioc.RegistryShutdownHub";
+    private static final String REGISTRY_SHUTDOWN_HUB_SERVICE_ID = "RegistryShutdownHub";
 
-    static final String THREAD_CLEANUP_HUB_SERVICE_ID = "tapestry.ioc.ThreadCleanupHub";
+    static final String THREAD_CLEANUP_HUB_SERVICE_ID = "ThreadCleanupHub";
 
     /**
      * Used to obtain the {@link org.apache.tapestry.ioc.services.ClassFactory} service, which is
      * crucial when creating runtime classes for proxies and the like.
      */
-    static final String CLASS_FACTORY_SERVICE_ID = "tapestry.ioc.ClassFactory";
+    static final String CLASS_FACTORY_SERVICE_ID = "ClassFactory";
 
-    static final String LOG_SOURCE_SERVICE_ID = "tapestry.ioc.LogSource";
+    static final String LOG_SOURCE_SERVICE_ID = "LogSource";
 
     private final OneShotLock _lock = new OneShotLock();
 
@@ -84,8 +83,8 @@
 
     private final LogSource _logSource;
 
-    /** Keyed on module id. */
-    private final Map<String, Module> _modules = newCaseInsensitiveMap();
+    /** Map from service id to the Module that contains the service. */
+    private final Map<String, Module> _serviceIdToModule = newCaseInsensitiveMap();
 
     private final Map<String, ServiceLifecycle> _lifecycles = newCaseInsensitiveMap();
 
@@ -95,7 +94,7 @@
      * have to stop at a certain "bounary" services by provide stub/ mock objects as their
      * implementations.
      */
-    private Map<String, Object> _serviceOverrides;
+    private final Map<String, Object> _serviceOverrides = newCaseInsensitiveMap();
 
     private final ThreadCleanupHubImpl _cleanupHub;
 
@@ -103,6 +102,8 @@
 
     private SymbolSource _symbolSource;
 
+    private final List<Module> _modules = newList();
+
     public static final class OrderedConfigurationToOrdererAdaptor<T> implements
             OrderedConfiguration<T>
     {
@@ -137,32 +138,43 @@
     {
         _logSource = logSource;
 
-        _serviceOverrides = serviceOverrides;
+        _serviceOverrides.putAll(serviceOverrides);
 
         for (ModuleDef def : moduleDefs)
         {
-            Log log = _logSource.getLog(def.getModuleId());
+            Log log = _logSource.getLog(def.getBuilderClass());
 
             Module module = new ModuleImpl(this, def, log);
 
-            _modules.put(def.getModuleId(), module);
+            _modules.add(module);
+
+            for (String serviceId : def.getServiceIds())
+            {
+                Module existing = _serviceIdToModule.get(serviceId);
+
+                if (existing != null)
+                    throw new RuntimeException(IOCMessages.serviceIdConflict(serviceId, existing
+                            .getServiceDef(serviceId), module.getServiceDef(serviceId)));
+
+                _serviceIdToModule.put(serviceId, module);
+            }
         }
 
         addBuiltin(LOG_SOURCE_SERVICE_ID, LogSource.class, _logSource);
 
-        Log log = _logSource.getLog(RegistryImpl.CLASS_FACTORY_SERVICE_ID);
+        Log log = logForBuiltinService(CLASS_FACTORY_SERVICE_ID);
 
         _classFactory = new ClassFactoryImpl(contextClassLoader, log);
 
-        addBuiltin(RegistryImpl.CLASS_FACTORY_SERVICE_ID, ClassFactory.class, _classFactory);
+        addBuiltin(CLASS_FACTORY_SERVICE_ID, ClassFactory.class, _classFactory);
 
-        log = _logSource.getLog(THREAD_CLEANUP_HUB_SERVICE_ID);
+        log = logForBuiltinService(THREAD_CLEANUP_HUB_SERVICE_ID);
 
         _cleanupHub = new ThreadCleanupHubImpl(log);
 
         addBuiltin(THREAD_CLEANUP_HUB_SERVICE_ID, ThreadCleanupHub.class, _cleanupHub);
 
-        log = _logSource.getLog(REGISTRY_SHUTDOWN_HUB_SERVICE_ID);
+        log = logForBuiltinService(REGISTRY_SHUTDOWN_HUB_SERVICE_ID);
 
         _registryShutdownHub = new RegistryShutdownHubImpl(log);
 
@@ -172,13 +184,34 @@
                 _registryShutdownHub);
 
         _lifecycles.put("singleton", new SingletonServiceLifecycle());
+    }
 
-        // Ask all modules to eager-load any services marked with @EagerLoad
-
-        for (Module m : _modules.values())
+    /**
+     * It's not unreasonable for an eagerly-loaded service to decide to start a thread, at which
+     * point we raise issues about improper publishing of the Registry instance from the
+     * RegistryImpl constructor. Moving eager loading of services out to its own method should
+     * ensure thread safety.
+     */
+    public void eagerLoadServices()
+    {
+        for (Module m : _modules)
             m.eagerLoadServices();
     }
 
+    public Log logForService(String serviceId)
+    {
+        Module module = _serviceIdToModule.get(serviceId);
+
+        assert module != null;
+
+        return _logSource.getLog(module.getLogName() + "." + serviceId);
+    }
+
+    private Log logForBuiltinService(String serviceId)
+    {
+        return _logSource.getLog(TapestryIOCModule.class + "." + serviceId);
+    }
+
     private <T> void addBuiltin(String serviceId, Class<T> serviceInterface, T service)
     {
         _builtinTypes.put(serviceId, serviceInterface);
@@ -193,7 +226,7 @@
     }
 
     /** Internal access, usually from another module. */
-    public <T> T getService(String serviceId, Class<T> serviceInterface, Module module)
+    public <T> T getService(String serviceId, Class<T> serviceInterface)
     {
         _lock.check();
 
@@ -208,7 +241,7 @@
 
         Module containingModule = locateModuleForService(serviceId);
 
-        return containingModule.getService(serviceId, serviceInterface, module);
+        return containingModule.getService(serviceId, serviceInterface);
     }
 
     private <T> T checkForBuiltinService(String serviceId, Class<T> serviceInterface)
@@ -245,16 +278,6 @@
         }
     }
 
-    /**
-     * Access for a service from the outside world (limited to publically visible services).
-     */
-    public <T> T getService(String serviceId, Class<T> serviceInterface)
-    {
-        _lock.check();
-
-        return getService(expandSymbols(serviceId), serviceInterface, null);
-    }
-
     public void cleanupThread()
     {
         _lock.check();
@@ -264,12 +287,11 @@
 
     private Module locateModuleForService(String serviceId)
     {
-        String moduleId = IOCUtilities.extractModuleId(serviceId);
-
-        Module module = _modules.get(moduleId);
+        Module module = _serviceIdToModule.get(serviceId);
 
         if (module == null)
-            throw new RuntimeException(IOCMessages.noSuchModule(moduleId, _modules.keySet()));
+            throw new RuntimeException(IOCMessages.noSuchService(serviceId, _serviceIdToModule
+                    .keySet()));
 
         return module;
     }
@@ -288,7 +310,7 @@
             }
         };
 
-        Collection<Module> modules = modulesThatContributeToService(serviceDef);
+        Collection<Module> modules = _modules;
 
         for (Module m : modules)
             addToUnorderedConfiguration(configuration, objectType, serviceDef, m);
@@ -300,13 +322,13 @@
     {
         _lock.check();
 
-        Log log = getLog(serviceDef.getServiceId());
+        Log log = null;
 
         final Orderer<T> orderer = new Orderer<T>(log);
 
         OrderedConfiguration<T> configuration = new OrderedConfigurationToOrdererAdaptor<T>(orderer);
 
-        Collection<Module> modules = modulesThatContributeToService(serviceDef);
+        Collection<Module> modules = _modules;
 
         for (Module m : modules)
             addToOrderedConfiguration(configuration, objectType, serviceDef, m);
@@ -331,7 +353,7 @@
 
         Map<K, ContributionDef> keyToContribution = newMap();
 
-        Collection<Module> modules = modulesThatContributeToService(serviceDef);
+        Collection<Module> modules = _modules;
 
         for (Module m : modules)
             addToMappedConfiguration(
@@ -345,19 +367,6 @@
         return result;
     }
 
-    private Collection<Module> modulesThatContributeToService(ServiceDef serviceDef)
-    {
-        if (serviceDef.isPrivate())
-        {
-            String moduleId = IOCUtilities.extractModuleId(serviceDef.getServiceId());
-            Module module = _modules.get(moduleId);
-
-            return Arrays.asList(module);
-        }
-
-        return _modules.values();
-    }
-
     private <K, V> void addToMappedConfiguration(MappedConfiguration<K, V> configuration,
             Map<K, ContributionDef> keyToContribution, Class<K> keyClass, Class<V> valueType,
             ServiceDef serviceDef, Module module)
@@ -367,7 +376,8 @@
 
         if (contributions.isEmpty()) return;
 
-        Log log = getLog(serviceId);
+        Log log = logForService(serviceId);
+
         boolean debug = log.isDebugEnabled();
 
         ServiceLocator locator = new ServiceResourcesImpl(this, module, serviceDef, log);
@@ -392,7 +402,8 @@
 
         if (contributions.isEmpty()) return;
 
-        Log log = getLog(serviceId);
+        Log log = logForService(serviceId);
+
         boolean debug = log.isDebugEnabled();
 
         ServiceLocator locator = new ServiceResourcesImpl(this, module, serviceDef, log);
@@ -416,7 +427,7 @@
 
         if (contributions.isEmpty()) return;
 
-        Log log = getLog(serviceId);
+        Log log = logForService(serviceId);
         boolean debug = log.isDebugEnabled();
 
         ServiceLocator locator = new ServiceResourcesImpl(this, module, serviceDef, log);
@@ -424,7 +435,7 @@
         for (ContributionDef def : contributions)
         {
             OrderedConfiguration<T> validating = new ValidatingOrderedConfigurationWrapper<T>(
-                    serviceId, module.getModuleId(), def, log, valueType, configuration);
+                    serviceId, def, log, valueType, configuration);
 
             if (debug) log.debug(IOCMessages.invokingMethod(def));
 
@@ -433,15 +444,15 @@
     }
 
     // Seems like something that could be cached.
-    public <T> T getService(Class<T> serviceInterface, Module module)
+    public <T> T getService(Class<T> serviceInterface)
     {
         _lock.check();
 
         List<String> ids = CollectionFactory.newList();
 
-        for (Module m : _modules.values())
+        for (Module m : _modules)
         {
-            Collection<String> matchingIds = m.findServiceIdsForInterface(serviceInterface, module);
+            Collection<String> matchingIds = m.findServiceIdsForInterface(serviceInterface);
             ids.addAll(matchingIds);
         }
 
@@ -455,7 +466,7 @@
 
                 String serviceId = ids.get(0);
 
-                return getService(serviceId, serviceInterface, module);
+                return getService(serviceId, serviceInterface);
 
             default:
 
@@ -465,13 +476,6 @@
         }
     }
 
-    public <T> T getService(Class<T> serviceInterface)
-    {
-        _lock.check();
-
-        return getService(serviceInterface, null);
-    }
-
     public ServiceLifecycle getServiceLifecycle(String lifecycle)
     {
         _lock.check();
@@ -481,7 +485,7 @@
         if (result == null)
         {
             ServiceLifecycleSource source = getService(
-                    "tapestry.ioc.ServiceLifecycleSource",
+                    "ServiceLifecycleSource",
                     ServiceLifecycleSource.class);
             result = source.get(lifecycle);
         }
@@ -495,103 +499,29 @@
     {
         _lock.check();
 
-        // This simply should never happen, yet we're seeing it. This falls into the
-        // category of "scary things that happen in multi-threaded applications".
-
         assert serviceDef != null;
 
-        Log log = getLog(serviceDef.getServiceId());
-
-        Orderer<DecoratorDef> orderer = new Orderer<DecoratorDef>(log);
-
-        addDecoratorDefsToOrderer(orderer, serviceDef);
+        Log log = logForService(serviceDef.getServiceId());
 
-        List<DecoratorDef> ordered = orderer.getOrdered();
+        Orderer<ServiceDecorator> orderer = new Orderer<ServiceDecorator>(log);
 
-        return convertDecoratorDefsToServiceDecorators(ordered, serviceDef, log);
-    }
-
-    private List<ServiceDecorator> convertDecoratorDefsToServiceDecorators(
-            List<DecoratorDef> ordered, ServiceDef serviceDef, Log log)
-    {
-        List<ServiceDecorator> result = newList();
-
-        ServiceResources resources = null;
-        String moduleId = null;
-        Module module = null;
-
-        for (DecoratorDef dd : ordered)
+        for (Module module : _modules)
         {
-            String decoratorModuleId = IOCUtilities.extractModuleId(dd.getDecoratorId());
-
-            // Whenever the module id containing the decorator changes,
-            // "refresh" the resources, etc., to point to the (new) module.
-            // This means that the ServiceResources will identify services within
-            // the decorators module (important in terms of service visibility
-            // and abbreviated service ids).
-
-            if (!decoratorModuleId.equals(moduleId))
-            {
-                moduleId = decoratorModuleId;
+            Set<DecoratorDef> decorators = module.findMatchingDecoratorDefs(serviceDef);
 
-                module = _modules.get(moduleId);
+            if (decorators.isEmpty()) continue;
 
-                resources = new ServiceResourcesImpl(this, module, serviceDef, log);
-            }
-
-            ServiceDecorator decorator = dd.createDecorator(module, resources);
-
-            result.add(decorator);
-        }
+            ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, log);
 
-        return result;
-    }
-
-    private void addDecoratorDefsToOrderer(Orderer<DecoratorDef> orderer, ServiceDef serviceDef)
-    {
-        if (serviceDef.isPrivate())
-        {
-            Set<DecoratorDef> privateDecorators = findDecoratorsDefsForPrivateService(serviceDef);
-            addToOrderer(orderer, privateDecorators);
-        }
-        else
-        {
-            for (Module m : _modules.values())
+            for (DecoratorDef dd : decorators)
             {
-                Set<DecoratorDef> moduleDecorators = m.findMatchingDecoratorDefs(serviceDef);
-                addToOrderer(orderer, moduleDecorators);
-            }
-        }
-    }
+                ServiceDecorator sd = dd.createDecorator(module, resources);
 
-    private void addToOrderer(Orderer<DecoratorDef> orderer, Set<DecoratorDef> decorators)
-    {
-        for (DecoratorDef df : decorators)
-        {
-            orderer.add(df.getDecoratorId(), df, df.getConstraints());
+                orderer.add(dd.getDecoratorId(), sd, dd.getConstraints());
+            }
         }
-    }
-
-    private Set<DecoratorDef> findDecoratorsDefsForPrivateService(ServiceDef serviceDef)
-    {
-        String moduleId = IOCUtilities.extractModuleId(serviceDef.getServiceId());
-        Module module = _modules.get(moduleId);
-
-        return module.findMatchingDecoratorDefs(serviceDef);
-    }
 
-    public Log getLog(Class clazz)
-    {
-        _lock.check();
-
-        return _logSource.getLog(clazz);
-    }
-
-    public Log getLog(String name)
-    {
-        _lock.check();
-
-        return _logSource.getLog(name);
+        return orderer.getOrdered();
     }
 
     public ClassFab newClass(Class serviceInterface)
@@ -629,6 +559,8 @@
 
     public String expandSymbols(String input)
     {
+        _lock.check();
+
         // Again, a bit of work to avoid instantiating the SymbolSource until absolutely necessary.
 
         if (!InternalUtils.containsSymbols(input)) return input;

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ServiceDefImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ServiceDefImpl.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ServiceDefImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ServiceDefImpl.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,79 +12,67 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc.internal;
-
-import java.lang.reflect.Method;
-
-import org.apache.tapestry.ioc.ObjectCreator;
-import org.apache.tapestry.ioc.ServiceBuilderResources;
-import org.apache.tapestry.ioc.def.ServiceDef;
+package org.apache.tapestry.ioc.internal;
+
+import java.lang.reflect.Method;
+
+import org.apache.tapestry.ioc.ObjectCreator;
+import org.apache.tapestry.ioc.ServiceBuilderResources;
+import org.apache.tapestry.ioc.def.ServiceDef;
 import org.apache.tapestry.ioc.internal.util.InternalUtils;
-
-/**
- * 
- */
-public class ServiceDefImpl implements ServiceDef
-{
-    private final Method _builderMethod;
-
-    private final String _serviceId;
-
-    private final String _lifecycle;
-
-    private final boolean _private;
-
-    private final boolean _eagerLoad;
-
-    ServiceDefImpl(String serviceId, String lifecycle, Method builderMethod, boolean isprivate,
-            boolean eagerLoad)
-    {
-        _serviceId = serviceId;
-        _lifecycle = lifecycle;
-        _builderMethod = builderMethod;
-        _private = isprivate;
-        _eagerLoad = eagerLoad;
-    }
-
-    @Override
-    public String toString()
-    {
-        return InternalUtils.asString(_builderMethod);
-    }
-
-    Method getBuilderMethod()
-    {
-        return _builderMethod;
-    }
-
-    public ObjectCreator createServiceCreator(ServiceBuilderResources resources)
-    {
-        return new ServiceBuilderMethodInvoker(_builderMethod, resources);
-    }
-
-    public String getServiceId()
-    {
-        return _serviceId;
-    }
-
-    public Class getServiceInterface()
-    {
-        return _builderMethod.getReturnType();
-    }
-
-    public String getServiceLifeycle()
-    {
-        return _lifecycle;
-    }
-
-    public boolean isPrivate()
-    {
-        return _private;
-    }
-
-    public boolean isEagerLoad()
-    {
-        return _eagerLoad;
-    }
-
-}
+
+public class ServiceDefImpl implements ServiceDef
+{
+    private final Method _builderMethod;
+
+    private final String _serviceId;
+
+    private final String _lifecycle;
+
+    private final boolean _eagerLoad;
+
+    ServiceDefImpl(String serviceId, String lifecycle, Method builderMethod, boolean eagerLoad)
+    {
+        _serviceId = serviceId;
+        _lifecycle = lifecycle;
+        _builderMethod = builderMethod;
+        _eagerLoad = eagerLoad;
+    }
+
+    @Override
+    public String toString()
+    {
+        return InternalUtils.asString(_builderMethod);
+    }
+
+    Method getBuilderMethod()
+    {
+        return _builderMethod;
+    }
+
+    public ObjectCreator createServiceCreator(ServiceBuilderResources resources)
+    {
+        return new ServiceBuilderMethodInvoker(_builderMethod, resources);
+    }
+
+    public String getServiceId()
+    {
+        return _serviceId;
+    }
+
+    public Class getServiceInterface()
+    {
+        return _builderMethod.getReturnType();
+    }
+
+    public String getServiceLifeycle()
+    {
+        return _lifecycle;
+    }
+
+    public boolean isEagerLoad()
+    {
+        return _eagerLoad;
+    }
+
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ServiceLocatorImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ServiceLocatorImpl.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ServiceLocatorImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ServiceLocatorImpl.java 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,8 +14,6 @@
 
 package org.apache.tapestry.ioc.internal;
 
-import static org.apache.tapestry.ioc.IOCUtilities.toQualifiedId;
-
 import org.apache.tapestry.ioc.ServiceLocator;
 
 /**
@@ -38,15 +36,12 @@
     {
         String expandedServiceId = _registry.expandSymbols(serviceId);
 
-        return _registry.getService(
-                toQualifiedId(_module.getModuleId(), expandedServiceId),
-                serviceInterface,
-                _module);
+        return _registry.getService(expandedServiceId, serviceInterface);
     }
 
     public <T> T getService(Class<T> serviceInterface)
     {
-        return _registry.getService(serviceInterface, _module);
+        return _registry.getService(serviceInterface);
     }
 
     public <T> T getObject(String reference, Class<T> objectType)

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ValidatingOrderedConfigurationWrapper.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ValidatingOrderedConfigurationWrapper.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ValidatingOrderedConfigurationWrapper.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ValidatingOrderedConfigurationWrapper.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,64 +12,55 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc.internal;
-
-import static org.apache.tapestry.ioc.IOCUtilities.toQualifiedId;
-
-import org.apache.commons.logging.Log;
-import org.apache.tapestry.ioc.OrderedConfiguration;
-import org.apache.tapestry.ioc.def.ContributionDef;
-
-/**
- * Implements validation of values provided to an
- * {@link org.apache.tapestry.ioc.OrderedConfiguration}. It also takes care of qualifying any ids.
- * If you provide an incorrect value type, the value is converted to null but added anyway. This
- * ensures that incorrect values contributed in don't screw up the
- * {@link org.apache.tapestry.ioc.internal.util.Orderer} (and generate a bunch of error messages there).
- * 
- * @param <T>
- */
-public class ValidatingOrderedConfigurationWrapper<T> implements OrderedConfiguration<T>
-{
-    private final String _serviceId;
-
-    /** Module id containing the contribution (not necessarily the service). */
-    private final String _moduleId;
-
-    private final ContributionDef _contributionDef;
-
-    private final Log _log;
-
-    private final Class _expectedType;
-
-    private final OrderedConfiguration<T> _delegate;
-
-    public ValidatingOrderedConfigurationWrapper(String serviceId, String moduleId,
-            ContributionDef contributionDef, Log log, Class expectedType,
-            OrderedConfiguration<T> delegate)
-    {
-        _serviceId = serviceId;
-        _moduleId = moduleId;
-        _contributionDef = contributionDef;
-        _log = log;
-        _expectedType = expectedType;
-        _delegate = delegate;
-    }
-
-    public void add(String id, T object, String... constraints)
-    {
-        _delegate.add(toQualifiedId(_moduleId, id), validVersionOf(object), constraints);
-    }
-
-    private T validVersionOf(T object)
-    {
-        if (object == null || _expectedType.isInstance(object))
-            return object;
-
-        if (!_expectedType.isInstance(object))
-            _log.warn(IOCMessages.contributionWrongValueType(_serviceId, _contributionDef, object
-                    .getClass(), _expectedType));
-
-        return null;
-    }
-}
+package org.apache.tapestry.ioc.internal;
+
+import org.apache.commons.logging.Log;
+import org.apache.tapestry.ioc.OrderedConfiguration;
+import org.apache.tapestry.ioc.def.ContributionDef;
+
+/**
+ * Implements validation of values provided to an
+ * {@link org.apache.tapestry.ioc.OrderedConfiguration}. If you provide an incorrect value type,
+ * the value is converted to null but added anyway. This ensures that incorrect values contributed
+ * in don't screw up the {@link org.apache.tapestry.ioc.internal.util.Orderer} (and generate a bunch
+ * of error messages there).
+ * 
+ * @param <T>
+ */
+public class ValidatingOrderedConfigurationWrapper<T> implements OrderedConfiguration<T>
+{
+    private final String _serviceId;
+
+    private final ContributionDef _contributionDef;
+
+    private final Log _log;
+
+    private final Class _expectedType;
+
+    private final OrderedConfiguration<T> _delegate;
+
+    public ValidatingOrderedConfigurationWrapper(String serviceId, ContributionDef contributionDef,
+            Log log, Class expectedType, OrderedConfiguration<T> delegate)
+    {
+        _serviceId = serviceId;
+        _contributionDef = contributionDef;
+        _log = log;
+        _expectedType = expectedType;
+        _delegate = delegate;
+    }
+
+    public void add(String id, T object, String... constraints)
+    {
+        _delegate.add(id, validVersionOf(object), constraints);
+    }
+
+    private T validVersionOf(T object)
+    {
+        if (object == null || _expectedType.isInstance(object)) return object;
+
+        _log.warn(IOCMessages.contributionWrongValueType(_serviceId, _contributionDef, object
+                .getClass(), _expectedType));
+
+        return null;
+    }
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ChainBuilderImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ChainBuilderImpl.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ChainBuilderImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ChainBuilderImpl.java Sat Mar 10 18:00:22 2007
@@ -15,7 +15,7 @@
 package org.apache.tapestry.ioc.internal.services;
 
 import static java.lang.String.format;
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newThreadSafeMap;
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newConcurrentMap;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Modifier;
@@ -41,7 +41,7 @@
      * Map, keyed on service interface, of implementation Class.
      */
 
-    private Map<Class, Class> _cache = newThreadSafeMap();
+    private Map<Class, Class> _cache = newConcurrentMap();
 
     public ChainBuilderImpl(ClassFactory classFactory)
     {

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/DefaultImplementationBuilderImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/DefaultImplementationBuilderImpl.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/DefaultImplementationBuilderImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/DefaultImplementationBuilderImpl.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.
@@ -15,7 +15,7 @@
 package org.apache.tapestry.ioc.internal.services;
 
 import static java.lang.String.format;
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newThreadSafeMap;
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newConcurrentMap;
 
 import java.util.Map;
 
@@ -30,7 +30,7 @@
  */
 public class DefaultImplementationBuilderImpl implements DefaultImplementationBuilder
 {
-    private final Map<Class, Object> _cache = newThreadSafeMap();
+    private final Map<Class, Object> _cache = newConcurrentMap();
 
     private final ClassFactory _classFactory;
 

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/PropertyAccessImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/PropertyAccessImpl.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/PropertyAccessImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/PropertyAccessImpl.java Sat Mar 10 18:00:22 2007
@@ -16,7 +16,7 @@
 
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newLinkedList;
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newThreadSafeMap;
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newConcurrentMap;
 
 import java.beans.BeanInfo;
 import java.beans.IntrospectionException;
@@ -31,7 +31,7 @@
 
 public class PropertyAccessImpl implements PropertyAccess
 {
-    private final Map<Class, ClassPropertyAdapter> _adapters = newThreadSafeMap();
+    private final Map<Class, ClassPropertyAdapter> _adapters = newConcurrentMap();
 
     public Object get(Object instance, String propertyName)
     {

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ServiceObjectProvider.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ServiceObjectProvider.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ServiceObjectProvider.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ServiceObjectProvider.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,27 +12,25 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc.internal.services;
-
-import org.apache.tapestry.ioc.ObjectProvider;
-import org.apache.tapestry.ioc.ServiceLocator;
-
-/**
- * Simple implementation of {@link org.apache.tapestry.ioc.ObjectProvider} that is mapped to the
- * "service" provider prefix.
- * 
- * 
- */
-public class ServiceObjectProvider implements ObjectProvider
-{
-    /**
-     * Interprets the expression as a local or fully qualified service id.
-     * 
-     * @see ServiceLocator#getService(String, Class)
-     */
-    public <T> T provide(String expression, Class<T> objectType, ServiceLocator locator)
-    {
-        return locator.getService(expression, objectType);
-    }
-
-}
+package org.apache.tapestry.ioc.internal.services;
+
+import org.apache.tapestry.ioc.ObjectProvider;
+import org.apache.tapestry.ioc.ServiceLocator;
+
+/**
+ * Simple implementation of {@link org.apache.tapestry.ioc.ObjectProvider} that is mapped to the
+ * "service" provider prefix.
+ */
+public class ServiceObjectProvider implements ObjectProvider
+{
+    /**
+     * Interprets the expression as a service id.
+     * 
+     * @see ServiceLocator#getService(String)
+     */
+    public <T> T provide(String expression, Class<T> objectType, ServiceLocator locator)
+    {
+        return locator.getService(expression, objectType);
+    }
+
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/SymbolSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/SymbolSourceImpl.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/SymbolSourceImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/SymbolSourceImpl.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.
@@ -15,7 +15,7 @@
 package org.apache.tapestry.ioc.internal.services;
 
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newLinkedList;
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newThreadSafeMap;
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newConcurrentMap;
 
 import java.util.LinkedList;
 import java.util.List;
@@ -29,7 +29,7 @@
     private final List<SymbolProvider> _providers;
 
     /** Cache of symbol name to fully expanded symbol value. */
-    private final Map<String, String> _cache = newThreadSafeMap();
+    private final Map<String, String> _cache = newConcurrentMap();
 
     /**
      * Contains execution data needed when performing an expansion (largely, to check for endless

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImpl.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/TypeCoercerImpl.java Sat Mar 10 18:00:22 2007
@@ -18,7 +18,7 @@
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newSet;
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newThreadSafeMap;
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newConcurrentMap;
 import static org.apache.tapestry.ioc.internal.util.Defense.notNull;
 
 import java.util.Collection;
@@ -42,7 +42,7 @@
 
     // Access to the cache must be thread safe
 
-    private final Map<CacheKey, Coercion> _cache = newThreadSafeMap();
+    private final Map<CacheKey, Coercion> _cache = newConcurrentMap();
 
     static class CacheKey
     {

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/CollectionFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/CollectionFactory.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/CollectionFactory.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/CollectionFactory.java Sat Mar 10 18:00:22 2007
@@ -24,6 +24,7 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.apache.tapestry.ioc.util.CaseInsensitiveMap;
@@ -84,9 +85,9 @@
     }
 
     /**
-     * Constructs a new thread safe map.
+     * Constructs a new concurrent map, which is safe to access via multiple threads.
      */
-    public static <K, V> Map<K, V> newThreadSafeMap()
+    public static <K, V> ConcurrentMap<K, V> newConcurrentMap()
     {
         return new ConcurrentHashMap<K, V>();
     }
@@ -133,7 +134,7 @@
     {
         return new CaseInsensitiveMap<V>();
     }
-    
+
     public static <V> Map<String, V> newCaseInsensitiveMap(Map<String, ? extends V> map)
     {
         return new CaseInsensitiveMap<V>(map);

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/Orderer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/Orderer.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/Orderer.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/util/Orderer.java Sat Mar 10 18:00:22 2007
@@ -1,4 +1,4 @@
-// Copyright 2004, 2005, 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.
@@ -22,7 +22,6 @@
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
-import org.apache.tapestry.ioc.IOCUtilities;
 import org.apache.tapestry.ioc.IdMatcher;
 import org.apache.tapestry.ioc.Orderable;
 import org.apache.tapestry.ioc.internal.IdMatcherImpl;
@@ -218,9 +217,7 @@
 
     private Collection<DependencyNode<T>> findDependencies(String sourceId, String patternList)
     {
-        String sourceModuleId = IOCUtilities.extractModuleId(sourceId);
-
-        IdMatcher matcher = buildMatcherForPattern(sourceModuleId, patternList);
+        IdMatcher matcher = buildMatcherForPattern(patternList);
 
         Collection<DependencyNode<T>> result = newList();
 
@@ -234,15 +231,14 @@
         return result;
     }
 
-    private IdMatcher buildMatcherForPattern(String sourceModuleId, String patternList)
+    private IdMatcher buildMatcherForPattern(String patternList)
     {
         List<IdMatcher> matchers = newList();
 
         for (String pattern : patternList.split(","))
         {
-            IdMatcher matcher = new IdMatcherImpl(IOCUtilities.toQualifiedId(
-                    sourceModuleId,
-                    pattern.trim()));
+            IdMatcher matcher = new IdMatcherImpl(pattern.trim());
+
             matchers.add(matcher);
         }
 

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=516840&r1=516839&r2=516840
==============================================================================
--- 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 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.
@@ -27,7 +27,6 @@
 import org.apache.tapestry.ioc.ObjectProvider;
 import org.apache.tapestry.ioc.OrderedConfiguration;
 import org.apache.tapestry.ioc.ServiceLifecycle;
-import org.apache.tapestry.ioc.annotations.Id;
 import org.apache.tapestry.ioc.annotations.InjectService;
 import org.apache.tapestry.ioc.annotations.Lifecycle;
 import org.apache.tapestry.ioc.internal.services.ChainBuilderImpl;
@@ -52,7 +51,6 @@
 /**
  * Defines the base set of services for the Tapestry IOC container.
  */
-@Id("tapestry.ioc")
 public final class TapestryIOCModule
 {
     private final ClassFactory _classFactory;

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/test/IOCTestCase.java Sat 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.
@@ -191,11 +191,6 @@
     protected final void train_getLog(LogSource source, String serviceId, Log log)
     {
         expect(source.getLog(serviceId)).andReturn(log).atLeastOnce();
-    }
-
-    protected final void train_getModuleId(ModuleDef def, String moduleId)
-    {
-        expect(def.getModuleId()).andReturn(moduleId).atLeastOnce();
     }
 
     /** Frequently used as a placeholder for an arbitrary service (but its nice and simple). */

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/util/StrategyRegistry.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/util/StrategyRegistry.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/util/StrategyRegistry.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/util/StrategyRegistry.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,127 +12,123 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package org.apache.tapestry.ioc.util;
-
+package org.apache.tapestry.ioc.util;
+
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newConcurrentMap;
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newThreadSafeMap;
 
 import java.util.List;
 import java.util.Map;
 
 import org.apache.tapestry.ioc.internal.util.InheritanceSearch;
-import org.apache.tapestry.ioc.internal.util.InternalUtils;
-
-/**
- * A key component in implementing the "Gang of Four" Strategy pattern. A StrategyRegistry will
- * match up a given input type with a registered strategy for that type.
- * 
- * @param <A>
- *            the type of the strategy adapter
- */
-public final class StrategyRegistry<A>
-{
-    private final Class<A> _adapterType;
-
-    private final Map<Class, A> _registrations = newMap();
-
-    private final Map<Class, A> _cache = newThreadSafeMap();
-
-    /**
-     * Creates a strategy registry for the given adapter type.
-     * 
-     * @param adapterType
-     *            the type of adapter retrieved from the registry
-     * @param registrations
-     *            map of registrations (the contents of the map are copied)
-     */
-    public StrategyRegistry(final Class<A> adapterType, Map<Class, A> registrations)
-    {
-        _adapterType = adapterType;
-        _registrations.putAll(registrations);
-    }
-
-    public static <A> StrategyRegistry<A> newInstance(Class<A> adapterType,
-            Map<Class, A> registrations)
-    {
-        return new StrategyRegistry<A>(adapterType, registrations);
-    }
-
-    public void clearCache()
-    {
-        _cache.clear();
-    }
-
-    public Class<A> getAdapterType()
-    {
-        return _adapterType;
-    }
-
-    /**
-     * Gets an adapter for an object. Searches based on the value's class, unless the value is null,
-     * in which case, a search on class void is used.
-     * 
-     * @param value
-     *            for which an adapter is needed
-     * @return the adaptoer for the value
-     * @throws IllegalArgumentException
-     *             if no matching adapter may be found
-     */
-
-    public A getByInstance(Object value)
-    {
-        return get(value == null ? void.class : value.getClass());
-    }
-
-    /**
-     * Searches for an adapter corresponding to the given input type.
-     * 
-     * @param type
-     *            the type to search
-     * @return the corresponding adapter
-     * @throws IllegalArgumentException
-     *             if no matching adapter may be found
-     */
-    public A get(Class type)
-    {
-        A result = _cache.get(type);
-
-        if (result == null)
-        {
-            result = findMatch(type);
-            _cache.put(type, result);
-        }
-
-        return result;
-    }
-
-    private A findMatch(Class type)
-    {
-        for (Class t : new InheritanceSearch(type))
-        {
-            A result = _registrations.get(t);
-
-            if (result != null)
-                return result;
-        }
-
-        // Report the error. These things really confused the hell out of people in Tap4, so we're
-        // going the extra mile on the exception message.
-
-        List<String> names = newList();
-        for (Class t : _registrations.keySet())
-            names.add(t.getName());
-
-        throw new IllegalArgumentException(UtilMessages.noStrategyAdapter(
-                type,
-                _adapterType,
-                InternalUtils.joinSorted(names)));
-    }
-
-    @Override
-    public String toString()
-    {
-        return String.format("StrategyRegistry[%s]", _adapterType.getName());
-    }
-}
+
+/**
+ * A key component in implementing the "Gang of Four" Strategy pattern. A StrategyRegistry will
+ * match up a given input type with a registered strategy for that type.
+ * 
+ * @param <A>
+ *            the type of the strategy adapter
+ */
+public final class StrategyRegistry<A>
+{
+    private final Class<A> _adapterType;
+
+    private final Map<Class, A> _registrations = newMap();
+
+    private final Map<Class, A> _cache = newConcurrentMap();
+
+    /**
+     * Creates a strategy registry for the given adapter type.
+     * 
+     * @param adapterType
+     *            the type of adapter retrieved from the registry
+     * @param registrations
+     *            map of registrations (the contents of the map are copied)
+     */
+    public StrategyRegistry(final Class<A> adapterType, Map<Class, A> registrations)
+    {
+        _adapterType = adapterType;
+        _registrations.putAll(registrations);
+    }
+
+    public static <A> StrategyRegistry<A> newInstance(Class<A> adapterType,
+            Map<Class, A> registrations)
+    {
+        return new StrategyRegistry<A>(adapterType, registrations);
+    }
+
+    public void clearCache()
+    {
+        _cache.clear();
+    }
+
+    public Class<A> getAdapterType()
+    {
+        return _adapterType;
+    }
+
+    /**
+     * Gets an adapter for an object. Searches based on the value's class, unless the value is null,
+     * in which case, a search on class void is used.
+     * 
+     * @param value
+     *            for which an adapter is needed
+     * @return the adaptoer for the value
+     * @throws IllegalArgumentException
+     *             if no matching adapter may be found
+     */
+
+    public A getByInstance(Object value)
+    {
+        return get(value == null ? void.class : value.getClass());
+    }
+
+    /**
+     * Searches for an adapter corresponding to the given input type.
+     * 
+     * @param type
+     *            the type to search
+     * @return the corresponding adapter
+     * @throws IllegalArgumentException
+     *             if no matching adapter may be found
+     */
+    public A get(Class type)
+    {
+        A result = _cache.get(type);
+
+        if (result == null)
+        {
+            result = findMatch(type);
+            _cache.put(type, result);
+        }
+
+        return result;
+    }
+
+    private A findMatch(Class type)
+    {
+        for (Class t : new InheritanceSearch(type))
+        {
+            A result = _registrations.get(t);
+
+            if (result != null) return result;
+        }
+
+        // Report the error. These things really confused the hell out of people in Tap4, so we're
+        // going the extra mile on the exception message.
+
+        List<String> names = newList();
+        for (Class t : _registrations.keySet())
+            names.add(t.getName());
+
+        throw new IllegalArgumentException(UtilMessages
+                .noStrategyAdapter(type, _adapterType, names));
+    }
+
+    @Override
+    public String toString()
+    {
+        return String.format("StrategyRegistry[%s]", _adapterType.getName());
+    }
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/util/UtilMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/util/UtilMessages.java?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/util/UtilMessages.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/util/UtilMessages.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,7 +14,10 @@
 
 package org.apache.tapestry.ioc.util;
 
+import java.util.Collection;
+
 import org.apache.tapestry.ioc.Messages;
+import org.apache.tapestry.ioc.internal.util.InternalUtils;
 import org.apache.tapestry.ioc.internal.util.MessagesImpl;
 
 /**
@@ -28,13 +31,13 @@
     {
     }
 
-    static String noStrategyAdapter(Class inputType, Class adapterType, String catalog)
+    static String noStrategyAdapter(Class inputType, Class adapterType, Collection<String> catalog)
     {
         return MESSAGES.format(
                 "no-strategy-adapter",
                 inputType.getName(),
                 adapterType.getName(),
-                catalog);
+                InternalUtils.joinSorted(catalog));
     }
 
     static String stackIsEmpty()

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/resources/org/apache/tapestry/ioc/internal/IOCStrings.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/resources/org/apache/tapestry/ioc/internal/IOCStrings.properties?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/resources/org/apache/tapestry/ioc/internal/IOCStrings.properties (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/resources/org/apache/tapestry/ioc/internal/IOCStrings.properties 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.
@@ -19,18 +19,14 @@
  The method has been ignored.
 decorator-method-wrong-return-type=Method %s is named like a service decorator method, \
   but the return type (%s) is not acceptible (try Object). The method has been ignored.
-missing-service=Service '%s' does not exist.
 builder-locked=The Registry Builder has created the Registry, further operations are not allowed.
-module-id-conflict=Module '%s' has already been defined. The duplicate definition will be ignored.
-no-such-module=Module '%s' does not exist. Please ensure that the JAR file for the module is on the classpath. Available modules: %s.
 service-wrong-interface=Service '%s' implements interface %s, which is not compatible with the requested type %s.
-instantiate-builder-error=Unable to instantiate class %s as builder for module '%s': %s
+instantiate-builder-error=Unable to instantiate class %s as a module builder: %s
 builder-method-error=Error invoking service builder method %s (for service '%s'): %s
 decorator-method-error=Error invoking service decorator method %s (for service '%s'): %s
 builder-method-returned-null=Builder method %s (for service '%s') returned null.
-service-is-private=Service '%s' is private, and may not be referenced outside of its containing module.
-no-service-matches-type=No (visible) service implements the interface %s.
-many-service-matches=Service interface %s is matched by %d (visible) services: %s.  \
+no-service-matches-type=No service implements the interface %s.
+many-service-matches=Service interface %s is matched by %d services: %s.  \
   Automatic dependency resolution requires that exactly one service implement the interface.
 unknown-lifecycle=Unknown service lifecycle '%s'.
 decorator-method-needs-delegate-parameter=Decorator methods must a parameter for the service delegate \
@@ -67,12 +63,15 @@
 generic-type-not-supported=Generic type '%s' is not supported. Only simple parameterized lists are \
   supported.
 error-building-service=Error building service proxy for service '%s' (at %s): %s
-no-public-constructors=Module builder for module '%s' (class %s) does not contain any public constructors.
-too-many-public-constructors=Module bulider for module '%s' (class %s) contains more than one public constructor. \
+no-public-constructors=Module builder class %s does not contain any public constructors.
+too-many-public-constructors=Module bulider class %s contains more than one public constructor. \
   The first constructor, %s, is being used. \
   You should change the class to have only a single public constructor.
-recursive-module-constructor=The constructor for module '%s' (class %s) is recursive: it depends on itself in some way. \
+recursive-module-constructor=The constructor for module class %s is recursive: it depends on itself in some way. \
   The constructor, %s, is in some way is triggering a service builder, decorator or contribution method within the class.
 registry-shutdown=Proxy for service %s is no longer active because the IOC Registry has been shut down.
 constructed-configuration=Constructed configuration: %s
-service-construction-failed=Construction of service %s failed: %s
\ No newline at end of file
+service-construction-failed=Construction of service %s failed: %s
+no-such-service=Service id '%s' is not defined by any module.  Defined services: %s.
+service-id-conflict=Service id '%s' has already been defined by %s and may not be redefined by %s. \
+ You should rename one of the service builder methods.
\ No newline at end of file

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=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/case.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/case.apt Sat Mar 10 18:00:22 2007
@@ -18,7 +18,7 @@
   
   []
   
-  Thus, <<<getService("foo.bar.Baz", Baz.class)>>> is preferred, but <<<getService("FOO.BAR.BAZ", Baz.class)>>> (or any variation thereof) will work just exactly as well.  This also extends to other naming conventions,
+  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,
   such as <<<contributeFoo>>> methods. It also applies to values inside annotations.
   
   Just case is ignored --

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/coerce.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/coerce.apt?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/coerce.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/coerce.apt Sat Mar 10 18:00:22 2007
@@ -41,8 +41,7 @@
   inform the TypeCoercer about this coercion.
   
 +---+    
-   @Contribute("tapestry.ioc.TypeCoercer")
-   public void contributeMoneyCoercion(Configuration<CoercionTuple> configuration)
+   public void contributeTypeCoercer(Configuration<CoercionTuple> configuration)
    {
      Coercion<BigDecimal, Money> coercion = new Coercion<BigDecimal, Money>()
      {

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/command.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/command.apt?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/command.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/command.apt Sat Mar 10 18:00:22 2007
@@ -32,7 +32,7 @@
 
   Because this pattern is used so often inside Tapestry, a built-in service exists
   to create implementations of the pattern as needed.  The
-  {{{apidocs/org/apache/tapestry/ioc/services/ChainBuilder.html}tapestry.ioc.ChainBuilder}}
+  {{{apidocs/org/apache/tapestry/ioc/services/ChainBuilder.html}ChainBuilder}}
   service takes care of all the work:
   
 +----+
@@ -55,7 +55,7 @@
   
 +----+
   public static MyChainService buildMyChainService(List<MyChainService> commands,
-    @InjectService("tapestry.ioc.ChainBuilder")
+    @InjectService("ChainBuilder")
     ChainBuilder chainBuilder)
   {
      return chainBuilder.build(MyChainService.class, commands);

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=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/configuration.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/configuration.apt Sat Mar 10 18:00:22 2007
@@ -53,7 +53,9 @@
 +------+
   @Contribute("FileServicerDispatcher")
   public static void contributeFileServicers(MappedConfiguration<String,FileServicer> configuration,
+  
     @InjectService("TextFileServicer") FileServicer textFileServicer,
+    
     @InjectService("PDFFileServicer") FileServicer pdfFileServicer,
   {
     configuration.add("txt", textFileServicer);
@@ -61,13 +63,11 @@
   }  
 +------+  
    
-  The <<extensibility>> comes from the fact that many different methods in all kinds 
-  of different module builder classes can make these contributions.  So, another module
-  might understand Microsoft Office formats:
+  The <<extensibility>> comes from the fact multiple modules may all contribute to the same
+  service configuration:
   
 +------+
-  @Contribute("some.module.FileServicerDispatcher")
-  public static void contributeOfficeFileServicers(MappedConfiguration<String,FileServicer> configuration)
+   public static void contributeFileServicers(MappedConfiguration<String,FileServicer> configuration)
   {
     configuration.add("doc", new WordFileServicer());
     configuration.add("ppt", new PowerPointFileServicer());
@@ -134,8 +134,7 @@
   {{{apidocs/org/apache/tapestry/ioc/Configuration.html}Configuration}} object:
   
 +------+
-  @Contribute("some.module.Startup")
-  public static void contributeStartups(Configuration<Runnable> configuration)
+  public static void contributeStartup(Configuration<Runnable> configuration)
   {
     configuration.add(new JMSStartup());
     configuration.add(new FileSystemStartup());
@@ -194,21 +193,18 @@
   {{{apidocs/org/apache/tapestry/ioc/OrderedConfiguration.html}OrderedConfiguration}}:
  
 +------+
-  @Contribute("some.module.Startup")
-  public static void contributeStartups(OrderedConfiguration<Runnable> configuration)
+  public static void contributeStartup(OrderedConfiguration<Runnable> configuration)
   {
     configuration.add("JMS", new JMSStartup());
-    configuration.add("FileSystem", new FileSystemStartup(), "after:*.CacheSetup");
+    configuration.add("FileSystem", new FileSystemStartup(), "after:CacheSetup");
   }    
 +------+
   
-  Often, you don't care about ordering, the first form of the add method is used then. The id value you
-  provide will be prefixed with the contributing module's id.  The ordering algorithm will find a spot for the
+  Often, you don't care about ordering, the first form of the add method is used then.   The ordering algorithm will find a spot for the
   object (here the JMSStartup instance) based on the constraints of other contributed objects.
   
   For the "FileSystem" contribution, a constraint has been specified, indicating
-  that FileSystem should be ordered after some other contribution named "CacheSetup"
-  in an unspecified module (the "*" part).  Any number of such
+  that FileSystem should be ordered after some other contribution named "CacheSetup". Any number of such
   {{{order.html}ordering constraints}} may be specified (the add() method accepts
   a variable number of arguments).
   
@@ -228,6 +224,11 @@
   the conflict), and ignore the conflicting value.
   
   The value may not be null.
+  
+  <<TODO:>> It is planned that for mapped configurations where the key is String, a 
+  {{{apidocs/org/apache/tapestry/ioc/util/CaseInsensitiveMap.html}CaseInsensitiveMap}}
+  will be used automatically, to help ensure that case insensitivity is automatic and pervasive. This has not yet been
+  implemented.
   
 Injecting Resources
 

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=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/decorator.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/decorator.apt Sat Mar 10 18:00:22 2007
@@ -57,10 +57,8 @@
 +---------------------+
 package org.example.myapp.services;
 
-import org.apache.tapestry.ioc.annotations.Id;
 import org.apache.tapestry.ioc.services.LoggingDecorator;
 
-@Id("myapp")
 public class MyAppModule
 {
   public static Indexer buildIndexer()
@@ -70,7 +68,8 @@
   
   public static <T> T decorateIndexer(Class<T> serviceInterface, T delegate, 
     String serviceId, Log serviceLog,
-    @InjectService("tapestry.ioc.LoggingDecorator")
+    
+    @InjectService("LoggingDecorator")
     LoggingDecorator decorator)
   {
     return decorator.build(serviceInterface, delegate, serviceId, serviceLog);
@@ -99,7 +98,7 @@
    and an interceptor factory that generates logging interceptors.
    
    The "heavy lifting" is provided by the factory, which will create a new interceptor
-   that logs methods entry before delegating to the core service implementation. The interceptor
+   that logs method entry before delegating to the core service implementation. The interceptor
    will also log method parameters, return values, and even log exceptions.
    
    The return value of the method is the new interceptor. You may return null if your
@@ -112,14 +111,12 @@
 +---------------------+
 package org.example.myapp.services;
 
-import org.apache.tapestry.ioc.annotations.Id;
 import org.apache.tapestry.ioc.services.LoggingDecorator;
 
-@Id("myapp")
 public class MyAppModule
 {
   public static Indexer buildIndexer(Class serviceInterface, Log serviceLog,
-    @InjectService("tapestry.ioc.LoggingDecorator")
+    @InjectService("LoggingDecorator")
     LoggingInterceptorFactory decorator)
   {
     return decorator.build(serviceInterface, serviceLog,  new IndexerImpl());
@@ -146,7 +143,7 @@
   @Match("*")
   public static <T> T decorateLogging(Class<T> serviceInterface, T delegate, 
     String serviceId, Log serviceLog,
-    @InjectService("tapestry.ioc.LoggingDecorator")
+    @InjectService("LoggingDecorator")
     LoggingDecorator decorator)
   {
     return decorator.build(serviceInterface, delegate, serviceId, serviceLog);
@@ -158,17 +155,21 @@
   logging for your data access and business logic services, you might end up with
   <<<@Match("Data*", "*Logic")>>> (based, of course, on how you name your services). 
   
-  For example, you might add <<<@Match("myapp.internal.*.*")>>> to match all services within
-  any of your application's internal modules.
-  
-  Thus, <<<@Match("*.*")>>> is dangerous, because it will match every (public) service in every
+  As the precending example showed, a simple "glob" matching is supported, where a asterisk ('*')
+  may be used at the start or end of the match string to match any number of characters.
+  As elsewhere, matching is case insensitive.
+
+
+  Thus, <<<@Match("*")>>> is dangerous, because it will match every (public) service in every
   module.  
   
-  <Note: It is not possible to decorate the services of the tapestry.ioc module.>
+  <Note: It is not possible to decorate the services of the TapestryIOCModule.>
   
   <Note: Another idea will be other ways of matching services: base on inheritance of the
   service interface and/or based on the presence of particular class annotations on the
-  service interface.>
+  service interface. None of this has been implemented yet, and can readily be accompllished
+  inside the decorator method (which will return null if it decides the service doesn't
+  need decoration).>
   
     
 Ordering of Decorators
@@ -185,10 +186,10 @@
    
 +---------------------+    
   @Match("*")
-  @Order("before:*.*")
+  @Order("before:*")
   public static <T> T decorateLogging(Class<T> serviceInterface, T delegate, 
     String serviceId, Log serviceLog,
-    @InjectService("tapestry.ioc.LoggingDecorator")
+    @InjectService("LoggingDecorator")
     LoggingDecorator decorator)
   {
     return decorator.build(serviceInterface, delegate, serviceId, serviceLog);
@@ -196,14 +197,13 @@
 +---------------------+     
    
    
-   "before:*.*" indicates that this decorator should come before any decorator in <any> module.
+   "before:*" indicates that this decorator should come before any decorator in <any> module.
    
-   <<Note:>> the ordering of decorators is in terms of the <effect> desired. In the earlier 
-   example, the order of the effects is logging, then timing, then security, then transactions
-   (then the core service implementation). Internally, the decorators are invoked
+   <<Note:>> the ordering of decorators is in terms of the <effect> desired.
+   Internally, the decorators are invoked
    last to first (since each once receives the "next" interceptor as its delegate).
    So the core service implementation is created (via a service builder method)
-   and that is passed to the transaction decorator method. The interceptor created there
-   is passed to the the security decorator, and so forth.
+   and that is passed to the last decorator method. The interceptor created there
+   is passed to the the next-to-last decorator method, and so forth.
 
     

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/index.apt?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/index.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/index.apt Sat Mar 10 18:00:22 2007
@@ -18,7 +18,7 @@
   specifically for use as the IoC container for Tapestry 4.  Tapestry 4 has met its goals for extensibility and configurability, largely
   because of HiveMind's flexibility.
   
-  Tapestry 5 extends on this, replacing HiveMind with a new container specifically build for Tapestry,
+  Tapestry 5 extends on this, replacing HiveMind with a new container specifically build for Tapestry 5,
   designed for greater ease of use, expressiveness and performance.  And it can be used seperately from the rest of Tapestry!
   
 * Why Not Spring?
@@ -27,15 +27,10 @@
   integrated {{{http://aspectj.org}AspectJ}} support, and a large number of libraries built on top of the container. Spring is an excellent
   <application> container, but lacks a number of features necessary for a <framework> container:
   
-  * Spring does not have the concept of a <namespace>.  The names of beans are simple and unqualified, which could lead to naming conflicts.
-  
   * Spring beans can be wired together by name (or id), but it is not possible to introduce additional naming abstractions. Tapestry 4's 
     "infrastructure:" abstraction was the key to allowing easy spot overrides of internal Tapestry services without having to
     duplicate the large web of interrelated services (nearly 200 in Tapestry 4.0).
-    
-  * Spring doesn't have a concept of <visibility>, whereby some service implementations are internal to a module (Spring doesn't
-    have modules), which makes it easier to create service facades.
-    
+        
   * Although Spring allows beans to be intercepted, it does so in the form of a new bean, leaving the un-intercepted bean visible
     (and subject to misuse).  HiveMind and Tapestry IoC "wrap" the service inside interceptors, preventing unintercepted access
     to the core service implementation.
@@ -148,17 +143,14 @@
   only be a single service per service interface, but in some situations, there may be many different services and service implementations
   all sharing the same service interface.
   
-  Services have a visibility: either public (the default) or private (only visible within the same module). 
   
-  Services are identified by a unique id, which combines an unqualified id for the service with the containing module's id (see below).
-  Typically, a service id matches the name of the service interface.
+  Services are identified by a unique id.  Typically, a service id matches the unqualified name of the service interface, but
+  this is simply a convention.
   
   Services are aggregated into <<modules>>:
-  
-  * A module defines a <<module id>> that is used as a prefix when naming services within the module. This is very much equivalent
-    to a Java package name.  Module ids must be unique within the registry of modules.
-    
-  * A module is defined by a <<module builder>>, a specific class containing static or instance methods.
+      
+  * A module is defined by a <<module builder>>, a specific class containing a mix of static or instance methods, used to define
+   services, decorate them (see below), or contribute to service configurations (again, more below).
   
   * Methods of the module builder class define the services provided by the module, 
     and the same methods are responsible
@@ -169,7 +161,8 @@
   The methods which define and construct services are called <<service builder methods>>.
   
   The <<registry>> is the outside world's view of the modules and services. From the registry, it is possible to obtain
-  a service, via its qualified id or by its service interface. 
+  a service, via its unique id or by its service interface.  Access by unique id is <caseless> (meaning, a match will be found
+  even the case of the search key doesn't match the case of the service itself). 
     
     
   Services may be <<decorated>> by <<service decorator methods>>.  These methods create
@@ -187,10 +180,11 @@
   to linked pairs of similarily named services and configurations. For Tapestry IoC, each service is allowed to have a single configuration,
   which is normally sufficient.>
   
-  Services are typically instantiated as needed. In this case, "need" translates to "when a method of the service is invoked".
-  In nearly all cases, a service is represented (to the outside world, or to other services) as a <<proxy>> that implements
-  the service interface. The first time a method is invoked on the proxy, the full service (implementation and interceptors) is
-  constructed. This occurs in a completely <<thread-safe>> manner.
+  Services are instantiated as needed. In this case, "need" translates to "when a method of the service is invoked".
+  A service is represented (to the outside world, or to other services) as a <<proxy>> that implements
+  the service interface. The first time a method is invoked on the proxy, the full service (consisting of the core service implementation wrapped with any interceptors) is
+  constructed. This occurs in a completely <<thread-safe>> manner. Just-in-time instantiation allows for more complex, more finely grained networks of services, and improves
+  startup time.
   
   Services define a <<lifecycle>> that controls when the service is constructed.  The default lifecycle is <<singleton>>, meaning a single
   global instance created as needed.  Other lifecycles allow service implementations to be bound to the current thread (i.e., the current

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=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/module.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/module.apt Sat Mar 10 18:00:22 2007
@@ -25,51 +25,25 @@
 }
 +-----------------------------------------------------------------------------------+
 
-  By default, a module's id is the same as its package name (we'll see how to override
-  that shortly).  Here the module id will be org.example.myapp.services.
-
   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
   the Indexer service interface (presumably also in the org.example.myapp.services
   package).
 
-  The service's unqualified id (the part after the module id) is derived from the method name.
-  Here "build" was stripped off of "buildIndexer", leaving "Indexer".  That's the unqualified id.
-  Prefixing with the module id results in the fully qualfied id 
-  org.example.myapp.services.Indexer.
+  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
+  refer to this service as "indexer" or "INDEXER" or any variation thereof, and connect to
+  this service.
+  
+  Service ids must be unique; if another module contributes a service with the id "Indexer" 
+  (or any case variation thereof) a runtime exception will occur when the Registry is created.
 
   We could extend this example by adding additional service builder methods, or by showing
   how to inject dependencies. See {{{service.html#Injecting Dependencies}the service documentation}} 
   for more details.
-
-Overriding the Module id
-
-  Adding an {{{apidocs/org/apache/tapestry/ioc/annotations/Id.html}@Id annnotation}}
-  to the module builder class will control the module's id.
-  
-+-----------------------------------------------------------------------------------+
-package org.example.myapp.services;
-
-import org.apache.tapestry.ioc.annotations.Id;
-
-@Id("myapp")
-public class MyAppModule
-{
-  public static Indexer buildIndexer()
-  {
-    return new IndexerImpl();
-  }
-}
-+-----------------------------------------------------------------------------------+
-
-  This time, the module's id is "myapp" and the service's id is "myapp.Indexer".
-  
-  Remember that module ids must be unique, no other module builder class, even one
-  in a different package, may declare the id "myapp", or runtime warnings or
-  errors will occur.
-  
   
-{Caching Services}
+{Cacheing Services}
 
   You will often find yourself in the position of injecting the same services
   into your service builder or service decorator methods repeatedly. This can be quite
@@ -90,6 +64,7 @@
   public MyModule(
     @Inject("service:JobScheduler")
     JobScheduler scheduler, 
+    
     @Inject("service:FileSystem")
     FileSystem fileSystem)
   {
@@ -115,15 +90,21 @@
 
   In addition to injecting dependencies with the @InjectService and @Inject annotations,
   you may also inject a number of <module> resources:
-  
-  * java.lang.String: the module id
-    
-  * org.apache.commons.logging.Log: log for the module
+      
+  * org.apache.commons.logging.Log: log for the module (derived from the module's class name)
    
   * {{{apidocs/org/apache/tapestry/ioc/ServiceLocator.html}ServiceLocator}}:  access to other services
   
   []
   
+  Note that the fields are final: this is important. Tapestry IoC is thread-safe and you largely
+  never have to think about concurrency issues. But in a busy application, different services may be
+  built by different threads simultaneously. Each module builder class is instantiated at most once, and
+  making these fields final ensures that the values are available across multiple threads.
+  Refer to Brian Goetz's {{{http://www.javaconcurrencyinpractice.com/}Java Concurrency in Practice}}
+  for a more complete explantation of the relationship between final fields, constructors, and threads ...
+  or just trust us!
+  
   Care should be taken with this approach: in some circustances, you may force a situtation in which
   the module constructor is dependent on itself. For example, if you invoke a method on any injected services
   defined within the same module from the module builder's constructor,
@@ -199,7 +180,6 @@
   exactly as if they were identified in the manifest.  For example:
   
 +----+
-@Id("tapestry.internal.services")
 @SubModule(
 { InternalTransformModule.class })
 public final class InternalModule

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/order.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/order.apt?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/order.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/order.apt Sat Mar 10 18:00:22 2007
@@ -34,8 +34,6 @@
   Often a single contribution will have more than one constraint.
   
 Constraint Types
-
-  Constraint types can be "before" or "after".
   
   Each constraint string begins with a prefix, "before:" or "after:", used to
   identify  the type of constraint.
@@ -52,15 +50,7 @@
   appear at the start, or end, or both of the pattern, and will match zero or more
   characters there.  Thus you can have patterns such as "Data*" or "*Logic" or even "*User*".
 
-  Patterns that do not contain a period ('.') character are <simple> patterns; simple patterns
-  only match within their own module.  When a period does exist, it is the seperator between
-  the module id pattern and the service id pattern.  When there is more than one period, it is
-  the <last> period that is the divider (which makes sense, as unqualified service ids
-  can't contain a period).
-  
-  Because a pattern with a period in it is really <two> patterns, you can create patterns like 
-  "app.internal*.*Data".  This matches services whose id ends with "Data" inside modules whose id
-  starts with "app.internal".
+  Matching is case insensitive.
 
   
   

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=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/pipeline.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/pipeline.apt Sat Mar 10 18:00:22 2007
@@ -59,7 +59,7 @@
 +-----+  
 
   The
-  {{{apidocs/org/apache/tapestry/ioc/services/PipelineBuilder.html}tapestry.ioc.PipelineBuilder}}
+  {{{apidocs/org/apache/tapestry/ioc/services/PipelineBuilder.html}PipelineBuilder}}
   service is useful for constructing pipelines. The service is often injected
   into a service builder method, along with an ordered configuration of services.
   
@@ -73,7 +73,7 @@
   
 +-----+
   public static StringTransformService buildStringTransform(
-    @InjectService("tapestry.ioc.PipelineBuilder")
+    @InjectService("PipelineBuilder")
     PipelineBuilder builder,
     List<StringTransformFilter> configuration,
     Log serviceLog)

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/provider.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/provider.apt?view=diff&rev=516840&r1=516839&r2=516840
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/provider.apt (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/apt/provider.apt Sat Mar 10 18:00:22 2007
@@ -17,25 +17,24 @@
   understands the expression.
   
   In practice, @InjectService("Foo") and @Inject("service:Foo") work identically,
-  even with regards to the relative visibility of 
-  private services.  Here, the provider prefix is "service" and the expression
+  Here, the provider prefix is "service" and the expression
   is "Foo".
   
 * service provider
 
   As outlined above, the service provider interprets the expression as
-  a service id, either fully qualified or local.
+  a service id.
   
 * infrastructure provider
 
   The tapestry module (provided by the {{{http://tapestry.apache.org/tapestry5/tapestry-core/}tapestry-core library}}) provides the
-  {{{http://tapestry.apache.org/tapestry5/tapestry-core/guide/infrastructure.html}infrastructure}} object provider, which exists
-  to provide shorter names for injecting services and to support overrides.  
+  {{{http://tapestry.apache.org/tapestry5/tapestry-core/guide/infrastructure.html}infrastructure}} object provider, which to allow
+  for various forms of overrides.
     
 * default provider  
   
   If the string does not contain a prefix, then the value is treated as a literal string.
-  It will be coerced to the proper type (such as int or long).
+  It will be {{{coerce.html}coerced}} to the proper type (such as int or long).
   
 Defining New Providers
 
@@ -47,8 +46,7 @@
   Example:
   
 +-----+
-  @Contribution("tapestry.ioc.MasterObjectProvider")
-  public void contributeMyProvider(MappedConfiguration<String,ObjectProvider> configuration)
+  public void contributeMasterObjectProvider(MappedConfiguration<String,ObjectProvider> configuration)
   {
     configuration.add("myprefix", new MyObjectProvider());
   }