You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2011/04/06 21:10:20 UTC

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

Author: hlship
Date: Wed Apr  6 19:10:20 2011
New Revision: 1089568

URL: http://svn.apache.org/viewvc?rev=1089568&view=rev
Log:
TAP5-853: Mark ClassFactory service deprecated in favor of new builtin PlasticProxyFactory service

Added:
    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
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/RegistryImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassFab.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassFactory.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=1089568&r1=1089567&r2=1089568&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 Wed Apr  6 19:10:20 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,
@@ -14,6 +14,11 @@
 
 package org.apache.tapestry5.ioc;
 
+import java.lang.reflect.AnnotatedElement;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
 import org.apache.tapestry5.ioc.annotations.SubModule;
 import org.apache.tapestry5.ioc.def.ModuleDef;
 import org.apache.tapestry5.ioc.internal.DefaultModuleDefImpl;
@@ -21,18 +26,15 @@ import org.apache.tapestry5.ioc.internal
 import org.apache.tapestry5.ioc.internal.RegistryImpl;
 import org.apache.tapestry5.ioc.internal.RegistryWrapper;
 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.internal.util.OneShotLock;
 import org.apache.tapestry5.ioc.services.ClassFactory;
+import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
 import org.apache.tapestry5.ioc.services.TapestryIOCModule;
 import org.slf4j.Logger;
 
-import java.lang.reflect.AnnotatedElement;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-
 /**
  * Used to construct the IoC {@link org.apache.tapestry5.ioc.Registry}. This class is <em>not</em> thread-safe. The
  * Registry, once created, <em>is</em> thread-safe.
@@ -54,6 +56,8 @@ public final class RegistryBuilder
 
     private final ClassFactory classFactory;
 
+    private final PlasticProxyFactory proxyFactory;
+
     private final Set<Class> addedModuleClasses = CollectionFactory.newSet();
 
     public RegistryBuilder()
@@ -78,6 +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);
 
         add(TapestryIOCModule.class);
     }
@@ -100,7 +105,7 @@ public final class RegistryBuilder
 
     /**
      * Adds a number of modules (as module classes) to the registry, returning the builder for further configuration.
-     *
+     * 
      * @see org.apache.tapestry5.ioc.annotations.SubModule
      */
     public RegistryBuilder add(Class... moduleClasses)
@@ -115,7 +120,8 @@ public final class RegistryBuilder
 
             // Quietly ignore previously added classes.
 
-            if (addedModuleClasses.contains(c)) continue;
+            if (addedModuleClasses.contains(c))
+                continue;
 
             addedModuleClasses.add(c);
 
@@ -126,7 +132,8 @@ public final class RegistryBuilder
 
             SubModule annotation = ((AnnotatedElement) c).getAnnotation(SubModule.class);
 
-            if (annotation == null) continue;
+            if (annotation == null)
+                continue;
 
             queue.addAll(Arrays.asList(annotation.value()));
         }
@@ -135,9 +142,9 @@ public final class RegistryBuilder
     }
 
     /**
-     * Adds a  modle class (specified by fully qualified class name) to the registry, returning the builder
+     * Adds a modle class (specified by fully qualified class name) to the registry, returning the builder
      * for further configuration.
-     *
+     * 
      * @see org.apache.tapestry5.ioc.annotations.SubModule
      */
     public RegistryBuilder add(String classname)
@@ -152,22 +159,22 @@ public final class RegistryBuilder
         }
         catch (Exception ex)
         {
-            throw new RuntimeException(String.format("Failure loading Tapestry IoC module class %s: %s",
-                                                     classname, InternalUtils.toMessage(ex), ex));
+            throw new RuntimeException(String.format("Failure loading Tapestry IoC module class %s: %s", classname,
+                    InternalUtils.toMessage(ex), ex));
         }
 
         return this;
     }
 
     /**
-     * Constructs and returns the registry; this may only be done once. The caller is responsible for invoking {@link
-     * org.apache.tapestry5.ioc.Registry#performRegistryStartup()}.
+     * Constructs and returns the registry; this may only be done once. The caller is responsible for invoking
+     * {@link org.apache.tapestry5.ioc.Registry#performRegistryStartup()}.
      */
     public Registry build()
     {
         lock.lock();
 
-        RegistryImpl registry = new RegistryImpl(modules, classFactory, loggerSource);
+        RegistryImpl registry = new RegistryImpl(modules, classFactory, null, loggerSource);
 
         return new RegistryWrapper(registry);
     }
