tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r927568 - in /tapestry/tapestry5/trunk/tapestry-ioc/src: main/java/org/apache/tapestry5/ioc/internal/ test/java/org/apache/tapestry5/ioc/
Date Thu, 25 Mar 2010 19:48:43 GMT
Author: hlship
Date: Thu Mar 25 19:48:43 2010
New Revision: 927568

URL: http://svn.apache.org/viewvc?rev=927568&view=rev
Log:
TAP5-1076: Eager loading services is incompatible with live service reloading

Added:
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/EagerLoadService.java
  (with props)
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/EagerLoadServiceImpl.java
  (with props)
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/EagerProxyReloadModule.java
  (with props)
Modified:
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ReloadableObjectCreatorSource.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/ReloadTest.java

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ReloadableObjectCreatorSource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ReloadableObjectCreatorSource.java?rev=927568&r1=927567&r2=927568&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ReloadableObjectCreatorSource.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ReloadableObjectCreatorSource.java
Thu Mar 25 19:48:43 2010
@@ -34,13 +34,16 @@ public class ReloadableObjectCreatorSour
 
     private final Class serviceImplementationClass;
 
+    private final boolean eagerLoad;
+
     public ReloadableObjectCreatorSource(ClassFactory classFactory, Method bindMethod, Class
serviceInterfaceClass,
-            Class serviceImplementationClass)
+            Class serviceImplementationClass, boolean eagerLoad)
     {
         this.classFactory = classFactory;
         this.bindMethod = bindMethod;
         this.serviceInterfaceClass = serviceInterfaceClass;
         this.serviceImplementationClass = serviceImplementationClass;
+        this.eagerLoad = eagerLoad;
     }
 
     public ObjectCreator constructCreator(final ServiceBuilderResources resources)
@@ -62,11 +65,14 @@ public class ReloadableObjectCreatorSour
 
     private Object createReloadableProxy(ServiceBuilderResources resources)
     {
-        ReloadableServiceImplementationObjectCreator reloadableCreator = new ReloadableServiceImplementationObjectCreator(resources,
classFactory
-                .getClassLoader(), serviceImplementationClass.getName());
+        ReloadableServiceImplementationObjectCreator reloadableCreator = new ReloadableServiceImplementationObjectCreator(
+                resources, classFactory.getClassLoader(), serviceImplementationClass.getName());
 
         resources.getService(UpdateListenerHub.class).addUpdateListener(reloadableCreator);
 
+        if (eagerLoad)
+            reloadableCreator.createObject();
+
         return classFactory.createProxy(serviceInterfaceClass, reloadableCreator, getDescription());
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java?rev=927568&r1=927567&r2=927568&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java
Thu Mar 25 19:48:43 2010
@@ -162,7 +162,8 @@ public class ServiceBinderImpl implement
 
     private ObjectCreatorSource createReloadableConstructorBasedObjectCreatorSource()
     {
-        return new ReloadableObjectCreatorSource(classFactory, bindMethod, serviceInterface,
serviceImplementation);
+        return new ReloadableObjectCreatorSource(classFactory, bindMethod, serviceInterface,
serviceImplementation,
+                eagerLoad);
     }
 
     @SuppressWarnings("unchecked")

Added: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/EagerLoadService.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/EagerLoadService.java?rev=927568&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/EagerLoadService.java
(added)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/EagerLoadService.java
Thu Mar 25 19:48:43 2010
@@ -0,0 +1,20 @@
+// 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;
+
+public interface EagerLoadService
+{
+
+}

Propchange: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/EagerLoadService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/EagerLoadServiceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/EagerLoadServiceImpl.java?rev=927568&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/EagerLoadServiceImpl.java
(added)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/EagerLoadServiceImpl.java
Thu Mar 25 19:48:43 2010
@@ -0,0 +1,26 @@
+// 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;
+
+import org.apache.tapestry5.ioc.annotations.EagerLoad;
+
+@EagerLoad
+public class EagerLoadServiceImpl implements EagerLoadService
+{
+    public EagerLoadServiceImpl()
+    {
+        ReloadTest.eagerLoadServiceWasInstantiated = true;
+    }
+}

Propchange: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/EagerLoadServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/EagerProxyReloadModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/EagerProxyReloadModule.java?rev=927568&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/EagerProxyReloadModule.java
(added)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/EagerProxyReloadModule.java
Thu Mar 25 19:48:43 2010
@@ -0,0 +1,23 @@
+// 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;
+
+public class EagerProxyReloadModule
+{
+    public static void bind(ServiceBinder binder)
+    {
+        binder.bind(EagerLoadService.class, EagerLoadServiceImpl.class);
+    }
+}

Propchange: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/EagerProxyReloadModule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/ReloadTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/ReloadTest.java?rev=927568&r1=927567&r2=927568&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/ReloadTest.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/ReloadTest.java
Thu Mar 25 19:48:43 2010
@@ -46,6 +46,8 @@ public class ReloadTest extends TestBase
 
     private ClassLoader classLoader;
 
+    public static boolean eagerLoadServiceWasInstantiated;
+
     @BeforeClass
     public void setup() throws Exception
     {
@@ -209,6 +211,18 @@ public class ReloadTest extends TestBase
         ctClass.addConstructor(constructor);
 
         ctClass.writeFile(classesDir.getAbsolutePath());
+    }
+
+    @Test
+    public void eager_load_service_with_proxy()
+    {
+
+        eagerLoadServiceWasInstantiated = false;
+
+        Registry r = new RegistryBuilder().add(EagerProxyReloadModule.class).build();
+
+        r.performRegistryStartup();
 
+        assertTrue(eagerLoadServiceWasInstantiated);
     }
 }



Mime
View raw message