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 2008/10/29 23:15:02 UTC

svn commit: r709030 - in /tapestry/tapestry5/trunk: tapestry-core/src/main/java/org/apache/tapestry5/internal/renderers/ tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ tapestry-core/src/main/java/org/apache/tapestry5/internal/test/...

Author: hlship
Date: Wed Oct 29 15:15:01 2008
New Revision: 709030

URL: http://svn.apache.org/viewvc?rev=709030&view=rev
Log:
TAP5-272: File uploads that exceed the upload limit throw an uncatchable exception; Tapestry should notify the page about the exception

Added:
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ScopeConstants.java
    tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/internal/services/UploadExceptionFilter.java
    tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadEvents.java
    tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/base/
    tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/base/UploadBasePage.java
    tapestry/tapestry5/trunk/tapestry-upload/src/test/resources/
    tapestry/tapestry5/trunk/tapestry-upload/src/test/resources/log4j.properties
Removed:
    tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/fileupload/
    tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/multipart/
    tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/apache/tapestry5/upload/services/
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/renderers/LocationRenderer.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClientPersistentFieldStorageImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/EnvironmentImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalRequestGlobalsImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderQueueImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RequestGlobalsImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/TemplateParserImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/test/TestableMarkupWriterFactoryImpl.java
    tapestry/tapestry5/trunk/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/HibernateModule.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/IOCConstants.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ServiceLifecycle.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/Scope.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImpl.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/ServiceBinderImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceDefImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/SingletonServiceLifecycle.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ExceptionTrackerImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PerThreadServiceLifecycle.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ThreadLocaleImpl.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PerThreadModule.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java
    tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java
    tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/internal/services/MultipartDecoderImpl.java
    tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/MultipartDecoder.java
    tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadModule.java
    tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadSymbols.java
    tapestry/tapestry5/trunk/tapestry-upload/src/site/apt/index.apt
    tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/apache/tapestry5/upload/internal/services/MultipartDecoderImplTest.java
    tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/pages/Ajaxified.java
    tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/pages/Start.java
    tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/services/AppModule.java
    tapestry/tapestry5/trunk/tapestry-upload/src/test/webapp/Ajaxified.tml
    tapestry/tapestry5/trunk/tapestry-upload/src/test/webapp/Start.tml
    tapestry/tapestry5/trunk/tapestry-upload/tapestry-upload.iml

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/renderers/LocationRenderer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/renderers/LocationRenderer.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/renderers/LocationRenderer.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/renderers/LocationRenderer.java Wed Oct 29 15:15:01 2008
@@ -16,9 +16,9 @@
 
 import org.apache.tapestry5.MarkupWriter;
 import org.apache.tapestry5.dom.Element;
-import static org.apache.tapestry5.ioc.IOCConstants.PERTHREAD_SCOPE;
 import org.apache.tapestry5.ioc.Location;
 import org.apache.tapestry5.ioc.Resource;
+import org.apache.tapestry5.ioc.ScopeConstants;
 import org.apache.tapestry5.ioc.annotations.Scope;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
@@ -32,7 +32,7 @@
  * snippet of the source file) once per render. This requires the use of the "perthread" scope (since the service
  * tracks, internally, which locations have already been rendered, to avoid repetition).
  */
-@Scope(PERTHREAD_SCOPE)
+@Scope(ScopeConstants.PERTHREAD)
 public class LocationRenderer implements ObjectRenderer<Location>
 {
     private static final int RANGE = 5;
@@ -118,5 +118,4 @@
 
         writer.end(); // div
     }
-
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClientPersistentFieldStorageImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClientPersistentFieldStorageImpl.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClientPersistentFieldStorageImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClientPersistentFieldStorageImpl.java Wed Oct 29 15:15:01 2008
@@ -17,7 +17,7 @@
 import org.apache.tapestry5.Link;
 import org.apache.tapestry5.internal.util.Base64ObjectInputStream;
 import org.apache.tapestry5.internal.util.Base64ObjectOutputStream;
-import static org.apache.tapestry5.ioc.IOCConstants.PERTHREAD_SCOPE;
+import org.apache.tapestry5.ioc.ScopeConstants;
 import org.apache.tapestry5.ioc.annotations.Scope;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newMap;
@@ -36,7 +36,7 @@
  * ensure that we don't uncessarily convert between objects and Base64 (the encoding used to record the value on the
  * client).
  */
-@Scope(PERTHREAD_SCOPE)
+@Scope(ScopeConstants.PERTHREAD)
 public class ClientPersistentFieldStorageImpl implements ClientPersistentFieldStorage
 {
     static final String PARAMETER_NAME = "t:state:client";
@@ -273,7 +273,6 @@
                 os.writeObject(e.getKey());
                 os.writeObject(e.getValue());
             }
