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 2011/04/11 19:33:46 UTC

svn commit: r1091136 - in /tapestry/tapestry5/trunk/tapestry-ioc/src: main/java/org/apache/tapestry5/ioc/ main/java/org/apache/tapestry5/ioc/internal/ main/java/org/apache/tapestry5/ioc/internal/services/ main/java/org/apache/tapestry5/ioc/services/ te...

Author: hlship
Date: Mon Apr 11 17:33:46 2011
New Revision: 1091136

URL: http://svn.apache.org/viewvc?rev=1091136&view=rev
Log:
TAP5-853: Add methods to PlasticProxyFactory for identifying the location of a Method or Constructor

Modified:
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/RegistryBuilder.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ModuleImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ReloadableObjectCreatorSource.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceResourcesImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PlasticProxyFactoryImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PlasticProxyFactory.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/RegistryBuilder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/RegistryBuilder.java?rev=1091136&r1=1091135&r2=1091136&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/RegistryBuilder.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/RegistryBuilder.java Mon Apr 11 17:33:46 2011
@@ -82,7 +82,7 @@ public final class RegistryBuilder
         Logger classFactoryLogger = loggerSource.getLogger(TapestryIOCModule.class.getName() + ".ClassFactory");
 
         classFactory = new ClassFactoryImpl(this.classLoader, classFactoryLogger);
-        proxyFactory = new PlasticProxyFactoryImpl(this.classLoader);
+        proxyFactory = new PlasticProxyFactoryImpl(classFactory, this.classLoader);
 
         add(TapestryIOCModule.class);
     }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImpl.java?rev=1091136&r1=1091135&r2=1091136&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImpl.java Mon Apr 11 17:33:46 2011
@@ -565,8 +565,8 @@ public class DefaultModuleDefImpl implem
             if (!Modifier.isStatic(bindMethod.getModifiers()))
                 throw new RuntimeException(IOCMessages.bindMethodMustBeStatic(toString(bindMethod)));
 