@@ -181,49 +188,49 @@ public final class RegistryBuilder
     {
         return logger;
     }
-    
+
     /**
-     * Constructs the registry, adds a {@link ModuleDef} and a number of modules (as module classes) to the registry and 
-     * performs registry startup. The returned registry is ready to use. The caller is must not invoke {@link
-     * org.apache.tapestry5.ioc.Registry#performRegistryStartup()}.
-     * 
-     * @param moduleDef {@link ModuleDef} to add 
-     * @param moduleClasses modules (as module classes) to add
-     * 
+     * Constructs the registry, adds a {@link ModuleDef} and a number of modules (as module classes) to the registry and
+     * performs registry startup. The returned registry is ready to use. The caller is must not invoke
+     * {@link org.apache.tapestry5.ioc.Registry#performRegistryStartup()}.
+     * 
+     * @param moduleDef
+     *            {@link ModuleDef} to add
+     * @param moduleClasses
+     *            modules (as module classes) to add
      * @return {@link Registry}
-     * 
      * @since 5.2.0
      */
     public static Registry buildAndStartupRegistry(ModuleDef moduleDef, Class... moduleClasses)
     {
         RegistryBuilder builder = new RegistryBuilder();
-        
-        if(moduleDef != null)
+
+        if (moduleDef != null)
             builder.add(moduleDef);
-        
+
         builder.add(moduleClasses);
-        
+
         Registry registry = builder.build();
-        
+
         registry.performRegistryStartup();
-        
+
         return registry;
     }
-    
+
     /**
-     * Constructs the registry, adds a number of modules (as module classes) to the registry and 
-     * performs registry startup. The returned registry is ready to use. The caller is must not invoke {@link
-     * org.apache.tapestry5.ioc.Registry#performRegistryStartup()}.
-     * 
-     * @param moduleDef {@link ModuleDef} to add 
-     * @param moduleClasses modules (as module classes) to add
-     * 
+     * Constructs the registry, adds a number of modules (as module classes) to the registry and
+     * performs registry startup. The returned registry is ready to use. The caller is must not invoke
+     * {@link org.apache.tapestry5.ioc.Registry#performRegistryStartup()}.
+     * 
+     * @param moduleDef
+     *            {@link ModuleDef} to add
+     * @param moduleClasses
+     *            modules (as module classes) to add
      * @return {@link Registry}
-     * 
      * @since 5.2.0
      */
     public static Registry buildAndStartupRegistry(Class... moduleClasses)
-    {   
+    {
         return buildAndStartupRegistry(null, moduleClasses);
     }
 }

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=1089568&r1=1089567&r2=1089568&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 Wed Apr  6 19:10:20 2011
@@ -67,6 +67,7 @@ import org.apache.tapestry5.ioc.services
 import org.apache.tapestry5.ioc.services.ClassFactory;
 import org.apache.tapestry5.ioc.services.MasterObjectProvider;
 import org.apache.tapestry5.ioc.services.PerthreadManager;
+import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
 import org.apache.tapestry5.ioc.services.RegistryShutdownHub;
 import org.apache.tapestry5.ioc.services.RegistryShutdownListener;
 import org.apache.tapestry5.ioc.services.ServiceActivityScoreboard;
@@ -94,12 +95,7 @@ public class RegistryImpl implements Reg
     /**
      * The set of marker annotations for a builtin service.
      */
