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 2006/09/12 15:11:29 UTC

svn commit: r442580 - in /tapestry/tapestry5/tapestry-core/trunk/src: main/java/org/apache/tapestry/internal/ioc/ main/java/org/apache/tapestry/ioc/annotations/ main/java/org/apache/tapestry/ioc/def/ site/apt/ioc/ test/java/org/apache/tapestry/internal...

Author: hlship
Date: Tue Sep 12 06:11:28 2006
New Revision: 442580

URL: http://svn.apache.org/viewvc?view=rev&rev=442580
Log:
Add support for eager loading of services, via the @EagerLoad annotation.

Added:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/EagerLoadServiceProxy.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/annotations/EagerLoad.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/EagerLoadModule.java
Modified:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/Module.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ModuleImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/RegistryImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceDefImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/def/ServiceDef.java
    tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/service.apt
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/OneShortServiceCreatorTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/SimpleModule.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImpl.java?view=diff&rev=442580&r1=442579&r2=442580
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImpl.java Tue Sep 12 06:11:28 2006
@@ -29,6 +29,7 @@
 import org.apache.tapestry.ioc.MappedConfiguration;
 import org.apache.tapestry.ioc.OrderedConfiguration;
 import org.apache.tapestry.ioc.annotations.Contribute;
+import org.apache.tapestry.ioc.annotations.EagerLoad;
 import org.apache.tapestry.ioc.annotations.Id;
 import org.apache.tapestry.ioc.annotations.Lifecycle;
 import org.apache.tapestry.ioc.annotations.Match;
@@ -338,8 +339,10 @@
 
         String lifecycle = extractLifecycle(method);
         boolean isPrivate = method.isAnnotationPresent(Private.class);
+        boolean eagerLoad = method.isAnnotationPresent(EagerLoad.class);
 
-        _serviceDefs.put(serviceId, new ServiceDefImpl(serviceId, lifecycle, method, isPrivate));
+        _serviceDefs.put(serviceId, new ServiceDefImpl(serviceId, lifecycle, method, isPrivate,
+                eagerLoad));
     }
 
     private String extractLifecycle(Method method)

Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/EagerLoadServiceProxy.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/EagerLoadServiceProxy.java?view=auto&rev=442580
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/EagerLoadServiceProxy.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/EagerLoadServiceProxy.java Tue Sep 12 06:11:28 2006
@@ -0,0 +1,26 @@
+// Copyright 2006 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.internal.ioc;
+
+/**
+ * Interface implemented by all service proxies. Service proxies are always
+ * {@link org.apache.tapestry.ioc.services.RegistryShutdownListener}s, they also can be eager-load
+ * 
+ * @author Howard M. Lewis Ship
+ */
+public interface EagerLoadServiceProxy
+{
+    void eagerLoadService();
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/Module.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/Module.java?view=diff&rev=442580&r1=442579&r2=442580
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/Module.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/Module.java Tue Sep 12 06:11:28 2006
@@ -94,4 +94,10 @@
 
     /** Finds any contributions that are targetted at the indicated service. */
     Set<ContributionDef> getContributorDefsForService(String serviceId);
+
+    /**
+     * Locates services with the {@link org.apache.tapestry.ioc.annotations.EagerLoad} annotation
+     * and forces them to instantiate fully. This is part of the Registry startup.
+     */
+    void eagerLoadServices();
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ModuleImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ModuleImpl.java?view=diff&rev=442580&r1=442579&r2=442580
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ModuleImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ModuleImpl.java Tue Sep 12 06:11:28 2006
@@ -180,6 +180,24 @@
         return result;
     }
 
