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 2010/01/02 20:52:12 UTC

svn commit: r895274 [1/2] - in /tapestry/tapestry5/trunk: tapestry-core/src/main/java/org/apache/tapestry5/internal/beaneditor/ tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ tapestry-core/src/test/java/org/apache/tapestry5/interna...

Author: hlship
Date: Sat Jan  2 19:52:09 2010
New Revision: 895274

URL: http://svn.apache.org/viewvc?rev=895274&view=rev
Log:
TAP5-967: ObjectLocator.autobuild would be more useful with an override that allowed a message about the object to be described

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/beaneditor/BeanModelImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ApplicationStateManagerImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ApplicationStateManagerImplTest.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ObjectLocator.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.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/RegistryWrapper.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/AutobuildObjectProvider.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/test/IOCTestCase.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/IntegrationTest.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/beaneditor/BeanModelImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/beaneditor/BeanModelImpl.java?rev=895274&r1=895273&r2=895274&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/beaneditor/BeanModelImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/beaneditor/BeanModelImpl.java Sat Jan  2 19:52:09 2010
@@ -14,24 +14,22 @@
 
 package org.apache.tapestry5.internal.beaneditor;
 
+import java.util.List;
+import java.util.Map;
+
 import org.apache.tapestry5.PropertyConduit;
 import org.apache.tapestry5.beaneditor.BeanModel;
 import org.apache.tapestry5.beaneditor.PropertyModel;
 import org.apache.tapestry5.beaneditor.RelativePosition;
 import org.apache.tapestry5.internal.services.CoercingPropertyConduitWrapper;
-import org.apache.tapestry5.ioc.Invokable;
 import org.apache.tapestry5.ioc.Messages;
 import org.apache.tapestry5.ioc.ObjectLocator;
-import org.apache.tapestry5.ioc.OperationTracker;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.internal.util.Defense;
 import org.apache.tapestry5.ioc.services.ClassFabUtils;
 import org.apache.tapestry5.ioc.services.TypeCoercer;
 import org.apache.tapestry5.services.PropertyConduitSource;
 
-import java.util.List;
-import java.util.Map;
-
 public class BeanModelImpl<T> implements BeanModel<T>
 {
     private final Class<T> beanType;
@@ -44,8 +42,6 @@
 
     private final ObjectLocator locator;
 
-    private final OperationTracker tracker;
-
     private final Map<String, PropertyModel> properties = CollectionFactory.newCaseInsensitiveMap();
 
     // The list of property names, in desired order (generally not alphabetical order).
@@ -53,8 +49,7 @@
     private final List<String> propertyNames = CollectionFactory.newList();
 
     public BeanModelImpl(Class<T> beanType, PropertyConduitSource propertyConduitSource,
-            TypeCoercer typeCoercer, Messages messages, ObjectLocator locator,
-            OperationTracker tracker)
+            TypeCoercer typeCoercer, Messages messages, ObjectLocator locator)
 
     {
         this.beanType = beanType;
@@ -62,7 +57,6 @@
         this.typeCoercer = typeCoercer;
         this.messages = messages;
         this.locator = locator;
-        this.tracker = tracker;
     }
 
     public Class<T> getBeanType()
@@ -72,14 +66,7 @@
 
     public T newInstance()
     {
-        return tracker.invoke("Instantiating new instance of " + beanType.getName(),
-                new Invokable<T>()
-                {
-                    public T invoke()
-                    {
-                        return locator.autobuild(beanType);
-                    }
-                });
+        return locator.autobuild("Instantiating new instance of " + beanType.getName(), beanType);
     }
 
     public PropertyModel add(String propertyName)

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ApplicationStateManagerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ApplicationStateManagerImpl.java?rev=895274&r1=895273&r2=895274&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ApplicationStateManagerImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ApplicationStateManagerImpl.java Sat Jan  2 19:52:09 2010
@@ -14,16 +14,17 @@
 
 package org.apache.tapestry5.internal.services;
 
-import org.apache.tapestry5.ioc.Invokable;
-import org.apache.tapestry5.ioc.ObjectLocator;
-import org.apache.tapestry5.ioc.OperationTracker;
-import org.apache.tapestry5.ioc.ServiceResources;
-
 import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newConcurrentMap;
-import org.apache.tapestry5.services.*;
 
 import java.util.Map;
 