-    private final static Set<Class> BUILTIN = CollectionFactory.newSet();
-
-    static
-    {
-        BUILTIN.add(Builtin.class);
-    }
+    private final static Set<Class> BUILTIN = CollectionFactory.newSet(Builtin.class);
 
     /**
      * Used to obtain the {@link org.apache.tapestry5.ioc.services.ClassFactory} service, which is
@@ -108,6 +104,8 @@ public class RegistryImpl implements Reg
      */
     static final String CLASS_FACTORY_SERVICE_ID = "ClassFactory";
 
+    static final String PLASTIC_PROXY_FACTORY_SERVICE_ID = "PlasticProxyFactory";
+
     static final String LOGGER_SOURCE_SERVICE_ID = "LoggerSource";
 
     private final OneShotLock lock = new OneShotLock();
@@ -133,6 +131,8 @@ public class RegistryImpl implements Reg
 
     private final ClassFactory classFactory;
 
+    private final PlasticProxyFactory proxyFactory;
+
     private final ServiceActivityTracker tracker;
 
     private SymbolSource symbolSource;
@@ -157,16 +157,20 @@ public class RegistryImpl implements Reg
      *            defines the modules (and builders, decorators, etc., within)
      * @param classFactory
      *            TODO
+     * @param proxyFactory
+     *            TODO
      * @param loggerSource
      *            used to obtain Logger instances
      */
