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 2006/07/20 15:41:21 UTC

svn commit: r423932 - in /tapestry/tapestry5/tapestry-core/trunk/src: main/java/org/apache/tapestry/internal/ioc/ main/java/org/apache/tapestry/internal/test/ main/java/org/apache/tapestry/internal/util/ main/java/org/apache/tapestry/ioc/ main/java/org...

Author: hlship
Date: Thu Jul 20 06:41:19 2006
New Revision: 423932

URL: http://svn.apache.org/viewvc?rev=423932&view=rev
Log:
Strip out the ErrorLog class: services can use a Log or throw a RuntimeException on their own.
Introduce a factory, LogSource, for Logs.

Added:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/LogSource.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/LogSourceImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/LogSourceImplTest.java
Removed:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/ErrorLog.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/ErrorLogImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/ErrorLogImplTest.java
Modified:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/BasicServiceCreator.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/InternalRegistry.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/RegistryImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceResourcesImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/DependencyNode.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/Orderer.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/IOCUtilities.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/RegistryBuilder.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/ServiceResources.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TestBase.java
    tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/decorator.apt
    tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/service.apt
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/BasicServiceCreatorTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/InterceptorStackBuilderTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/util/OrdererTest.java

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/BasicServiceCreator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/BasicServiceCreator.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/BasicServiceCreator.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/BasicServiceCreator.java Thu Jul 20 06:41:19 2006
@@ -21,7 +21,6 @@
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
-import org.apache.tapestry.ioc.ErrorLog;
 import org.apache.tapestry.ioc.ServiceCreator;
 import org.apache.tapestry.ioc.ServiceResources;
 
@@ -40,8 +39,6 @@
 
     private final Map<Class, Object> _parameterDefaults = newMap();
 
-    private final ErrorLog _log;
-
     private final ServiceResources _resources;
 
     private final Method _builderMethod;
@@ -51,12 +48,10 @@
         _serviceId = resources.getServiceId();
         _builderMethod = method;
         _moduleBuilder = moduleBuilder;
-        _log = resources.getErrorLog();
         _resources = resources;
 
         _parameterDefaults.put(String.class, _serviceId);
         _parameterDefaults.put(ServiceResources.class, resources);
-        _parameterDefaults.put(ErrorLog.class, _log);
         _parameterDefaults.put(Log.class, resources.getServiceLog());
         _parameterDefaults.put(Class.class, resources.getServiceInterface());
     }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImpl.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImpl.java Thu Jul 20 06:41:19 2006
@@ -28,8 +28,8 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.commons.logging.Log;
 import org.apache.hivemind.util.IdUtils;
-import org.apache.tapestry.ioc.ErrorLog;
 import org.apache.tapestry.ioc.IOCConstants;
 import org.apache.tapestry.ioc.annotations.After;
 import org.apache.tapestry.ioc.annotations.Before;
@@ -55,7 +55,7 @@
 
     private final Class _builderClass;
 
-    private final ErrorLog _log;
+    private final Log _log;
 
     /** Keyed on fully qualified service id. */
     private final Map<String, ServiceDef> _serviceDefs = newMap();
@@ -70,7 +70,7 @@
      *            the class that is responsible for building services, etc.
      * @param log
      */
