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 2010/03/25 20:34:44 UTC

svn commit: r927561 - in /tapestry/tapestry5/trunk: tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ tapestry-ioc/src...

Author: hlship
Date: Thu Mar 25 19:34:43 2010
New Revision: 927561

URL: http://svn.apache.org/viewvc?rev=927561&view=rev
Log:
TAP5-1079: Automatically proxy (rather then immediate autobuild) contributions to configurations when appropriate

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/MethodResultCache.java   (with props)
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/AbstractConfigurationImpl.java   (with props)
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/CachedWorker.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/TransformMessages.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/Configuration.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/MappedConfiguration.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/OrderedConfiguration.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/InternalRegistry.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ObjectLocatorImpl.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/ValidatingConfigurationWrapper.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ValidatingMappedConfigurationWrapper.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ValidatingOrderedConfigurationWrapper.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingConfigurationWrapperTest.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingMappedConfigurationWrapperTest.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingOrderedConfigurationWrapperTest.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/CachedWorker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/CachedWorker.java?rev=927561&r1=927560&r2=927561&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/CachedWorker.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/CachedWorker.java Thu Mar 25 19:34:43 2010
@@ -42,24 +42,6 @@ public class CachedWorker implements Com
     private final BindingSource bindingSource;
 
     /**
-     * Manages a cache value as the result of invoking a no-arguments method.
-     */
-    public interface MethodResultCache
-    {
-        /** Returns true if the cache contains a cached value. May also check to see if the cached value is valid. */
-        boolean isCached();
-
-        /** Stores a new cached value for later reference. */
-        void set(Object cachedValue);
-
-        /** Returns the previously cached value, if any. */
-        Object get();
-
-        /** Resets the cache, discarding the cached value. */
-        void reset();
-    }
-
-    /**
      * Handles the watching of a binding (usually a property or property expression), invalidating the
      * cache early if the watched binding's value changes.
      */

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/MethodResultCache.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/MethodResultCache.java?rev=927561&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/MethodResultCache.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/MethodResultCache.java Thu Mar 25 19:34:43 2010
@@ -0,0 +1,33 @@
+// Copyright 2010 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.internal.transform;
+
+/**
+ * Manages a cache value as the result of invoking a no-arguments method.
+ */
+public interface MethodResultCache
+{
+    /** Returns true if the cache contains a cached value. May also check to see if the cached value is valid. */
+    boolean isCached();
+
+    /** Stores a new cached value for later reference. */
+    void set(Object cachedValue);
+
+    /** Returns the previously cached value, if any. */
+    Object get();
+
+    /** Resets the cache, discarding the cached value. */
+    void reset();
+}

Propchange: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/MethodResultCache.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/TransformMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/TransformMessages.java?rev=927561&r1=927560&r2=927561&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/TransformMessages.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/TransformMessages.java Thu Mar 25 19:34:43 2010
@@ -23,19 +23,17 @@ import org.apache.tapestry5.ioc.internal
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
 import org.apache.tapestry5.ioc.internal.util.MessagesImpl;
 import org.apache.tapestry5.services.TransformField;
-import org.apache.tapestry5.services.TransformMethod;
-import org.apache.tapestry5.services.TransformMethodSignature;
 