+import org.apache.tapestry5.ioc.ObjectLocator;
+import org.apache.tapestry5.services.ApplicationStateContribution;
+import org.apache.tapestry5.services.ApplicationStateCreator;
+import org.apache.tapestry5.services.ApplicationStateManager;
+import org.apache.tapestry5.services.ApplicationStatePersistenceStrategy;
+import org.apache.tapestry5.services.ApplicationStatePersistenceStrategySource;
+
 public class ApplicationStateManagerImpl implements ApplicationStateManager
 {
     static final String DEFAULT_STRATEGY = "session";
@@ -71,16 +72,12 @@
 
     private final ObjectLocator locator;
 
-    private final OperationTracker tracker;
-
     @SuppressWarnings("unchecked")
     public ApplicationStateManagerImpl(Map<Class, ApplicationStateContribution> configuration,
-            ApplicationStatePersistenceStrategySource source, ObjectLocator locator,
-            OperationTracker tracker)
+            ApplicationStatePersistenceStrategySource source, ObjectLocator locator)
     {
         this.source = source;
         this.locator = locator;
-        this.tracker = tracker;
 
         for (Class asoClass : configuration.keySet())
         {
@@ -104,14 +101,8 @@
             {
                 public T create()
                 {
-                    return tracker.invoke("Instantiating instance of SSO class "
-                            + ssoClass.getName(), new Invokable<T>()
-                    {
-                        public T invoke()
-                        {
-                            return locator.autobuild(ssoClass);
-                        }
-                    });
+                    return locator.autobuild("Instantiating instance of SSO class "
+                            + ssoClass.getName(), ssoClass);
                 }
             };
         }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java?rev=895274&r1=895273&r2=895274&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java Sat Jan  2 19:52:09 2010
@@ -25,6 +25,7 @@
 import org.apache.tapestry5.internal.beaneditor.BeanModelUtils;
 import org.apache.tapestry5.ioc.Location;
 import org.apache.tapestry5.ioc.Messages;
+import org.apache.tapestry5.ioc.ObjectLocator;
 import org.apache.tapestry5.ioc.ServiceResources;
 import org.apache.tapestry5.ioc.annotations.Primary;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
@@ -51,7 +52,7 @@
 
     private final DataTypeAnalyzer dataTypeAnalyzer;
 
-    private final ServiceResources resources;
+    private final ObjectLocator locator;
 
     private static class PropertyOrder implements Comparable<PropertyOrder>
     {
@@ -132,14 +133,14 @@
     public BeanModelSourceImpl(TypeCoercer typeCoercer, PropertyAccess propertyAccess,
             PropertyConduitSource propertyConduitSource, @ComponentLayer
             ClassFactory classFactory, @Primary
-            DataTypeAnalyzer dataTypeAnalyzer, ServiceResources resources)
+            DataTypeAnalyzer dataTypeAnalyzer, ObjectLocator locator)
     {
         this.typeCoercer = typeCoercer;
         this.propertyAccess = propertyAccess;
         this.propertyConduitSource = propertyConduitSource;
         this.classFactory = classFactory;
         this.dataTypeAnalyzer = dataTypeAnalyzer;
-        this.resources = resources;
+        this.locator = locator;
     }
 
     public <T> BeanModel<T> createDisplayModel(Class<T> beanClass, Messages messages)
@@ -161,7 +162,7 @@
         ClassPropertyAdapter adapter = propertyAccess.getAdapter(beanClass);
 
         BeanModel<T> model = new BeanModelImpl<T>(beanClass, propertyConduitSource, typeCoercer,
-                messages, resources, resources.getTracker());
+                messages, locator);
 
         for (final String propertyName : adapter.getPropertyNames())
         {

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalModule.java?rev=895274&r1=895273&r2=895274&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalModule.java Sat Jan  2 19:52:09 2010
@@ -1,4 +1,4 @@
-// Copyright 2008, 2009 The Apache Software Foundation
+// Copyright 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.
@@ -14,6 +14,8 @@
 
 package org.apache.tapestry5.internal.services;
 
+import javax.servlet.http.Cookie;
+
 import org.apache.tapestry5.SymbolConstants;
 import org.apache.tapestry5.internal.pageload.PageLoaderImpl;
 import org.apache.tapestry5.internal.structure.ComponentPageElementResourcesSource;
@@ -26,12 +28,26 @@
 import org.apache.tapestry5.ioc.annotations.Scope;
 import org.apache.tapestry5.ioc.annotations.Symbol;
 import org.apache.tapestry5.ioc.internal.services.CtClassSource;
-import org.apache.tapestry5.ioc.services.*;
-import org.apache.tapestry5.services.*;
+import org.apache.tapestry5.ioc.services.Builtin;
+import org.apache.tapestry5.ioc.services.ClassFactory;
+import org.apache.tapestry5.ioc.services.ClasspathURLConverter;
+import org.apache.tapestry5.ioc.services.PerthreadManager;
+import org.apache.tapestry5.ioc.services.PropertyShadowBuilder;
+import org.apache.tapestry5.services.AssetFactory;
+import org.apache.tapestry5.services.ComponentClassResolver;
+import org.apache.tapestry5.services.ComponentClasses;
+import org.apache.tapestry5.services.ComponentLayer;
+import org.apache.tapestry5.services.ComponentMessages;
+import org.apache.tapestry5.services.ComponentTemplates;
+import org.apache.tapestry5.services.ContextProvider;
+import org.apache.tapestry5.services.Core;
+import org.apache.tapestry5.services.InvalidationEventHub;
+import org.apache.tapestry5.services.LocalizationSetter;
+import org.apache.tapestry5.services.RequestGlobals;
+import org.apache.tapestry5.services.ResponseCompressionAnalyzer;
+import org.apache.tapestry5.services.UpdateListenerHub;
 import org.slf4j.Logger;
 
-import javax.servlet.http.Cookie;
-
 /**
  * {@link org.apache.tapestry5.services.TapestryModule} has gotten too complicated and it is nice to demarkate public
  * (and stable) from internal (and volatile).

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ApplicationStateManagerImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ApplicationStateManagerImplTest.java?rev=895274&r1=895273&r2=895274&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ApplicationStateManagerImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ApplicationStateManagerImplTest.java Sat Jan  2 19:52:09 2010
@@ -18,7 +18,6 @@
 import org.apache.tapestry5.internal.transform.pages.ReadOnlyBean;
 import org.apache.tapestry5.internal.util.Holder;
 import org.apache.tapestry5.ioc.ObjectLocator;
-import org.apache.tapestry5.ioc.internal.QuietOperationTracker;
 import org.apache.tapestry5.services.*;
 import org.easymock.EasyMock;
 import static org.easymock.EasyMock.eq;
@@ -52,7 +51,7 @@
         replay();
 
         ApplicationStateManager manager = new ApplicationStateManagerImpl(configuration, source,
-                null, null);
+                null);
 
         assertSame(manager.get(asoClass), aso);
 
@@ -78,7 +77,7 @@
         replay();
 
         ApplicationStateManager manager = new ApplicationStateManagerImpl(configuration, source,
-                null, null);
+                null);
 
         assertFalse(manager.exists(asoClass));
 
@@ -104,7 +103,7 @@
         replay();
 
         ApplicationStateManager manager = new ApplicationStateManagerImpl(configuration, source,
-                null, null);
+                null);
 
         assertTrue(manager.exists(asoClass));
 
@@ -131,7 +130,7 @@
         replay();
 
         ApplicationStateManager manager = new ApplicationStateManagerImpl(configuration, source,
-                null, null);
+                null);
 
         manager.set(asoClass, aso);
 
@@ -167,14 +166,15 @@
 
         expect(strategy.get(eq(asoClass), isA(ApplicationStateCreator.class))).andAnswer(answer);
 
-        train_autobuild(locator, asoClass, new ReadOnlyBean());
+        expect(locator.autobuild(EasyMock.isA(String.class), EasyMock.eq(asoClass))).andReturn(
+                new ReadOnlyBean());
 
         replay();
 
         Map<Class, ApplicationStateContribution> configuration = Collections.emptyMap();
 
         ApplicationStateManager manager = new ApplicationStateManagerImpl(configuration, source,
-                locator, new QuietOperationTracker());
+                locator);
 
         Object actual = manager.get(asoClass);
 
@@ -201,7 +201,7 @@
         replay();
 
         ApplicationStateManager manager = new ApplicationStateManagerImpl(configuration, source,
-                null, null);
+                null);
 
         assertNull(manager.getIfExists(asoClass));
 
@@ -228,7 +228,7 @@
         replay();
 
         ApplicationStateManager manager = new ApplicationStateManagerImpl(configuration, source,
-                null, null);
+                null);
 
         assertSame(manager.getIfExists(asoClass), aso);
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java?rev=895274&r1=895273&r2=895274&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/test/InternalBaseTestCase.java Sat Jan  2 19:52:09 2010
@@ -1,4 +1,4 @@
-// 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.
@@ -14,15 +14,58 @@
 
 package org.apache.tapestry5.internal.test;
 
-import org.apache.tapestry5.*;
-import org.apache.tapestry5.internal.*;
+import static org.easymock.EasyMock.isA;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.io.Reader;
+import java.util.Arrays;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.ComponentResourcesCommon;
+import org.apache.tapestry5.ContentType;
+import org.apache.tapestry5.EventContext;
+import org.apache.tapestry5.internal.InternalComponentResources;
+import org.apache.tapestry5.internal.InternalSymbols;
+import org.apache.tapestry5.internal.SingleKeySymbolProvider;
+import org.apache.tapestry5.internal.SyntheticModuleDef;
+import org.apache.tapestry5.internal.SyntheticSymbolSourceContributionDef;
 import org.apache.tapestry5.internal.parser.ComponentTemplate;
 import org.apache.tapestry5.internal.parser.TemplateToken;
-import org.apache.tapestry5.internal.services.*;
+import org.apache.tapestry5.internal.services.ActionRenderResponseGenerator;
+import org.apache.tapestry5.internal.services.ComponentClassCache;
+import org.apache.tapestry5.internal.services.ComponentInstantiatorSource;
+import org.apache.tapestry5.internal.services.ComponentModelSource;
+import org.apache.tapestry5.internal.services.ComponentTemplateSource;
+import org.apache.tapestry5.internal.services.DocumentLinker;
+import org.apache.tapestry5.internal.services.Instantiator;
+import org.apache.tapestry5.internal.services.LinkSource;
+import org.apache.tapestry5.internal.services.PageContentTypeAnalyzer;
+import org.apache.tapestry5.internal.services.PageElementFactory;
+import org.apache.tapestry5.internal.services.PageLoader;
+import org.apache.tapestry5.internal.services.PagePool;
+import org.apache.tapestry5.internal.services.PageRenderQueue;
+import org.apache.tapestry5.internal.services.PageResponseRenderer;
+import org.apache.tapestry5.internal.services.PageTemplateLocator;
+import org.apache.tapestry5.internal.services.RequestPageCache;
+import org.apache.tapestry5.internal.services.RequestPathOptimizer;
+import org.apache.tapestry5.internal.services.RequestSecurityManager;
+import org.apache.tapestry5.internal.services.ResourceCache;
+import org.apache.tapestry5.internal.services.ResourceStreamer;
+import org.apache.tapestry5.internal.services.TemplateParser;
 import org.apache.tapestry5.internal.structure.ComponentPageElement;
 import org.apache.tapestry5.internal.structure.ComponentPageElementResources;
 import org.apache.tapestry5.internal.structure.Page;
-import org.apache.tapestry5.ioc.*;
+import org.apache.tapestry5.ioc.AnnotationProvider;
+import org.apache.tapestry5.ioc.Messages;
+import org.apache.tapestry5.ioc.Registry;
+import org.apache.tapestry5.ioc.RegistryBuilder;
+import org.apache.tapestry5.ioc.Resource;
 import org.apache.tapestry5.ioc.def.ContributionDef;
 import org.apache.tapestry5.ioc.def.ModuleDef;
 import org.apache.tapestry5.ioc.internal.InternalRegistry;
@@ -38,20 +81,20 @@
 import org.apache.tapestry5.runtime.Component;
 import org.apache.tapestry5.runtime.RenderCommand;
 import org.apache.tapestry5.runtime.RenderQueue;
-import org.apache.tapestry5.services.*;
+import org.apache.tapestry5.services.ClientBehaviorSupport;
+import org.apache.tapestry5.services.ComponentClassResolver;
+import org.apache.tapestry5.services.InvalidationListener;
+import org.apache.tapestry5.services.LinkCreationListener;
+import org.apache.tapestry5.services.LocalizationSetter;
+import org.apache.tapestry5.services.Request;
+import org.apache.tapestry5.services.TapestryModule;
 import org.apache.tapestry5.test.TapestryTestCase;
 import org.easymock.EasyMock;
-import static org.easymock.EasyMock.isA;
 import org.slf4j.Logger;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.AfterSuite;
 import org.testng.annotations.BeforeSuite;
 
-import java.io.*;
-import java.util.Arrays;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
 /**
  * Contains additional factory and training methods related to internal interfaces.
  */
@@ -71,8 +114,8 @@
         // A synthetic module to ensure that the tapestry.alias-mode is set correctly.
 
         SymbolProvider provider = new SingleKeySymbolProvider(InternalSymbols.ALIAS_MODE, "servlet");
-        ContributionDef contribution = new SyntheticSymbolSourceContributionDef("AliasMode", provider,
-                                                                                "before:ApplicationDefaults");
+        ContributionDef contribution = new SyntheticSymbolSourceContributionDef("AliasMode",
+                provider, "before:ApplicationDefaults");
 
         ModuleDef module = new SyntheticModuleDef(contribution);
 
@@ -124,7 +167,12 @@
         return registry.autobuild(clazz);
     }
 