-            ServiceBinderImpl binder = new ServiceBinderImpl(this, bindMethod, classFactory, proxyFactory,
-                    defaultMarkers, modulePreventsServiceDecoration);
+            ServiceBinderImpl binder = new ServiceBinderImpl(this, bindMethod, proxyFactory, defaultMarkers,
+                    modulePreventsServiceDecoration);
 
             bindMethod.invoke(null, binder);
 

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ModuleImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ModuleImpl.java?rev=1091136&r1=1091135&r2=1091136&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ModuleImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ModuleImpl.java Mon Apr 11 17:33:46 2011
@@ -289,7 +289,7 @@ public class ModuleImpl implements Modul
             {
                 try
                 {
-                    ServiceBuilderResources resources = new ServiceResourcesImpl(registry, module, def, classFactory,
+                    ServiceBuilderResources resources = new ServiceResourcesImpl(registry, module, def, proxyFactory,
                             logger);
 
                     // Build up a stack of operations that will be needed to realize the service

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java?rev=1091136&r1=1091135&r2=1091136&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryImpl.java Mon Apr 11 17:33:46 2011
@@ -580,7 +580,7 @@ public class RegistryImpl implements Reg
 
         boolean debug = logger.isDebugEnabled();
 
-        final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
+        final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, proxyFactory, logger);
 
         for (final ContributionDef def : contributions)
         {
@@ -615,7 +615,7 @@ public class RegistryImpl implements Reg
 
         boolean debug = logger.isDebugEnabled();
 
-        final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
+        final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, proxyFactory, logger);
 
         for (final ContributionDef def : contributions)
         {
@@ -650,7 +650,7 @@ public class RegistryImpl implements Reg
         Logger logger = getServiceLogger(serviceId);
         boolean debug = logger.isDebugEnabled();
 
-        final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
+        final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, proxyFactory, logger);
 
         for (final ContributionDef def : contributions)
         {
@@ -756,7 +756,7 @@ public class RegistryImpl implements Reg
             if (decoratorDefs.isEmpty())
                 continue;
 
-            ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
+            ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, proxyFactory, logger);
 
             for (DecoratorDef decoratorDef : decoratorDefs)
             {
@@ -786,7 +786,7 @@ public class RegistryImpl implements Reg
             if (advisorDefs.isEmpty())
                 continue;
 
-            ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
+            ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, proxyFactory, logger);
 
             for (AdvisorDef advisorDef : advisorDefs)
             {
@@ -1084,7 +1084,7 @@ public class RegistryImpl implements Reg
 
     private Object invokeConstructor(final Constructor constructor, final InjectionResources resources)
     {
-        final String description = classFactory.getConstructorLocation(constructor).toString();
+        final String description = proxyFactory.getConstructorLocation(constructor).toString();
 
         return invoke("Invoking " + description, new Invokable<Object>()
         {

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ReloadableObjectCreatorSource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ReloadableObjectCreatorSource.java?rev=1091136&r1=1091135&r2=1091136&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ReloadableObjectCreatorSource.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ReloadableObjectCreatorSource.java Mon Apr 11 17:33:46 2011
@@ -18,7 +18,6 @@ import java.lang.reflect.Method;
 
 import org.apache.tapestry5.ioc.ObjectCreator;
 import org.apache.tapestry5.ioc.ServiceBuilderResources;
-import org.apache.tapestry5.ioc.services.ClassFactory;
 import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
 import org.apache.tapestry5.services.UpdateListenerHub;
 
@@ -28,8 +27,6 @@ import org.apache.tapestry5.services.Upd
 @SuppressWarnings("unchecked")
 public class ReloadableObjectCreatorSource implements ObjectCreatorSource
 {
-    private final ClassFactory classFactory;
-
     private final PlasticProxyFactory proxyFactory;
 
     private final Method bindMethod;
@@ -40,10 +37,9 @@ public class ReloadableObjectCreatorSour
 
     private final boolean eagerLoad;
 
-    public ReloadableObjectCreatorSource(ClassFactory classFactory, PlasticProxyFactory proxyFactory,
-            Method bindMethod, Class serviceInterfaceClass, Class serviceImplementationClass, boolean eagerLoad)
+    public ReloadableObjectCreatorSource(PlasticProxyFactory proxyFactory, Method bindMethod,
+            Class serviceInterfaceClass, Class serviceImplementationClass, boolean eagerLoad)
     {
-        this.classFactory = classFactory;
         this.proxyFactory = proxyFactory;
         this.bindMethod = bindMethod;
         this.serviceInterfaceClass = serviceInterfaceClass;
@@ -65,7 +61,7 @@ public class ReloadableObjectCreatorSour
     public String getDescription()
     {
         return String.format("Reloadable %s via %s", serviceImplementationClass.getName(),
-                classFactory.getMethodLocation(bindMethod));
+                proxyFactory.getMethodLocation(bindMethod));
     }
 
     private Object createReloadableProxy(ServiceBuilderResources resources)

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java?rev=1091136&r1=1091135&r2=1091136&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java Mon Apr 11 17:33:46 2011
@@ -35,7 +35,6 @@ import org.apache.tapestry5.ioc.def.Serv
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
 import org.apache.tapestry5.ioc.internal.util.OneShotLock;
-import org.apache.tapestry5.ioc.services.ClassFactory;
 import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
 
 @SuppressWarnings("all")
@@ -47,20 +46,17 @@ public class ServiceBinderImpl implement
 
     private final ServiceDefAccumulator accumulator;
 
-    private final ClassFactory classFactory;
-
     private PlasticProxyFactory proxyFactory;
 
     private final Set<Class> defaultMarkers;
 
     private final boolean moduleDefaultPreventDecoration;
 
-    public ServiceBinderImpl(ServiceDefAccumulator accumulator, Method bindMethod, ClassFactory classFactory,
-            PlasticProxyFactory proxyFactory, Set<Class> defaultMarkers, boolean moduleDefaultPreventDecoration)
+    public ServiceBinderImpl(ServiceDefAccumulator accumulator, Method bindMethod, PlasticProxyFactory proxyFactory,
+            Set<Class> defaultMarkers, boolean moduleDefaultPreventDecoration)
     {
         this.accumulator = accumulator;
         this.bindMethod = bindMethod;
-        this.classFactory = classFactory;
         this.proxyFactory = proxyFactory;
         this.defaultMarkers = defaultMarkers;
         this.moduleDefaultPreventDecoration = moduleDefaultPreventDecoration;
@@ -164,16 +160,16 @@ public class ServiceBinderImpl implement
 
             public String getDescription()
             {
-                return String.format("%s via %s", classFactory.getConstructorLocation(constructor),
-                        classFactory.getMethodLocation(bindMethod));
+                return String.format("%s via %s", proxyFactory.getConstructorLocation(constructor),
+                        proxyFactory.getMethodLocation(bindMethod));
             }
         };
     }
 
     private ObjectCreatorSource createReloadableConstructorBasedObjectCreatorSource()
     {
-        return new ReloadableObjectCreatorSource(classFactory, proxyFactory, bindMethod, serviceInterface,
-                serviceImplementation, eagerLoad);
+        return new ReloadableObjectCreatorSource(proxyFactory, bindMethod, serviceInterface, serviceImplementation,
+                eagerLoad);
     }
 
     @SuppressWarnings("unchecked")
@@ -185,7 +181,7 @@ public class ServiceBinderImpl implement
             {
                 String expectedImplName = serviceClass.getName() + "Impl";
 
-                ClassLoader classLoader = classFactory.getClassLoader();
+                ClassLoader classLoader = proxyFactory.getClassLoader();
 
                 Class<T> implementationClass = (Class<T>) classLoader.loadClass(expectedImplName);
 
@@ -230,7 +226,7 @@ public class ServiceBinderImpl implement
 
             public String getDescription()
             {
-                return classFactory.getMethodLocation(bindMethod).toString();
+                return proxyFactory.getMethodLocation(bindMethod).toString();
             }
         };
 

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceResourcesImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceResourcesImpl.java?rev=1091136&r1=1091135&r2=1091136&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceResourcesImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceResourcesImpl.java Mon Apr 11 17:33:46 2011
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008, 2009, 2010 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009, 2010, 2011 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.
@@ -25,7 +25,7 @@ import org.apache.tapestry5.ioc.Operatio
 import org.apache.tapestry5.ioc.ServiceBuilderResources;
 import org.apache.tapestry5.ioc.def.ServiceDef;
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
-import org.apache.tapestry5.ioc.services.ClassFactory;
+import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
 import org.slf4j.Logger;
 
 /**
@@ -48,17 +48,17 @@ public class ServiceResourcesImpl extend
 
     private final Logger logger;
 
-    private final ClassFactory classFactory;
+    private final PlasticProxyFactory proxyFactory;
 
     public ServiceResourcesImpl(InternalRegistry registry, Module module, ServiceDef serviceDef,
-            ClassFactory classFactory, Logger logger)
+            PlasticProxyFactory proxyFactory, Logger logger)
     {
         super(registry, module);
 
         this.registry = registry;
         this.module = module;
         this.serviceDef = InternalUtils.toInternalServiceDef(serviceDef);
-        this.classFactory = classFactory;
+        this.proxyFactory = proxyFactory;
         this.logger = logger;
     }
 
@@ -152,7 +152,7 @@ public class ServiceResourcesImpl extend
                 if (constructor == null)
                     throw new RuntimeException(IOCMessages.noAutobuildConstructor(clazz));
 
-                String description = classFactory.getConstructorLocation(constructor).toString();
+                String description = proxyFactory.getConstructorLocation(constructor).toString();
 
                 ObjectCreator creator = new ConstructorServiceCreator(ServiceResourcesImpl.this, description,
                         constructor);

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PlasticProxyFactoryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PlasticProxyFactoryImpl.java?rev=1091136&r1=1091135&r2=1091136&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PlasticProxyFactoryImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PlasticProxyFactoryImpl.java Mon Apr 11 17:33:46 2011
@@ -1,10 +1,13 @@
 package org.apache.tapestry5.ioc.internal.services;
 
+import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 
+import org.apache.tapestry5.ioc.Location;
 import org.apache.tapestry5.ioc.ObjectCreator;
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
+import org.apache.tapestry5.ioc.services.ClassFactory;
 import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
 import org.apache.tapestry5.plastic.ClassInstantiator;
 import org.apache.tapestry5.plastic.InstructionBuilder;
@@ -19,10 +22,13 @@ import org.apache.tapestry5.plastic.Plas
 
 public class PlasticProxyFactoryImpl implements PlasticProxyFactory
 {
+    private final ClassFactory classFactory;
+
     private final PlasticManager manager;
 
-    public PlasticProxyFactoryImpl(ClassLoader parentClassLoader)
+    public PlasticProxyFactoryImpl(ClassFactory classFactory, ClassLoader parentClassLoader)
     {
+        this.classFactory = classFactory;
         manager = new PlasticManager(parentClassLoader);
     }
 
@@ -82,4 +88,14 @@ public class PlasticProxyFactoryImpl imp
         return interfaceType.cast(instantiator.newInstance());
     }
 
+    public Location getMethodLocation(Method method)
+    {
+        return classFactory.getMethodLocation(method);
+    }
+
+    public Location getConstructorLocation(Constructor constructor)
+    {
+        return classFactory.getConstructorLocation(constructor);
+    }
+
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PlasticProxyFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PlasticProxyFactory.java?rev=1091136&r1=1091135&r2=1091136&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PlasticProxyFactory.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PlasticProxyFactory.java Mon Apr 11 17:33:46 2011
@@ -14,13 +14,18 @@
 
 package org.apache.tapestry5.ioc.services;
 
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+import org.apache.tapestry5.ioc.Location;
 import org.apache.tapestry5.ioc.ObjectCreator;
 import org.apache.tapestry5.plastic.ClassInstantiator;
 import org.apache.tapestry5.plastic.PlasticClassTransformation;
 import org.apache.tapestry5.plastic.PlasticClassTransformer;
 
 /**
- * A service used to create proxies of varying types.
+ * A service used to create proxies of varying types. As a secondary concern, manages to identify the
+ * location of methods and constructors, which is important for exception reporting.
  * 
  * @since 5.3.0
  */
@@ -75,4 +80,19 @@ public interface PlasticProxyFactory
      */
     <T> T createProxy(Class<T> interfaceType, ObjectCreator<T> creator, Class<? extends T> annotationSource,
             String description);
+
+    /**
+     * Converts a method to a {@link Location}, which includes information about the source file name and line number.
+     * 
+     * @param method
+     *            to look up
+     * @return the location, or null if the necessary information is not available
+     */
+    Location getMethodLocation(Method method);
+
+    /**
+     * Return a string representation for the constructor (including class and parameters) and (if available) file name
+     * and line number.
+     */
+    Location getConstructorLocation(Constructor constructor);
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java?rev=1091136&r1=1091135&r2=1091136&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java Mon Apr 11 17:33:46 2011
@@ -4,7 +4,7 @@
 // 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
+// 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,
@@ -21,11 +21,13 @@ import org.apache.tapestry5.ioc.def.Deco
 import org.apache.tapestry5.ioc.def.ModuleDef;
 import org.apache.tapestry5.ioc.def.ServiceDef;
 import org.apache.tapestry5.ioc.internal.services.ClassFactoryImpl;
+import org.apache.tapestry5.ioc.internal.services.PlasticProxyFactoryImpl;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
 import org.apache.tapestry5.ioc.services.ClassFab;
 import org.apache.tapestry5.ioc.services.ClassFactory;
 import org.apache.tapestry5.ioc.services.MethodSignature;
+import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
 import org.apache.tapestry5.ioc.test.IOCTestCase;
 import static org.easymock.EasyMock.contains;
 import org.slf4j.Logger;
@@ -42,18 +44,22 @@ public class DefaultModuleDefImplTest ex
 {
     private ClassFactory classFactory;
 
+    private PlasticProxyFactory proxyFactory;
+
     private final OperationTracker tracker = new QuietOperationTracker();
 
     @BeforeClass
     public void setup()
     {
         classFactory = new ClassFactoryImpl();
+        proxyFactory = new PlasticProxyFactoryImpl(classFactory, Thread.currentThread().getContextClassLoader());
     }
 
     @AfterClass
     public void cleanup()
     {
         classFactory = null;
+        proxyFactory = null;
     }
 
     @Test
@@ -123,7 +129,7 @@ public class DefaultModuleDefImplTest ex
 
         verify();
     }
-    
+
     @Test
     public void default_service_id_from_annotation()
     {
@@ -141,7 +147,7 @@ public class DefaultModuleDefImplTest ex
 
         verify();
     }
-    
+
     @Test
     public void default_service_id_from_method_named_annotation()
     {
@@ -159,7 +165,7 @@ public class DefaultModuleDefImplTest ex
 
         verify();
     }
-    
+
     @Test
     public void default_service_id_from_named_annotation()
     {
@@ -177,7 +183,7 @@ public class DefaultModuleDefImplTest ex
 
         verify();
     }
-    
+
     @Test
     public void default_service_id_from_return_type()
     {
@@ -205,8 +211,8 @@ public class DefaultModuleDefImplTest ex
         Method conflictMethod = ServiceIdConflictMethodModule.class.getMethod("buildFred");
         String conflictMethodString = InternalUtils.asString(conflictMethod, classFactory);
 
-        String expectedMethod = InternalUtils.asString(ServiceIdConflictMethodModule.class
-                .getMethod("buildFred", Object.class), classFactory);
+        String expectedMethod = InternalUtils.asString(
+                ServiceIdConflictMethodModule.class.getMethod("buildFred", Object.class), classFactory);
 
         Logger logger = mockLogger();
 
@@ -222,12 +228,12 @@ public class DefaultModuleDefImplTest ex
         }
         catch (RuntimeException ex)
         {
-            assertMessageContains(ex,
-                                  "Service Fred (defined by org.apache.tapestry5.ioc.internal.ServiceIdConflictMethodModule.buildFred()",
-                                  "conflicts with previously defined service defined by org.apache.tapestry5.ioc.internal.ServiceIdConflictMethodModule.buildFred(Object)");
+            assertMessageContains(
+                    ex,
+                    "Service Fred (defined by org.apache.tapestry5.ioc.internal.ServiceIdConflictMethodModule.buildFred()",
+                    "conflicts with previously defined service defined by org.apache.tapestry5.ioc.internal.ServiceIdConflictMethodModule.buildFred(Object)");
         }
 
-
         verify();
     }
 
@@ -324,7 +330,7 @@ public class DefaultModuleDefImplTest ex
     public void ordered_contribution_method()
     {
         attemptConfigurationMethod(OrderedConfigurationModule.class, "Ordered",
-                                   "contributeOrdered(OrderedConfiguration)");
+                "contributeOrdered(OrderedConfiguration)");
     }
 
     @Test
@@ -376,11 +382,11 @@ public class DefaultModuleDefImplTest ex
         }
         catch (RuntimeException ex)
         {
-            assertEquals(ex.getMessage(),
-                         "Service contribution method org.apache.tapestry5.ioc.internal.TooManyContributionParametersModule.contributeTooMany(Configuration, OrderedConfiguration) contains more than one parameter of type Configuration, OrderedConfiguration, or MappedConfiguration. Exactly one such parameter is required for a service contribution method.");
+            assertEquals(
+                    ex.getMessage(),
+                    "Service contribution method org.apache.tapestry5.ioc.internal.TooManyContributionParametersModule.contributeTooMany(Configuration, OrderedConfiguration) contains more than one parameter of type Configuration, OrderedConfiguration, or MappedConfiguration. Exactly one such parameter is required for a service contribution method.");
         }
 
-
         verify();
     }
 
@@ -401,8 +407,9 @@ public class DefaultModuleDefImplTest ex
         }
         catch (RuntimeException ex)
         {
-            assertEquals(ex.getMessage(),
-                         "Service contribution method org.apache.tapestry5.ioc.internal.NoUsableContributionParameterModule.contributeNoParameter(UpcaseService) does not contain a parameter of type Configuration, OrderedConfiguration or MappedConfiguration. This parameter is how the method make contributions into the service's configuration.");
+            assertEquals(
+                    ex.getMessage(),
+                    "Service contribution method org.apache.tapestry5.ioc.internal.NoUsableContributionParameterModule.contributeNoParameter(UpcaseService) does not contain a parameter of type Configuration, OrderedConfiguration or MappedConfiguration. This parameter is how the method make contributions into the service's configuration.");
         }
 
         verify();
@@ -460,8 +467,9 @@ public class DefaultModuleDefImplTest ex
         }
         catch (RuntimeException ex)
         {
-            assertMessageContains(ex,
-                                  "Class org.apache.tapestry5.ioc.internal.RunnableServiceImpl (implementation of service \'Runnable\') does not contain any public constructors.");
+            assertMessageContains(
+                    ex,
+                    "Class org.apache.tapestry5.ioc.internal.RunnableServiceImpl (implementation of service \'Runnable\') does not contain any public constructors.");
         }
 
         verify();