+    public void eagerLoadServices()
+    {
+        for (String id : _moduleDef.getServiceIds())
+        {
+            ServiceDef def = _moduleDef.getServiceDef(id);
+
+            if (!def.isEagerLoad())
+                continue;
+
+            // The proxy implements the service interface, and RegistryShutdownListener, and (for
+            // eager load services), EagerLoadServiceProxy
+
+            EagerLoadServiceProxy proxy = (EagerLoadServiceProxy) findOrCreate(def);
+
+            proxy.eagerLoadService();
+        }
+    }
+
     /**
      * Creates the service and updates the cache of created services. Method is called from
      * synchronized block.
@@ -215,7 +233,7 @@
 
             creator = new OneShotServiceCreator(def, creator);
 
-            Object service = createProxy(resources, creator);
+            Object service = createProxy(resources, creator, def.isEagerLoad());
 
             _services.put(serviceId, service);
 
@@ -298,7 +316,7 @@
                 .getModuleId(), fail), fail);
     }
 
-    private Object createProxy(ServiceResources resources, ObjectCreator creator)
+    private Object createProxy(ServiceResources resources, ObjectCreator creator, boolean eagerLoad)
     {
         String serviceId = resources.getServiceId();
         Class serviceInterface = resources.getServiceInterface();
@@ -309,6 +327,7 @@
                 creator,
                 serviceId,
                 serviceInterface,
+                eagerLoad,
                 toString);
 
         _registry.addRegistryShutdownListener(proxy);
@@ -317,9 +336,9 @@
     }
 
     private RegistryShutdownListener createProxyInstance(ObjectCreator creator, String serviceId,
-            Class serviceInterface, String description)
+            Class serviceInterface, boolean eagerLoad, String description)
     {
-        Class proxyClass = createProxyClass(serviceId, serviceInterface, description);
+        Class proxyClass = createProxyClass(serviceId, serviceInterface, eagerLoad, description);
 
         try
         {
@@ -333,7 +352,8 @@
         }
     }
 
-    private Class createProxyClass(String serviceId, Class serviceInterface, String proxyDescription)
+    private Class createProxyClass(String serviceId, Class serviceInterface, boolean eagerLoad,
+            String proxyDescription)
     {
         ClassFab cf = _registry.newClass(serviceInterface);
 
@@ -349,6 +369,17 @@
         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();
     }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/RegistryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/RegistryImpl.java?view=diff&rev=442580&r1=442579&r2=442580
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/RegistryImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/RegistryImpl.java Tue Sep 12 06:11:28 2006
@@ -145,6 +145,11 @@
                 _registryShutdownHub);
 
         _lifecycles.put("singleton", new SingletonServiceLifecycle());
+
+        // Ask all modules to eager-load any services marked with @EagerLoad
+
+        for (Module m : _modules.values())
+            m.eagerLoadServices();
     }
 
     private <T> void addBuiltin(String serviceId, Class<T> serviceInterface, T service)

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceDefImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceDefImpl.java?view=diff&rev=442580&r1=442579&r2=442580
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceDefImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/ServiceDefImpl.java Tue Sep 12 06:11:28 2006
@@ -34,12 +34,16 @@
 
     private final boolean _private;
 
-    ServiceDefImpl(String serviceId, String lifecycle, Method builderMethod, boolean isprivate)
+    private final boolean _eagerLoad;
+
+    ServiceDefImpl(String serviceId, String lifecycle, Method builderMethod, boolean isprivate,
+            boolean eagerLoad)
     {
         _serviceId = serviceId;
         _lifecycle = lifecycle;
         _builderMethod = builderMethod;
         _private = isprivate;
+        _eagerLoad = eagerLoad;
     }
 
     @Override
@@ -76,6 +80,11 @@
     public boolean isPrivate()
     {
         return _private;
+    }
+
+    public boolean isEagerLoad()
+    {
+        return _eagerLoad;
     }
 
 }

Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/annotations/EagerLoad.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/annotations/EagerLoad.java?view=auto&rev=442580
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/annotations/EagerLoad.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/annotations/EagerLoad.java Tue Sep 12 06:11:28 2006
@@ -0,0 +1,36 @@
+// Copyright 2006 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.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Marker annotation placed on a service builder method to indicate that the service should be
+ * eagerly loaded: instantiated as if a service method had been invoked. This will cause the service
+ * builder method to be invoked, as well as any service decorator methods that apply to the service.
+ * 
+ * @author Howard M. Lewis Ship
+ */
+@Target(ElementType.METHOD)
+@Retention(RUNTIME)
+@Documented
+public @interface EagerLoad {
+
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/def/ServiceDef.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/def/ServiceDef.java?view=diff&rev=442580&r1=442579&r2=442580
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/def/ServiceDef.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ioc/def/ServiceDef.java Tue Sep 12 06:11:28 2006
@@ -26,9 +26,9 @@
 {
     /**
      * Returns an {@link ObjectCreator} that can create the core service implementation.
+     * 
      * @param resources
      *            used to resolve dependencies of the service, or access its configuration
-     * 
      * @return an object that can (later) be used to instantiate the service itself
      */
     ObjectCreator createServiceCreator(ServiceBuilderResources resources);
@@ -49,6 +49,17 @@
      */
     String getServiceLifeycle();
 
-    /** Returns true if the service is private, visible only within the same module. */
+    /**
+     * Returns true if the service is private, visible only within the same module.
+     * 
+     * @see org.apache.tapestry.ioc.annotations.Private
+     */
     boolean isPrivate();
-}
+
+    /**
+     * Returns true if the service should be eagerly loaded at Registry startup.
+     * 
+     * @see org.apache.tapestry.ioc.annotations.EagerLoad
+     */
+    boolean isEagerLoad();
+}
\ No newline at end of file