-    public <T> T proxy(Class<T> interfaceClass, Class<? extends T> implementationClass)
+    public final <T> T autobuild(String description, Class<T> clazz)
+    {
+        return registry.autobuild(description, clazz);
+    }
+
+    public final <T> T proxy(Class<T> interfaceClass, Class<? extends T> implementationClass)
     {
         return registry.proxy(interfaceClass, implementationClass);
     }
@@ -144,8 +192,8 @@
         return newMock(ComponentTemplate.class);
     }
 
-    protected final <T> void train_getService(InternalRegistry registry, String serviceId, Class<T> serviceInterface,
-                                              T service)
+    protected final <T> void train_getService(InternalRegistry registry, String serviceId,
+            Class<T> serviceInterface, T service)
     {
         expect(registry.getService(serviceId, serviceInterface)).andReturn(service);
     }
@@ -180,7 +228,8 @@
         return newMock(RenderQueue.class);
     }
 
-    protected final void train_parseTemplate(TemplateParser parser, Resource resource, ComponentTemplate template)
+    protected final void train_parseTemplate(TemplateParser parser, Resource resource,
+            ComponentTemplate template)
     {
         expect(parser.parseTemplate(resource)).andReturn(template);
     }
@@ -215,8 +264,8 @@
         expect(request.getContextPath()).andReturn(contextPath).atLeastOnce();
     }
 
-    protected final void train_resolvePageClassNameToPageName(ComponentClassResolver resolver, String pageClassName,
-                                                              String pageName)
+    protected final void train_resolvePageClassNameToPageName(ComponentClassResolver resolver,
+            String pageClassName, String pageName)
     {
         expect(resolver.resolvePageClassNameToPageName(pageClassName)).andReturn(pageName);
     }
@@ -226,7 +275,8 @@
         expect(element.getContainingPage()).andReturn(page).atLeastOnce();
     }
 
-    protected final void train_getComponentResources(ComponentPageElement element, InternalComponentResources resources)
+    protected final void train_getComponentResources(ComponentPageElement element,
+            InternalComponentResources resources)
     {
         expect(element.getComponentResources()).andReturn(resources).atLeastOnce();
     }
@@ -252,7 +302,7 @@
     }
 
     protected final void train_getEmbeddedComponentModel(ComponentModel model, String embeddedId,
-                                                         EmbeddedComponentModel emodel)
+            EmbeddedComponentModel emodel)
     {
         expect(model.getEmbeddedComponentModel(embeddedId)).andReturn(emodel).atLeastOnce();
     }
@@ -287,8 +337,8 @@
         expect(model.getEmbeddedComponentIds()).andReturn(Arrays.asList(ids));
     }
 
-    protected void train_getTemplate(ComponentTemplateSource templateSource, ComponentModel model, Locale locale,
-                                     ComponentTemplate template)
+    protected void train_getTemplate(ComponentTemplateSource templateSource, ComponentModel model,
+            Locale locale, ComponentTemplate template)
     {
         expect(templateSource.getTemplate(model, locale)).andReturn(template);
     }
@@ -318,7 +368,8 @@
         return newMock(RequestPageCache.class);
     }
 
-    protected final void train_getComponentElementByNestedId(Page page, String nestedId, ComponentPageElement element)
+    protected final void train_getComponentElementByNestedId(Page page, String nestedId,
+            ComponentPageElement element)
     {
         expect(page.getComponentElementByNestedId(nestedId)).andReturn(element).atLeastOnce();
     }
@@ -348,7 +399,8 @@
         return newMock(ResourceCache.class);
     }
 
-    protected final void train_requiresDigest(ResourceCache cache, Resource resource, boolean requiresChecksum)
+    protected final void train_requiresDigest(ResourceCache cache, Resource resource,
+            boolean requiresChecksum)
     {
         expect(cache.requiresDigest(resource)).andReturn(requiresChecksum);
     }
@@ -358,7 +410,8 @@
         return newMock(InvalidationListener.class);
     }
 
-    protected final void train_getTimeModified(ResourceCache cache, Resource resource, long timeModified)
+    protected final void train_getTimeModified(ResourceCache cache, Resource resource,
+            long timeModified)
     {
         expect(cache.getTimeModified(resource)).andReturn(timeModified).atLeastOnce();
     }
@@ -373,8 +426,8 @@
         expect(cache.get(pageName)).andReturn(page).atLeastOnce();
     }
 
-    protected final void train_findPageTemplateResource(PageTemplateLocator locator, ComponentModel model,
-                                                        Locale locale, Resource resource)
+    protected final void train_findPageTemplateResource(PageTemplateLocator locator,
+            ComponentModel model, Locale locale, Resource resource)
     {
         expect(locator.findPageTemplateResource(model, locale)).andReturn(resource).atLeastOnce();
     }