-class TransformMessages
+public class TransformMessages
 {
     private static final Messages MESSAGES = MessagesImpl.forClass(TransformMessages.class);
 
-    static String fieldInjectionError(String className, String fieldName, Throwable cause)
+    public static String fieldInjectionError(String className, String fieldName, Throwable cause)
     {
         return MESSAGES.format("field-injection-error", className, fieldName, cause);
     }
 
-    static String illegalNumberOfPageActivationContextHandlers(List<TransformField> fields)
+    public static String illegalNumberOfPageActivationContextHandlers(List<TransformField> fields)
     {
         List<String> names = CollectionFactory.newList();
 

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/Configuration.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/Configuration.java?rev=927561&r1=927560&r2=927561&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/Configuration.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/Configuration.java Thu Mar 25 19:34:43 2010
@@ -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,
@@ -18,9 +18,12 @@ package org.apache.tapestry5.ioc;
  * Object passed into a service contributor method that allows the method provide contributed values to the service's
  * configuration.
  * <p/>
- * A service can <em>collect</em> contributions in three different ways: <ul> <li>As an un-ordered collection of
- * values</li> <li>As an ordered list of values (where each value has a unique id, pre-requisites and
- * post-requisites)</li> <li>As a map of keys and values </ul>
+ * A service can <em>collect</em> contributions in three different ways:
+ * <ul>
+ * <li>As an un-ordered collection of values</li>
+ * <li>As an ordered list of values (where each value has a unique id, pre-requisites and post-requisites)</li>
+ * <li>As a map of keys and values
+ * </ul>
  * <p/>
  * This implementation is used for un-ordered configuration data.
  * <p/>
@@ -31,16 +34,19 @@ public interface Configuration<T>
 {
     /**
      * Adds an object to the service's contribution.
-     *
-     * @param object to add to the service's configuration
+     * 
+     * @param object
+     *            to add to the service's configuration
      */
     void add(T object);
 
     /**
-     * Automatically instantiates an instance of the class, with dependencies injeted, and adds it to the
-     * configuration.
-     *
-     * @param clazz what class to instantiate
+     * Automatically instantiates an instance of the class, with dependencies injected, and adds it to the
+     * configuration. When the configuration type is an interface and the class to be contributed is a local file,
+     * then a reloadable proxy for the class will be created and contributed.
+     * 
+     * @param clazz
+     *            what class to instantiate
      * @since 5.1.0.0
      */
     void addInstance(Class<? extends T> clazz);

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/MappedConfiguration.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/MappedConfiguration.java?rev=927561&r1=927560&r2=927561&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/MappedConfiguration.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/MappedConfiguration.java Thu Mar 25 19:34:43 2010
@@ -1,10 +1,10 @@
-// Copyright 2006, 2008, 2009 The Apache Software Foundation
+// Copyright 2006, 2008, 2009, 2010 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,
@@ -18,9 +18,12 @@ package org.apache.tapestry5.ioc;
  * Object passed into a service contributor method that allows the method provide contributed values to the service's
  * configuration.
  * <p/>
- * A service can <em>collect</em> contributions in three different ways: <ul> <li>As an un-ordered collection of
- * values</li> <li>As an ordered list of values (where each value has a unique id, pre-requisites and
- * post-requisites)</li> <li>As a map of keys and values </ul>
+ * A service can <em>collect</em> contributions in three different ways:
+ * <ul>
+ * <li>As an un-ordered collection of values</li>
+ * <li>As an ordered list of values (where each value has a unique id, pre-requisites and post-requisites)</li>
+ * <li>As a map of keys and values
+ * </ul>
  * <p/>
  * The service defines the <em>type</em> of contribution, in terms of a base class or service interface. Contributions
  * must be compatible with the type.
@@ -30,36 +33,49 @@ public interface MappedConfiguration<K, 
 
     /**
      * Adds a keyed object to the service's contribution.
-     *
-     * @param key   unique id for the value
-     * @param value to contribute
-     * @throws IllegalArgumentException if key is not unique
+     * 
+     * @param key
+     *            unique id for the value
+     * @param value
+     *            to contribute
+     * @throws IllegalArgumentException
+     *             if key is not unique
      */
     void add(K key, V value);
 
     /**
      * Overrides an existing contribution by its key.
-     *
-     * @param key   unique id of value to override
-     * @param value new value, or null to remove the key entirely
+     * 
+     * @param key
+     *            unique id of value to override
+     * @param value
+     *            new value, or null to remove the key entirely
      * @since 5.1.0.0
      */
     void override(K key, V value);
 
     /**
-     * Adds a keyed object as an instantiated instance (with dependencies injected) of a class.
-     *
-     * @param key   unique id for the value
-     * @param clazz class to instantiate and contribute
+     * Adds a keyed object as an instantiated instance (with dependencies injected) of a class. When the value
+     * type is an interface and the class to be contributed is a local file,
+     * then a reloadable proxy for the value class will be created and contributed.
+     * 
+     * @param key
+     *            unique id for the value
+     * @param clazz
+     *            class to instantiate and contribute
      * @since 5.1.0.0
      */
     void addInstance(K key, Class<? extends V> clazz);
 
     /**
-     * Overrides an existing contribution with a new instance.
-     *
-     * @param key   unique id of value to override
-     * @param clazz class to instantiate as override
+     * Overrides an existing contribution with a new instance. When the value
+     * type is an interface and the class to be contributed is a local file,
+     * then a reloadable proxy for the value class will be created and contributed.
+     * 
+     * @param key
+     *            unique id of value to override
+     * @param clazz
+     *            class to instantiate as override
      */
     void overrideInstance(K key, Class<? extends V> clazz);
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/OrderedConfiguration.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/OrderedConfiguration.java?rev=927561&r1=927560&r2=927561&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/OrderedConfiguration.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/OrderedConfiguration.java Thu Mar 25 19:34:43 2010
@@ -1,10 +1,10 @@
-// Copyright 2006, 2008, 2009 The Apache Software Foundation
+// Copyright 2006, 2008, 2009, 2010 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,
@@ -18,9 +18,12 @@ package org.apache.tapestry5.ioc;
  * Object passed into a service contributor method that allows the method provide contributed values to the service's
  * configuration.
  * <p/>
- * A service can <em>collect</em> contributions in three different ways: <ul> <li>As an un-ordered collection of
- * values</li> <li>As an ordered list of values (where each value has a unique id, pre-requisites and
- * post-requisites)</li> <li>As a map of keys and values </ul>
+ * A service can <em>collect</em> contributions in three different ways:
+ * <ul>
+ * <li>As an un-ordered collection of values</li>
+ * <li>As an ordered list of values (where each value has a unique id, pre-requisites and post-requisites)</li>
+ * <li>As a map of keys and values
+ * </ul>
  * <p/>
  * The service defines the <em>type</em> of contribution, in terms of a base class or service interface. Contributions
  * must be compatible with the type.
@@ -31,40 +34,55 @@ public interface OrderedConfiguration<T>
      * Adds an ordered object to a service's contribution. Each object has an id (which must be unique). Optionally,
      * pre-requisites (a list of ids that must precede this object) and post-requisites (ids that must follow) can be
      * provided.
-     *
-     * @param id          a unique id for the object; the id will be fully qualified with the contributing module's id
-     * @param constraints used to order the object relative to other contributed objects
+     * 
+     * @param id
+     *            a unique id for the object; the id will be fully qualified with the contributing module's id
+     * @param constraints
+     *            used to order the object relative to other contributed objects
      * @parm object to add to the service's configuration
      */
     void add(String id, T object, String... constraints);
 
     /**
-     * Overrides a normally contributed object.  Each override must match a single normally contributed object.
-     *
-     * @param id          identifies object to override
-     * @param object      overriding object (may be null)
-     * @param constraints contrains for the overridden object, replacing constraints for the original object (even if
-     *                    omitted, in which case the override object will have no orderring contraints)
+     * Overrides a normally contributed object. Each override must match a single normally contributed object.
+     * 
+     * @param id
+     *            identifies object to override
+     * @param object
+     *            overriding object (may be null)
+     * @param constraints
+     *            contrains for the overridden object, replacing constraints for the original object (even if
+     *            omitted, in which case the override object will have no orderring contraints)
      * @since 5.1.0.0
      */
     void override(String id, T object, String... constraints);
 
     /**
-     * Adds an ordered object by instantiating (with dependencies) the indicated class.
-     *
-     * @param id          of contribution (used for ordering)
-     * @param clazz       class to instantiate
-     * @param constraints used to order the object relative to other contributed objects
+     * Adds an ordered object by instantiating (with dependencies) the indicated class. When the configuration type is
+     * an interface and the class to be contributed is a local file,
+     * then a reloadable proxy for the class will be created and contributed.
+     * 
+     * @param id
+     *            of contribution (used for ordering)
+     * @param clazz
+     *            class to instantiate
+     * @param constraints
+     *            used to order the object relative to other contributed objects
      * @since 5.1.0.0
      */
     void addInstance(String id, Class<? extends T> clazz, String... constraints);
 
     /**
-     * Instantiates an object and adds it as an override.
-     *
-     * @param id          of object to override
-     * @param clazz       to instantiate
-     * @param constraints override contraints
+     * Instantiates an object and adds it as an override. When the configuration type is an interface and the class to
+     * be contributed is a local file,
+     * then a reloadable proxy for the class will be created and contributed.
+     * 
+     * @param id
+     *            of object to override
+     * @param clazz
+     *            to instantiate
+     * @param constraints
+     *            override contraints
      * @since 5.1.0.0
      */
     void overrideInstance(String id, Class<? extends T> clazz, String... constraints);

Added: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/AbstractConfigurationImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/AbstractConfigurationImpl.java?rev=927561&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/AbstractConfigurationImpl.java (added)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/AbstractConfigurationImpl.java Thu Mar 25 19:34:43 2010
@@ -0,0 +1,42 @@
+// Copyright 2010 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.internal;
+
+import org.apache.tapestry5.ioc.ObjectLocator;
+import org.apache.tapestry5.ioc.internal.util.Defense;
+import org.apache.tapestry5.ioc.internal.util.InternalUtils;
+
+public abstract class AbstractConfigurationImpl<T>
+{
+    private final Class<T> contributionType;
+
+    private final ObjectLocator locator;
+
+    public AbstractConfigurationImpl(Class<T> contributionType, ObjectLocator locator)
+    {
+        this.contributionType = contributionType;
+        this.locator = locator;
+    }
+
+    protected T instantiate(Class<? extends T> clazz)
+    {
+        Defense.notNull(clazz, "clazz");
+
+        if (contributionType.isInterface() && InternalUtils.isLocalFile(clazz))
+            return locator.proxy(contributionType, clazz);
+
+        return locator.autobuild(clazz);
+    }
+}

Propchange: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/AbstractConfigurationImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/InternalRegistry.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/InternalRegistry.java?rev=927561&r1=927560&r2=927561&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/InternalRegistry.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/InternalRegistry.java Thu Mar 25 19:34:43 2010
@@ -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,
@@ -32,34 +32,41 @@ public interface InternalRegistry extend
     /**
      * As with {@link org.apache.tapestry5.ioc.Registry#getObject(Class, org.apache.tapestry5.ioc.AnnotationProvider)},
      * but handles the {@link org.apache.tapestry5.ioc.annotations.Local} annotation.
-     *
-     * @param objectType         type of object o be injected
-     * @param annotationProvider access to annotations at point of injection
-     * @param locator            used to resolve any subsequent injections
-     * @param localModule        module to limit services to, if Local annotaton present
+     * 
+     * @param objectType
+     *            type of object o be injected
+     * @param annotationProvider
+     *            access to annotations at point of injection
+     * @param locator
+     *            used to resolve any subsequent injections
+     * @param localModule
+     *            module to limit services to, if Local annotaton present
      * @return the service or object
      */
     <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator,
-                    Module localModule);
+            Module localModule);
 
     /**
      * Returns a service lifecycle by service scope name.
-     *
-     * @param scope the name of the service scope (case insensitive)
+     * 
+     * @param scope
+     *            the name of the service scope (case insensitive)
      * @return the lifecycle corresponding to the scope
-     * @throws RuntimeException if the lifecycle name does not match a known lifecycle
+     * @throws RuntimeException
+     *             if the lifecycle name does not match a known lifecycle
      */
     ServiceLifecycle2 getServiceLifecycle(String scope);
 
     /**
-     * Searches for decorators for a particular service. The resulting {@link org.apache.tapestry5.ioc.def.DecoratorDef}s
+     * Searches for decorators for a particular service. The resulting {@link org.apache.tapestry5.ioc.def.DecoratorDef}
+     * s
      * are ordered, then converted into {@link ServiceDecorator}s.
      */
     List<ServiceDecorator> findDecoratorsForService(ServiceDef serviceDef);
 
     /**
      * Searches for advisors for a particular service, returning them in order of application.
-     *
+     * 
      * @since 5.1.0.0
      */
     List<ServiceAdvisor> findAdvisorsForService(ServiceDef serviceDef);
@@ -67,10 +74,12 @@ public interface InternalRegistry extend
     /**
      * Builds up an unordered collection by invoking service contributor methods that target the service (from any
      * module, unless the service is private).
-     *
+     * 
      * @param <T>
-     * @param serviceDef defines the service for which configuration data is being assembled
-     * @param valueType  identifies the type of object allowed into the collection
+     * @param serviceDef
+     *            defines the service for which configuration data is being assembled
+     * @param valueType
+     *            identifies the type of object allowed into the collection
      * @return the final collection
      */
     <T> Collection<T> getUnorderedConfiguration(ServiceDef serviceDef, Class<T> valueType);
@@ -79,10 +88,12 @@ public interface InternalRegistry extend
      * Builds up an ordered collection by invoking service contributor methods that target the service (from any module,
      * unless the service is private). Once all values have been added (each with an id, and pre/post constraints), the
      * values are ordered, null values dropped, and the final sorted list is returned.
-     *
+     * 
      * @param <T>
-     * @param serviceDef defines the service for which configuration data is being assembled
-     * @param valueType  identifies the type of object allowed into the collection
+     * @param serviceDef
+     *            defines the service for which configuration data is being assembled
+     * @param valueType
+     *            identifies the type of object allowed into the collection
      * @return the final ordered list
      */
     <T> List<T> getOrderedConfiguration(ServiceDef serviceDef, Class<T> valueType);
@@ -91,28 +102,31 @@ public interface InternalRegistry extend
      * Builds up a map of key/value pairs by invoking service contribution methods that tharget the service (from any
      * module, unless the service is private). Values and keys may not be null. Invalid values (keys or values that are
      * the wrong type, or duplicate keys) result in warnings and are ignored.
-     *
-     * @param <K,        V>
-     * @param serviceDef defines the service for which configuration data is being assembled
-     * @param keyType    identifies the type of key object allowed into the map
-     * @param valueType  identifies the type of value object allowed into the map
+     * 
+     * @param <K, V>
+     * @param serviceDef
+     *            defines the service for which configuration data is being assembled
+     * @param keyType
+     *            identifies the type of key object allowed into the map
+     * @param valueType
+     *            identifies the type of value object allowed into the map
      * @return the final ordered list
      */
-    <K, V> Map<K, V> getMappedConfiguration(ServiceDef serviceDef, Class<K> keyType,
-                                            Class<V> valueType);
+    <K, V> Map<K, V> getMappedConfiguration(ServiceDef serviceDef, Class<K> keyType, Class<V> valueType);
 
     /**
-     * Convieience for creating a new {@link org.apache.tapestry5.ioc.services.ClassFab} instance using a {@link
-     * org.apache.tapestry5.ioc.services.ClassFactory}.
-     *
-     * @param serviceInterface the interface to be implemented by the provided class
+     * Convieience for creating a new {@link org.apache.tapestry5.ioc.services.ClassFab} instance using a
+     * {@link org.apache.tapestry5.ioc.services.ClassFactory}.
+     * 
+     * @param serviceInterface
+     *            the interface to be implemented by the provided class
      */
     ClassFab newClass(Class serviceInterface);
 
     /**
      * Given an input string that <em>may</em> contain symbols, returns the string with any and all symbols fully
      * expanded.
-     *
+     * 
      * @param input
      * @return expanded input
      */
@@ -121,9 +135,17 @@ public interface InternalRegistry extend
     /**
      * Returns a logger for the service, which consists of the Module's {@link Module#getLoggerName() log name} suffixed
      * with a period and the service id.
-     *
+     * 
      * @param serviceId
      * @return the logger for the service
      */
     Logger getServiceLogger(String serviceId);
+
+    /**
+     * Creates a just-in-time (and possibly, live reloading) proxy for the indicated class and interface, using the
+     * provided locator to autobuild the implementationClass (when necessary).
+     * 
+     * @since 5.2.0
+     */
+    <T> T proxy(Class<T> interfaceClass, Class<? extends T> implementationClass, ObjectLocator locator);
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ObjectLocatorImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ObjectLocatorImpl.java?rev=927561&r1=927560&r2=927561&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ObjectLocatorImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ObjectLocatorImpl.java Thu Mar 25 19:34:43 2010
@@ -62,6 +62,6 @@ public class ObjectLocatorImpl implement
 
     public <T> T proxy(Class<T> interfaceClass, Class<? extends T> implementationClass)
     {
-        return registry.proxy(interfaceClass, implementationClass);
+        return registry.proxy(interfaceClass, implementationClass, this);
     }
 }

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=927561&r1=927560&r2=927561&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 Thu Mar 25 19:34:43 2010
@@ -515,8 +515,8 @@ public class RegistryImpl implements Reg
 
         for (final ContributionDef def : contributions)
         {
-            final MappedConfiguration<K, V> validating = new ValidatingMappedConfigurationWrapper<K, V>(map, overrides,
-                    serviceId, def, keyClass, valueType, keyToContribution, resources);
+            final MappedConfiguration<K, V> validating = new ValidatingMappedConfigurationWrapper<K, V>(valueType,
+                    resources, map, overrides, serviceId, def, keyClass, keyToContribution);
 
             String description = IOCMessages.invokingMethod(def);
 
@@ -550,8 +550,8 @@ public class RegistryImpl implements Reg
 
         for (final ContributionDef def : contributions)
         {
-            final Configuration<T> validating = new ValidatingConfigurationWrapper<T>(collection, serviceId, valueType,
-                    resources);
+            final Configuration<T> validating = new ValidatingConfigurationWrapper<T>(valueType, resources, collection,
+                    serviceId);
 
             String description = IOCMessages.invokingMethod(def);
 
@@ -585,8 +585,8 @@ public class RegistryImpl implements Reg
 
         for (final ContributionDef def : contributions)
         {
-            final OrderedConfiguration<T> validating = new ValidatingOrderedConfigurationWrapper<T>(orderer, overrides,
-                    def, serviceId, valueType, resources);
+            final OrderedConfiguration<T> validating = new ValidatingOrderedConfigurationWrapper<T>(valueType,
+                    resources, orderer, overrides, def, serviceId);
 
             String description = IOCMessages.invokingMethod(def);
 
@@ -966,7 +966,12 @@ public class RegistryImpl implements Reg
         return result;
     }
 
-    public <T> T proxy(Class<T> interfaceClass, final Class<? extends T> implementationClass)
+    public <T> T proxy(Class<T> interfaceClass, Class<? extends T> implementationClass)
+    {
+        return proxy(interfaceClass, implementationClass, this);
+    }
+
+    public <T> T proxy(Class<T> interfaceClass, Class<? extends T> implementationClass, ObjectLocator locator)
     {
         Defense.notNull(interfaceClass, "interfaceClass");
         Defense.notNull(implementationClass, "implementationClass");
@@ -975,18 +980,19 @@ public class RegistryImpl implements Reg
         // TODO: Check impl class extends interfaceClass and is concrete
 
         if (InternalUtils.isLocalFile(implementationClass))
-            return createReloadingProxy(interfaceClass, implementationClass);
+            return createReloadingProxy(interfaceClass, implementationClass, locator);
 
-        return createNonReloadingProxy(interfaceClass, implementationClass);
+        return createNonReloadingProxy(interfaceClass, implementationClass, locator);
     }
 
-    private <T> T createNonReloadingProxy(Class<T> interfaceClass, final Class<? extends T> implementationClass)
+    private <T> T createNonReloadingProxy(Class<T> interfaceClass, final Class<? extends T> implementationClass,
+            final ObjectLocator locator)
     {
         final ObjectCreator autobuildCreator = new ObjectCreator()
         {
             public Object createObject()
             {
-                return autobuild(implementationClass);
+                return locator.autobuild(implementationClass);
             }
         };
 
@@ -1007,10 +1013,11 @@ public class RegistryImpl implements Reg
                 implementationClass.getName(), interfaceClass.getName()));
     }
 