@@ -482,8 +490,8 @@ public class DefaultModuleDefImplTest ex
         catch (RuntimeException ex)
         {
             assertMessageContains(ex,
-                                  "Method org.apache.tapestry5.ioc.internal.NonStaticBindMethodModule.bind(ServiceBinder)",
-                                  "appears to be a service binder method, but is an instance method, not a static method.");
+                    "Method org.apache.tapestry5.ioc.internal.NonStaticBindMethodModule.bind(ServiceBinder)",
+                    "appears to be a service binder method, but is an instance method, not a static method.");
         }
 
         verify();
@@ -501,9 +509,7 @@ public class DefaultModuleDefImplTest ex
 
         // The point is, we're choosing the constructor with the largest number of parameters.
 
-        logger
-                .debug(contains(
-                        "Invoking constructor org.apache.tapestry5.ioc.internal.MultipleConstructorsAutobuildService(StringHolder)"));
+        logger.debug(contains("Invoking constructor org.apache.tapestry5.ioc.internal.MultipleConstructorsAutobuildService(StringHolder)"));
 
         train_getServiceId(resources, "StringHolder");
         train_getLogger(resources, logger);
@@ -513,7 +519,7 @@ public class DefaultModuleDefImplTest ex
         replay();
 
         ModuleDef def = new DefaultModuleDefImpl(MutlipleAutobuildServiceConstructorsModule.class, logger,
-                                                 classFactory, null);
+                classFactory, proxyFactory);
 
         ServiceDef sd = def.getServiceDef("StringHolder");
 