@@ -420,7 +473,8 @@
         expect(resolver.isPageName(isA(String.class))).andStubReturn(result);
     }
 
-    protected final void train_isPageName(ComponentClassResolver resolver, String pageName, boolean result)
+    protected final void train_isPageName(ComponentClassResolver resolver, String pageName,
+            boolean result)
     {
         expect(resolver.isPageName(pageName)).andReturn(result);
     }
@@ -431,10 +485,12 @@
     }
 
     /**
-     * Reads the content of a file into a string. Each line is trimmed of line separators and leading/trailing
+     * Reads the content of a file into a string. Each line is trimmed of line separators and
+     * leading/trailing
      * whitespace.
-     *
-     * @param file trim each line of whitespace
+     * 
+     * @param file
+     *            trim each line of whitespace
      */
     protected final String readFile(String file) throws Exception
     {
@@ -449,7 +505,8 @@
         {
             String line = in.readLine();
 
-            if (line == null) break;
+            if (line == null)
+                break;
 
             buffer.append(line);
 
@@ -466,8 +523,8 @@
         return newMock(DocumentLinker.class);
     }
 
-    protected final void train_canonicalizePageName(ComponentClassResolver resolver, String pageName,
-                                                    String canonicalized)
+    protected final void train_canonicalizePageName(ComponentClassResolver resolver,
+            String pageName, String canonicalized)
     {
         expect(resolver.canonicalizePageName(pageName)).andReturn(canonicalized);
     }
@@ -477,8 +534,8 @@
         expect(page.getName()).andReturn(pageName).atLeastOnce();
     }
 
-    protected final void train_resolvePageNameToClassName(ComponentClassResolver resolver, String pageName,
-                                                          String pageClassName)
+    protected final void train_resolvePageNameToClassName(ComponentClassResolver resolver,
+            String pageName, String pageClassName)
     {
         expect(resolver.resolvePageNameToClassName(pageName)).andReturn(pageClassName)
                 .atLeastOnce();
@@ -509,7 +566,8 @@
         return newMock(ComponentClassCache.class);
     }
 
-    protected void train_findContentType(PageContentTypeAnalyzer analyzer, Page page, ContentType contentType)
+    protected void train_findContentType(PageContentTypeAnalyzer analyzer, Page page,
+            ContentType contentType)
     {
         expect(analyzer.findContentType(page)).andReturn(contentType).atLeastOnce();
     }
@@ -519,13 +577,13 @@
         return newMock(PageContentTypeAnalyzer.class);
     }
 
-
     protected final RequestPathOptimizer mockRequestPathOptimizer()
     {
         return newMock(RequestPathOptimizer.class);
     }
 
-    protected final void train_optimizePath(RequestPathOptimizer optimizer, String path, String optimizedPath)
+    protected final void train_optimizePath(RequestPathOptimizer optimizer, String path,
+            String optimizedPath)
     {
         expect(optimizer.optimizePath(path)).andReturn(optimizedPath);
     }
@@ -550,14 +608,15 @@
         return newMock(ComponentPageElementResources.class);
     }
 
-    protected final void train_toClass(ComponentPageElementResources resources, String className, Class toClass)
+    protected final void train_toClass(ComponentPageElementResources resources, String className,
+            Class toClass)
     {
         expect(resources.toClass(className)).andReturn(toClass).atLeastOnce();
     }
 
-    protected final <S, T> void train_coerce(ComponentPageElementResources componentPageElementResources, S input,
-                                             Class<T> expectedType,
-                                             T coercedValue)
+    protected final <S, T> void train_coerce(
+            ComponentPageElementResources componentPageElementResources, S input,
+            Class<T> expectedType, T coercedValue)
     {
         expect(componentPageElementResources.coerce(input, expectedType)).andReturn(coercedValue);
     }
@@ -578,14 +637,14 @@
     }
 
     protected final void train_getPropertyAdapter(ClassPropertyAdapter classPropertyAdapter,
-                                                  String propertyName, PropertyAdapter propertyAdapter)
+            String propertyName, PropertyAdapter propertyAdapter)
     {
         expect(classPropertyAdapter.getPropertyAdapter(propertyName)).andReturn(propertyAdapter)
                 .atLeastOnce();
     }
 
     protected final void train_getAdapter(PropertyAccess access, Object object,
-                                          ClassPropertyAdapter classPropertyAdapter)
+            ClassPropertyAdapter classPropertyAdapter)
     {
         expect(access.getAdapter(object)).andReturn(classPropertyAdapter);
     }
@@ -613,8 +672,8 @@
         return newMock(FieldComponent.class);
     }
 
-    protected final void train_setLocaleFromLocaleName(LocalizationSetter localizationSetter, String localeName,
-                                                       boolean recognized)
+    protected final void train_setLocaleFromLocaleName(LocalizationSetter localizationSetter,
+            String localeName, boolean recognized)
     {
         expect(localizationSetter.setLocaleFromLocaleName(localeName)).andReturn(recognized);
     }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ObjectLocator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ObjectLocator.java?rev=895274&r1=895273&r2=895274&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ObjectLocator.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ObjectLocator.java Sat Jan  2 19:52:09 2010
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 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.
@@ -14,53 +14,71 @@
 
 package org.apache.tapestry5.ioc;
 
