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/09/02 19:30:24 UTC

svn commit: r439620 - in /tapestry/tapestry5/tapestry-core/trunk/src: main/java/org/apache/tapestry/internal/ioc/ main/resources/org/apache/tapestry/internal/ioc/ test/java/org/apache/tapestry/internal/ioc/

Author: hlship
Date: Sat Sep  2 10:30:23 2006
New Revision: 439620

URL: http://svn.apache.org/viewvc?rev=439620&view=rev
Log:
Log invocations of service contributor methods.
Log the invocation of service builder methods just before actually invoking the method.

Modified:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/IOCMessages.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/ServiceBuilderMethodInvoker.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceResourcesImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/ioc/IOCStrings.properties
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodInvokerTest.java

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/IOCMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/IOCMessages.java?rev=439620&r1=439619&r2=439620&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/IOCMessages.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/IOCMessages.java Sat Sep  2 10:30:23 2006
@@ -17,7 +17,9 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
+import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.tapestry.Messages;
 import org.apache.tapestry.internal.MessagesImpl;
@@ -164,6 +166,12 @@
         return MESSAGES.format("invoking-method", asString(method));
     }
 
+    static String invokingMethod(ContributionDef def)
+    {
+        // The toString() of a contribution def is the name of the method.
+        return MESSAGES.format("invoking-method", def);
+    }
+
     static String recursiveServiceBuild(ServiceDef def)
     {
         return MESSAGES.format("recursive-service-build", def.getServiceId(), def.toString());
@@ -270,5 +278,15 @@
     static String registryShutdown(String serviceId)
     {
         return MESSAGES.format("registry-shutdown", serviceId);
+    }
+
+    static String constructedConfiguration(Collection result)
+    {
+        return MESSAGES.format("constructed-configuration", result);
+    }
+
+    static String constructedConfiguration(Map result)
+    {
+        return MESSAGES.format("constructed-configuration", result);
     }
 }

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=439620&r1=439619&r2=439620&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 Sat Sep  2 10:30:23 2006
@@ -107,7 +107,8 @@
         }
     }
 
-    public RegistryImpl(Collection<ModuleDef> moduleDefs, ClassLoader contextClassLoader, LogSource logSource)
+    public RegistryImpl(Collection<ModuleDef> moduleDefs, ClassLoader contextClassLoader,
+            LogSource logSource)
     {
         _logSource = logSource;
 
@@ -307,6 +308,7 @@
             return;
 
         Log log = getLog(serviceId);
+        boolean debug = log.isDebugEnabled();
 
         Object moduleBuilder = module.getModuleBuilder();
         ServiceLocator locator = new ServiceResourcesImpl(this, module, serviceDef, log);
@@ -316,6 +318,9 @@
             MappedConfiguration<K, V> validating = new ValidatingMappedConfigurationWrapper<K, V>(
                     serviceId, def, log, keyClass, valueType, keyToContribution, configuration);
 
+            if (debug)
+                log.debug(IOCMessages.invokingMethod(def));
+
             def.contribute(moduleBuilder, locator, validating);
         }
 
@@ -331,6 +336,7 @@
             return;
 
         Log log = getLog(serviceId);
+        boolean debug = log.isDebugEnabled();
 
         Object moduleBuilder = module.getModuleBuilder();
         ServiceLocator locator = new ServiceResourcesImpl(this, module, serviceDef, log);
@@ -340,6 +346,9 @@
             Configuration<T> validating = new ValidatingConfigurationWrapper<T>(serviceId, log,
                     valueType, def, configuration);
 
+            if (debug)
+                log.debug(IOCMessages.invokingMethod(def));
+
             def.contribute(moduleBuilder, locator, validating);
         }
     }
@@ -354,6 +363,7 @@
             return;
 
         Log log = getLog(serviceId);
+        boolean debug = log.isDebugEnabled();
 
         Object moduleBuilder = module.getModuleBuilder();
         ServiceLocator locator = new ServiceResourcesImpl(this, module, serviceDef, log);
@@ -362,6 +372,9 @@
         {
             OrderedConfiguration<T> validating = new ValidatingOrderedConfigurationWrapper<T>(
                     serviceId, module.getModuleId(), def, log, valueType, configuration);
+
+            if (debug)
+                log.debug(IOCMessages.invokingMethod(def));
 
             def.contribute(moduleBuilder, locator, validating);
         }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodInvoker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodInvoker.java?rev=439620&r1=439619&r2=439620&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodInvoker.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodInvoker.java Sat Sep  2 10:30:23 2006