-    public DefaultModuleDefImpl(Class builderClass, ErrorLog log)
+    public DefaultModuleDefImpl(Class builderClass, Log log)
     {
         _builderClass = builderClass;
         _log = log;

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/InternalRegistry.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/InternalRegistry.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/InternalRegistry.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/InternalRegistry.java Thu Jul 20 06:41:19 2006
@@ -16,6 +16,7 @@
 
 import java.util.List;
 
+import org.apache.tapestry.ioc.LogSource;
 import org.apache.tapestry.ioc.Registry;
 import org.apache.tapestry.ioc.ServiceDecorator;
 import org.apache.tapestry.ioc.ServiceLifecycle;
@@ -26,7 +27,7 @@
  * 
  * @author Howard M. Lewis Ship
  */
-public interface InternalRegistry extends Registry
+public interface InternalRegistry extends Registry, LogSource
 {
     /**
      * Locates a service given a fully qualified service id and the corresponding service interface

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/RegistryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/RegistryImpl.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/RegistryImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/RegistryImpl.java Thu Jul 20 06:41:19 2006
@@ -22,8 +22,10 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.logging.Log;
 import org.apache.hivemind.util.IdUtils;
 import org.apache.tapestry.internal.annotations.SuppressNullCheck;
+import org.apache.tapestry.ioc.LogSource;
 import org.apache.tapestry.ioc.Registry;
 import org.apache.tapestry.ioc.ServiceDecorator;
 import org.apache.tapestry.ioc.ServiceLifecycle;
@@ -36,6 +38,8 @@
  */
 public class RegistryImpl implements Registry, InternalRegistry
 {
+    private final LogSource _logSource;
+
     /** Keyed on module id. */
     private final Map<String, Module> _modules = newMap();
 
@@ -46,8 +50,10 @@
         _lifecycles.put("primitive", new PrimitiveServiceLifecycle());
     }
 
-    public RegistryImpl(Collection<ModuleDef> moduleDefs)
+    public RegistryImpl(Collection<ModuleDef> moduleDefs, LogSource logSource)
     {
+        _logSource = logSource;
+
         for (ModuleDef def : moduleDefs)
         {
             Module module = new ModuleImpl(this, def);
@@ -142,4 +148,13 @@
         return newList();
     }
 
+    public Log getLog(Class clazz)
+    {
+        return _logSource.getLog(clazz);
+    }
+
+    public Log getLog(String name)
+    {
+        return _logSource.getLog(name);
+    }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImpl.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImpl.java Thu Jul 20 06:41:19 2006
@@ -21,7 +21,6 @@
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
-import org.apache.tapestry.ioc.ErrorLog;
 import org.apache.tapestry.ioc.ServiceDecorator;
 import org.apache.tapestry.ioc.ServiceResources;
 
@@ -38,7 +37,7 @@
 
     private final Map<Class, Object> _parameterDefaults = newMap();
 
-    private final ErrorLog _log;
+    private final Log _log;
 
     private final ServiceResources _resources;
 
@@ -51,14 +50,13 @@
         _serviceId = resources.getServiceId();
         _decoratorMethod = method;
         _moduleBuilder = moduleBuilder;
-        _log = resources.getErrorLog();
         _resources = resources;
         _serviceInterface = resources.getServiceInterface();
+        _log = resources.getServiceLog();
 
         _parameterDefaults.put(String.class, _serviceId);
         _parameterDefaults.put(ServiceResources.class, resources);
-        _parameterDefaults.put(ErrorLog.class, _log);
-        _parameterDefaults.put(Log.class, resources.getServiceLog());
+        _parameterDefaults.put(Log.class, _log);
         _parameterDefaults.put(Class.class, _serviceInterface);
     }
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceResourcesImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceResourcesImpl.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceResourcesImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceResourcesImpl.java Thu Jul 20 06:41:19 2006
@@ -15,9 +15,6 @@
 package org.apache.tapestry.internal.ioc;
 
 import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.tapestry.ioc.ErrorLog;
-import org.apache.tapestry.ioc.ErrorLogImpl;
 import org.apache.tapestry.ioc.ServiceResources;
 import org.apache.tapestry.ioc.def.ServiceDef;
 
@@ -36,13 +33,12 @@
 
     private Log _log;
 
-    private ErrorLog _errorLog;
-
     public ServiceResourcesImpl(InternalRegistry registry, Module module, ServiceDef serviceDef)
     {
         _registry = registry;
         _module = module;
         _serviceDef = serviceDef;
+        _log = registry.getLog(serviceDef.getServiceId());
     }
 
     public String getServiceId()
@@ -65,19 +61,8 @@
         return _registry.getService(serviceInterface, _module);
     }
 
-    public synchronized ErrorLog getErrorLog()
-    {
-        if (_errorLog == null)
-            _errorLog = new ErrorLogImpl(getServiceLog());
-
-        return _errorLog;
-    }
-
-    public synchronized Log getServiceLog()
+    public Log getServiceLog()
     {
-        if (_log == null)
-            _log = LogFactory.getLog(getServiceId());
-
         return _log;
     }
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java Thu Jul 20 06:41:19 2006
@@ -16,19 +16,26 @@
 
 import java.util.List;
 
+import org.apache.commons.logging.Log;
 import org.apache.tapestry.internal.InternalComponentResources;
+import org.apache.tapestry.internal.annotations.SuppressNullCheck;
 import org.apache.tapestry.internal.ioc.InternalRegistry;
 import org.apache.tapestry.internal.ioc.Module;
 import org.apache.tapestry.internal.parser.ComponentTemplate;
+import org.apache.tapestry.ioc.LogSource;
 import org.apache.tapestry.ioc.ServiceDecorator;
 import org.apache.tapestry.ioc.ServiceLifecycle;
+import org.apache.tapestry.ioc.def.ServiceDef;
 import org.apache.tapestry.test.BaseTestCase;
+import org.apache.tapestry.util.CollectionFactory;
+import org.easymock.EasyMock;
 
 /**
  * Contains additional factory and training methods related to internal interfaces.
  * 
  * @author Howard M. Lewis Ship
  */
+@SuppressNullCheck
 public class InternalBaseTestCase extends BaseTestCase
 {
 
@@ -42,20 +49,23 @@
         return newMock(ComponentTemplate.class);
     }
 
-    protected final <T> void trainGetService(InternalRegistry registry, String serviceId, Class<T> serviceInterface, Module module, T service)
+    protected final <T> void trainGetService(InternalRegistry registry, String serviceId,
+            Class<T> serviceInterface, Module module, T service)
     {
         registry.getService(serviceId, serviceInterface, module);
         setReturnValue(service);
-    
+
     }
 
-    protected final void trainGetLifecycle(InternalRegistry registry, String name, ServiceLifecycle lifecycle)
+    protected final void trainGetLifecycle(InternalRegistry registry, String name,
+            ServiceLifecycle lifecycle)
     {
         registry.getServiceLifecycle(name);
         setReturnValue(lifecycle);
     }
 
-    protected final void trainFindDecoratorsForService(Module module, String serviceId, List<ServiceDecorator> decorators)
+    protected final void trainFindDecoratorsForService(Module module, String serviceId,
+            List<ServiceDecorator> decorators)
     {
         module.findDecoratorsForService(serviceId);
         setReturnValue(decorators);
@@ -66,7 +76,8 @@
         return newMock(Module.class);
     }
 
-    protected final void trainCreateInterceptor(ServiceDecorator decorator, Object coreObject, Object interceptor)
+    protected final void trainCreateInterceptor(ServiceDecorator decorator, Object coreObject,
+            Object interceptor)
     {
         decorator.createInterceptor(coreObject);
         setReturnValue(interceptor);
@@ -75,5 +86,17 @@
     protected final ServiceDecorator newServiceDecorator()
     {
         return newMock(ServiceDecorator.class);
+    }
+
+    protected void trainFindDecoratorsForService(InternalRegistry registry)
+    {
+        registry.findDecoratorsForService(EasyMock.isA(ServiceDef.class));
+        setReturnValue(CollectionFactory.newList());
+    }
+
+    protected final void trainGetLog(LogSource source, String serviceId, Log log)
+    {
+        source.getLog(serviceId);
+        setReturnValue(log);
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/DependencyNode.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/DependencyNode.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/DependencyNode.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/DependencyNode.java Thu Jul 20 06:41:19 2006
@@ -21,8 +21,8 @@
 
 import java.util.List;
 
+import org.apache.commons.logging.Log;
 import org.apache.tapestry.internal.annotations.SuppressNullCheck;
-import org.apache.tapestry.ioc.ErrorLog;
 import org.apache.tapestry.ioc.Orderable;
 
 /**
@@ -34,15 +34,15 @@
 @SuppressNullCheck
 class DependencyNode<T>
 {
-    private final ErrorLog _errorLog;
+    private final Log _log;
 
     private final Orderable<T> _orderable;
 
     private final List<DependencyNode<T>> _dependencies = newList();
 
-    DependencyNode(ErrorLog errorLog, Orderable<T> orderable)
+    DependencyNode(Log errorLog, Orderable<T> orderable)
     {
-        _errorLog = errorLog;
+        _log = errorLog;
         _orderable = orderable;
     }
 
@@ -81,7 +81,7 @@
         if (node.isReachable(this))
         {
             String message = UtilMessages.dependencyCycle(node, this);
-            _errorLog.warn(message, null);
+            _log.warn(message, null);
             return;
         }
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/Orderer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/Orderer.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/Orderer.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/util/Orderer.java Thu Jul 20 06:41:19 2006
@@ -20,9 +20,9 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.logging.Log;
 import org.apache.hivemind.util.StringUtils;
 import org.apache.tapestry.internal.annotations.SuppressNullCheck;
-import org.apache.tapestry.ioc.ErrorLog;
 import org.apache.tapestry.ioc.Orderable;
 
 /**
@@ -33,7 +33,7 @@
  */
 public class Orderer<T>
 {
-    private final ErrorLog _errorLog;
+    private final Log _log;
 
     private final List<Orderable> _orderables = newList();
 
@@ -45,9 +45,9 @@
 
     private DependencyNode<T> _trailer;
 
-    public Orderer(ErrorLog errorLog)
+    public Orderer(Log log)
     {
-        _errorLog = errorLog;
+        _log = log;
     }
 
     public void add(Orderable<T> orderable)
@@ -56,7 +56,7 @@
 
         if (_orderablesById.containsKey(id))
         {
-            _errorLog.warn(UtilMessages.duplicateOrderer(id), null);
+            _log.warn(UtilMessages.duplicateOrderer(id), null);
             return;
         }
 
@@ -103,10 +103,10 @@
         addNodes();
 
         if (_leader == null)
-            _leader = new DependencyNode(_errorLog, new Orderable<T>("*-leader-*", null));
+            _leader = new DependencyNode(_log, new Orderable<T>("*-leader-*", null));
 
         if (_trailer == null)
-            _trailer = new DependencyNode(_errorLog, new Orderable<T>("*-trailer-*", null));
+            _trailer = new DependencyNode(_log, new Orderable<T>("*-trailer-*", null));
 
         addDependencies();
     }
@@ -115,7 +115,7 @@
     {
         for (Orderable<T> orderable : _orderables)
         {
-            DependencyNode<T> node = new DependencyNode<T>(_errorLog, orderable);
+            DependencyNode<T> node = new DependencyNode<T>(_log, orderable);
 
             _dependencyNodesById.put(orderable.getId(), node);
 
@@ -125,7 +125,7 @@
                     _leader = node;
                 else
                 {
-                    _errorLog.warn(UtilMessages.duplicateLeader(node, _leader), null);
+                    _log.warn(UtilMessages.duplicateLeader(node, _leader), null);
                 }
             }
 
@@ -135,7 +135,7 @@
                     _trailer = node;
                 else
                 {
-                    _errorLog.warn(UtilMessages.duplicateTrailer(node, _trailer), null);
+                    _log.warn(UtilMessages.duplicateTrailer(node, _trailer), null);
                 }
             }
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/IOCUtilities.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/IOCUtilities.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/IOCUtilities.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/IOCUtilities.java Thu Jul 20 06:41:19 2006
@@ -65,7 +65,7 @@
         }
         catch (Exception ex)
         {
-            builder.getErrorLog().fail(ex.getMessage(), ex);
+            throw new RuntimeException(ex.getMessage(), ex);
         }
     }
 

Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/LogSource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/LogSource.java?rev=423932&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/LogSource.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/LogSource.java Thu Jul 20 06:41:19 2006
@@ -0,0 +1,32 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.ioc;
+
+import org.apache.commons.logging.Log;
+
+/**
+ * A wrapper around commons-logging's LogFactory that exists to allow particular projects to "hook"
+ * the creation of Log instances.
+ * 
+ * @author Howard M. Lewis Ship
+ */
+public interface LogSource
+{
+    /** Creates or retrieves a log based on Class. This is rarely used in Tapestry IOC. */
+    Log getLog(Class clazz);
+
+    /** Creates or retrieves a log based on name. Typically, the name will be a service id. */
+    Log getLog(String name);
+}

Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/LogSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/LogSourceImpl.java?rev=423932&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/LogSourceImpl.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/LogSourceImpl.java Thu Jul 20 06:41:19 2006
@@ -0,0 +1,39 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.ioc;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Simple wrapper around {@link org.apache.commons.logging.LogFactory}. The concept here is that
+ * Log implementations could be provided that promote warnings or errors upto thrown exceptions, for
+ * people who like their IOC container extra finicky.
+ * 
+ * @author Howard M. Lewis Ship
+ */
+public class LogSourceImpl implements LogSource
+{
+    public Log getLog(Class clazz)
+    {
+        return LogFactory.getLog(clazz);
+    }
+
+    public Log getLog(String name)
+    {
+        return LogFactory.getLog(name);
+    }
+
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/RegistryBuilder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/RegistryBuilder.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/RegistryBuilder.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/RegistryBuilder.java Thu Jul 20 06:41:19 2006
@@ -14,17 +14,16 @@
 
 package org.apache.tapestry.ioc;
 
+import static org.apache.tapestry.util.CollectionFactory.newMap;
+
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.tapestry.internal.ioc.DefaultModuleDefImpl;
 import org.apache.tapestry.internal.ioc.IOCMessages;
 import org.apache.tapestry.internal.ioc.RegistryImpl;
 import org.apache.tapestry.ioc.def.ModuleDef;
 
-import static org.apache.tapestry.util.CollectionFactory.newMap;
-
 /**
  * Used to construct the IoC {@link org.apache.tapestry.ioc.Registry}. This class is <em>not</em>
  * threadsafe. The registry, once created, <em>is</em> threadsafe.
@@ -36,14 +35,14 @@
     /** Module defs, keyed on module id. */
     final Map<String, ModuleDef> _modules = newMap();
 
-    private final ErrorLog _errorLog;
-
     private final ClassLoader _classLoader;
 
     private final Log _log;
 
     private boolean _locked;
 
+    private final LogSource _logSource;
+
     public RegistryBuilder()
     {
         this(Thread.currentThread().getContextClassLoader());
@@ -51,19 +50,14 @@
 
     public RegistryBuilder(ClassLoader classLoader)
     {
-        this(classLoader, LogFactory.getLog(RegistryBuilder.class));
+        this(classLoader, new LogSourceImpl());
     }
 
-    public RegistryBuilder(ClassLoader classLoader, Log log)
-    {
-        this(classLoader, log, new ErrorLogImpl(log));
-    }
-
-    public RegistryBuilder(ClassLoader classLoader, Log log, ErrorLog errorLog)
+    public RegistryBuilder(ClassLoader classLoader, LogSource logSource)
     {
         _classLoader = classLoader;
-        _log = log;
-        _errorLog = errorLog;
+        _logSource = logSource;
+        _log = logSource.getLog(RegistryBuilder.class);
     }
 
     public void add(ModuleDef moduleDef)
@@ -74,7 +68,7 @@
 
         if (_modules.containsKey(id))
         {
-            _errorLog.warn(IOCMessages.moduleIdConflict(id), null);
+            _log.warn(IOCMessages.moduleIdConflict(id), null);
             return;
         }
 
@@ -85,7 +79,7 @@
     {
         for (Class c : moduleBuilderClasses)
         {
-            ModuleDef def = new DefaultModuleDefImpl(c, _errorLog);
+            ModuleDef def = new DefaultModuleDefImpl(c, _log);
             add(def);
         }
     }
@@ -118,17 +112,12 @@
 
         // TODO: Consistency checks, once we have interceptors and contributions
 
-        return new RegistryImpl(_modules.values());
+        return new RegistryImpl(_modules.values(), _logSource);
     }
 
     public ClassLoader getClassLoader()
     {
         return _classLoader;
-    }
-
-    public ErrorLog getErrorLog()
-    {
-        return _errorLog;
     }
 
     public Log getLog()

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/ServiceResources.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/ServiceResources.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/ServiceResources.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/ServiceResources.java Thu Jul 20 06:41:19 2006
@@ -65,9 +65,6 @@
      */
     <T> T getService(Class<T> serviceInterface);
 
-    /** Returns an error log appropriate for the service. */
-    ErrorLog getErrorLog();
-
     /**
      * Returns a Log object appropriate for logging messages. Use of {@link #getErrorLog()} is
      * better, but that's only for error situations, not ordinary logging (for debug of

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java Thu Jul 20 06:41:19 2006
@@ -30,7 +30,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.hivemind.Resource;
 import org.apache.tapestry.internal.annotations.SuppressNullCheck;
-import org.apache.tapestry.ioc.ErrorLog;
 import org.apache.tapestry.ioc.ServiceCreator;
 import org.apache.tapestry.ioc.ServiceResources;
 import org.apache.tapestry.ioc.def.ServiceDef;
@@ -77,11 +76,6 @@
         return newMock(ClassTransformation.class);
     }
 
-    protected final Log newLog()
-    {
-        return newMock(Log.class);
-    }
-
     protected final void trainAddInjectedField(ClassTransformation ct, Class type,
             String suggestedName, Object value, String fieldName)
     {
@@ -157,12 +151,6 @@
     {
         def.getServiceInterface();
         setReturnValue(serviceInterface);
-    }
-
-    protected final void trainGetErrorLog(ServiceResources resources, ErrorLog log)
-    {
-        resources.getErrorLog();
-        setReturnValue(log);
     }
 
     protected final void trainGetServiceId(ServiceDef def, String serviceId)

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TestBase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TestBase.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TestBase.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TestBase.java Thu Jul 20 06:41:19 2006
@@ -14,15 +14,15 @@
 
 package org.apache.tapestry.test;
 
+import static org.easymock.EasyMock.expectLastCall;
+import static org.testng.Assert.fail;
+
+import org.apache.commons.logging.Log;
 import org.apache.tapestry.internal.annotations.SuppressNullCheck;
-import org.apache.tapestry.ioc.ErrorLog;
 import org.easymock.EasyMock;
 import org.easymock.IMocksControl;
 import org.testng.annotations.Configuration;
 
-import static org.easymock.EasyMock.expectLastCall;
-import static org.testng.Assert.fail;
-
 /**
  * Manages a set of EasyMock mock objects. Used as a base class for test cases.
  * 
@@ -111,9 +111,8 @@
         fail("This code should not be reachable.");
     }
 
-    protected final ErrorLog newErrorLog()
+    protected final Log newLog()
     {
-        return newMock(ErrorLog.class);
+        return newMock(Log.class);
     }
-
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/decorator.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/decorator.apt?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/decorator.apt (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/decorator.apt Thu Jul 20 06:41:19 2006
@@ -52,11 +52,11 @@
     return new IndexerImpl();
   }
   
-  public Object decorateIndexer(Object service, Class serviceInterface, Log serviceLog,
+  public <T> T decorateIndexer(Class<T> serviceInterface, T delegate, Log serviceLog,
     @InjectService("tapestry.ioc.LoggingInterceptorFactory")
     LoggingInterceptorFactory factory)
   {
-    return factory.createLoggingInterceptor(serviceInterface, serviceLog, service);
+    return factory.createLoggingInterceptor(serviceInterface, serviceLog, delegate);
   } 
 }
 +---------------------+
@@ -66,6 +66,11 @@
    even if there are other services in this module or others ... this is because
    of the name match ("decorateIndexer" and "buildIndexer"), but we'll shortly see how
    annotations can be used to target many services for decoration.
+   
+   We are using the parameterized types here (the \<T\>), to reinforce the fact that the delegate object
+   passed in (which will be the core service implementation, or some other interceptor)
+   must implement the service interface, and that the decorator method must return an
+   instance of the service interface.
    
    The values that may be provided to a decorator method are exactly the same as for a builder
    method, with one addition:  The underlying service will be passed in

Modified: tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/service.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/service.apt?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/service.apt (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/service.apt Thu Jul 20 06:41:19 2006
@@ -89,10 +89,8 @@
   other things to be injected.
   
   * java.lang.String: fully qualified service id for the service being created
-  
-  * {{{../apidocs/org/apache/tapestry/ioc/ErrorLog.html}ErrorLog}}: to which errors and warnings can be logged
-  
-  * org.apache.commons.logging.Log: to which normal service logging can occur
+    
+  * org.apache.commons.logging.Log: to which service logging can occur
   
   * java.lang.Class: service interface implemented by the service to be constructed
   

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/BasicServiceCreatorTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/BasicServiceCreatorTest.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/BasicServiceCreatorTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/BasicServiceCreatorTest.java Thu Jul 20 06:41:19 2006
@@ -21,8 +21,8 @@
 import java.lang.reflect.Method;
 
 import org.apache.commons.logging.Log;
+import org.apache.hivemind.ErrorLog;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
-import org.apache.tapestry.ioc.ErrorLog;
 import org.apache.tapestry.ioc.ServiceCreator;
 import org.apache.tapestry.ioc.ServiceResources;
 import org.apache.tapestry.ioc.annotations.InjectService;
@@ -42,8 +42,6 @@
 
     private ServiceResources _expectedServiceResources;
 
-    private ErrorLog _expectedErrorLog;
-
     private Class _expectedServiceInterface;
 
     private Log _expectedLog;
@@ -71,11 +69,10 @@
     public void noargs_method()
     {
         ServiceResources resources = newServiceResources();
-        ErrorLog errorLog = newErrorLog();
         Log log = newLog();
         _fie = newFieService();
 
-        trainForConstructor(resources, errorLog, log);
+        trainForConstructor(resources, log);
 
         replay();
 
@@ -88,12 +85,10 @@
         verify();
     }
 
-    private void trainForConstructor(ServiceResources resources, ErrorLog errorLog, Log log)
+    private void trainForConstructor(ServiceResources resources, Log log)
     {
         trainGetServiceId(resources, SERVICE_ID);
 
-        trainGetErrorLog(resources, errorLog);
-
         trainGetServiceLog(resources, log);
 
         trainGetServiceInterface(resources, FieService.class);
@@ -103,10 +98,8 @@
     public void method_with_args()
     {
         ServiceResources resources = newServiceResources();
-        ErrorLog errorLog = newErrorLog();
         Log log = newLog();
 
-        _expectedErrorLog = errorLog;
         _expectedServiceId = SERVICE_ID;
         _expectedServiceInterface = FieService.class;
         _expectedServiceResources = resources;
@@ -114,7 +107,7 @@
 
         _fie = newFieService();
 
-        trainForConstructor(resources, errorLog, log);
+        trainForConstructor(resources, log);
 
         replay();
 
@@ -131,13 +124,12 @@
     public void injected_service_method()
     {
         ServiceResources resources = newServiceResources();
-        ErrorLog errorLog = newErrorLog();
         Log log = newLog();
 
         _fie = newFieService();
         _expectedFoe = newFoe();
 
-        trainForConstructor(resources, errorLog, log);
+        trainForConstructor(resources, log);
 
         trainGetService(resources, "Foe", FoeService.class, _expectedFoe);
 
@@ -161,12 +153,11 @@
     public void builder_method_returns_null()
     {
         ServiceResources resources = newServiceResources();
-        ErrorLog errorLog = newErrorLog();
         Log log = newLog();
 
         _fie = null;
 
-        trainForConstructor(resources, errorLog, log);
+        trainForConstructor(resources, log);
 
         replay();
 
@@ -191,12 +182,11 @@
     public void builder_method_failed()
     {
         ServiceResources resources = newServiceResources();
-        ErrorLog errorLog = newErrorLog();
         Log log = newLog();
 
         _fie = null;
 
-        trainForConstructor(resources, errorLog, log);
+        trainForConstructor(resources, log);
 
         replay();
 
@@ -226,13 +216,12 @@
     public void auto_dependency()
     {
         ServiceResources resources = newServiceResources();
-        ErrorLog errorLog = newErrorLog();
         Log log = newLog();
 
         _fie = newFieService();
         _expectedFoe = newFoeService();
 
-        trainForConstructor(resources, errorLog, log);
+        trainForConstructor(resources, log);
 
         Method method = findMethod("build_auto");
 
@@ -284,12 +273,11 @@
         throw new RuntimeException("Method failed.");
     }
 
-    public FieService build_args(String serviceId, ServiceResources resources, ErrorLog errorLog,
+    public FieService build_args(String serviceId, ServiceResources resources,
             Class serviceInterface, Log log)
     {
         assertEquals(serviceId, _expectedServiceId);
         assertSame(resources, _expectedServiceResources);
-        assertSame(errorLog, _expectedErrorLog);
         assertSame(serviceInterface, _expectedServiceInterface);
         assertSame(log, _expectedLog);
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java Thu Jul 20 06:41:19 2006
@@ -23,8 +23,9 @@
 import java.math.BigDecimal;
 import java.util.Set;
 
+import org.apache.commons.logging.Log;
+import org.apache.hivemind.ErrorLog;
 import org.apache.tapestry.internal.util.InternalUtils;
-import org.apache.tapestry.ioc.ErrorLog;
 import org.apache.tapestry.ioc.IOCConstants;
 import org.apache.tapestry.ioc.def.DecoratorDef;
 import org.apache.tapestry.ioc.def.ModuleDef;
@@ -41,7 +42,7 @@
     @Test
     public void module_builder_without_id()
     {
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         replay();
 
@@ -57,7 +58,7 @@
     @Test
     public void module_builder_with_id()
     {
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         replay();
 
@@ -75,7 +76,7 @@
     {
         String className = SimpleModuleBuilder.class.getName();
 
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         replay();
 
@@ -134,7 +135,7 @@
         String expectedMethod = InternalUtils.asString(ServiceIdConflictMethodBuilder.class
                 .getMethod("buildFred", Object.class));
 
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         log.warn(buildMethodConflict(conflictMethod, expectedMethod), null);
 
@@ -169,7 +170,7 @@
     {
         Method m = VoidBuilderMethodModule.class.getMethod("buildNull");
 
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         log.warn(IOCMessages.buildMethodWrongReturnType(m), null);
 
@@ -193,7 +194,7 @@
     {
         Method m = moduleClass.getMethod(methodName, Object.class);
 
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         log.warn(IOCMessages.decoratorMethodWrongReturnType(m), null);
 
@@ -224,7 +225,7 @@
         Class moduleClass = NoDelegateDecoratorMethodModule.class;
         Method m = moduleClass.getMethod("decorateNoDelegate");
 
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         log.warn(IOCMessages.decoratorMethodNeedsDelegateParameter(m), null);
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/InterceptorStackBuilderTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/InterceptorStackBuilderTest.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/InterceptorStackBuilderTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/InterceptorStackBuilderTest.java Thu Jul 20 06:41:19 2006
@@ -102,7 +102,7 @@
         trainFindDecoratorsForService(module, SERVICE_ID, decorators);
 
         // Notice: reverse order!
-        
+
         trainCreateInterceptor(decorator2, coreObject, interceptor2);
         trainCreateInterceptor(decorator1, interceptor2, interceptor1);
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ModuleImplTest.java Thu Jul 20 06:41:19 2006
@@ -14,23 +14,20 @@
 
 package org.apache.tapestry.internal.ioc;
 
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
 import java.util.Collection;
 
+import org.apache.commons.logging.Log;
 import org.apache.hivemind.service.ClassFactory;
 import org.apache.hivemind.service.impl.ClassFactoryImpl;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
-import org.apache.tapestry.ioc.ErrorLog;
 import org.apache.tapestry.ioc.Registry;
 import org.apache.tapestry.ioc.RegistryBuilder;
 import org.apache.tapestry.ioc.def.ModuleDef;
-import org.apache.tapestry.ioc.def.ServiceDef;
-import org.apache.tapestry.util.CollectionFactory;
-import org.easymock.EasyMock;
 import org.testng.annotations.Test;
 
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
 /**
  * @author Howard M. Lewis Ship
  */
@@ -41,7 +38,7 @@
     public void get_service_by_id_exists()
     {
         InternalRegistry registry = newMock(InternalRegistry.class);
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         ModuleDef moduleDef = new DefaultModuleDefImpl(ModuleImplTestModule.class, log);
 
@@ -49,6 +46,8 @@
 
         trainGetLifecycle(registry, "singleton", new SingletonServiceLifecycle());
 
+        trainGetLog(registry, "ioc.test.Upcase", log);
+
         trainGetService(
                 registry,
                 "tapestry.ioc.ClassFactory",
@@ -67,17 +66,11 @@
         verify();
     }
 
-    private void trainFindDecoratorsForService(InternalRegistry registry)
-    {
-        registry.findDecoratorsForService(EasyMock.isA(ServiceDef.class));
-        setReturnValue(CollectionFactory.newList());
-    }
-
     @Test
     public void get_service_by_id_private()
     {
         InternalRegistry registry = newMock(InternalRegistry.class);
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         ModuleDef moduleDef = new DefaultModuleDefImpl(ModuleImplTestModule.class, log);
 
@@ -85,6 +78,8 @@
 
         trainGetLifecycle(registry, "singleton", new SingletonServiceLifecycle());
 
+        trainGetLog(registry, "ioc.test.PrivateUpcase", log);
+
         trainGetService(
                 registry,
                 "tapestry.ioc.ClassFactory",
@@ -110,7 +105,7 @@
     public void get_service_by_id_private_wrong_module()
     {
         InternalRegistry registry = newMock(InternalRegistry.class);
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         ModuleDef moduleDef = new DefaultModuleDefImpl(ModuleImplTestModule.class, log);
 
@@ -137,7 +132,7 @@
     public void find_service_ids_for_interface()
     {
         InternalRegistry registry = newMock(InternalRegistry.class);
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         ModuleDef moduleDef = new DefaultModuleDefImpl(ModuleImplTestModule.class, log);
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImplTest.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceDecoratorImplTest.java Thu Jul 20 06:41:19 2006
@@ -23,7 +23,6 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
-import org.apache.tapestry.ioc.ErrorLog;
 import org.apache.tapestry.ioc.ServiceResources;
 import org.testng.annotations.Test;
 
@@ -44,19 +43,18 @@
     public void decorator_returns_interceptor() throws Exception
     {
         ServiceResources resources = newServiceResources();
-        ErrorLog errorLog = newErrorLog();
         Log log = newLog();
         _expectedDelegate = newFieService();
         _interceptorToReturn = newFieService();
 
-        trainForConstructor(resources, errorLog, log);
+        trainForConstructor(resources, log);
 
         replay();
 
         // Check that the delegate gets passed in; check that the return value of the
         // decorator method is the return value of the ServiceDecorator.
 
-        Method m = getClass().getMethod("decoratorReturnsInterceptor", Object.class);
+        Method m = getClass().getMethod("decoratorReturnsInterceptor", Class.class, Object.class);
 
         ServiceDecoratorImpl decorator = new ServiceDecoratorImpl(m, this, resources);
 
@@ -67,7 +65,15 @@
         verify();
     }
 
-    public Object decoratorReturnsInterceptor(Object delegate)
+    public <T> T decoratorReturnsInterceptor(Class<T> serviceInterface, T delegate)
+    {
+        assertSame(serviceInterface, FieService.class);
+        assertSame(delegate, _expectedDelegate);
+
+        return serviceInterface.cast(_interceptorToReturn);
+    }
+
+    public Object decoratorUntyped(Object delegate)
     {
         assertSame(delegate, _expectedDelegate);
 
@@ -78,11 +84,10 @@
     public void decorator_returns_null_interceptor() throws Exception
     {
         ServiceResources resources = newServiceResources();
-        ErrorLog errorLog = newErrorLog();
         Log log = newLog();
         Object delegate = newFieService();
 
-        trainForConstructor(resources, errorLog, log);
+        trainForConstructor(resources, log);
 
         replay();
 
@@ -101,16 +106,15 @@
     public void decorator_returns_incorrect_type() throws Exception
     {
         ServiceResources resources = newServiceResources();
-        ErrorLog errorLog = newErrorLog();
         Log log = newLog();
         _expectedDelegate = newFieService();
         _interceptorToReturn = newMock(FoeService.class);
 
-        Method m = getClass().getMethod("decoratorReturnsInterceptor", Object.class);
+        Method m = getClass().getMethod("decoratorUntyped", Object.class);
 
-        trainForConstructor(resources, errorLog, log);
+        trainForConstructor(resources, log);
 
-        errorLog.warn(IOCMessages.decoratorReturnedWrongType(
+        log.warn(IOCMessages.decoratorReturnedWrongType(
                 m,
                 SERVICE_ID,
                 _interceptorToReturn,
@@ -131,12 +135,11 @@
     public void decorator_method_throws_exception() throws Exception
     {
         ServiceResources resources = newServiceResources();
-        ErrorLog errorLog = newErrorLog();
         Log log = newLog();
         Object delegate = newFieService();
         _exception = new RuntimeException("Ouch!");
 
-        trainForConstructor(resources, errorLog, log);
+        trainForConstructor(resources, log);
 
         replay();
 
@@ -179,11 +182,9 @@
         return null;
     }
 
-    private void trainForConstructor(ServiceResources resources, ErrorLog errorLog, Log log)
+    private void trainForConstructor(ServiceResources resources, Log log)
     {
         trainGetServiceId(resources, SERVICE_ID);
-
-        trainGetErrorLog(resources, errorLog);
 
         trainGetServiceInterface(resources, FieService.class);
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/util/OrdererTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/util/OrdererTest.java?rev=423932&r1=423931&r2=423932&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/util/OrdererTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/util/OrdererTest.java Thu Jul 20 06:41:19 2006
@@ -19,8 +19,8 @@
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.commons.logging.Log;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
-import org.apache.tapestry.ioc.ErrorLog;
 import org.apache.tapestry.ioc.Orderable;
 import org.testng.annotations.Test;
 
@@ -32,7 +32,7 @@
     @Test
     public void no_dependencies()
     {
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         replay();
 
@@ -53,7 +53,7 @@
     @Test
     public void nulls_not_included_in_result()
     {
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         replay();
 
@@ -76,7 +76,7 @@
     @Test
     public void duplicate_id()
     {
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         replay();
 
@@ -111,7 +111,7 @@
     @Test
     public void leader()
     {
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         replay();
 
@@ -132,7 +132,7 @@
     @Test
     public void trailer()
     {
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         replay();
 
@@ -153,7 +153,7 @@
     @Test
     public void duplicate_trailer()
     {
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         log.warn("Could not set 'wilma' as the last object, "
                 + "because 'barney' has already been set.", null);
@@ -177,7 +177,7 @@
     @Test
     public void duplicate_leader()
     {
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         log.warn("Could not set 'wilma' as the first object, "
                 + "because 'barney' has already been set.", null);
@@ -201,7 +201,7 @@
     @Test
     public void prereqs()
     {
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         replay();
 
@@ -222,7 +222,7 @@
     @Test
     public void pre_and_post_reqs()
     {
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         replay();
 
@@ -243,7 +243,7 @@
     @Test
     public void dependency_cycle()
     {
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         log.warn("Unable to add 'barney' as a dependency of 'betty', as that forms a "
                 + "dependency cycle ('betty' depends on itself via 'barney'). "
@@ -280,7 +280,7 @@
     @Test
     public void toString_DependencyNode()
     {
-        ErrorLog log = newErrorLog();
+        Log log = newLog();
 
         replay();
 

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/LogSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/LogSourceImplTest.java?rev=423932&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/LogSourceImplTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/LogSourceImplTest.java Thu Jul 20 06:41:19 2006
@@ -0,0 +1,53 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.ioc;
+
+import static org.testng.Assert.assertSame;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tapestry.internal.test.InternalBaseTestCase;
+import org.testng.annotations.Test;
+
+/**
+ * @author Howard M. Lewis Ship
+ */
+public class LogSourceImplTest extends InternalBaseTestCase
+{
+    @Test
+    public void get_by_class()
+    {
+        Class clazz = getClass();
+
+        Log expected = LogFactory.getLog(clazz);
+        LogSource logSource = new LogSourceImpl();
+        Log actual = logSource.getLog(clazz);
+
+        assertSame(actual, expected);
+    }
+
+    @Test
+    public void get_by_name()
+    {
+        String name = "foo.Bar";
+
+        Log expected = LogFactory.getLog(name);
+        LogSource logSource = new LogSourceImpl();
+        Log actual = logSource.getLog(name);
+
+        assertSame(actual, expected);
+
+    }
+}