+import org.apache.tapestry5.ioc.annotations.Inject;
 import org.apache.tapestry5.ioc.services.MasterObjectProvider;
 
 /**
- * Defines an object which can provide access to services defined within a {@link org.apache.tapestry5.ioc.Registry}, or
- * to objects or object instances available by other means. Services are accessed via service id, or (when appropriate)
- * by just service interface. The Registry itself implements this interface, as does {@link
- * org.apache.tapestry5.ioc.ServiceResources}.
+ * Defines an object which can provide access to services defined within a
+ * {@link org.apache.tapestry5.ioc.Registry}, or
+ * to objects or object instances available by other means. Services are accessed via service id, or
+ * (when appropriate)
+ * by just service interface. The Registry itself implements this interface, as does
+ * {@link org.apache.tapestry5.ioc.ServiceResources}.
  */
 public interface ObjectLocator
 {
 
     /**
-     * Obtains a service via its unique service id. Returns the service's proxy. The service proxy implements the same
-     * interface as the actual service, and is used to instantiate the actual service only as needed (this is
+     * Obtains a service via its unique service id. Returns the service's proxy. The service proxy
+     * implements the same
+     * interface as the actual service, and is used to instantiate the actual service only as needed
+     * (this is
      * transparent to the application).
-     *
+     * 
      * @param <T>
-     * @param serviceId        unique Service id used to locate the service object (may contain <em>symbols</em>, which
-     *                         will be expanded), case is ignored
-     * @param serviceInterface the interface implemented by the service (or an interface extended by the service
-     *                         interface)
+     * @param serviceId
+     *            unique Service id used to locate the service object (may contain <em>symbols</em>,
+     *            which
+     *            will be expanded), case is ignored
+     * @param serviceInterface
+     *            the interface implemented by the service (or an interface extended by the service
+     *            interface)
      * @return the service instance
-     * @throws RuntimeException if the service is not defined, or if an error occurs instantiating it
+     * @throws RuntimeException
+     *             if the service is not defined, or if an error occurs instantiating it
      */
     <T> T getService(String serviceId, Class<T> serviceInterface);
 
     /**
-     * Locates a service given just a service interface. A single service must implement the service interface (which
-     * can be hard to guarantee). The search takes into account inheritance of the service interface (not the service
-     * <em>implementation</em>), which may result in a failure due to extra matches.
-     *
+     * Locates a service given just a service interface. A single service must implement the service
+     * interface (which
+     * can be hard to guarantee). The search takes into account inheritance of the service interface
+     * (not the service <em>implementation</em>), which may result in a failure due to extra
+     * matches.
+     * 
      * @param <T>
-     * @param serviceInterface the interface the service implements
+     * @param serviceInterface
+     *            the interface the service implements
      * @return the service's proxy
-     * @throws RuntimeException if the service does not exist (this is considered programmer error), or multiple
-     *                          services directly implement, or extend from, the service interface
+     * @throws RuntimeException
+     *             if the service does not exist (this is considered programmer error), or multiple
+     *             services directly implement, or extend from, the service interface
      */
     <T> T getService(Class<T> serviceInterface);
 
     /**
-     * Obtains an object indirectly, using the {@link org.apache.tapestry5.ioc.services.MasterObjectProvider} service.
-     *
-     * @param objectType         the type of object to be returned
-     * @param annotationProvider provides access to annotations on the field or parameter for which a value is to be
-     *                           obtained, which may be utilized in selecting an appropriate object, use
-     *                           <strong>null</strong> when annotations are not available (in which case, selection will
-     *                           be based only on the object type)
+     * Obtains an object indirectly, using the
+     * {@link org.apache.tapestry5.ioc.services.MasterObjectProvider} service.
+     * 
+     * @param objectType
+     *            the type of object to be returned
+     * @param annotationProvider
+     *            provides access to annotations on the field or parameter for which a value is to
+     *            be
+     *            obtained, which may be utilized in selecting an appropriate object, use
+     *            <strong>null</strong> when annotations are not available (in which case, selection
+     *            will
+     *            be based only on the object type)
      * @param <T>
      * @return the requested object
      * @see ObjectProvider
@@ -68,26 +86,55 @@
     <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider);
 
     /**
-     * Autobuilds a class by finding the public constructor with the most parameters. Services and resources will be
-     * injected into the parameters of the constructor.
-     *
+     * Autobuilds a class by finding the public constructor with the most parameters. Services and
+     * resources will be
+     * injected into the parameters of the constructor and private field marked with the
+     * {@link Inject} annotation.
+     * 
      * @param <T>
-     * @param clazz the type of object to instantiate
+     * @param clazz
+     *            the type of object to instantiate
      * @return the instantiated instance
-     * @throws RuntimeException if the autobuild fails
+     * @throws RuntimeException
+     *             if the autobuild fails
      * @see MasterObjectProvider
      */
     <T> T autobuild(Class<T> clazz);
 
     /**
-     * Creates a proxy. The proxy will defer invocation of {@link #autobuild(Class)} until just-in-time (that is, first
-     * method invocation). In a limited number of cases, it is necessary to use such a proxy to prevent service
-     * construction cycles, particularly when contributing (directly or indirectly) to the {@link
-     * org.apache.tapestry5.ioc.services.MasterObjectProvider} (which is itself at the heart of autobuilding).
-     *
+     * Autobuilds a class by finding the public constructor with the most parameters. Services and
+     * resources will be
+     * injected into the parameters of the constructor and private field marked with the
+     * {@link Inject} annotation. This version tracks the operation using
+     * {@link OperationTracker#invoke(String, Invokable)}.
+     * 
      * @param <T>
-     * @param interfaceClass      the interface implemented by the proxy
-     * @param implementationClass a concrete class that implements the interface
+     * @param description
+     *            description used with {@link OperationTracker}
+     * @param clazz
+     *            the type of object to instantiate
+     * @return the instantiated instance
+     * @throws RuntimeException
+     *             if the autobuild fails
+     * @see MasterObjectProvider
+     * @since 5.2.0
+     */
+    <T> T autobuild(String description, Class<T> clazz);
+
+    /**
+     * Creates a proxy. The proxy will defer invocation of {@link #autobuild(Class)} until
+     * just-in-time (that is, first
+     * method invocation). In a limited number of cases, it is necessary to use such a proxy to
+     * prevent service
+     * construction cycles, particularly when contributing (directly or indirectly) to the
+     * {@link org.apache.tapestry5.ioc.services.MasterObjectProvider} (which is itself at the heart
+     * of autobuilding).
+     * 
+     * @param <T>
+     * @param interfaceClass
+     *            the interface implemented by the proxy
+     * @param implementationClass
+     *            a concrete class that implements the interface
      * @return a proxy
      */
     <T> T proxy(Class<T> interfaceClass, Class<? extends T> implementationClass);

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java?rev=895274&r1=895273&r2=895274&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/IOCInternalTestCase.java Sat Jan  2 19:52:09 2010
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2009 The Apache Software Foundation
+// Copyright 2006, 2007, 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.
@@ -14,18 +14,22 @@
 
 package org.apache.tapestry5.ioc.internal;
 
-import org.apache.tapestry5.ioc.*;
+import static org.easymock.EasyMock.isA;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.tapestry5.ioc.AnnotationProvider;
+import org.apache.tapestry5.ioc.Registry;
+import org.apache.tapestry5.ioc.RegistryBuilder;
+import org.apache.tapestry5.ioc.ServiceDecorator;
 import org.apache.tapestry5.ioc.def.ServiceDef;
 import org.apache.tapestry5.ioc.services.ClassFactory;
 import org.apache.tapestry5.ioc.test.IOCTestCase;
-import static org.easymock.EasyMock.isA;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.AfterSuite;
 import org.testng.annotations.BeforeSuite;
 
-import java.util.Collections;
-import java.util.List;
-
 public class IOCInternalTestCase extends IOCTestCase implements Registry
 {
     private static Registry registry;
@@ -63,6 +67,11 @@
         return registry.autobuild(clazz);
     }
 
+    public final <T> T autobuild(String description, Class<T> clazz)
+    {
+        return registry.autobuild(description, clazz);
+    }
+
     public final void performRegistryStartup()
     {
         registry.performRegistryStartup();
@@ -73,7 +82,6 @@
         return registry.proxy(interfaceClass, implementationClass);
     }
 
-
     @BeforeSuite
     public final void setup_registry()
     {
@@ -91,7 +99,6 @@
         throw new UnsupportedOperationException("No registry shutdown until @AfterSuite.");
     }
 
-
     @AfterSuite
     public final void shutdown_registry()
     {
@@ -128,8 +135,8 @@
         expect(source.getDescription()).andReturn(description).atLeastOnce();
     }
 
-    protected final <T> void train_getService(InternalRegistry registry, String serviceId, Class<T> serviceInterface,
-                                              T service)
+    protected final <T> void train_getService(InternalRegistry registry, String serviceId,
+            Class<T> serviceInterface, T service)
     {
         expect(registry.getService(serviceId, serviceInterface)).andReturn(service);
     }

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=895274&r1=895273&r2=895274&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 Sat Jan  2 19:52:09 2010
@@ -1,4 +1,4 @@
-// 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.
@@ -18,7 +18,8 @@
 import org.apache.tapestry5.ioc.ObjectLocator;
 
 /**
- * Base service locator class used when only the module is known (i.e., when instantiating a module class).
+ * Base service locator class used when only the module is known (i.e., when instantiating a module
+ * class).
  */
 public class ObjectLocatorImpl implements ObjectLocator
 {
@@ -54,6 +55,11 @@
         return registry.autobuild(clazz);
     }
 
+    public <T> T autobuild(String description, Class<T> clazz)
+    {
+        return registry.autobuild(description, clazz);
+    }
+
     public <T> T proxy(Class<T> interfaceClass, Class<? extends T> implementationClass)
     {
         return registry.proxy(interfaceClass, implementationClass);

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=895274&r1=895273&r2=895274&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 Sat Jan  2 19:52:09 2010
@@ -1,4 +1,4 @@
-// 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.
@@ -48,7 +48,8 @@
     }
 
     /**
-     * Used to obtain the {@link org.apache.tapestry5.ioc.services.ClassFactory} service, which is crucial when creating
+     * Used to obtain the {@link org.apache.tapestry5.ioc.services.ClassFactory} service, which is
+     * crucial when creating
      * runtime classes for proxies and the like.
      */
     static final String CLASS_FACTORY_SERVICE_ID = "ClassFactory";
@@ -72,7 +73,8 @@
      */
     private final Map<String, Module> serviceIdToModule = CollectionFactory.newCaseInsensitiveMap();
 
-    private final Map<String, ServiceLifecycle2> lifecycles = CollectionFactory.newCaseInsensitiveMap();
+    private final Map<String, ServiceLifecycle2> lifecycles = CollectionFactory
+            .newCaseInsensitiveMap();
 
     private final PerthreadManager perthreadManager;
 
@@ -95,12 +97,16 @@
 
     /**
      * Constructs the registry from a set of module definitions and other resources.
-     *
-     * @param moduleDefs   defines the modules (and builders, decorators, etc., within)
-     * @param classFactory TODO
-     * @param loggerSource used to obtain Logger instances
+     * 
+     * @param moduleDefs
+     *            defines the modules (and builders, decorators, etc., within)
+     * @param classFactory
+     *            TODO
+     * @param loggerSource
+     *            used to obtain Logger instances
      */
-    public RegistryImpl(Collection<ModuleDef> moduleDefs, ClassFactory classFactory, LoggerSource loggerSource)
+    public RegistryImpl(Collection<ModuleDef> moduleDefs, ClassFactory classFactory,
+            LoggerSource loggerSource)
     {
         this.loggerSource = loggerSource;
 
@@ -116,12 +122,10 @@
 
         perthreadManager = new PerthreadManagerImpl(logger);
 
-
         logger = loggerForBuiltinService(REGISTRY_SHUTDOWN_HUB_SERVICE_ID);
 
         registryShutdownHub = new RegistryShutdownHubImpl(logger);
 
-
         lifecycles.put("singleton", new SingletonServiceLifecycle());
 
         registryShutdownHub.addRegistryShutdownListener(new RegistryShutdownListener()
@@ -165,7 +169,8 @@
             moduleToServiceDefs.put(module, moduleServiceDefs);
         }
 
-        addBuiltin(SERVICE_ACTIVITY_SCOREBOARD_SERVICE_ID, ServiceActivityScoreboard.class, scoreboardAndTracker);
+        addBuiltin(SERVICE_ACTIVITY_SCOREBOARD_SERVICE_ID, ServiceActivityScoreboard.class,
+                scoreboardAndTracker);
         addBuiltin(LOGGER_SOURCE_SERVICE_ID, LoggerSource.class, this.loggerSource);
         addBuiltin(CLASS_FACTORY_SERVICE_ID, ClassFactory.class, this.classFactory);
         addBuiltin(PERTHREAD_MANAGER_SERVICE_ID, PerthreadManager.class, perthreadManager);
@@ -194,18 +199,17 @@
         {
             String serviceId = cd.getServiceId();
 
-            if (!serviceIdToModule.containsKey(serviceId))
-            {
-                throw new IllegalArgumentException(
-                        String.format("Contribution %s is for service '%s', which does not exist.",
-                                      cd, serviceId));
-            }
+            if (!serviceIdToModule.containsKey(serviceId)) { throw new IllegalArgumentException(
+                    String.format("Contribution %s is for service '%s', which does not exist.", cd,
+                            serviceId)); }
         }
     }
 
     /**
-     * It's not unreasonable for an eagerly-loaded service to decide to start a thread, at which point we raise issues
-     * about improper publishing of the Registry instance from the RegistryImpl constructor. Moving eager loading of
+     * It's not unreasonable for an eagerly-loaded service to decide to start a thread, at which
+     * point we raise issues
+     * about improper publishing of the Registry instance from the RegistryImpl constructor. Moving
+     * eager loading of
      * services out to its own method should ensure thread safety.
      */
     public void performRegistryStartup()
@@ -310,7 +314,8 @@
         lock.check();
 
         T result = checkForBuiltinService(serviceId, serviceInterface);
-        if (result != null) return result;
+        if (result != null)
+            return result;
 
         // Checking serviceId and serviceInterface is overkill; they have been checked and rechecked
         // all the way to here.
@@ -324,7 +329,8 @@
     {
         Object service = builtinServices.get(serviceId);
 
-        if (service == null) return null;
+        if (service == null)
+            return null;
 
         try
         {
@@ -348,8 +354,9 @@
     {
         Module module = serviceIdToModule.get(serviceId);
 
-        if (module == null) throw new RuntimeException(IOCMessages.noSuchService(serviceId, serviceIdToModule
-                .keySet()));
+        if (module == null)
+            throw new RuntimeException(IOCMessages.noSuchService(serviceId, serviceIdToModule
+                    .keySet()));
 
         return module;
     }
@@ -375,7 +382,8 @@
         Logger logger = getServiceLogger(serviceId);
 
         Orderer<T> orderer = new Orderer<T>(logger);
-        Map<String, OrderedConfigurationOverride<T>> overrides = CollectionFactory.newCaseInsensitiveMap();
+        Map<String, OrderedConfigurationOverride<T>> overrides = CollectionFactory
+                .newCaseInsensitiveMap();
 
         for (Module m : moduleToServiceDefs.keySet())
             addToOrderedConfiguration(orderer, overrides, objectType, serviceDef, m);
@@ -387,7 +395,8 @@
         {
             ObjectProvider contribution = new ObjectProvider()
             {
-                public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator)
+                public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider,
+                        ObjectLocator locator)
                 {
                     return findServiceByMarkerAndType(objectType, annotationProvider, null);
                 }
@@ -402,7 +411,8 @@
         return orderer.getOrdered();
     }
 
-    public <K, V> Map<K, V> getMappedConfiguration(ServiceDef serviceDef, Class<K> keyType, Class<V> objectType)
+    public <K, V> Map<K, V> getMappedConfiguration(ServiceDef serviceDef, Class<K> keyType,
+            Class<V> objectType)
     {
         lock.check();
 
@@ -413,7 +423,8 @@
         Map<K, MappedConfigurationOverride<K, V>> overrides = newConfigurationMap(keyType);
 
         for (Module m : moduleToServiceDefs.keySet())
-            addToMappedConfiguration(result, overrides, keyToContribution, keyType, objectType, serviceDef, m);
+            addToMappedConfiguration(result, overrides, keyToContribution, keyType, objectType,
+                    serviceDef, m);
 
         for (MappedConfigurationOverride<K, V> override : overrides.values())
         {
@@ -437,26 +448,28 @@
     }
 
     private <K, V> void addToMappedConfiguration(Map<K, V> map,
-                                                 Map<K, MappedConfigurationOverride<K, V>> overrides,
-                                                 Map<K, ContributionDef> keyToContribution, Class<K> keyClass,
-                                                 Class<V> valueType, ServiceDef serviceDef, final Module module)
+            Map<K, MappedConfigurationOverride<K, V>> overrides,
+            Map<K, ContributionDef> keyToContribution, Class<K> keyClass, Class<V> valueType,
+            ServiceDef serviceDef, final Module module)
     {
         String serviceId = serviceDef.getServiceId();
         Set<ContributionDef> contributions = module.getContributorDefsForService(serviceId);
 
-        if (contributions.isEmpty()) return;
+        if (contributions.isEmpty())
+            return;
 
         Logger logger = getServiceLogger(serviceId);
 
         boolean debug = logger.isDebugEnabled();
 
-        final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
+        final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef,
+                classFactory, logger);
 
         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>(
+                    map, overrides, serviceId, def, keyClass, valueType, keyToContribution,
+                    resources);
 
             String description = IOCMessages.invokingMethod(def);
 
@@ -473,25 +486,26 @@
         }
     }
 