@@ -543,10 +549,9 @@ public class DefaultModuleDefImplTest ex
         }
         catch (RuntimeException ex)
         {
-            assertTrue(ex
-                    .getMessage()
-                    .matches(
-                    "Error invoking service binder method org.apache.tapestry5.ioc.internal.ExceptionInBindMethod.bind\\(ServiceBinder\\) " + "\\(at ExceptionInBindMethod.java:\\d+\\): Really, how often is this going to happen\\?"));
+            assertTrue(ex.getMessage().matches(
+                    "Error invoking service binder method org.apache.tapestry5.ioc.internal.ExceptionInBindMethod.bind\\(ServiceBinder\\) "
+                            + "\\(at ExceptionInBindMethod.java:\\d+\\): Really, how often is this going to happen\\?"));
         }
 
         verify();
@@ -654,7 +659,7 @@ public class DefaultModuleDefImplTest ex
         ModuleDef md = new DefaultModuleDefImpl(moduleClass, logger, classFactory, null);
 
         // reality check that a service was found
-        
+
         assertEquals(md.getServiceIds().size(), 1);
 
         verify();
@@ -677,7 +682,7 @@ public class DefaultModuleDefImplTest ex
         // make sure we really managed to create a synthetic method
 
         assertTrue(moduleClass.getMethod("size").isSynthetic());
-        
+
         return moduleClass;
     }