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 2007/03/19 00:59:56 UTC

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

Author: hlship
Date: Sun Mar 18 16:59:54 2007
New Revision: 519748

URL: http://svn.apache.org/viewvc?view=rev&rev=519748
Log:
Rename OneShotServiceCreator to RecursiveServiceCreationCheckWrapper to reflect what it actually does.
Create a JustInTimeObjectCreator to encapsulate thread-safe service realization, eager service loading and registry shutdown, and move some logic out of generated proxy code and into the new class.

Added:
    tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/RecursiveServiceCreationCheckWrapper.java
      - copied, changed from r516833, tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/OneShotServiceCreator.java
    tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/JustInTimeObjectCreator.java
    tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/JustInTimeObjectCreatorTest.java
    tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/RecursiveServiceCreationCheckWrapperTest.java
      - copied, changed from r517073, tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/OneShotServiceCreatorTest.java
Removed:
    tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/IOCProxyUtilities.java
    tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/OneShotServiceCreator.java
    tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/OneShotServiceCreatorTest.java
Modified:
    tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/IOCMessages.java
    tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ModuleImpl.java
    tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ServiceMessages.java
    tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassFabUtils.java
    tapestry/tapestry5/tapestry-ioc/trunk/src/main/resources/org/apache/tapestry/ioc/internal/IOCStrings.properties
    tapestry/tapestry5/tapestry-ioc/trunk/src/main/resources/org/apache/tapestry/ioc/internal/services/ServiceStrings.properties

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/IOCMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/IOCMessages.java?view=diff&rev=519748&r1=519747&r2=519748
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/IOCMessages.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/IOCMessages.java Sun Mar 18 16:59:54 2007
@@ -245,11 +245,6 @@
         return MESSAGES.format("recursive-module-constructor", builderClass.getName(), constructor);
     }
 