-    private <T> void addToUnorderedConfiguration(Collection<T> collection,
-                                                 Class<T> valueType,
-                                                 ServiceDef serviceDef, final Module module)
+    private <T> void addToUnorderedConfiguration(Collection<T> collection, Class<T> valueType,
+            ServiceDef serviceDef, final Module module)
     {
         String serviceId = serviceDef.getServiceId();
         Set<ContributionDef> contributions = module.getContributorDefsForService(serviceId);
 
-        if (contributions.isEmpty()) return;
+        if (contributions.isEmpty())
+            return;
 
         Logger logger = getServiceLogger(serviceId);
 
         boolean debug = logger.isDebugEnabled();
 
-        final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
+        final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef,
+                classFactory, logger);
 
         for (final ContributionDef def : contributions)
         {
-            final Configuration<T> validating =
-                    new ValidatingConfigurationWrapper<T>(collection, serviceId, valueType, resources);
+            final Configuration<T> validating = new ValidatingConfigurationWrapper<T>(collection,
+                    serviceId, valueType, resources);
 
             String description = IOCMessages.invokingMethod(def);
 
@@ -509,25 +523,25 @@
     }
 
     private <T> void addToOrderedConfiguration(Orderer<T> orderer,
-                                               Map<String, OrderedConfigurationOverride<T>> overrides,
-                                               Class<T> valueType,
-                                               ServiceDef serviceDef, final Module module)
+            Map<String, OrderedConfigurationOverride<T>> overrides, Class<T> valueType,
+            ServiceDef serviceDef, final Module module)
     {
         String serviceId = serviceDef.getServiceId();
         Set<ContributionDef> contributions = module.getContributorDefsForService(serviceId);
 
-        if (contributions.isEmpty()) return;
+        if (contributions.isEmpty())
+            return;
 
         Logger logger = getServiceLogger(serviceId);
         boolean debug = logger.isDebugEnabled();
 
-        final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
+        final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef,
+                classFactory, logger);
 
         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>(
+                    orderer, overrides, def, serviceId, valueType, resources);
 
             String description = IOCMessages.invokingMethod(def);
 
