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 2007/06/24 00:56:04 UTC

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

Author: hlship
Date: Sat Jun 23 15:56:04 2007
New Revision: 550136

URL: http://svn.apache.org/viewvc?view=rev&rev=550136
Log:
TAPESTRY-1596: Contributing a service to the Alias service configuration fails if the service uses a non-standard scope, such as perthread

Modified:
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/LifecycleWrappedServiceCreator.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ModuleImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/LifecycleWrappedServiceCreator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/LifecycleWrappedServiceCreator.java?view=diff&rev=550136&r1=550135&r2=550136
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/LifecycleWrappedServiceCreator.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/LifecycleWrappedServiceCreator.java Sat Jun 23 15:56:04 2007
@@ -26,16 +26,19 @@
  */
 public class LifecycleWrappedServiceCreator implements ObjectCreator
 {
-    private final ServiceLifecycle _lifecycle;
+    private final InternalRegistry _registry;
+
+    private final String _serviceScope;
 
     private final ServiceResources _resources;
 
     private final ObjectCreator _creator;
 
-    public LifecycleWrappedServiceCreator(ServiceLifecycle lifecycle, ServiceResources resources,
-            ObjectCreator creator)
+    public LifecycleWrappedServiceCreator(InternalRegistry registry, String serviceScope,
+            ServiceResources resources, ObjectCreator creator)
     {
-        _lifecycle = lifecycle;
+        _registry = registry;
+        _serviceScope = serviceScope;
         _resources = resources;
         _creator = creator;
     }
@@ -46,7 +49,9 @@
      */
     public Object createObject()
     {
-        return _lifecycle.createService(_resources, _creator);
+        ServiceLifecycle lifecycle = _registry.getServiceLifecycle(_serviceScope);
+
+        return lifecycle.createService(_resources, _creator);
     }
 
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ModuleImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ModuleImpl.java?view=diff&rev=550136&r1=550135&r2=550136
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ModuleImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ModuleImpl.java Sat Jun 23 15:56:04 2007
@@ -34,10 +34,9 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.tapestry.ioc.ObjectCreator;
+import org.apache.tapestry.ioc.ObjectLocator;
 import org.apache.tapestry.ioc.ServiceBuilderResources;
 import org.apache.tapestry.ioc.ServiceDecorator;
-import org.apache.tapestry.ioc.ServiceLifecycle;
-import org.apache.tapestry.ioc.ObjectLocator;
 import org.apache.tapestry.ioc.ServiceResources;
 import org.apache.tapestry.ioc.def.ContributionDef;
 import org.apache.tapestry.ioc.def.DecoratorDef;
@@ -215,8 +214,6 @@
 
         try
         {
-            ServiceLifecycle lifecycle = _registry.getServiceLifecycle(def.getServiceScope());
-
             ServiceBuilderResources resources = new ServiceResourcesImpl(_registry, this, def,
                     _classFactory, log);
 
@@ -233,7 +230,8 @@
 
             if (!serviceInterface.isInterface()) return creator.createObject();
 
-            creator = new LifecycleWrappedServiceCreator(lifecycle, resources, creator);
+            creator = new LifecycleWrappedServiceCreator(_registry, def.getServiceScope(),
+                    resources, creator);
 
             // Don't allow the core IOC services services to be decorated.
 

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java?view=diff&rev=550136&r1=550135&r2=550136
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java Sat Jun 23 15:56:04 2007
@@ -219,14 +219,17 @@
 
         try
         {
-            r.getService("UnknownScope", Runnable.class);
+            Runnable runnable = r.getService("UnknownScope", Runnable.class);
+
+            runnable.run();
+
             unreachable();
         }
         catch (Exception ex)
         {
             assertMessageContains(
                     ex,
-                    "Error building service proxy for service 'UnknownScope'",
+                    "Exception constructing service 'UnknownScope'",
                     "Unknown service scope 'magic'");
         }
     }