-    static String registryShutdown(String serviceId)
-    {
-        return MESSAGES.format("registry-shutdown", serviceId);
-    }
-
     static String constructedConfiguration(Collection result)
     {
         return MESSAGES.format("constructed-configuration", result);

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ModuleImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ModuleImpl.java?view=diff&rev=519748&r1=519747&r2=519748
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ModuleImpl.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/ModuleImpl.java Sun Mar 18 16:59:54 2007
@@ -43,12 +43,11 @@
 import org.apache.tapestry.ioc.def.DecoratorDef;
 import org.apache.tapestry.ioc.def.ModuleDef;
 import org.apache.tapestry.ioc.def.ServiceDef;
+import org.apache.tapestry.ioc.internal.services.JustInTimeObjectCreator;
 import org.apache.tapestry.ioc.internal.util.InternalUtils;
 import org.apache.tapestry.ioc.services.ClassFab;
 import org.apache.tapestry.ioc.services.MethodSignature;
-import org.apache.tapestry.ioc.services.RegistryShutdownListener;
 import org.apache.tapestry.ioc.services.TapestryIOCModule;
-import org.apache.tapestry.ioc.util.BodyBuilder;
 
 public class ModuleImpl implements Module
 {
@@ -94,7 +93,7 @@
         // RegistryImpl should already have checked that the service exists.
         assert def != null;
 
-        Object service = findOrCreate(def);
+        Object service = findOrCreate(def, null);
 
         try
         {
@@ -155,9 +154,11 @@
      * 
      * @param def
      *            defines the service
+     * @param eagerLoadProxies
+     *            TODO
      * @return the service proxy
      */
-    private Object findOrCreate(ServiceDef def)
+    private Object findOrCreate(ServiceDef def, List<EagerLoadServiceProxy> eagerLoadProxies)
     {
         synchronized (MUTEX)
         {
@@ -167,7 +168,7 @@
 
             if (result == null)
             {
-                result = create(def);
+                result = create(def, eagerLoadProxies);
                 _services.put(key, result);
             }
 
@@ -177,26 +178,30 @@
 
     public void eagerLoadServices()
     {
-        for (String id : _moduleDef.getServiceIds())
-        {
-            ServiceDef def = _moduleDef.getServiceDef(id);
+        List<EagerLoadServiceProxy> proxies = newList();
 
-            if (!def.isEagerLoad()) continue;
-
-            // The proxy implements the service interface, and RegistryShutdownListener, and (for
-            // eager load services), EagerLoadServiceProxy
+        synchronized (MUTEX)
+        {
+            for (String serviceId : _moduleDef.getServiceIds())
+            {
+                ServiceDef def = _moduleDef.getServiceDef(serviceId);
 
-            EagerLoadServiceProxy proxy = (EagerLoadServiceProxy) findOrCreate(def);
+                if (def.isEagerLoad()) findOrCreate(def, proxies);
+            }
 
-            proxy.eagerLoadService();
+            for (EagerLoadServiceProxy proxy : proxies)
+                proxy.eagerLoadService();
         }
     }
 
     /**
      * Creates the service and updates the cache of created services. Access is synchronized via
      * {@link #MUTEX}.
+     * 
+     * @param eagerLoadProxies
+     *            a list into which any eager loaded proxies should be added
      */
-    private Object create(ServiceDef def)
+    private Object create(ServiceDef def, List<EagerLoadServiceProxy> eagerLoadProxies)
     {
         String serviceId = def.getServiceId();
 
@@ -210,23 +215,37 @@
 
             ServiceBuilderResources resources = new ServiceResourcesImpl(_registry, this, def, log);
 
-            // Build up a stack of operations that will be needed to instantiate the service
+            // Build up a stack of operations that will be needed to realize the service
             // (by the proxy, at a later date).
 
             ObjectCreator creator = def.createServiceCreator(resources);
 
             creator = new LifecycleWrappedServiceCreator(lifecycle, resources, creator);
 
-            // Don't allow the tapestry.ioc services to be decorated.
+            // Don't allow the core IOC services services to be decorated.
 
-            if (!_moduleDef.getBuilderClass().equals(TapestryIOCModule.class))
+            if (!TapestryIOCModule.class.equals(_moduleDef.getBuilderClass()))
                 creator = new InterceptorStackBuilder(this, serviceId, creator);
 
-            // Add a wrapper that makes sure that it only gets created once.
+            // Add a wrapper that checks for recursion.
 
-            creator = new OneShotServiceCreator(def, creator, log);
+            creator = new RecursiveServiceCreationCheckWrapper(def, creator, log);
 
-            return createProxy(resources, creator, def.isEagerLoad());
+            JustInTimeObjectCreator delegate = new JustInTimeObjectCreator(creator, serviceId);
+
+            Object proxy = createProxy(resources, delegate);
+
+            _registry.addRegistryShutdownListener(delegate);
+
+            // Occasionally service A may invoke service B from its service builder method; if
+            // service B
+            // is eager loaded, we'll hit this method but eagerLoadProxies will be null. That's OK
+            // ... service B
+            // is being realized anyway.
+
+            if (def.isEagerLoad() && eagerLoadProxies != null) eagerLoadProxies.add(delegate);
+
+            return proxy;
         }
         catch (Exception ex)
         {
@@ -316,33 +335,24 @@
         throw new RuntimeException(IOCMessages.instantiateBuilderError(builderClass, fail), fail);
     }
 
-    private Object createProxy(ServiceResources resources, ObjectCreator creator, boolean eagerLoad)
+    private Object createProxy(ServiceResources resources, ObjectCreator creator)
     {
         String serviceId = resources.getServiceId();
         Class serviceInterface = resources.getServiceInterface();
 
         String toString = format("<Proxy for %s(%s)>", serviceId, serviceInterface.getName());
 
-        RegistryShutdownListener proxy = createProxyInstance(
-                creator,
-                serviceId,
-                serviceInterface,
-                eagerLoad,
-                toString);
-
-        _registry.addRegistryShutdownListener(proxy);
-
-        return proxy;
+        return createProxyInstance(creator, serviceId, serviceInterface, toString);
     }
 
-    private RegistryShutdownListener createProxyInstance(ObjectCreator creator, String serviceId,
-            Class serviceInterface, boolean eagerLoad, String description)
+    private Object createProxyInstance(ObjectCreator creator, String serviceId,
+            Class serviceInterface, String description)
     {
-        Class proxyClass = createProxyClass(serviceId, serviceInterface, eagerLoad, description);
+        Class proxyClass = createProxyClass(serviceId, serviceInterface, description);
 
         try
         {
-            return (RegistryShutdownListener) proxyClass.getConstructors()[0].newInstance(creator);
+            return proxyClass.getConstructors()[0].newInstance(creator);
         }
         catch (Exception ex)
         {
@@ -352,84 +362,29 @@
         }
     }
 
-    private Class createProxyClass(String serviceId, Class serviceInterface, boolean eagerLoad,
-            String proxyDescription)
+    private Class createProxyClass(String serviceId, Class serviceInterface, String proxyDescription)
     {
         ClassFab cf = _registry.newClass(serviceInterface);
 
         cf.addField("_creator", ObjectCreator.class);
-        cf.addField("_delegate", serviceInterface);
-        cf.addField("_shutdown", boolean.class);
 
         cf.addConstructor(new Class[]
         { ObjectCreator.class }, null, "_creator = $1;");
 
         addDelegateGetter(cf, serviceInterface, serviceId);
 
-        addShutdownListenerMethod(cf);
-
         cf.proxyMethodsToDelegate(serviceInterface, "_delegate()", proxyDescription);
 
-        // For eager load services, add an eagerLoadService() method that calls _delegate(), to
-        // force the creation of the service.
-
-        if (eagerLoad)
-        {
-            cf.addInterface(EagerLoadServiceProxy.class);
-
-            cf.addMethod(Modifier.PUBLIC, new MethodSignature(void.class, "eagerLoadService", null,
-                    null), "_delegate();");
-        }
-
         return cf.createClass();
     }
 
     private void addDelegateGetter(ClassFab cf, Class serviceInterface, String serviceId)
     {
-        BodyBuilder builder = new BodyBuilder();
-        builder.begin();
-
-        // Check to see if the registry has shutdown. The registryShutdown() method
-        // throws IllegalStateException.
-
-        builder.addln("if (_shutdown) %s.registryShutdown(\"%s\");", IOCProxyUtilities.class
-                .getName(), serviceId);
-
-        // We can release the creator after invoking it, we only create the service once.
-
-        builder.addln("if (_delegate == null)");
-        builder.begin();
-        builder.addln("_delegate = (%s) _creator.createObject();", serviceInterface.getName());
-        builder.addln("_creator = null;");
-        builder.end();
-
-        builder.addln("return _delegate;");
-        builder.end();
+        String body = format("return (%s) _creator.createObject();", serviceInterface.getName());
 
         MethodSignature sig = new MethodSignature(serviceInterface, "_delegate", null, null);
 
-        // Here's the rub, this _delegate() method has to be synchronized. But after the first
-        // time through (when we create the service), the time inside the method is infintesmal.
-        // Let's hope that they aren't lying when they say that synchronized is now super cheap!
-
-        cf.addMethod(Modifier.PRIVATE | Modifier.SYNCHRONIZED, sig, builder.toString());
-    }
-
-    /**
-     * All proxies implement {@link RegistryShutdownListener}. When the registry shuts down, the
-     * proxy sets a flag that ultimately converts method invocations to
-     * {@link IllegalStateException}s, and discards its delegate and creator.
-     */
-    private void addShutdownListenerMethod(ClassFab cf)
-    {
-        cf.addInterface(RegistryShutdownListener.class);
-
-        MethodSignature sig = new MethodSignature(void.class, "registryDidShutdown", null, null);
-
-        cf.addMethod(
-                Modifier.PUBLIC | Modifier.SYNCHRONIZED,
-                sig,
-                "{ _shutdown = true; _delegate = null; _creator = null; }");
+        cf.addMethod(Modifier.PRIVATE, sig, body);
     }
 
     public Set<ContributionDef> getContributorDefsForService(String serviceId)

Copied: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/RecursiveServiceCreationCheckWrapper.java (from r516833, tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/OneShotServiceCreator.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/RecursiveServiceCreationCheckWrapper.java?view=diff&rev=519748&p1=tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/OneShotServiceCreator.java&r1=516833&p2=tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/RecursiveServiceCreationCheckWrapper.java&r2=519748
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/OneShotServiceCreator.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/RecursiveServiceCreationCheckWrapper.java Sun Mar 18 16:59:54 2007
@@ -22,9 +22,10 @@
  * Decorator for {@link org.apache.tapestry.ioc.ObjectCreator} that ensures the service is only
  * created once. This detects a situation where the service builder for a service directly or
  * indirectly invokes methods on the service itself. This would show up as a second call up the
- * ServiceCreator stack injected into the proxy.
+ * ServiceCreator stack injected into the proxy, potentially leading to endless recursion. We try to
+ * identify that recursion and produce a useable exception report.
  */
-public class OneShotServiceCreator implements ObjectCreator
+public class RecursiveServiceCreationCheckWrapper implements ObjectCreator
 {
     private final ServiceDef _serviceDef;
 
@@ -34,7 +35,7 @@
 
     private boolean _locked;
 
-    public OneShotServiceCreator(ServiceDef serviceDef, ObjectCreator delegate, Log log)
+    public RecursiveServiceCreationCheckWrapper(ServiceDef serviceDef, ObjectCreator delegate, Log log)
     {
         _serviceDef = serviceDef;
         _delegate = delegate;

Added: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/JustInTimeObjectCreator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/JustInTimeObjectCreator.java?view=auto&rev=519748
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/JustInTimeObjectCreator.java (added)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/JustInTimeObjectCreator.java Sun Mar 18 16:59:54 2007
@@ -0,0 +1,86 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.ioc.internal.services;
+
+import org.apache.tapestry.ioc.ObjectCreator;
+import org.apache.tapestry.ioc.internal.EagerLoadServiceProxy;
+import org.apache.tapestry.ioc.services.RegistryShutdownListener;
+
+/**
+ * Invoked from a fabricated service delegate to get or realize (instantiate and configure) the
+ * service implementation. This includes synchronization logic, to prevent multiple threads from
+ * attempting to realize the same service at the same time (a service should be realized only once).
+ * The additional interfaces implemented by this class support eager loading of services (at
+ * application startup), and orderly shutdown of proxies.
+ */
+public class JustInTimeObjectCreator implements ObjectCreator, EagerLoadServiceProxy,
+        RegistryShutdownListener
+{
+    private ObjectCreator _creator;
+
+    private boolean _shutdown;
+
+    private Object _object;
+
+    private final String _serviceId;
+
+    public JustInTimeObjectCreator(ObjectCreator creator, String serviceId)
+    {
+        _creator = creator;
+        _serviceId = serviceId;
+    }
+
+    /**
+     * Checks to see if the proxy has been shutdown, then invokes
+     * {@link ObjectCreator#createObject()} if it has not already done so.
+     * 
+     * @throws IllegalStateException
+     *             if the registry has been shutdown
+     */
+    public synchronized Object createObject()
+    {
+        if (_shutdown)
+            throw new IllegalStateException(ServiceMessages.registryShutdown(_serviceId));
+
+        if (_object == null)
+        {
+            _object = _creator.createObject();
+            _creator = null;
+        }
+
+        return _object;
+    }
+
+    /**
+     * Invokes {@link #createObject()} to force the creation of the underlying service.
+     */
+    public void eagerLoadService()
+    {
+        // Force object creation now
+
+        createObject();
+    }
+
+    /**
+     * Sets the shutdown flag and releases the object and the creator.
+     */
+    public synchronized void registryDidShutdown()
+    {
+        _shutdown = true;
+        _object = null;
+        _creator = null;
+    }
+
+}

Added: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/JustInTimeObjectCreatorTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/JustInTimeObjectCreatorTest.java?view=auto&rev=519748
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/JustInTimeObjectCreatorTest.java (added)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/JustInTimeObjectCreatorTest.java Sun Mar 18 16:59:54 2007
@@ -0,0 +1,79 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.ioc.internal.services;
+
+import org.apache.tapestry.ioc.ObjectCreator;
+import org.apache.tapestry.ioc.internal.IOCInternalTestCase;
+import org.testng.annotations.Test;
+
+public class JustInTimeObjectCreatorTest extends IOCInternalTestCase
+{
+    private static final String SERVICE_ID = "FooBar";
+
+    @Test
+    public void create_after_shutdown()
+    {
+        ObjectCreator creator = newObjectCreator();
+
+        replay();
+
+        JustInTimeObjectCreator j = new JustInTimeObjectCreator(creator, SERVICE_ID);
+
+        j.registryDidShutdown();
+
+        try
+        {
+            j.createObject();
+            unreachable();
+        }
+        catch (IllegalStateException ex)
+        {
+            assertEquals(
+                    ex.getMessage(),
+                    "Proxy for service FooBar is no longer active because the IOC Registry has been shut down.");
+        }
+    }
+
+    @Test
+    public void eager_load()
+    {
+        ObjectCreator creator = newObjectCreator();
+        Object service = new Object();
+
+        replay();
+
+        JustInTimeObjectCreator j = new JustInTimeObjectCreator(creator, SERVICE_ID);
+
+        verify();
+
+        // First access: use the creator to get the actual object.
+
+        train_createObject(creator, service);
+
+        replay();
+
+        j.eagerLoadService();
+
+        verify();
+
+        // This part tests the caching part.
+
+        replay();
+
+        assertSame(j.createObject(), service);
+
+        verify();
+    }
+}

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ServiceMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ServiceMessages.java?view=diff&rev=519748&r1=519747&r2=519748
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ServiceMessages.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/internal/services/ServiceMessages.java Sun Mar 18 16:59:54 2007
@@ -176,4 +176,10 @@
         return MESSAGES.format("failed-coercion", String.valueOf(input), ClassFabUtils
                 .toJavaClassName(targetType), coercion, cause);
     }
+
+    static String registryShutdown(String serviceId)
+    {
+        return MESSAGES.format("registry-shutdown", serviceId);
+    }
+
 }

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassFabUtils.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassFabUtils.java?view=diff&rev=519748&r1=519747&r2=519748
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassFabUtils.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/java/org/apache/tapestry/ioc/services/ClassFabUtils.java Sun Mar 18 16:59:54 2007
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007The Apache Software Foundation
+// Copyright 2006, 2007 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.

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/resources/org/apache/tapestry/ioc/internal/IOCStrings.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/resources/org/apache/tapestry/ioc/internal/IOCStrings.properties?view=diff&rev=519748&r1=519747&r2=519748
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/resources/org/apache/tapestry/ioc/internal/IOCStrings.properties (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/resources/org/apache/tapestry/ioc/internal/IOCStrings.properties Sun Mar 18 16:59:54 2007
@@ -69,7 +69,6 @@
   You should change the class to have only a single public constructor.
 recursive-module-constructor=The constructor for module class %s is recursive: it depends on itself in some way. \
   The constructor, %s, is in some way is triggering a service builder, decorator or contribution method within the class.
-registry-shutdown=Proxy for service %s is no longer active because the IOC Registry has been shut down.
 constructed-configuration=Constructed configuration: %s
 service-construction-failed=Construction of service %s failed: %s
 no-such-service=Service id '%s' is not defined by any module.  Defined services: %s.

Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/main/resources/org/apache/tapestry/ioc/internal/services/ServiceStrings.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/main/resources/org/apache/tapestry/ioc/internal/services/ServiceStrings.properties?view=diff&rev=519748&r1=519747&r2=519748
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/main/resources/org/apache/tapestry/ioc/internal/services/ServiceStrings.properties (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/main/resources/org/apache/tapestry/ioc/internal/services/ServiceStrings.properties Sun Mar 18 16:59:54 2007
@@ -38,3 +38,4 @@
 missing-symbol-close-brace=Input string '%s' is missing a symbol closing brace.
 missing-symbol-close-brace-in-path=Input string '%s' is missing a symbol closing brace (in %s).
 failed-coercion=Coercion of %s to type %s (via %s) failed: %s
+registry-shutdown=Proxy for service %s is no longer active because the IOC Registry has been shut down.

Copied: tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/RecursiveServiceCreationCheckWrapperTest.java (from r517073, tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/OneShotServiceCreatorTest.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/RecursiveServiceCreationCheckWrapperTest.java?view=diff&rev=519748&p1=tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/OneShotServiceCreatorTest.java&r1=517073&p2=tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/RecursiveServiceCreationCheckWrapperTest.java&r2=519748
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/OneShotServiceCreatorTest.java (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/test/java/org/apache/tapestry/ioc/internal/RecursiveServiceCreationCheckWrapperTest.java Sun Mar 18 16:59:54 2007
@@ -19,11 +19,9 @@
 import org.apache.commons.logging.Log;
 import org.apache.tapestry.ioc.ObjectCreator;
 import org.apache.tapestry.ioc.def.ServiceDef;
-import org.apache.tapestry.ioc.services.ClassFactory;
-import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
-public class OneShotServiceCreatorTest extends IOCInternalTestCase
+public class RecursiveServiceCreationCheckWrapperTest extends IOCInternalTestCase
 {
 
     @Test
@@ -41,13 +39,13 @@
 
         replay();
 
-        ObjectCreator oneShot = new OneShotServiceCreator(def, delegate, log);
+        ObjectCreator wrapper = new RecursiveServiceCreationCheckWrapper(def, delegate, log);
 
-        assertSame(oneShot.createObject(), service);
+        assertSame(wrapper.createObject(), service);
 
         try
         {
-            oneShot.createObject();
+            wrapper.createObject();
             unreachable();
         }
         catch (IllegalStateException ex)
@@ -72,19 +70,19 @@
         ObjectCreator delegate = newObjectCreator();
         Object service = new Object();
 
-        ServiceDef def = new ServiceDefImpl("foo.Bar", "singleton", method, false, null);
+        ServiceDef def = new ServiceDefImpl("Bar", "singleton", method, false, null);
 
         expect(delegate.createObject()).andThrow(failure);
 
-        log.error("Construction of service foo.Bar failed: Just cranky.", failure);
+        log.error("Construction of service Bar failed: Just cranky.", failure);
 
         replay();
 
-        ObjectCreator oneShot = new OneShotServiceCreator(def, delegate, log);
+        ObjectCreator wrapper = new RecursiveServiceCreationCheckWrapper(def, delegate, log);
 
         try
         {
-            oneShot.createObject();
+            wrapper.createObject();
             unreachable();
         }
         catch (RuntimeException ex)
@@ -100,7 +98,7 @@
 
         replay();
 
-        assertSame(service, oneShot.createObject());
+        assertSame(service, wrapper.createObject());
 
         verify();