@@ -551,7 +565,8 @@
 
         List<String> serviceIds = findServiceIdsForInterface(serviceInterface);
 
-        if (serviceIds == null) serviceIds = Collections.emptyList();
+        if (serviceIds == null)
+            serviceIds = Collections.emptyList();
 
         switch (serviceIds.size())
         {
@@ -569,7 +584,8 @@
 
                 Collections.sort(serviceIds);
 
-                throw new RuntimeException(IOCMessages.manyServiceMatches(serviceInterface, serviceIds));
+                throw new RuntimeException(IOCMessages.manyServiceMatches(serviceInterface,
+                        serviceIds));
         }
     }
 
@@ -582,7 +598,8 @@
 
         for (Map.Entry<String, Object> entry : builtinServices.entrySet())
         {
-            if (serviceInterface.isInstance(entry.getValue())) result.add(entry.getKey());
+            if (serviceInterface.isInstance(entry.getValue()))
+                result.add(entry.getKey());
         }
 
         Collections.sort(result);
@@ -598,7 +615,8 @@
 
         if (result == null)
         {
-            ServiceLifecycleSource source = getService("ServiceLifecycleSource", ServiceLifecycleSource.class);
+            ServiceLifecycleSource source = getService("ServiceLifecycleSource",
+                    ServiceLifecycleSource.class);
 
             result = source.get(scope);
         }
@@ -623,15 +641,19 @@
         {
             Set<DecoratorDef> decoratorDefs = module.findMatchingDecoratorDefs(serviceDef);
 
-            if (decoratorDefs.isEmpty()) continue;
+            if (decoratorDefs.isEmpty())
+                continue;
 
-            ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
+            ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef,
+                    classFactory, logger);
 
             for (DecoratorDef decoratorDef : decoratorDefs)
             {
                 ServiceDecorator decorator = decoratorDef.createDecorator(module, resources);
 
-                orderer.add(decoratorDef.getDecoratorId(), decorator, decoratorDef.getConstraints());
+                orderer
+                        .add(decoratorDef.getDecoratorId(), decorator, decoratorDef
+                                .getConstraints());
             }
         }
 
@@ -652,9 +674,11 @@
         {
             Set<AdvisorDef> advisorDefs = module.findMatchingServiceAdvisors(serviceDef);
 
-            if (advisorDefs.isEmpty()) continue;
+            if (advisorDefs.isEmpty())
+                continue;
 
-            ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
+            ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef,
+                    classFactory, logger);
 
             for (AdvisorDef advisorDef : advisorDefs)
             {
@@ -674,12 +698,13 @@
         return classFactory.newClass(serviceInterface);
     }
 
-    public <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator,
-                           Module localModule)
+    public <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider,
+            ObjectLocator locator, Module localModule)
     {
         lock.check();
 
-        AnnotationProvider effectiveProvider = annotationProvider != null ? annotationProvider : new NullAnnotationProvider();
+        AnnotationProvider effectiveProvider = annotationProvider != null ? annotationProvider
+                : new NullAnnotationProvider();
 
         // We do a check here for known marker/type combinations, so that you can use a marker
         // annotation
@@ -688,15 +713,17 @@
 
         T result = findServiceByMarkerAndType(objectType, annotationProvider, localModule);
 
-        if (result != null) return result;
+        if (result != null)
+            return result;
 
-        MasterObjectProvider masterProvider = getService(IOCConstants.MASTER_OBJECT_PROVIDER_SERVICE_ID,
-                                                         MasterObjectProvider.class);
+        MasterObjectProvider masterProvider = getService(
+                IOCConstants.MASTER_OBJECT_PROVIDER_SERVICE_ID, MasterObjectProvider.class);
 
         return masterProvider.provide(objectType, effectiveProvider, locator, true);
     }
 
-    private Collection<ServiceDef2> filterByType(Class<?> objectType, Collection<ServiceDef2> serviceDefs)
+    private Collection<ServiceDef2> filterByType(Class<?> objectType,
+            Collection<ServiceDef2> serviceDefs)
     {
         Collection<ServiceDef2> result = CollectionFactory.newSet();
 
@@ -712,37 +739,40 @@
     }
 
     @SuppressWarnings("unchecked")