Modified: tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/service.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/service.apt?view=diff&rev=442580&r1=442579&r2=442580
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/service.apt (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/service.apt Tue Sep 12 06:11:28 2006
@@ -162,6 +162,27 @@
   the most part, perthread services should be simple holders of data specific to a thread or
   a request, and should not have overly complex relationships with the other services
   in the registry.
+  
+Eager Loading Services
+
+  Services are normally created only as needed (per the lifecycle discussion above).
+  
+  This can be tweaked slightly; by adding the 
+  {{{../apidocs/org/apache/tapestry/ioc/annotations/EagerLoad.html}EagerLoad}} annotation to
+  the service builder method, Tapestry will instantiate the service when the Registry is first created.
+  
+  This will cause the service builder method to be invoked, as well as any service decorator methods.
+  
+  This feature is used when a service manages a resource, such as a thread, that needs to be created
+  as soon as the application starts up.  Another common example is a service that listens for events produced
+  by a second service; the first service may need to be created, and start listing, before any of its
+  service methods are invoked (which would normally trigger the instantiation of the service).
+  
+  Many services may be annotated with @EagerLoad; the order in which services are created is not defined. 
+  
+  With the perthread lifecycle, the service builder method will not be invoked (this won't happen until
+  a service method is invoked), but the decorators for
+  the service will be created. 
      
 Injecting Resources
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java?view=diff&rev=442580&r1=442579&r2=442580
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/DefaultModuleDefImplTest.java Tue Sep 12 06:11:28 2006
@@ -83,9 +83,10 @@
 
         Set<String> ids = md.getServiceIds();
 
-        assertEquals(ids.size(), 2);
+        assertEquals(ids.size(), 3);
         assertTrue(ids.contains("ioc.Fred"));
         assertTrue(ids.contains("ioc.Barney"));
+        assertTrue(ids.contains("ioc.Wilma"));
 
         ServiceDef sd = md.getServiceDef("ioc.Fred");
 
@@ -96,6 +97,7 @@
         assertEquals(sd.toString(), className + ".buildFred()");
         assertEquals(sd.getServiceLifeycle(), IOCConstants.DEFAULT_LIFECYCLE);
         assertEquals(sd.isPrivate(), false);
+        assertEquals(sd.isEagerLoad(), false);
 
         sd = md.getServiceDef("ioc.Barney");
 
@@ -107,6 +109,9 @@
         assertEquals(sd.getServiceLifeycle(), "threaded");
         assertEquals(sd.isPrivate(), true);
 
+        sd = md.getServiceDef("ioc.Wilma");
+        assertEquals(sd.isEagerLoad(), true);
+        
         // Now the decorator method.
 
         Set<DecoratorDef> defs = md.getDecoratorDefs();

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/OneShortServiceCreatorTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/OneShortServiceCreatorTest.java?view=diff&rev=442580&r1=442579&r2=442580
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/OneShortServiceCreatorTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/OneShortServiceCreatorTest.java Tue Sep 12 06:11:28 2006
@@ -34,7 +34,7 @@
         ObjectCreator delegate = newServiceCreator();
         Object service = new Object();
 
-        ServiceDef def = new ServiceDefImpl("foo.Bar", "singleton", method, false);
+        ServiceDef def = new ServiceDefImpl("foo.Bar", "singleton", method, false, false);
 
         train_greateService(delegate, service);
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/SimpleModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/SimpleModule.java?view=diff&rev=442580&r1=442579&r2=442580
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/SimpleModule.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/SimpleModule.java Tue Sep 12 06:11:28 2006
@@ -15,6 +15,7 @@
 package org.apache.tapestry.internal.ioc;
 
 import org.apache.tapestry.ioc.Configuration;
+import org.apache.tapestry.ioc.annotations.EagerLoad;
 import org.apache.tapestry.ioc.annotations.Id;
 import org.apache.tapestry.ioc.annotations.Lifecycle;
 import org.apache.tapestry.ioc.annotations.Private;
@@ -35,6 +36,12 @@
     @Lifecycle("threaded")
     @Private
     public FoeService buildBarney()
+    {
+        return null;
+    }
+
+    @EagerLoad
+    public FoeService buildWilma()
     {
         return null;
     }

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/EagerLoadModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/EagerLoadModule.java?view=auto&rev=442580
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/EagerLoadModule.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/EagerLoadModule.java Tue Sep 12 06:11:28 2006
@@ -0,0 +1,37 @@
+// Copyright 2006 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;
+
+import org.apache.tapestry.ioc.annotations.EagerLoad;
+import org.apache.tapestry.ioc.annotations.Id;
+
+/**
+ * Used to test service eager loading.
+ * 
+ * @author Howard M. Lewis Ship
+ */
+@Id("ioc.eager")
+public class EagerLoadModule
+{
+    public static boolean _eagerLoadDidHappen = false;
+
+    @EagerLoad
+    public StringHolder buildStringHolder()
+    {
+        _eagerLoadDidHappen = true;
+
+        return new StringHolderImpl();
+    }
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java?view=diff&rev=442580&r1=442579&r2=442580
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java Tue Sep 12 06:11:28 2006
@@ -251,7 +251,7 @@
         Registry r = buildRegistry(PerThreadModule.class);
 
         r.cleanupThread();
-        
+
         StringHolder holder = r.getService(StringHolder.class);
 
         assertNull(holder.getValue());
@@ -300,5 +300,15 @@
         {
             assertTrue(ex.getMessage().contains("has failed due to recursion"));
         }
+    }
+
+    @Test
+    public void eager_service_loading()
+    {
+        assertFalse(EagerLoadModule._eagerLoadDidHappen);
+
+        Registry r = buildRegistry(EagerLoadModule.class);
+
+        assertTrue(EagerLoadModule._eagerLoadDidHappen);
     }
 }