Return-Path: X-Original-To: apmail-tapestry-dev-archive@www.apache.org Delivered-To: apmail-tapestry-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9456D101EB for ; Tue, 23 Apr 2013 00:38:43 +0000 (UTC) Received: (qmail 15245 invoked by uid 500); 23 Apr 2013 00:38:38 -0000 Delivered-To: apmail-tapestry-dev-archive@tapestry.apache.org Received: (qmail 15079 invoked by uid 500); 23 Apr 2013 00:38:37 -0000 Mailing-List: contact commits-help@tapestry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tapestry.apache.org Delivered-To: mailing list commits@tapestry.apache.org Received: (qmail 13816 invoked by uid 99); 23 Apr 2013 00:38:36 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Apr 2013 00:38:36 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 6B6E081E41C; Tue, 23 Apr 2013 00:38:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: hlship@apache.org To: commits@tapestry.apache.org Date: Tue, 23 Apr 2013 00:39:00 -0000 Message-Id: <945743d426ed49e0bf97239ef0f82469@git.apache.org> In-Reply-To: <2eae43f1e8934f5fbac709b4ae25b7db@git.apache.org> References: <2eae43f1e8934f5fbac709b4ae25b7db@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [26/31] git commit: Move UploadModule into a modules package Move UploadModule into a modules package Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/ed79f2e4 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/ed79f2e4 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/ed79f2e4 Branch: refs/heads/master Commit: ed79f2e48f17f013d011837401f1cb2f0cb7f11c Parents: be8884d Author: Howard M. Lewis Ship Authored: Mon Apr 22 17:10:46 2013 -0700 Committer: Howard M. Lewis Ship Committed: Mon Apr 22 17:10:46 2013 -0700 ---------------------------------------------------------------------- tapestry-upload/build.gradle | 2 +- .../tapestry5/upload/modules/UploadModule.java | 122 +++++++++++++++ .../tapestry5/upload/services/UploadModule.java | 121 -------------- .../org/example/upload/services/AppModule.java | 4 +- 4 files changed, 125 insertions(+), 124 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/ed79f2e4/tapestry-upload/build.gradle ---------------------------------------------------------------------- diff --git a/tapestry-upload/build.gradle b/tapestry-upload/build.gradle index d34da2f..b149b46 100644 --- a/tapestry-upload/build.gradle +++ b/tapestry-upload/build.gradle @@ -11,6 +11,6 @@ dependencies { jar { manifest { - attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.upload.services.UploadModule' + attributes 'Tapestry-Module-Classes': 'org.apache.tapestry5.upload.modules.UploadModule' } } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/ed79f2e4/tapestry-upload/src/main/java/org/apache/tapestry5/upload/modules/UploadModule.java ---------------------------------------------------------------------- diff --git a/tapestry-upload/src/main/java/org/apache/tapestry5/upload/modules/UploadModule.java b/tapestry-upload/src/main/java/org/apache/tapestry5/upload/modules/UploadModule.java new file mode 100755 index 0000000..c9de59a --- /dev/null +++ b/tapestry-upload/src/main/java/org/apache/tapestry5/upload/modules/UploadModule.java @@ -0,0 +1,122 @@ +// Copyright 2007-2013 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.modules; + +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.commons.io.FileCleaner; +import org.apache.tapestry5.internal.InternalConstants; +import org.apache.tapestry5.ioc.Configuration; +import org.apache.tapestry5.ioc.MappedConfiguration; +import org.apache.tapestry5.ioc.OrderedConfiguration; +import org.apache.tapestry5.ioc.ScopeConstants; +import org.apache.tapestry5.ioc.annotations.Autobuild; +import org.apache.tapestry5.ioc.annotations.Scope; +import org.apache.tapestry5.ioc.annotations.Symbol; +import org.apache.tapestry5.ioc.services.PerthreadManager; +import org.apache.tapestry5.ioc.services.RegistryShutdownHub; +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 org.apache.tapestry5.upload.services.MultipartDecoder; +import org.apache.tapestry5.upload.services.UploadSymbols; + +import java.io.File; +import java.util.concurrent.atomic.AtomicBoolean; + +public class UploadModule +{ + private static final String NO_LIMIT = "-1"; + + private static final AtomicBoolean needToAddShutdownListener = new AtomicBoolean(true); + + public static void contributeComponentClassResolver(Configuration configuration) + { + // Add the component to the "core" library. + + configuration.add(new LibraryMapping(InternalConstants.CORE_LIBRARY, "org.apache.tapestry5.upload")); + } + + @Scope(ScopeConstants.PERTHREAD) + public static MultipartDecoder buildMultipartDecoder(PerthreadManager perthreadManager, + + RegistryShutdownHub shutdownHub, + + @Autobuild + MultipartDecoderImpl multipartDecoder) + { + // This is proabably overkill since the FileCleaner should catch temporary files, but lets + // be safe. + perthreadManager.addThreadCleanupListener(multipartDecoder); + + if (needToAddShutdownListener.getAndSet(false)) + { + shutdownHub.addRegistryShutdownListener(new Runnable() + { + public void run() + { + FileCleaner.exitWhenFinished(); + } + }); + } + + return multipartDecoder; + } + + /** + * Contributes a filter, "MultipartFilter" after "IgnoredPaths". + */ + public static void contributeHttpServletRequestHandler( + OrderedConfiguration configuration, MultipartDecoder multipartDecoder) + { + 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 configuration) + { + configuration.addInstance("UploadException", UploadExceptionFilter.class, "after:Secure", "before:Ajax"); + } + + /** + * The default FileItemFactory used by the MultipartDecoder is + * {@link org.apache.commons.fileupload.disk.DiskFileItemFactory}. + */ + public static FileItemFactory buildDefaultFileItemFactory(@Symbol(UploadSymbols.REPOSITORY_THRESHOLD) + int repositoryThreshold, + + @Symbol(UploadSymbols.REPOSITORY_LOCATION) + String repositoryLocation) + { + return new DiskFileItemFactory(repositoryThreshold, new File(repositoryLocation)); + } + + public static void contributeFactoryDefaults(MappedConfiguration configuration) + { + configuration.add(UploadSymbols.REPOSITORY_THRESHOLD, Integer + .toString(DiskFileItemFactory.DEFAULT_SIZE_THRESHOLD)); + configuration.add(UploadSymbols.REPOSITORY_LOCATION, System.getProperty("java.io.tmpdir")); + configuration.add(UploadSymbols.REQUESTSIZE_MAX, NO_LIMIT); + configuration.add(UploadSymbols.FILESIZE_MAX, NO_LIMIT); + } +} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/ed79f2e4/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadModule.java ---------------------------------------------------------------------- diff --git a/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadModule.java b/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadModule.java deleted file mode 100755 index 9a40b05..0000000 --- a/tapestry-upload/src/main/java/org/apache/tapestry5/upload/services/UploadModule.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2007, 2008, 2009, 2011 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; - -import org.apache.commons.fileupload.FileItemFactory; -import org.apache.commons.fileupload.disk.DiskFileItemFactory; -import org.apache.commons.io.FileCleaner; -import org.apache.tapestry5.internal.InternalConstants; -import org.apache.tapestry5.ioc.Configuration; -import org.apache.tapestry5.ioc.MappedConfiguration; -import org.apache.tapestry5.ioc.OrderedConfiguration; -import org.apache.tapestry5.ioc.ScopeConstants; -import org.apache.tapestry5.ioc.annotations.Autobuild; -import org.apache.tapestry5.ioc.annotations.Scope; -import org.apache.tapestry5.ioc.annotations.Symbol; -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.io.File; -import java.util.concurrent.atomic.AtomicBoolean; - -public class UploadModule -{ - private static final String NO_LIMIT = "-1"; - - private static final AtomicBoolean needToAddShutdownListener = new AtomicBoolean(true); - - public static void contributeComponentClassResolver(Configuration configuration) - { - // Add the component to the "core" library. - - configuration.add(new LibraryMapping(InternalConstants.CORE_LIBRARY, "org.apache.tapestry5.upload")); - } - - @Scope(ScopeConstants.PERTHREAD) - public static MultipartDecoder buildMultipartDecoder(PerthreadManager perthreadManager, - - RegistryShutdownHub shutdownHub, - - @Autobuild - MultipartDecoderImpl multipartDecoder) - { - // This is proabably overkill since the FileCleaner should catch temporary files, but lets - // be safe. - perthreadManager.addThreadCleanupListener(multipartDecoder); - - if (needToAddShutdownListener.getAndSet(false)) - { - shutdownHub.addRegistryShutdownListener(new Runnable() - { - public void run() - { - FileCleaner.exitWhenFinished(); - } - }); - } - - return multipartDecoder; - } - - /** - * Contributes a filter, "MultipartFilter" after "IgnoredPaths". - */ - public static void contributeHttpServletRequestHandler( - OrderedConfiguration configuration, MultipartDecoder multipartDecoder) - { - 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 configuration) - { - configuration.addInstance("UploadException", UploadExceptionFilter.class, "after:Secure", "before:Ajax"); - } - - /** - * The default FileItemFactory used by the MultipartDecoder is - * {@link org.apache.commons.fileupload.disk.DiskFileItemFactory}. - */ - public static FileItemFactory buildDefaultFileItemFactory(@Symbol(UploadSymbols.REPOSITORY_THRESHOLD) - int repositoryThreshold, - - @Symbol(UploadSymbols.REPOSITORY_LOCATION) - String repositoryLocation) - { - return new DiskFileItemFactory(repositoryThreshold, new File(repositoryLocation)); - } - - public static void contributeFactoryDefaults(MappedConfiguration configuration) - { - configuration.add(UploadSymbols.REPOSITORY_THRESHOLD, Integer - .toString(DiskFileItemFactory.DEFAULT_SIZE_THRESHOLD)); - configuration.add(UploadSymbols.REPOSITORY_LOCATION, System.getProperty("java.io.tmpdir")); - configuration.add(UploadSymbols.REQUESTSIZE_MAX, NO_LIMIT); - configuration.add(UploadSymbols.FILESIZE_MAX, NO_LIMIT); - } -} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/ed79f2e4/tapestry-upload/src/test/java/org/example/upload/services/AppModule.java ---------------------------------------------------------------------- diff --git a/tapestry-upload/src/test/java/org/example/upload/services/AppModule.java b/tapestry-upload/src/test/java/org/example/upload/services/AppModule.java index 6a3e9cc..d376800 100755 --- a/tapestry-upload/src/test/java/org/example/upload/services/AppModule.java +++ b/tapestry-upload/src/test/java/org/example/upload/services/AppModule.java @@ -1,4 +1,4 @@ -// Copyright 2007, 2008 The Apache Software Foundation +// Copyright 2007-2013 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. @@ -17,7 +17,7 @@ package org.example.upload.services; import org.apache.tapestry5.SymbolConstants; 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.modules.UploadModule; import org.apache.tapestry5.upload.services.UploadSymbols; /**