-    private <T> T findServiceByMarkerAndType(Class<T> objectType, AnnotationProvider provider, Module localModule)
+    private <T> T findServiceByMarkerAndType(Class<T> objectType, AnnotationProvider provider,
+            Module localModule)
     {
-        if (provider == null) return null;
+        if (provider == null)
+            return null;
 
         boolean localOnly = localModule != null && provider.getAnnotation(Local.class) != null;
 
-
         Set<ServiceDef2> matches = CollectionFactory.newSet();
 
-        matches.addAll(filterByType(objectType, localOnly
-                                                ? moduleToServiceDefs.get(localModule)
-                                                : allServiceDefs
-        ));
+        matches.addAll(filterByType(objectType, localOnly ? moduleToServiceDefs.get(localModule)
+                : allServiceDefs));
 
         List<Class> markers = CollectionFactory.newList();
 
-        if (localOnly) markers.add(Local.class);
+        if (localOnly)
+            markers.add(Local.class);
 
         for (Class marker : markerToServiceDef.keySet())
         {
-            if (provider.getAnnotation(marker) == null) continue;
+            if (provider.getAnnotation(marker) == null)
+                continue;
 
             markers.add(marker);
 
             matches = intersection(matches, markerToServiceDef.get(marker));
         }
 
-        // If didn't see @Local or any recognized marker annotation, then don't try to filter that way.
+        // If didn't see @Local or any recognized marker annotation, then don't try to filter that
+        // way.
         // Continue on, eventually to the MasterObjectProvider service.
 
-        if (markers.isEmpty()) return null;
+        if (markers.isEmpty())
+            return null;
 
         switch (matches.size())
         {
@@ -766,38 +796,42 @@
                 throw new RuntimeException(IOCMessages.noServicesMatchMarker(objectType, markers));
 
             default:
-                throw new RuntimeException(IOCMessages.manyServicesMatchMarker(objectType, markers, matches));
+                throw new RuntimeException(IOCMessages.manyServicesMatchMarker(objectType, markers,
+                        matches));
         }
     }
 
     /**
-     * Filters the set into a new set, containing only elements shared between the set and the filter collection.
-     *
-     * @param set    to be filtered
-     * @param filter values to keep from the set
+     * Filters the set into a new set, containing only elements shared between the set and the
+     * filter collection.
+     * 
+     * @param set
+     *            to be filtered
+     * @param filter
+     *            values to keep from the set
      * @return a new set containing only the shared values
      */
     private static <T> Set<T> intersection(Set<T> set, Collection<T> filter)
     {
-        if (set.isEmpty()) return Collections.emptySet();
+        if (set.isEmpty())
+            return Collections.emptySet();
 
         Set<T> result = CollectionFactory.newSet();
 
         for (T elem : filter)
         {
-            if (set.contains(elem)) result.add(elem);
+            if (set.contains(elem))
+                result.add(elem);
         }
 
         return result;
     }
 
-
     public <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider)
     {
         return getObject(objectType, annotationProvider, this, null);
     }
 
-
     public void addRegistryShutdownListener(RegistryShutdownListener listener)
     {
         lock.check();
@@ -811,7 +845,8 @@
 
         // Again, a bit of work to avoid instantiating the SymbolSource until absolutely necessary.
 
-        if (!InternalUtils.containsSymbols(input)) return input;
+        if (!InternalUtils.containsSymbols(input))
+            return input;
 
         return getSymbolSource().expandSymbols(input);
     }
@@ -821,18 +856,31 @@
      */
     private synchronized SymbolSource getSymbolSource()
     {
-        if (symbolSource == null) symbolSource = getService(SYMBOL_SOURCE_SERVICE_ID, SymbolSource.class);
+        if (symbolSource == null)
+            symbolSource = getService(SYMBOL_SOURCE_SERVICE_ID, SymbolSource.class);
 
         return symbolSource;
     }
 
+    public <T> T autobuild(String description, final Class<T> clazz)
+    {
+        return invoke(description, new Invokable<T>()
+        {
+            public T invoke()
+            {
+                return autobuild(clazz);
+            }
+        });
+    }
+
     public <T> T autobuild(final Class<T> clazz)
     {
         Defense.notNull(clazz, "clazz");
 
         final Constructor constructor = InternalUtils.findAutobuildConstructor(clazz);
 
-        if (constructor == null) throw new RuntimeException(IOCMessages.noAutobuildConstructor(clazz));
+        if (constructor == null)
+            throw new RuntimeException(IOCMessages.noAutobuildConstructor(clazz));
 
         final ObjectLocator locator = this;
         final OperationTracker tracker = this;
@@ -842,23 +890,18 @@
 
         final InjectionResources resources = new MapInjectionResources(resourcesMap);
 
-
         final Invokable<T> operation = new Invokable<T>()
         {
             public T invoke()
             {
                 Throwable failure;
-                // An empty map, because when performing autobuilding outside the context of building a
-                // service, we don't have defaults for Log, service id, etc.
 
                 try
                 {
                     InternalUtils.validateConstructorForAutobuild(constructor);
 
-                    Object[] parameters = InternalUtils.calculateParametersForConstructor(constructor,
-                                                                                          locator,
-                                                                                          resources,
-                                                                                          tracker);
+                    Object[] parameters = InternalUtils.calculateParametersForConstructor(
+                            constructor, locator, resources, tracker);
 
                     Object result = constructor.newInstance(parameters);
 
@@ -877,13 +920,12 @@
 
                 String description = classFactory.getConstructorLocation(constructor).toString();
 
-                throw new RuntimeException(IOCMessages.autobuildConstructorError(description, failure),
-                                           failure);
+                throw new RuntimeException(IOCMessages.autobuildConstructorError(description,
+                        failure), failure);
             }
         };
 
-        T result = invoke("Autobuilding instance of class " + clazz.getName(),
-                          operation);
+        T result = invoke("Autobuilding instance of class " + clazz.getName(), operation);
 
         InternalUtils.invokePostInjectionMethods(result, locator, resources, this);
 
@@ -912,7 +954,8 @@
 
             public synchronized Object createObject()
             {
-                if (delegate == null) delegate = autobuildCreator.createObject();
+                if (delegate == null)
+                    delegate = autobuildCreator.createObject();
 
                 return delegate;
             }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryWrapper.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryWrapper.java?rev=895274&r1=895273&r2=895274&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryWrapper.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/RegistryWrapper.java Sat Jan  2 19:52:09 2010
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 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.
@@ -19,8 +19,8 @@
 import org.apache.tapestry5.ioc.Registry;
 
 /**
- * A wrapper around {@link InternalRegistry} that exists to expand symbols in a service id before invoking {@link
- * ObjectLocator#getService(Class)}.
+ * A wrapper around {@link InternalRegistry} that exists to expand symbols in a service id before
+ * invoking {@link ObjectLocator#getService(Class)}.
  */
 public class RegistryWrapper implements Registry
 {
@@ -63,6 +63,11 @@
         return registry.autobuild(clazz);
     }
 
+    public <T> T autobuild(String description, Class<T> clazz)
+    {
+        return registry.autobuild(description, clazz);
+    }
+
     public void performRegistryStartup()
     {
         registry.performRegistryStartup();

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/AutobuildObjectProvider.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/AutobuildObjectProvider.java?rev=895274&r1=895273&r2=895274&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/AutobuildObjectProvider.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/AutobuildObjectProvider.java Sat Jan  2 19:52:09 2010
@@ -1,4 +1,4 @@
-//  Copyright 2008 The Apache Software Foundation
+//  Copyright 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.
@@ -20,17 +20,19 @@
 import org.apache.tapestry5.ioc.annotations.Autobuild;
 
 /**
- * Checks for the {@link org.apache.tapestry5.ioc.annotations.Autobuild} annotation and, if so invokes {@link
- * org.apache.tapestry5.ioc.ObjectLocator#autobuild(Class)} on it.
+ * Checks for the {@link org.apache.tapestry5.ioc.annotations.Autobuild} annotation and, if so
+ * invokes {@link org.apache.tapestry5.ioc.ObjectLocator#autobuild(Class)} on it.
  */
 public class AutobuildObjectProvider implements ObjectProvider
 {
-    public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator)
+    public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider,
+            ObjectLocator locator)
     {
         Autobuild annotation = annotationProvider.getAnnotation(Autobuild.class);
 
         if (annotation != null)
-            return locator.autobuild(objectType);
+            return locator
+                    .autobuild("Autobuilding instance of " + objectType.getName(), objectType);
 
         return null;
     }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/test/IOCTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/test/IOCTestCase.java?rev=895274&r1=895273&r2=895274&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/test/IOCTestCase.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/test/IOCTestCase.java Sat Jan  2 19:52:09 2010
@@ -1,4 +1,4 @@
-// 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.