-
         }
         catch (Exception ex)
         {

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/EnvironmentImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/EnvironmentImpl.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/EnvironmentImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/EnvironmentImpl.java Wed Oct 29 15:15:01 2008
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2008 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,7 +14,7 @@
 
 package org.apache.tapestry5.internal.services;
 
-import static org.apache.tapestry5.ioc.IOCConstants.PERTHREAD_SCOPE;
+import org.apache.tapestry5.ioc.ScopeConstants;
 import org.apache.tapestry5.ioc.annotations.Scope;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newLinkedList;
@@ -27,7 +27,7 @@
 /**
  * A non-threadsafe implementation (expects to use the "perthread" service lifecyle).
  */
-@Scope(PERTHREAD_SCOPE)
+@Scope(ScopeConstants.PERTHREAD)
 public class EnvironmentImpl implements Environment
 {
     // My generics mojo breaks down when we talk about the key and the value being related

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=709030&r1=709029&r2=709030&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 Wed Oct 29 15:15:01 2008
@@ -17,8 +17,8 @@
 import org.apache.tapestry5.SymbolConstants;
 import org.apache.tapestry5.internal.structure.PageResourcesSource;
 import org.apache.tapestry5.internal.structure.PageResourcesSourceImpl;
-import static org.apache.tapestry5.ioc.IOCConstants.PERTHREAD_SCOPE;
 import org.apache.tapestry5.ioc.ObjectLocator;
+import org.apache.tapestry5.ioc.ScopeConstants;
 import org.apache.tapestry5.ioc.ServiceBinder;
 import org.apache.tapestry5.ioc.ServiceResources;
 import org.apache.tapestry5.ioc.annotations.Inject;
@@ -103,7 +103,7 @@
     }
 
 
-    @Scope(PERTHREAD_SCOPE)
+    @Scope(ScopeConstants.PERTHREAD)
     public static RequestPageCache buildRequestPageCache(ObjectLocator locator, PerthreadManager perthreadManager)
     {
         RequestPageCacheImpl service = locator.autobuild(RequestPageCacheImpl.class);

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalRequestGlobalsImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalRequestGlobalsImpl.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalRequestGlobalsImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/InternalRequestGlobalsImpl.java Wed Oct 29 15:15:01 2008
@@ -14,11 +14,11 @@
 
 package org.apache.tapestry5.internal.services;
 
-import static org.apache.tapestry5.ioc.IOCConstants.PERTHREAD_SCOPE;
+import org.apache.tapestry5.ioc.ScopeConstants;
 import org.apache.tapestry5.ioc.annotations.Scope;
 
 
-@Scope(PERTHREAD_SCOPE)
+@Scope(ScopeConstants.PERTHREAD)
 public class InternalRequestGlobalsImpl implements InternalRequestGlobals
 {
     private Throwable classLoaderException;

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderQueueImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderQueueImpl.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderQueueImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderQueueImpl.java Wed Oct 29 15:15:01 2008
@@ -17,8 +17,8 @@
 import org.apache.tapestry5.MarkupWriter;
 import org.apache.tapestry5.dom.Element;
 import org.apache.tapestry5.internal.structure.Page;
-import static org.apache.tapestry5.ioc.IOCConstants.PERTHREAD_SCOPE;
 import org.apache.tapestry5.ioc.LoggerSource;
+import org.apache.tapestry5.ioc.ScopeConstants;
 import org.apache.tapestry5.ioc.annotations.Scope;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.internal.util.Defense;
@@ -34,7 +34,7 @@
  * request/thread scoped.  There's a filter pipeline around the rendering, and that gets to be stateless because this
  * service, at the end of the pipeline, is stateful.
  */
-@Scope(PERTHREAD_SCOPE)
+@Scope(ScopeConstants.PERTHREAD)
 public class PageRenderQueueImpl implements PageRenderQueue
 {
     private final LoggerSource loggerSource;

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RequestGlobalsImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RequestGlobalsImpl.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RequestGlobalsImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RequestGlobalsImpl.java Wed Oct 29 15:15:01 2008
@@ -14,7 +14,7 @@
 
 package org.apache.tapestry5.internal.services;
 
-import static org.apache.tapestry5.ioc.IOCConstants.PERTHREAD_SCOPE;
+import org.apache.tapestry5.ioc.ScopeConstants;
 import org.apache.tapestry5.ioc.annotations.Scope;
 import org.apache.tapestry5.services.Request;
 import org.apache.tapestry5.services.RequestGlobals;
@@ -26,7 +26,7 @@
 /**
  * Dumb data holder for per-request data.
  */
-@Scope(PERTHREAD_SCOPE)
+@Scope(ScopeConstants.PERTHREAD)
 public class RequestGlobalsImpl implements RequestGlobals
 {
     private HttpServletRequest servletRequest;
@@ -68,5 +68,4 @@
     {
         return response;
     }
-
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/TemplateParserImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/TemplateParserImpl.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/TemplateParserImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/TemplateParserImpl.java Wed Oct 29 15:15:01 2008
@@ -16,9 +16,9 @@
 
 import org.apache.tapestry5.SymbolConstants;
 import org.apache.tapestry5.internal.parser.*;
-import static org.apache.tapestry5.ioc.IOCConstants.PERTHREAD_SCOPE;
 import org.apache.tapestry5.ioc.Location;
 import org.apache.tapestry5.ioc.Resource;
+import org.apache.tapestry5.ioc.ScopeConstants;
 import org.apache.tapestry5.ioc.annotations.Scope;
 import org.apache.tapestry5.ioc.annotations.Symbol;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
@@ -43,7 +43,7 @@
 /**
  * Non-threadsafe implementation; the IOC service uses the perthread lifecycle.
  */
-@Scope(PERTHREAD_SCOPE)
+@Scope(ScopeConstants.PERTHREAD)
 public class TemplateParserImpl implements TemplateParser, LexicalHandler, ContentHandler, EntityResolver
 {
     private static final String MIXINS_ATTRIBUTE_NAME = "mixins";
@@ -477,8 +477,6 @@
         compressWhitespaceStack.push(compressWhitespace);
 
         endTagHandlerStack.push(endOfElementHandler);
-
-
     }
 
     private String findSingleParameter(String elementName, String attributeName, Attributes attributes)
@@ -803,5 +801,4 @@
 
         return null;
     }
-
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/test/TestableMarkupWriterFactoryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/test/TestableMarkupWriterFactoryImpl.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/test/TestableMarkupWriterFactoryImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/test/TestableMarkupWriterFactoryImpl.java Wed Oct 29 15:15:01 2008
@@ -16,12 +16,12 @@
 
 import org.apache.tapestry5.ContentType;
 import org.apache.tapestry5.MarkupWriter;
-import static org.apache.tapestry5.ioc.IOCConstants.PERTHREAD_SCOPE;
+import org.apache.tapestry5.ioc.ScopeConstants;
 import org.apache.tapestry5.ioc.annotations.Scope;
 import org.apache.tapestry5.services.Core;
 import org.apache.tapestry5.services.MarkupWriterFactory;
 
-@Scope(PERTHREAD_SCOPE)
+@Scope(ScopeConstants.PERTHREAD)
 public class TestableMarkupWriterFactoryImpl implements TestableMarkupWriterFactory
 {
     private final MarkupWriterFactory delegate;

Modified: tapestry/tapestry5/trunk/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/HibernateModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/HibernateModule.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/HibernateModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/HibernateModule.java Wed Oct 29 15:15:01 2008
@@ -18,7 +18,6 @@
 import org.apache.tapestry5.internal.InternalConstants;
 import org.apache.tapestry5.internal.hibernate.*;
 import org.apache.tapestry5.ioc.*;
-import static org.apache.tapestry5.ioc.IOCConstants.PERTHREAD_SCOPE;
 import org.apache.tapestry5.ioc.annotations.Inject;
 import org.apache.tapestry5.ioc.annotations.Local;
 import org.apache.tapestry5.ioc.annotations.Scope;
@@ -81,7 +80,7 @@
      * The session manager manages sessions on a per-thread/per-request basis. A {@link org.hibernate.Transaction} is
      * created initially, and is committed at the end of the request.
      */
-    @Scope(PERTHREAD_SCOPE)
+    @Scope(ScopeConstants.PERTHREAD)
     public static HibernateSessionManager buildHibernateSessionManager(HibernateSessionSource sessionSource,
                                                                        PerthreadManager perthreadManager)
     {

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/IOCConstants.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/IOCConstants.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/IOCConstants.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/IOCConstants.java Wed Oct 29 15:15:01 2008
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2008 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.
@@ -16,9 +16,15 @@
 
 public class IOCConstants
 {
-    public static final String DEFAULT_SCOPE = "singleton";
-
-    public static final String PERTHREAD_SCOPE = "perthread";
+    /**
+     * @deprecated Use {@link org.apache.tapestry5.ioc.ScopeConstants#DEFAULT} instead.
+     */
+    public static final String DEFAULT_SCOPE = ScopeConstants.DEFAULT;
+
+    /**
+     * @deprecated Use {@link org.apache.tapestry5.ioc.ScopeConstants#PERTHREAD} instead.
+     */
+    public static final String PERTHREAD_SCOPE = ScopeConstants.PERTHREAD;
 
     public static final String MODULE_BUILDER_MANIFEST_ENTRY_NAME = "Tapestry-Module-Classes";
 

Added: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ScopeConstants.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ScopeConstants.java?rev=709030&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ScopeConstants.java (added)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ScopeConstants.java Wed Oct 29 15:15:01 2008
@@ -0,0 +1,41 @@
+//  Copyright 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.ioc;
+
+
+/**
+ * Defines constants for built-in scopes (used with the {@link org.apache.tapestry5.ioc.annotations.Scope} annotation.
+ */
+public class ScopeConstants
+{
+    /**
+     * The default scope is a singleton within the {@link org.apache.tapestry5.ioc.Registry}. A single instance will be
+     * created on demand.  The lifespan of the instance lasts until the registry is {@linkplain Registry#shutdown() shut
+     * down}. <p/>Some implementations will want to know when the Registry is shutdown; they should register for
+     * notifications via the {@link org.apache.tapestry5.ioc.services.RegistryShutdownHub} service.
+     */
+    public static final String DEFAULT = "singleton";
+
+    /**
+     * An alternate scope provided with Tapestry; a per-thread instance is created on demand, behind a shared proxy.
+     * Method invocations on the shared proxy are forwarded to the per-thread instance. Each per-thread instance lasts
+     * until the {@linkplain Registry#cleanupThread() thread is cleaned up} (at the end of a request for a web
+     * application). <p>Some implementations will want to be notified before being discarded and should register with
+     * the {@link org.apache.tapestry5.ioc.services.PerthreadManager} to receive notifications.
+     *
+     * @see org.apache.tapestry5.ioc.internal.services.PerThreadServiceLifecycle
+     */
+    public static final String PERTHREAD = "perthread";
+}

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ServiceLifecycle.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ServiceLifecycle.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ServiceLifecycle.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/ServiceLifecycle.java Wed Oct 29 15:15:01 2008
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2008 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.
@@ -29,4 +29,14 @@
      * @return the service or equivalent service proxy
      */
     Object createService(ServiceResources resources, ObjectCreator creator);
+
+    /**
+     * Returns true if the lifecycle is a singleton (a service that will only be created once).  Return false if the
+     * underlying service instance may be created multiple times (for example, the {@link
+     * org.apache.tapestry5.ioc.ScopeConstants#PERTHREAD} scope}. A future version of Tapestry IoC may optimize for the
+     * later case.
+     *
+     * @return true for singletons, false   for services that can be repeatedly constructed
+     */
+    boolean isSingleton();
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/Scope.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/Scope.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/Scope.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/annotations/Scope.java Wed Oct 29 15:15:01 2008
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2008 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.
@@ -35,9 +35,11 @@
  * <p/>
  * The annotation may also be placed directly on a service implementation class, when using service autobuilding (via
  * the {@link ServiceBinder}.
+ *
+ * @see org.apache.tapestry5.ioc.ScopeConstants
  */
 @Target(
-        { TYPE, METHOD })
+        {TYPE, METHOD})
 @Retention(RUNTIME)
 @Documented
 public @interface Scope

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImpl.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImpl.java Wed Oct 29 15:15:01 2008
@@ -334,7 +334,7 @@
     {
         Scope scope = method.getAnnotation(Scope.class);
 
-        return scope != null ? scope.value() : IOCConstants.DEFAULT_SCOPE;
+        return scope != null ? scope.value() : ScopeConstants.DEFAULT;
     }
 
     public Set<DecoratorDef> getDecoratorDefs()

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=709030&r1=709029&r2=709030&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 Wed Oct 29 15:15:01 2008
@@ -260,7 +260,7 @@
 
             public String getServiceScope()
             {
-                return IOCConstants.DEFAULT_SCOPE;
+                return ScopeConstants.DEFAULT;
             }
 
             public boolean isEagerLoad()

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceBinderImpl.java Wed Oct 29 15:15:01 2008
@@ -159,7 +159,7 @@
         flush();
 
         this.serviceInterface = serviceInterface;
-        this.scope = IOCConstants.DEFAULT_SCOPE;
+        this.scope = ScopeConstants.DEFAULT;
 
         serviceId = serviceInterface.getSimpleName();
 
@@ -205,7 +205,7 @@
 
         Scope scope = serviceImplementation.getAnnotation(Scope.class);
 
-        this.scope = scope != null ? scope.value() : IOCConstants.DEFAULT_SCOPE;
+        this.scope = scope != null ? scope.value() : ScopeConstants.DEFAULT;
 
         Marker marker = serviceImplementation.getAnnotation(Marker.class);
 

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceDefImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceDefImpl.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceDefImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/ServiceDefImpl.java Wed Oct 29 15:15:01 2008
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2008 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,7 +14,6 @@
 
 package org.apache.tapestry5.ioc.internal;
 
-import org.apache.tapestry5.ioc.IOCConstants;
 import org.apache.tapestry5.ioc.ObjectCreator;
 import org.apache.tapestry5.ioc.ServiceBuilderResources;
 import org.apache.tapestry5.ioc.def.ServiceDef;
@@ -40,7 +39,7 @@
      *                         non-proxied services)
      * @param serviceId        unique id for the service
      * @param markers          set of marker annotation classes (will be retained not copied)
-     * @param scope            scope of the service (i.e., {@link IOCConstants#DEFAULT_SCOPE}).
+     * @param scope            scope of the service (i.e., {@link org.apache.tapestry5.ioc.ScopeConstants#DEFAULT}).
      * @param eagerLoad        if true, the service is realized at startup, rather than on-demand
      * @param source           used to create the service implementation when needed
      */
@@ -91,5 +90,4 @@
     {
         return markers;
     }
-
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/SingletonServiceLifecycle.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/SingletonServiceLifecycle.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/SingletonServiceLifecycle.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/SingletonServiceLifecycle.java Wed Oct 29 15:15:01 2008
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2008 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.
@@ -28,4 +28,9 @@
     {
         return creator.createObject();
     }
+
+    public boolean isSingleton()
+    {
+        return true;
+    }
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ExceptionTrackerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ExceptionTrackerImpl.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ExceptionTrackerImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ExceptionTrackerImpl.java Wed Oct 29 15:15:01 2008
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2008 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,14 +14,14 @@
 
 package org.apache.tapestry5.ioc.internal.services;
 
-import static org.apache.tapestry5.ioc.IOCConstants.PERTHREAD_SCOPE;
+import org.apache.tapestry5.ioc.ScopeConstants;
 import org.apache.tapestry5.ioc.annotations.Scope;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.services.ExceptionTracker;
 
 import java.util.Set;
 
-@Scope(PERTHREAD_SCOPE)
+@Scope(ScopeConstants.PERTHREAD)
 public class ExceptionTrackerImpl implements ExceptionTracker
 {
     private final Set<Throwable> exceptions = CollectionFactory.newSet();

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PerThreadServiceLifecycle.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PerThreadServiceLifecycle.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PerThreadServiceLifecycle.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PerThreadServiceLifecycle.java Wed Oct 29 15:15:01 2008
@@ -50,6 +50,14 @@
         this.classFactory = classFactory;
     }
 
+    /**
+     * Returns false; this lifecycle represents a service that will be created many times (by each thread).
+     */
+    public boolean isSingleton()
+    {
+        return false;
+    }
+
     public Object createService(ServiceResources resources, ObjectCreator creator)
     {
         Class proxyClass = createProxyClass(resources);
@@ -83,7 +91,7 @@
         // Constructor takes a ServiceCreator
 
         cf.addConstructor(new Class[]
-                { ObjectCreator.class }, null, "_creator = $1;");
+                {ObjectCreator.class}, null, "_creator = $1;");
 
         String body = format("return (%s) _creator.createObject();", serviceInterface.getName());
 

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ThreadLocaleImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ThreadLocaleImpl.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ThreadLocaleImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/ThreadLocaleImpl.java Wed Oct 29 15:15:01 2008
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2008 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,14 +14,14 @@
 
 package org.apache.tapestry5.ioc.internal.services;
 
-import static org.apache.tapestry5.ioc.IOCConstants.PERTHREAD_SCOPE;
+import org.apache.tapestry5.ioc.ScopeConstants;
 import org.apache.tapestry5.ioc.annotations.Scope;
 import static org.apache.tapestry5.ioc.internal.util.Defense.notNull;
 import org.apache.tapestry5.ioc.services.ThreadLocale;
 
 import java.util.Locale;
 
-@Scope(PERTHREAD_SCOPE)
+@Scope(ScopeConstants.PERTHREAD)
 public class ThreadLocaleImpl implements ThreadLocale
 {
     private Locale locale = Locale.getDefault();

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java Wed Oct 29 15:15:01 2008
@@ -15,7 +15,6 @@
 package org.apache.tapestry5.ioc.services;
 
 import org.apache.tapestry5.ioc.*;
-import static org.apache.tapestry5.ioc.IOCConstants.PERTHREAD_SCOPE;
 import org.apache.tapestry5.ioc.annotations.Marker;
 import org.apache.tapestry5.ioc.internal.services.*;
 import org.apache.tapestry5.ioc.util.TimeInterval;
@@ -79,7 +78,7 @@
     public void contributeServiceLifecycleSource(MappedConfiguration<String, ServiceLifecycle> configuration,
                                                  ObjectLocator locator)
     {
-        configuration.add(PERTHREAD_SCOPE, locator.autobuild(PerThreadServiceLifecycle.class));
+        configuration.add(ScopeConstants.PERTHREAD, locator.autobuild(PerThreadServiceLifecycle.class));
     }
 
     /**

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PerThreadModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PerThreadModule.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PerThreadModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/PerThreadModule.java Wed Oct 29 15:15:01 2008
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007 The Apache Software Foundation
+// Copyright 2006, 2007, 2008 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,12 +14,11 @@
 
 package org.apache.tapestry5.ioc;
 
-import static org.apache.tapestry5.ioc.IOCConstants.PERTHREAD_SCOPE;
 import org.apache.tapestry5.ioc.annotations.Scope;
 
 public class PerThreadModule
 {
-    @Scope(PERTHREAD_SCOPE)
+    @Scope(ScopeConstants.PERTHREAD)
     public StringHolder buildStringHolder()
     {
         return new StringHolderImpl();

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java Wed Oct 29 15:15:01 2008
@@ -79,7 +79,7 @@
         assertEquals(sd.getServiceInterface(), FieService.class);
 
         assertTrue(sd.toString().contains(className + ".buildFred()"));
-        assertEquals(sd.getServiceScope(), IOCConstants.DEFAULT_SCOPE);
+        assertEquals(sd.getServiceScope(), ScopeConstants.DEFAULT);
         assertEquals(sd.isEagerLoad(), false);
         assertTrue(sd.getMarkers().isEmpty());
 
@@ -318,7 +318,7 @@
 
         assertEquals(sd.getServiceInterface(), StringHolder.class);
         assertEquals(sd.getServiceId(), "StringHolder");
-        assertEquals(sd.getServiceScope(), IOCConstants.DEFAULT_SCOPE);
+        assertEquals(sd.getServiceScope(), ScopeConstants.DEFAULT);
         assertFalse(sd.isEagerLoad());
 
         verify();

Modified: tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java (original)
+++ tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java Wed Oct 29 15:15:01 2008
@@ -14,8 +14,8 @@
 
 package org.apache.tapestry5.internal.spring;
 
-import org.apache.tapestry5.ioc.IOCConstants;
 import org.apache.tapestry5.ioc.ObjectCreator;
+import org.apache.tapestry5.ioc.ScopeConstants;
 import org.apache.tapestry5.ioc.ServiceBuilderResources;
 import org.apache.tapestry5.ioc.def.ContributionDef;
 import org.apache.tapestry5.ioc.def.DecoratorDef;
@@ -79,7 +79,7 @@
 
                 public String getServiceScope()
                 {
-                    return IOCConstants.DEFAULT_SCOPE;
+                    return ScopeConstants.DEFAULT;
                 }
 
                 public boolean isEagerLoad()
@@ -92,7 +92,6 @@
                 {
                     return Collections.emptySet();
                 }
-
             };
 
             serviceDefs.put(beanName, serviceDef);
@@ -125,7 +124,7 @@
 
             public String getServiceScope()
             {
-                return IOCConstants.DEFAULT_SCOPE;
+                return ScopeConstants.DEFAULT;
             }
 
             public boolean isEagerLoad()
@@ -138,7 +137,6 @@
             {
                 return Collections.emptySet();
             }
-
         };
 
         serviceDefs.put(CONTEXT_SERVICE_ID, serviceDef);
@@ -179,5 +177,4 @@
     {
         return serviceDefs.keySet();
     }
-
 }

Modified: tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/internal/services/MultipartDecoderImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/internal/services/MultipartDecoderImpl.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/internal/services/MultipartDecoderImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/internal/services/MultipartDecoderImpl.java Wed Oct 29 15:15:01 2008
@@ -31,6 +31,7 @@
 import javax.servlet.http.HttpServletRequest;
 import java.io.File;
 import java.io.UnsupportedEncodingException;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -51,6 +52,8 @@
 
     private final String requestEncoding;
 
+    private FileUploadException uploadException;
+
     public MultipartDecoderImpl(
 
             @Inject @Symbol(UploadSymbols.REPOSITORY_LOCATION)
@@ -111,15 +114,18 @@
         {
             return createFileUpload().parseRequest(request);
         }
-        catch (FileUploadException e)
+        catch (FileUploadException ex)
         {
-            throw new RuntimeException(UploadMessages.unableToDecode(), e);
+            uploadException = ex;
+
+            return Collections.emptyList();
         }
     }
 
     protected ServletFileUpload createFileUpload()
     {
         FileItemFactory factory = new DiskFileItemFactory(repositoryThreshold, new File(repositoryLocation));
+
         ServletFileUpload upload = new ServletFileUpload(factory);
 
         // set maximum file upload size
@@ -131,7 +137,7 @@
 
     protected HttpServletRequest processFileItems(HttpServletRequest request, List<FileItem> fileItems)
     {
-        if (fileItems == null || fileItems.isEmpty())
+        if (uploadException == null && fileItems.isEmpty())
         {
             return request;
         }
@@ -170,4 +176,9 @@
     {
         uploads.put(name, file);
     }
+
+    public FileUploadException getUploadException()
+    {
+        return uploadException;
+    }
 }

Added: tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/internal/services/UploadExceptionFilter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/internal/services/UploadExceptionFilter.java?rev=709030&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/internal/services/UploadExceptionFilter.java (added)
+++ tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/internal/services/UploadExceptionFilter.java Wed Oct 29 15:15:01 2008
@@ -0,0 +1,73 @@
+//  Copyright 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.upload.internal.services;
+
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.tapestry5.internal.services.ComponentResultProcessorWrapper;
+import org.apache.tapestry5.runtime.Component;
+import org.apache.tapestry5.services.*;
+import org.apache.tapestry5.upload.services.MultipartDecoder;
+import org.apache.tapestry5.upload.services.UploadEvents;
+
+import java.io.IOException;
+
+/**
+ * Determines if there was an {@link org.apache.commons.fileupload.FileUploadException} processing the request and, if
+ * so, triggers an exception event on the page. If the page fails to respond to the event, then
+ */
+public class UploadExceptionFilter implements ComponentEventRequestFilter
+{
+    private final MultipartDecoder decoder;
+
+    private final ComponentEventResultProcessor resultProcessor;
+
+    private ComponentSource componentSource;
+
+    public UploadExceptionFilter(MultipartDecoder decoder, @Traditional ComponentEventResultProcessor resultProcessor,
+                                 ComponentSource componentSource)
+    {
+        this.decoder = decoder;
+        this.resultProcessor = resultProcessor;
+        this.componentSource = componentSource;
+    }
+
+    public void handle(ComponentEventRequestParameters parameters, ComponentEventRequestHandler handler)
+            throws IOException
+    {
+        FileUploadException uploadException = decoder.getUploadException();
+
+        if (uploadException != null)
+        {
+            Component page = componentSource.getPage(parameters.getActivePageName());
+
+            ComponentResultProcessorWrapper callback = new ComponentResultProcessorWrapper(resultProcessor);
+
+            page.getComponentResources().triggerEvent(UploadEvents.UPLOAD_EXCEPTION, new Object[] {uploadException},
+                                                      callback);
+
+            // If an event handler exists and returns a value, then the callback will be aborted and a response
+            // (typically a redirect) will already have been sent to the client.
+
+            if (callback.isAborted()) return;
+
+            // If the page does not properly handle the exception, then we throw it now.
+
+            throw new RuntimeException(UploadMessages.unableToDecode(), uploadException);
+        }
+
+
+        handler.handle(parameters);
+    }
+}

Modified: tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/MultipartDecoder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/MultipartDecoder.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/MultipartDecoder.java (original)
+++ tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/MultipartDecoder.java Wed Oct 29 15:15:01 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 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.upload.services;
 
+import org.apache.commons.fileupload.FileUploadException;
+
 import javax.servlet.http.HttpServletRequest;
 
 /**
@@ -37,4 +39,10 @@
      * @return decoded http request
      */
     HttpServletRequest decode(HttpServletRequest request);
+
+    /**
+     * Returns the exception the occured during the file upload, or null if the processing of the multipart upload
+     * stream was succesful.
+     */
+    FileUploadException getUploadException();
 }

Added: tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadEvents.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadEvents.java?rev=709030&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadEvents.java (added)
+++ tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadEvents.java Wed Oct 29 15:15:01 2008
@@ -0,0 +1,27 @@
+//  Copyright 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.upload.services;
+
+/**
+ * Names of events that may be triggered on components due to file uploads.
+ */
+public class UploadEvents
+{
+    /**
+     * Name of event fired on a page when an upload form associated with that page encounters a {@link
+     * org.apache.commons.fileupload.FileUploadException} while processing the multipart form submission.
+     */
+    public static final String UPLOAD_EXCEPTION = "uploadException";
+}                       
\ No newline at end of file

Modified: tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadModule.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadModule.java Wed Oct 29 15:15:01 2008
@@ -21,18 +21,21 @@
 import org.apache.tapestry5.ioc.services.PerthreadManager;
 import org.apache.tapestry5.ioc.services.RegistryShutdownHub;
 import org.apache.tapestry5.ioc.services.RegistryShutdownListener;
+import org.apache.tapestry5.services.ComponentEventRequestFilter;
 import org.apache.tapestry5.services.HttpServletRequestFilter;
 import org.apache.tapestry5.services.LibraryMapping;
 import org.apache.tapestry5.upload.internal.services.MultipartDecoderImpl;
 import org.apache.tapestry5.upload.internal.services.MultipartServletRequestFilter;
+import org.apache.tapestry5.upload.internal.services.UploadExceptionFilter;
 
 import java.util.concurrent.atomic.AtomicBoolean;
 
 public class UploadModule
 {
-    private static final AtomicBoolean needToAddShutdownListener = new AtomicBoolean(true);
     private static final String NO_LIMIT = "-1";
 
+    private static final AtomicBoolean needToAddShutdownListener = new AtomicBoolean(true);
+
     public static void contributeComponentClassResolver(Configuration<LibraryMapping> configuration)
     {
         // Add the component to the "core" library.
@@ -40,7 +43,7 @@
         configuration.add(new LibraryMapping("core", "org.apache.tapestry5.upload"));
     }
 
-    @Scope(IOCConstants.PERTHREAD_SCOPE)
+    @Scope(ScopeConstants.PERTHREAD)
     public static MultipartDecoder buildMultipartDecoder(PerthreadManager perthreadManager,
 
                                                          RegistryShutdownHub shutdownHub,
@@ -76,6 +79,19 @@
         configuration.add("MultipartFilter", new MultipartServletRequestFilter(multipartDecoder), "after:IgnoredPaths");
     }
 
+    /**
+     * Adds UploadException to the pipeline, between Secure and Ajax (both provided by TapestryModule). UploadException
+     * is responsible for triggering the {@linkplain org.apache.tapestry5.upload.services.UploadEvents#UPLOAD_EXCEPTION
+     * upload exception event}.
+     */
+    public static void contributeComponentEventRequestHandler(
+            OrderedConfiguration<ComponentEventRequestFilter> configuration,
+            ObjectLocator locator)
+    {
+        configuration.add("UploadException", locator.autobuild(UploadExceptionFilter.class), "after:Secure",
+                          "before:Ajax");
+    }
+
     public static void contributeFactoryDefaults(MappedConfiguration<String, String> configuration)
     {
         configuration.add(UploadSymbols.REPOSITORY_THRESHOLD, Integer

Modified: tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadSymbols.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadSymbols.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadSymbols.java (original)
+++ tapestry/tapestry5/trunk/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadSymbols.java Wed Oct 29 15:15:01 2008
@@ -1,17 +1,17 @@
-// Copyright 2007 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
+// Copyright 2007, 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package org.apache.tapestry5.upload.services;
 
 /**
@@ -20,27 +20,26 @@
 public final class UploadSymbols
 {
     /**
-     * Location where temporary files will be written. Defaults to java.io.tmpdir property
+     * Location where temporary files will be written. Defaults to java.io.tmpdir property.
      */
     public static final String REPOSITORY_LOCATION = "upload.repository-location";
 
     /**
-     * Threshold (in bytes) that determines when an uploaded file will be written to the repository
+     * Threshold (in bytes) that determines when an uploaded file will be written to the repository.
      */
     public static final String REPOSITORY_THRESHOLD = "upload.repository-threshold";
 
     /**
-     * Maximum size (in bytes) of a single upload request Defaults to -1 ( no limit)
+     * Maximum size (in bytes) of a single upload request Defaults to -1 (no limit).
      */
     public static final String REQUESTSIZE_MAX = "upload.requestsize-max";
 
     /**
-     * Maximum size (in bytes) of a single file within an upload request Defaults to -1 ( no limit)
+     * Maximum size (in bytes) of a single file within an upload request Defaults to -1 (no limit).
      */
     public static final String FILESIZE_MAX = "upload.filesize-max";
 
     private UploadSymbols()
     {
     }
-
 }

Modified: tapestry/tapestry5/trunk/tapestry-upload/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/src/site/apt/index.apt?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/src/site/apt/index.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-upload/src/site/apt/index.apt Wed Oct 29 15:15:01 2008
@@ -35,18 +35,9 @@
 +---+
     public class UploadExample
     {
+        @Property
         private UploadedFile file;
 
-        public UploadedFile getFile()
-        {
-            return file;
-        }
-
-        public void setFile(UploadedFile file)
-        {
-            this.file = file;
-        }
-
         public void onSuccess()
         {
             File copied = new File("/my/file/location/" + file.getFileName());
@@ -57,7 +48,56 @@
 +---+
 
 
+Upload Exceptions
+
+  In some cases, file uploads may fail.  This can be because of a simple communication exception, or more likely,
+  because the configured  maximum upload size was exceeded.
+
+  When a file upload exception occurs, Tapestry will trigger a "uploadException" event on the page to notify it of
+  the error. All other normal processing is skipped (no "activate" event, no form submission, etc.).
+
+  The event handler should return a non-null object, which will be handled as a navigational result.  Example:
+
+----
+
+   @Persist(PersistenceConstants.FLASH)
+    @Property
+    private String message;
+
+
+    Object onUploadException(FileUploadException ex)
+    {
+        message = "Upload exception: " + ex.getMessage();
+
+        return this;
+    }
+----
+
+  Note the importance of <<<return this;>>>.  A void event handler method, or one that returns null, will result
+  in the FileUploadException being reported to the user as an uncaught runtime exception.
+
+Configuration
+
+  Four values may be configured as {{{../tapestry-ioc/symbols.html}symbols}}:
+
+  [upload.repository-location]
+  The directory to which files that are too large to keep in memory will be written to.
+  The default is from the java.io.tmpdir system property.
+
+  [upload.repository-threshold]
+  Upload size, in bytes, at which point the uploaded file is written to disk rather than kept in memory.
+  The default is 10 kilobytes.
+
+  [upload.requestsize-max]
+  Maximim size, in bytes, for the overall request.  If exceeed, a FileUploadException will occur.
+  The default is no maximum.
+
+  [upload.filesize-max]
+  Maximum size, in bytes, for any individual uploaded file.  Again, a FileUploadException will occur
+  if exceeded.              The default is no maximum.
 
+  The class {{{../apidocs/org/apache/tapestry5/upload/services/UploadSymbols.html}UploadSymbols}}
+  defines constants for all four of these.
 
 Potential Issues
 

Modified: tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/apache/tapestry5/upload/internal/services/MultipartDecoderImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/apache/tapestry5/upload/internal/services/MultipartDecoderImplTest.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/apache/tapestry5/upload/internal/services/MultipartDecoderImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/apache/tapestry5/upload/internal/services/MultipartDecoderImplTest.java Wed Oct 29 15:15:01 2008
@@ -51,10 +51,11 @@
     {
         HttpServletRequest request = mockHttpServletRequest();
         MultipartDecoderImpl decoder = new MultipartDecoderImpl("/tmp", 888, -1, -1, CHARSET);
+        List<FileItem> items = Collections.emptyList();
 
         replay();
 
-        HttpServletRequest decodedRequest = decoder.processFileItems(request, null);
+        HttpServletRequest decodedRequest = decoder.processFileItems(request, items);
 
         verify();
 
@@ -205,5 +206,4 @@
 
         return item;
     }
-
 }

Added: tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/base/UploadBasePage.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/base/UploadBasePage.java?rev=709030&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/base/UploadBasePage.java (added)
+++ tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/base/UploadBasePage.java Wed Oct 29 15:15:01 2008
@@ -0,0 +1,37 @@
+//  Copyright 2008 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.example.upload.base;
+
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.upload.services.UploadedFile;
+
+import java.io.File;
+
+public class UploadBasePage
+{
+    public static final String TARGET_DIR = "target/tmp/";
+
+    @Persist
+    @Property
+    private UploadedFile file;
+
+    public void onSuccess()
+    {
+        File copied = new File(TARGET_DIR + file.getFileName());
+
+        file.write(copied);
+    }
+}

Modified: tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/pages/Ajaxified.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/pages/Ajaxified.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/pages/Ajaxified.java (original)
+++ tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/pages/Ajaxified.java Wed Oct 29 15:15:01 2008
@@ -20,8 +20,9 @@
 import org.apache.tapestry5.annotations.InjectComponent;
 import org.apache.tapestry5.corelib.components.FormInjector;
 import org.apache.tapestry5.ioc.annotations.Inject;
+import org.example.upload.base.UploadBasePage;
 
-public class Ajaxified extends Start
+public class Ajaxified extends UploadBasePage
 {
     @Inject
     private Block content;

Modified: tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/pages/Start.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/pages/Start.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/pages/Start.java (original)
+++ tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/pages/Start.java Wed Oct 29 15:15:01 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2008 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,32 +14,24 @@
 
 package org.example.upload.pages;
 
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.tapestry5.PersistenceConstants;
 import org.apache.tapestry5.annotations.Persist;
-import org.apache.tapestry5.upload.services.UploadedFile;
+import org.apache.tapestry5.annotations.Property;
+import org.example.upload.base.UploadBasePage;
 
-import java.io.File;
-
-public class Start
+public class Start extends UploadBasePage
 {
-    public static final String TARGET_DIR = "target/tmp/";
-
-    @Persist
-    private UploadedFile file;
 
-    public UploadedFile getFile()
-    {
-        return file;
-    }
+    @Persist(PersistenceConstants.FLASH)
+    @Property
+    private String message;
 
-    public void setFile(UploadedFile file)
-    {
-        this.file = file;
-    }
 
-    public void onSuccess()
+    Object onUploadException(FileUploadException ex)
     {
-        File copied = new File(TARGET_DIR + file.getFileName());
+        message = "Upload exception: " + ex.getMessage();
 
-        file.write(copied);
+        return this;
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/services/AppModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/services/AppModule.java?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/services/AppModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-upload/src/test/java/org/example/upload/services/AppModule.java Wed Oct 29 15:15:01 2008
@@ -18,10 +18,11 @@
 import org.apache.tapestry5.ioc.MappedConfiguration;
 import org.apache.tapestry5.ioc.annotations.SubModule;
 import org.apache.tapestry5.upload.services.UploadModule;
+import org.apache.tapestry5.upload.services.UploadSymbols;
 
 /**
  * The SubModule is not normally needed, except that during tests of tapestry-upload, the necessary JAR Manifest does
- * not yet exist, so we force the tapestry.upload module into the registry explicitly.
+ * not yet exist, so we force the tapestry-upload module into the registry explicitly.
  */
 @SubModule(UploadModule.class)
 public class AppModule
@@ -29,5 +30,7 @@
     public static void contributeApplicationDefaults(MappedConfiguration<String, String> configuration)
     {
         configuration.add(SymbolConstants.PRODUCTION_MODE, "false");
+
+        configuration.add(UploadSymbols.FILESIZE_MAX, "5000");
     }
 }

Added: tapestry/tapestry5/trunk/tapestry-upload/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/src/test/resources/log4j.properties?rev=709030&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/src/test/resources/log4j.properties (added)
+++ tapestry/tapestry5/trunk/tapestry-upload/src/test/resources/log4j.properties Wed Oct 29 15:15:01 2008
@@ -0,0 +1,27 @@
+# Copyright 2008 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.
+
+log4j.rootCategory=INFO, A1
+
+# A1 is set to be a ConsoleAppender.
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+
+# A1 uses PatternLayout.
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=[%p] %c{1} %m%n
+
+log4j.category.org.apache.tapestry5.services.TapestryModule.ComponentEventRequestHandler=debug
+
+# log4j.category.org.apache.tapestry5.corelib.components=debug
+

Modified: tapestry/tapestry5/trunk/tapestry-upload/src/test/webapp/Ajaxified.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/src/test/webapp/Ajaxified.tml?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/src/test/webapp/Ajaxified.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-upload/src/test/webapp/Ajaxified.tml Wed Oct 29 15:15:01 2008
@@ -16,8 +16,7 @@
             <input type="submit" value="Upload"/>
         </t:form>
         <t:if test="file">
-            <p>File: ${file.filePath}</p>
-            <p>Size: ${file.size}</p>
+            <t:beandisplay object="file"/>
         </t:if>
 
         <t:block id="content">

Modified: tapestry/tapestry5/trunk/tapestry-upload/src/test/webapp/Start.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/src/test/webapp/Start.tml?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/src/test/webapp/Start.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-upload/src/test/webapp/Start.tml Wed Oct 29 15:15:01 2008
@@ -6,6 +6,13 @@
         <p>
             This test of the upload component
         </p>
+
+        <t:if test="message">
+            <p>
+                <strong>${message}</strong>
+            </p>
+        </t:if>
+
         <t:form>
             <t:errors/>
             <t:label for="file"/>
@@ -14,8 +21,7 @@
             <input type="submit" value="Upload"/>
         </t:form>
         <t:if test="file">
-            <p>File: ${file.filePath}</p>
-            <p>Size: ${file.size}</p>
+            <t:beandisplay object="file"/>
         </t:if>
     </body>
 </html>
\ No newline at end of file

Modified: tapestry/tapestry5/trunk/tapestry-upload/tapestry-upload.iml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/tapestry-upload.iml?rev=709030&r1=709029&r2=709030&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/tapestry-upload.iml (original)
+++ tapestry/tapestry5/trunk/tapestry-upload/tapestry-upload.iml Wed Oct 29 15:15:01 2008
@@ -9,6 +9,11 @@
         <webroots>
           <root url="file://$MODULE_DIR$/src/test/webapp" relative="/" />
         </webroots>
+        <sourceRoots>
+          <root url="file://$MODULE_DIR$/src/main/java" />
+          <root url="file://$MODULE_DIR$/src/main/resources" />
+          <root url="file://$MODULE_DIR$/src/test/java" />
+        </sourceRoots>
         <building>
           <setting name="EXPLODED_URL" value="file://$MODULE_DIR$/../out/exploded/tapestry-uploadWeb" />
           <setting name="EXPLODED_ENABLED" value="true" />
@@ -34,32 +39,32 @@
             <attribute name="URI" value="&lt;N/A&gt;" />
           </containerElement>
           <containerElement type="module" name="tapestry-annotations">
-            <attribute name="method" value="1" />
-            <attribute name="URI" value="/WEB-INF/classes" />
+            <attribute name="method" value="5" />
+            <attribute name="URI" value="/WEB-INF/lib/tapestry-annotations.jar" />
           </containerElement>
           <containerElement type="module" name="tapestry-core">
-            <attribute name="method" value="1" />
-            <attribute name="URI" value="/WEB-INF/classes" />
+            <attribute name="method" value="5" />
+            <attribute name="URI" value="/WEB-INF/lib/tapestry-core.jar" />
           </containerElement>
           <containerElement type="module" name="tapestry-ioc">
-            <attribute name="method" value="1" />
-            <attribute name="URI" value="/WEB-INF/classes" />
+            <attribute name="method" value="5" />
+            <attribute name="URI" value="/WEB-INF/lib/tapestry-ioc.jar" />
           </containerElement>
           <containerElement type="module" name="tapestry-test">
-            <attribute name="method" value="0" />
-            <attribute name="URI" value="&lt;N/A&gt;" />
+            <attribute name="method" value="5" />
+            <attribute name="URI" value="/WEB-INF/lib/tapestry-test.jar" />
           </containerElement>
           <containerElement type="module" name="tapestry-upload">
-            <attribute name="method" value="5" />
-            <attribute name="URI" value="/WEB-INF/lib/tapestry-upload.jar" />
+            <attribute name="method" value="1" />
+            <attribute name="URI" value="/WEB-INF/classes" />
           </containerElement>
           <containerElement type="library" name="ant:ant:1.6.5" level="module">
             <attribute name="method" value="0" />
-            <attribute name="URI" value="/WEB-INF/lib" />
+            <attribute name="URI" value="&lt;N/A&gt;" />
           </containerElement>
           <containerElement type="library" name="bouncycastle:bcprov-jdk15:135" level="module">
             <attribute name="method" value="0" />
-            <attribute name="URI" value="/WEB-INF/lib" />
+            <attribute name="URI" value="&lt;N/A&gt;" />
           </containerElement>
           <containerElement type="library" name="commons-codec:commons-codec:1.3" level="module">
             <attribute name="method" value="1" />
@@ -184,6 +189,7 @@
       <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" />
       <excludeFolder url="file://$MODULE_DIR$/target" />
     </content>
     <orderEntry type="inheritedJdk" />