-    private <T> T createReloadingProxy(Class<T> interfaceClass, final Class<? extends T> implementationClass)
+    private <T> T createReloadingProxy(Class<T> interfaceClass, final Class<? extends T> implementationClass,
+            ObjectLocator locator)
     {
         ReloadableObjectCreator creator = new ReloadableObjectCreator(implementationClass.getClassLoader(),
-                implementationClass.getName(), loggerSource.getLogger(implementationClass), this);
+                implementationClass.getName(), loggerSource.getLogger(implementationClass), locator);
 
         getService(UpdateListenerHub.class).addUpdateListener(creator);
 

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ValidatingConfigurationWrapper.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ValidatingConfigurationWrapper.java?rev=927561&r1=927560&r2=927561&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ValidatingConfigurationWrapper.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ValidatingConfigurationWrapper.java Thu Mar 25 19:34:43 2010
@@ -1,10 +1,10 @@
-// Copyright 2006, 2007, 2008 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2010 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,
@@ -14,34 +14,31 @@
 
 package org.apache.tapestry5.ioc.internal;
 
+import java.util.Collection;
+
 import org.apache.tapestry5.ioc.Configuration;
 import org.apache.tapestry5.ioc.ObjectLocator;
 
-import java.util.Collection;
-
 /**
  * Wraps a {@link java.util.Collection} as a {@link org.apache.tapestry5.ioc.Configuration} and perform validation that
  * collected value are of the correct type.
  */