@@ -236,9 +236,6 @@
 
         Object moduleBuilder = _resources.getModuleBuilder();
 
-        if (_log.isDebugEnabled())
-            _log.debug(IOCMessages.invokingMethod(_builderMethod));
-
         Object result = null;
         Throwable failure = null;
 
@@ -248,6 +245,9 @@
                     _builderMethod,
                     _resources,
                     getParameterDefaultsWithConfigurations());
+
+            if (_log.isDebugEnabled())
+                _log.debug(IOCMessages.invokingMethod(_builderMethod));
 
             result = _builderMethod.invoke(moduleBuilder, parameters);
         }

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=439620&r1=439619&r2=439620&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 Sat Sep  2 10:30:23 2006
@@ -63,17 +63,36 @@
 
     public <T> Collection<T> getUnorderedConfiguration(Class<T> valueType)
     {
-        return getRegistry().getUnorderedConfiguration(_serviceDef, valueType);
+        Collection<T> result = getRegistry().getUnorderedConfiguration(_serviceDef, valueType);
+
+        logConfiguration(result);
+
+        return result;
+    }
+
+    private void logConfiguration(Collection configuration)
+    {
+        if (_log.isDebugEnabled())
+            _log.debug(IOCMessages.constructedConfiguration(configuration));
     }
 
     public <T> List<T> getOrderedConfiguration(Class<T> valueType)
     {
-        return getRegistry().getOrderedConfiguration(_serviceDef, valueType);
+        List<T> result = getRegistry().getOrderedConfiguration(_serviceDef, valueType);
+
+        logConfiguration(result);
+
+        return result;
     }
 
     public <K, V> Map<K, V> getMappedConfiguration(Class<K> keyType, Class<V> valueType)
     {
-        return getRegistry().getMappedConfiguration(_serviceDef, keyType, valueType);
+        Map<K, V> result = getRegistry().getMappedConfiguration(_serviceDef, keyType, valueType);
+
+        if (_log.isDebugEnabled())
+            _log.debug(IOCMessages.constructedConfiguration(result));
+
+        return result;
     }
 
     public Object getModuleBuilder()

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/ioc/IOCStrings.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/ioc/IOCStrings.properties?rev=439620&r1=439619&r2=439620&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/ioc/IOCStrings.properties (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/ioc/IOCStrings.properties Sat Sep  2 10:30:23 2006
@@ -74,3 +74,4 @@
 recursive-module-constructor=The constructor for module '%s' (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
\ No newline at end of file

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodInvokerTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodInvokerTest.java?rev=439620&r1=439619&r2=439620&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodInvokerTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/ServiceBuilderMethodInvokerTest.java Sat Sep  2 10:30:23 2006
@@ -120,10 +120,10 @@
 
         train_getModuleBuilder(resources, fixture);
 
-        train_isDebugEnabled(log, false);
-
         train_getService(resources, "Foe", FoeService.class, fixture._expectedFoe);
 
+        train_isDebugEnabled(log, false);
+
         replay();
 
         ObjectCreator sc = new ServiceBuilderMethodInvoker(findMethod(fixture, "build_injected"),
@@ -150,11 +150,11 @@
 
         train_getModuleBuilder(resources, fixture);
 
-        train_isDebugEnabled(log, false);
-
         resources.getOrderedConfiguration(Runnable.class);
         setReturnValue(fixture._expectedConfiguration);
 
+        train_isDebugEnabled(log, false);
+
         replay();
 
         ObjectCreator sc = new ServiceBuilderMethodInvoker(findMethod(
@@ -183,11 +183,11 @@
 
         train_getModuleBuilder(resources, fixture);
 
-        train_isDebugEnabled(log, false);
-
         resources.getUnorderedConfiguration(Runnable.class);
         setReturnValue(fixture._expectedConfiguration);
 
+        train_isDebugEnabled(log, false);
+
         replay();
 
         ObjectCreator sc = new ServiceBuilderMethodInvoker(findMethod(
@@ -292,9 +292,9 @@
 
         train_getModuleBuilder(resources, fixture);
 
-        train_isDebugEnabled(log, false);
-
         train_getService(resources, FoeService.class, fixture._expectedFoe);
+
+        train_isDebugEnabled(log, false);
 
         replay();