-    public RegistryImpl(Collection<ModuleDef> moduleDefs, ClassFactory classFactory, LoggerSource loggerSource)
+    public RegistryImpl(Collection<ModuleDef> moduleDefs, ClassFactory classFactory, PlasticProxyFactory proxyFactory,
+            LoggerSource loggerSource)
     {
         this.loggerSource = loggerSource;
 
         operationTracker = new PerThreadOperationTracker(loggerSource.getLogger(Registry.class));
 
         this.classFactory = classFactory;
+        this.proxyFactory = proxyFactory;
 
         Logger logger = loggerForBuiltinService(PERTHREAD_MANAGER_SERVICE_ID);
 
@@ -228,6 +232,7 @@ public class RegistryImpl implements Reg
         addBuiltin(CLASS_FACTORY_SERVICE_ID, ClassFactory.class, this.classFactory);
         addBuiltin(PERTHREAD_MANAGER_SERVICE_ID, PerthreadManager.class, perthreadManager);
         addBuiltin(REGISTRY_SHUTDOWN_HUB_SERVICE_ID, RegistryShutdownHub.class, registryShutdownHub);
+        addBuiltin(PLASTIC_PROXY_FACTORY_SERVICE_ID, PlasticProxyFactory.class, proxyFactory);
 
         validateContributeDefs(moduleDefs);
 

Added: 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=1089568&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PlasticProxyFactoryImpl.java (added)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PlasticProxyFactoryImpl.java Wed Apr  6 19:10:20 2011
@@ -0,0 +1,26 @@
+package org.apache.tapestry5.ioc.internal.services;
+
+import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
+import org.apache.tapestry5.plastic.ClassInstantiator;
+import org.apache.tapestry5.plastic.PlasticClassTransformer;
+import org.apache.tapestry5.plastic.PlasticManager;
+
+public class PlasticProxyFactoryImpl implements PlasticProxyFactory
+{
+    private final PlasticManager manager;
+
+    public PlasticProxyFactoryImpl(ClassLoader parentClassLoader)
+    {
+        manager = new PlasticManager(parentClassLoader);
+    }
+
+    public ClassLoader getClassLoader()
+    {
+        return manager.getClassLoader();
+    }
+
+    public ClassInstantiator createProxy(Class interfaceType, PlasticClassTransformer callback)
+    {
+        return manager.createProxy(interfaceType, callback);
+    }
+}

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassFab.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassFab.java?rev=1089568&r1=1089567&r2=1089568&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassFab.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassFab.java Wed Apr  6 19:10:20 2011
@@ -1,10 +1,10 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 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.
 // 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,
@@ -22,17 +22,25 @@ package org.apache.tapestry5.ioc.service
  * home page</a>.
  * <p/>
  * Method bodies look largely like Java. References to java classes must be fully qualified. Several special variables
- * are used: <ul> <li><code>$0</code> first parameter, equivalent to <code>this</code> in Java code (and can't be used
- * when creating a static method) <li><code>$1, $2, ...</code> actual parameters to the method <li><code>$args</code>
- * all the parameters as an <code>Object[]</code> <li><code>$r</code> the return type of the method, typically used as
- * <code>return ($r) ...</code>. <code>$r</code> is valid with method that return <code>void</code>. This also handles
- * conversions between wrapper types and primitive types. <li><code>$w</code> conversion from primitive type to wrapper
- * type, used as <code>($w) foo()</code> where <code>foo()</code> returns a primitive type and a wrapper type is needed
- * <li> </ul>
+ * are used:
+ * <ul>
+ * <li><code>$0</code> first parameter, equivalent to <code>this</code> in Java code (and can't be used when creating a
+ * static method)
+ * <li><code>$1, $2, ...</code> actual parameters to the method
+ * <li><code>$args</code> all the parameters as an <code>Object[]</code>
+ * <li><code>$r</code> the return type of the method, typically used as <code>return ($r) ...</code>. <code>$r</code> is
+ * valid with method that return <code>void</code>. This also handles conversions between wrapper types and primitive
+ * types.
+ * <li><code>$w</code> conversion from primitive type to wrapper type, used as <code>($w) foo()</code> where
+ * <code>foo()</code> returns a primitive type and a wrapper type is needed
+ * <li>
+ * </ul>
  * <p/>
  * ClassFab instances are not thread safe.
  * <p/>
  * ClassFab instances are created by a {@link org.apache.tapestry5.ioc.services.ClassFactory}.
+ * 
+ * @deprecated In 5.3.0, use {@link PlasticProxyFactory} instead
  */
 public interface ClassFab
 {
@@ -54,22 +62,29 @@ public interface ClassFab
 
     /**
      * Adds a method. The method is a public instance method.
-     *
-     * @param modifiers Modifiers for the method (see {@link java.lang.reflect.Modifier}).
-     * @param signature defines the name, return type, parameters and exceptions thrown
-     * @param body      The body of the method.
+     * 
+     * @param modifiers
+     *            Modifiers for the method (see {@link java.lang.reflect.Modifier}).
+     * @param signature
+     *            defines the name, return type, parameters and exceptions thrown
+     * @param body
+     *            The body of the method.
      * @return a method fabricator, used to add catch handlers.
-     * @throws RuntimeException if a method with that signature has already been added, or if there is a Javassist
-     *                          compilation error
+     * @throws RuntimeException
+     *             if a method with that signature has already been added, or if there is a Javassist
+     *             compilation error
      */
     void addMethod(int modifiers, MethodSignature signature, String body);
 
     /**
      * Adds a constructor to the class. The constructor will be public.
-     *
-     * @param parameterTypes the type of each parameter, or null if the constructor takes no parameters.
-     * @param exceptions     the type of each exception, or null if the constructor throws no exceptions.
-     * @param body           The body of the constructor.
+     * 
+     * @param parameterTypes
+     *            the type of each parameter, or null if the constructor takes no parameters.
+     * @param exceptions
+     *            the type of each exception, or null if the constructor throws no exceptions.
+     * @param body
+     *            The body of the constructor.
      */
     void addConstructor(Class[] parameterTypes, Class[] exceptions, String body);
 
@@ -83,29 +98,33 @@ public interface ClassFab
      * in the interface will be delegate wrappers. If toString() is not part of the delegate interface, then an
      * implementation will be supplied that returns the provided string. This method is used when creating objects that
      * proxy their behavior to some other object.
-     *
-     * @param serviceInterface   the interface to implement
-     * @param delegateExpression the expression used to find the delegate on which methods should be invoked. Typically
-     *                           a field name, such as "_delegate", or a method to invoke, such as "_service()".
-     * @param toString           fixed value to be returned as the description of the resultant object
+     * 
+     * @param serviceInterface
+     *            the interface to implement
+     * @param delegateExpression
+     *            the expression used to find the delegate on which methods should be invoked. Typically
+     *            a field name, such as "_delegate", or a method to invoke, such as "_service()".
+     * @param toString
+     *            fixed value to be returned as the description of the resultant object
      */
     void proxyMethodsToDelegate(Class serviceInterface, String delegateExpression, String toString);
-    
+
     /**
-     * Copies annotations from delegate class to the fabricated class. 
-     * 
-     * @param delegateClass class of the delegate
+     * Copies annotations from delegate class to the fabricated class.
      * 
+     * @param delegateClass
+     *            class of the delegate
      * @since 5.2.0
      */
     void copyClassAnnotationsFromDelegate(Class delegateClass);
-    
+
     /**
-     * Copies method annotations from delegate class to the methods of the fabricated class. 
-     * 
-     * @param serviceInterface service interface
-     * @param delegateClass class of the delegate
+     * Copies method annotations from delegate class to the methods of the fabricated class.
      * 
+     * @param serviceInterface
+     *            service interface
+     * @param delegateClass
+     *            class of the delegate
      * @since 5.2.0
      */
     void copyMethodAnnotationsFromDelegate(Class serviceInterface, Class delegateClass);

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassFactory.java?rev=1089568&r1=1089567&r2=1089568&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassFactory.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/ClassFactory.java Wed Apr  6 19:10:20 2011
@@ -22,6 +22,8 @@ import java.lang.reflect.Method;
 
 /**
  * Service used when dynamically creating new classes.
+ * 
+ * @deprecated In 5.3.0, use {@link PlasticProxyFactory} instead
  */
 public interface ClassFactory
 {
@@ -96,7 +98,7 @@ public interface ClassFactory
      * @param proxyInterface
      *            proxy interface class
      * @parame delegateCreator
-     *            creates the delegate
+     *         creates the delegate
      * @param description
      *            used for the toString() method
      * @since 5.2.0
@@ -114,12 +116,13 @@ public interface ClassFactory
      * @param proxyInterface
      *            proxy interface class
      * @parame delegateClass
-     *            delegate class
+     *         delegate class
      * @parame delegateCreator
-     *            creates the delegate
+     *         creates the delegate
      * @param description
      *            used for the toString() method
      * @since 5.2.0
      */
-    <T> T createProxy(Class<T> proxyInterface, Class<? extends T> delegateClass, ObjectCreator delegateCreator, String description);
+    <T> T createProxy(Class<T> proxyInterface, Class<? extends T> delegateClass, ObjectCreator delegateCreator,
+            String description);
 }

Added: 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=1089568&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PlasticProxyFactory.java (added)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PlasticProxyFactory.java Wed Apr  6 19:10:20 2011
@@ -0,0 +1,44 @@
+// Copyright 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.
+// 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.tapestry5.ioc.services;
+
+import org.apache.tapestry5.plastic.ClassInstantiator;
+import org.apache.tapestry5.plastic.PlasticClassTransformer;
+
+/**
+ * A service used to create proxies of varying types.
+ * 
+ * @since 5.3.0
+ */
+public interface PlasticProxyFactory
+{
+    /**
+     * Returns the class loader used when creating new classes, this is a child class loader
+     * of another class loader (usually, the thread's context class loader).
+     */
+    ClassLoader getClassLoader();
+
+    /**
+     * Creates a proxy object that implements the indicated interface, then invokes the callback to further
+     * configure the proxy.
+     * 
+     * @param interfaceType
+     *            interface implemented by proxy
+     * @param callback
+     *            configures the proxy
+     * @return instantiator that can be used to create an instance of the proxy class
+     */
+    ClassInstantiator createProxy(Class interfaceType, PlasticClassTransformer callback);
+}