-public class ValidatingConfigurationWrapper<T> implements Configuration<T>
+public class ValidatingConfigurationWrapper<T> extends AbstractConfigurationImpl<T> implements Configuration<T>
 {
     private final String serviceId;
 
-    private final Class expectedType;
+    private final Class<T> expectedType;
 
     private final Collection<T> collection;
 
-    private final ObjectLocator locator;
-
-    // Need a strategy for determing the right order for this mass of parameters!
-
-    public ValidatingConfigurationWrapper(Collection<T> collection, String serviceId, Class expectedType,
-                                          ObjectLocator locator)
+    public ValidatingConfigurationWrapper(Class<T> expectedType, ObjectLocator locator, Collection<T> collection,
+            String serviceId)
     {
+        super(expectedType, locator);
+
         this.collection = collection;
         this.serviceId = serviceId;
         this.expectedType = expectedType;
-        this.locator = locator;
     }
 
     public void add(T object)
@@ -52,9 +49,7 @@ public class ValidatingConfigurationWrap
         // Sure, we say it is type T ... but is it really?
 
         if (!expectedType.isInstance(object))
-            throw new IllegalArgumentException(IOCMessages.contributionWrongValueType(
-                    serviceId,
-                    object.getClass(),
+            throw new IllegalArgumentException(IOCMessages.contributionWrongValueType(serviceId, object.getClass(),
                     expectedType));
 
         collection.add(object);
@@ -62,6 +57,6 @@ public class ValidatingConfigurationWrap
 
     public void addInstance(Class<? extends T> clazz)
     {
-        add(locator.autobuild(clazz));
+        add(instantiate(clazz));
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ValidatingMappedConfigurationWrapper.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ValidatingMappedConfigurationWrapper.java?rev=927561&r1=927560&r2=927561&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ValidatingMappedConfigurationWrapper.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ValidatingMappedConfigurationWrapper.java Thu Mar 25 19:34:43 2010
@@ -1,10 +1,10 @@
-// Copyright 2006, 2007, 2008, 2009 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009, 2010 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,
@@ -14,26 +14,30 @@
 
 package org.apache.tapestry5.ioc.internal;
 
+import java.util.Map;
+
 import org.apache.tapestry5.ioc.MappedConfiguration;
 import org.apache.tapestry5.ioc.ObjectLocator;
 import org.apache.tapestry5.ioc.def.ContributionDef;
 
-import java.util.Map;
-
 /**
  * A wrapper around a Map that provides the {@link org.apache.tapestry5.ioc.MappedConfiguration} interface, and provides
- * two forms of validation for mapped configurations: <ul> <li>If either key or value is null, then a warning is logged
- * </li> <li>If the key has previously been stored (by some other {@link org.apache.tapestry5.ioc.def.ContributionDef},
- * then a warning is logged</li> </ul>
+ * two forms of validation for mapped configurations:
+ * <ul>
+ * <li>If either key or value is null, then a warning is logged</li>
+ * <li>If the key has previously been stored (by some other {@link org.apache.tapestry5.ioc.def.ContributionDef}, then a
+ * warning is logged</li>
+ * </ul>
  * <p/>
  * When a warning is logged, the key/value pair is not added to the delegate.
  * <p/>
  * Handles instantiation of instances.
- *
+ * 
  * @param <K>
  * @param <V>
  */
-public class ValidatingMappedConfigurationWrapper<K, V> implements MappedConfiguration<K, V>
+public class ValidatingMappedConfigurationWrapper<K, V> extends AbstractConfigurationImpl<V> implements
+        MappedConfiguration<K, V>
 {
     private final Map<K, V> map;
 
@@ -49,14 +53,12 @@ public class ValidatingMappedConfigurati
 
     private final Map<K, ContributionDef> keyToContributor;
 
-    private final ObjectLocator locator;
-
-    public ValidatingMappedConfigurationWrapper(Map<K, V> map, Map<K, MappedConfigurationOverride<K, V>> overrides,
-                                                String serviceId, ContributionDef contributionDef,
-                                                Class<K> expectedKeyType, Class<V> expectedValueType,
-                                                Map<K, ContributionDef> keyToContributor,
-                                                ObjectLocator locator)
+    public ValidatingMappedConfigurationWrapper(Class<V> expectedValueType, ObjectLocator locator, Map<K, V> map,
+            Map<K, MappedConfigurationOverride<K, V>> overrides, String serviceId, ContributionDef contributionDef,
+            Class<K> expectedKeyType, Map<K, ContributionDef> keyToContributor)
     {
+        super(expectedValueType, locator);
+
         this.map = map;
         this.overrides = overrides;
         this.serviceId = serviceId;
@@ -64,7 +66,6 @@ public class ValidatingMappedConfigurati
         this.expectedKeyType = expectedKeyType;
         this.expectedValueType = expectedValueType;
         this.keyToContributor = keyToContributor;
-        this.locator = locator;
     }
 
     public void add(K key, V value)
@@ -74,7 +75,6 @@ public class ValidatingMappedConfigurati
         if (value == null)
             throw new NullPointerException(IOCMessages.contributionWasNull(serviceId));
 
-
         validateValue(value);
 
         ContributionDef existing = keyToContributor.get(key);
@@ -93,8 +93,8 @@ public class ValidatingMappedConfigurati
     private void validateValue(V value)
     {
         if (!expectedValueType.isInstance(value))
-            throw new IllegalArgumentException(IOCMessages.contributionWrongValueType(serviceId, value
-                    .getClass(), expectedValueType));
+            throw new IllegalArgumentException(IOCMessages.contributionWrongValueType(serviceId, value.getClass(),
+                    expectedValueType));
     }
 
     private void validateKey(K key)
@@ -103,38 +103,33 @@ public class ValidatingMappedConfigurati
             throw new NullPointerException(IOCMessages.contributionKeyWasNull(serviceId));
 
         if (!expectedKeyType.isInstance(key))
-            throw new IllegalArgumentException(
-                    IOCMessages.contributionWrongKeyType(serviceId, key
-                            .getClass(), expectedKeyType));
+            throw new IllegalArgumentException(IOCMessages.contributionWrongKeyType(serviceId, key.getClass(),
+                    expectedKeyType));
     }
 
     public void addInstance(K key, Class<? extends V> clazz)
     {
-        V value = locator.autobuild(clazz);
-
-        add(key, value);
+        add(key, instantiate(clazz));
     }
 
     public void override(K key, V value)
     {
         validateKey(key);
 
-        if (value != null) validateValue(value);
+        if (value != null)
+            validateValue(value);
 
         MappedConfigurationOverride<K, V> existing = overrides.get(key);
 
         if (existing != null)
-            throw new IllegalArgumentException(
-                    String.format("Contribution key %s has already been overridden (by %s).",
-                                  key, existing.getContribDef()));
-
+            throw new IllegalArgumentException(String.format(
+                    "Contribution key %s has already been overridden (by %s).", key, existing.getContribDef()));
 
         overrides.put(key, new MappedConfigurationOverride<K, V>(contributionDef, map, key, value));
     }
 
-
     public void overrideInstance(K key, Class<? extends V> clazz)
     {
-        override(key, locator.autobuild(clazz));
+        override(key, instantiate(clazz));
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ValidatingOrderedConfigurationWrapper.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ValidatingOrderedConfigurationWrapper.java?rev=927561&r1=927560&r2=927561&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ValidatingOrderedConfigurationWrapper.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ValidatingOrderedConfigurationWrapper.java Thu Mar 25 19:34:43 2010
@@ -1,10 +1,10 @@
-// Copyright 2006, 2007, 2008, 2009 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009, 2010 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,
@@ -14,46 +14,43 @@
 
 package org.apache.tapestry5.ioc.internal;
 
+import java.util.Map;
+
 import org.apache.tapestry5.ioc.ObjectLocator;
 import org.apache.tapestry5.ioc.OrderedConfiguration;
 import org.apache.tapestry5.ioc.def.ContributionDef;
 import org.apache.tapestry5.ioc.internal.util.Defense;
 import org.apache.tapestry5.ioc.internal.util.Orderer;
 
-import java.util.Map;
-
 /**
  * Wraps a {@link java.util.List} as a {@link org.apache.tapestry5.ioc.OrderedConfiguration}, implementing validation of
  * values provided to an {@link org.apache.tapestry5.ioc.OrderedConfiguration}.
- *
+ * 
  * @param <T>
  */
-public class ValidatingOrderedConfigurationWrapper<T> implements OrderedConfiguration<T>
+public class ValidatingOrderedConfigurationWrapper<T> extends AbstractConfigurationImpl<T> implements
+        OrderedConfiguration<T>
 {
     private final Orderer<T> orderer;
 
     private final String serviceId;
 
-    private final Class expectedType;
-
-    private final ObjectLocator locator;
+    private final Class<T> expectedType;
 
     private final Map<String, OrderedConfigurationOverride<T>> overrides;
 
     private final ContributionDef contribDef;
 
-    public ValidatingOrderedConfigurationWrapper(Orderer<T> orderer,
-                                                 Map<String, OrderedConfigurationOverride<T>> overrides,
-                                                 ContributionDef contribDef, String serviceId,
-                                                 Class expectedType,
-                                                 ObjectLocator locator)
+    public ValidatingOrderedConfigurationWrapper(Class<T> expectedType, ObjectLocator locator, Orderer<T> orderer,
+            Map<String, OrderedConfigurationOverride<T>> overrides, ContributionDef contribDef, String serviceId)
     {
+        super(expectedType, locator);
+
         this.orderer = orderer;
         this.overrides = overrides;
         this.contribDef = contribDef;
         this.serviceId = serviceId;
         this.expectedType = expectedType;
-        this.locator = locator;
     }
 
     public void add(String id, T object, String... constraints)
@@ -69,29 +66,31 @@ public class ValidatingOrderedConfigurat
 
         checkValid(object);
 
-        OrderedConfigurationOverride existing = overrides.get(id);
+        OrderedConfigurationOverride<T> existing = overrides.get(id);
+
         if (existing != null)
             throw new IllegalArgumentException(String.format("Contribution '%s' has already been overridden (by %s).",
-                                                             id, existing.getContribDef()));
+                    id, existing.getContribDef()));
 
-        overrides.put(id, new OrderedConfigurationOverride(orderer, id, object, constraints, contribDef));
+        overrides.put(id, new OrderedConfigurationOverride<T>(orderer, id, object, constraints, contribDef));
     }
 
     public void addInstance(String id, Class<? extends T> clazz, String... constraints)
     {
-        add(id, locator.autobuild(clazz), constraints);
+        add(id, instantiate(clazz), constraints);
     }
 
     public void overrideInstance(String id, Class<? extends T> clazz, String... constraints)
     {
-        override(id, locator.autobuild(clazz), constraints);
+        override(id, instantiate(clazz), constraints);
     }
 
     private void checkValid(T object)
     {
-        if (object == null || expectedType.isInstance(object)) return;
+        if (object == null || expectedType.isInstance(object))
+            return;
 
-        throw new IllegalArgumentException(IOCMessages.contributionWrongValueType(serviceId, object
-                .getClass(), expectedType));
+        throw new IllegalArgumentException(IOCMessages.contributionWrongValueType(serviceId, object.getClass(),
+                expectedType));
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java?rev=927561&r1=927560&r2=927561&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java Thu Mar 25 19:34:43 2010
@@ -989,7 +989,14 @@ public class InternalUtils
     {
         String path = ClassFabUtils.getPathForClass(clazz);
 
-        URL classFileURL = clazz.getClassLoader().getResource(path);
+        ClassLoader loader = clazz.getClassLoader();
+
+        // System classes have no visible class loader, and are not local files.
+
+        if (loader == null)
+            return false;
+
+        URL classFileURL = loader.getResource(path);
 
         return classFileURL != null && classFileURL.getProtocol().equals("file");
     }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingConfigurationWrapperTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingConfigurationWrapperTest.java?rev=927561&r1=927560&r2=927561&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingConfigurationWrapperTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingConfigurationWrapperTest.java Thu Mar 25 19:34:43 2010
@@ -34,8 +34,8 @@ public class ValidatingConfigurationWrap
 
         replay();
 
-        Configuration wrapper = new ValidatingConfigurationWrapper(collection, "foo.Bar",
-                                                                   Runnable.class, null);
+        Configuration wrapper = new ValidatingConfigurationWrapper(Runnable.class, null,
+                                                                   collection, "foo.Bar");
 
         wrapper.add(value);
 
@@ -55,8 +55,8 @@ public class ValidatingConfigurationWrap
 
         replay();
 
-        Configuration wrapper = new ValidatingConfigurationWrapper(collection, "foo.Bar",
-                                                                   Map.class, locator);
+        Configuration wrapper = new ValidatingConfigurationWrapper(Map.class, locator,
+                                                                   collection, "foo.Bar");
 
         wrapper.addInstance(HashMap.class);
 
@@ -71,8 +71,8 @@ public class ValidatingConfigurationWrap
     {
         List<Runnable> collection = CollectionFactory.newList();
 
-        Configuration wrapper = new ValidatingConfigurationWrapper(collection, "Bar", Runnable.class,
-                                                                   null);
+        Configuration wrapper = new ValidatingConfigurationWrapper(Runnable.class, null, collection,
+                                                                   "Bar");
 
         try
         {
@@ -92,8 +92,8 @@ public class ValidatingConfigurationWrap
         List<Runnable> collection = CollectionFactory.newList();
 
 
-        Configuration wrapper = new ValidatingConfigurationWrapper(collection, "Bar", Runnable.class,
-                                                                   null);
+        Configuration wrapper = new ValidatingConfigurationWrapper(Runnable.class, null, collection,
+                                                                   "Bar");
 
         try
         {

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingMappedConfigurationWrapperTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingMappedConfigurationWrapperTest.java?rev=927561&r1=927560&r2=927561&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingMappedConfigurationWrapperTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingMappedConfigurationWrapperTest.java Thu Mar 25 19:34:43 2010
@@ -43,7 +43,7 @@ public class ValidatingMappedConfigurati
         replay();
 
         MappedConfiguration<Class, Runnable> wrapper = new ValidatingMappedConfigurationWrapper<Class, Runnable>(
-                map, null, SERVICE_ID, def, Class.class, Runnable.class, keyToContribution, locator);
+                Runnable.class, locator, map, null, SERVICE_ID, def, Class.class, keyToContribution);
 
         wrapper.add(key, value);
 
@@ -70,7 +70,7 @@ public class ValidatingMappedConfigurati
         replay();
 
         MappedConfiguration<Class, Runnable> wrapper = new ValidatingMappedConfigurationWrapper<Class, Runnable>(
-                map, null, SERVICE_ID, def2, Class.class, Runnable.class, keyToContribution, locator);
+                Runnable.class, locator, map, null, SERVICE_ID, def2, Class.class, keyToContribution);
 
         try
         {
@@ -101,7 +101,7 @@ public class ValidatingMappedConfigurati
         replay();
 
         MappedConfiguration<Class, Runnable> wrapper = new ValidatingMappedConfigurationWrapper<Class, Runnable>(
-                map, null, SERVICE_ID, def, Class.class, Runnable.class, keyToContribution, locator);
+                Runnable.class, locator, map, null, SERVICE_ID, def, Class.class, keyToContribution);
 
         try
         {
@@ -130,9 +130,9 @@ public class ValidatingMappedConfigurati
 
         replay();
 
-        MappedConfiguration wrapper = new ValidatingMappedConfigurationWrapper(map, null, SERVICE_ID, def,
-                                                                               Class.class, Runnable.class,
-                                                                               keyToContribution, locator);
+        MappedConfiguration wrapper = new ValidatingMappedConfigurationWrapper(Runnable.class, locator, map, null,
+                                                                               SERVICE_ID, def,
+                                                                               Class.class, keyToContribution);
 
         try
         {
@@ -162,9 +162,9 @@ public class ValidatingMappedConfigurati
 
         replay();
 
-        MappedConfiguration wrapper = new ValidatingMappedConfigurationWrapper(map, null, SERVICE_ID, def,
-                                                                               Class.class, Runnable.class,
-                                                                               keyToContribution, locator);
+        MappedConfiguration wrapper = new ValidatingMappedConfigurationWrapper(Runnable.class, locator, map, null,
+                                                                               SERVICE_ID, def,
+                                                                               Class.class, keyToContribution);
 
         try
         {
@@ -193,7 +193,7 @@ public class ValidatingMappedConfigurati
         replay();
 
         MappedConfiguration<Class, Runnable> wrapper = new ValidatingMappedConfigurationWrapper<Class, Runnable>(
-                map, null, SERVICE_ID, def, Class.class, Runnable.class, keyToContribution, locator);
+                Runnable.class, locator, map, null, SERVICE_ID, def, Class.class, keyToContribution);
 
         try
         {

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingOrderedConfigurationWrapperTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingOrderedConfigurationWrapperTest.java?rev=927561&r1=927560&r2=927561&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingOrderedConfigurationWrapperTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/ValidatingOrderedConfigurationWrapperTest.java Thu Mar 25 19:34:43 2010
@@ -41,7 +41,7 @@ public class ValidatingOrderedConfigurat
         replay();
 
         OrderedConfiguration<Runnable> wrapper = new ValidatingOrderedConfigurationWrapper<Runnable>(
-                orderer, null, null, "Service", Runnable.class, null);
+                Runnable.class, null, orderer, null, null, "Service");
 
         wrapper.add("id", contribution, "after:pre", "before:post");
 
@@ -68,7 +68,7 @@ public class ValidatingOrderedConfigurat
         replay();
 
         OrderedConfiguration<Map> wrapper = new ValidatingOrderedConfigurationWrapper<Map>(
-                orderer, null, null, "Service", Map.class, locator);
+                Map.class, locator, orderer, null, null, "Service");
 
         wrapper.addInstance("id", HashMap.class, "after:pre", "before:post");
 
@@ -86,7 +86,7 @@ public class ValidatingOrderedConfigurat
         replay();
 
         OrderedConfiguration<Runnable> wrapper = new ValidatingOrderedConfigurationWrapper<Runnable>(
-                orderer, null, null, "Service", Runnable.class, null);
+                Runnable.class, null, orderer, null, null, "Service");
 
         wrapper.add("id", null);
 
@@ -104,8 +104,8 @@ public class ValidatingOrderedConfigurat
 
         replay();
 
-        OrderedConfiguration wrapper = new ValidatingOrderedConfigurationWrapper(orderer, null, null, "Service",
-                                                                                 Runnable.class, null);
+        OrderedConfiguration wrapper = new ValidatingOrderedConfigurationWrapper(Runnable.class, null, orderer, null,
+                                                                                 null, "Service");
 
         try
         {