From e0b18f2c321fe09c10bb4e185e589fa5c5e3599e Mon Sep 17 00:00:00 2001 From: "Howard M. Lewis Ship" Date: Thu, 28 Mar 2013 10:24:14 -0700 Subject: [PATCH 1/4] Remove timing filter The filter consumes a microscopic amount of CPU and performs some logging that could affect performance. --- .../main/java/hello/services/AppModule.java | 70 ------------------- 1 file changed, 70 deletions(-) diff --git a/tapestry/hello/src/main/java/hello/services/AppModule.java b/tapestry/hello/src/main/java/hello/services/AppModule.java index beecf8321b2..0d6e41fa782 100644 --- a/tapestry/hello/src/main/java/hello/services/AppModule.java +++ b/tapestry/hello/src/main/java/hello/services/AppModule.java @@ -4,14 +4,7 @@ import org.apache.tapestry5.*; import org.apache.tapestry5.ioc.MappedConfiguration; -import org.apache.tapestry5.ioc.OrderedConfiguration; import org.apache.tapestry5.ioc.ServiceBinder; -import org.apache.tapestry5.ioc.annotations.Local; -import org.apache.tapestry5.services.Request; -import org.apache.tapestry5.services.RequestFilter; -import org.apache.tapestry5.services.RequestHandler; -import org.apache.tapestry5.services.Response; -import org.slf4j.Logger; /** * This module is automatically included as part of the Tapestry IoC Registry, it's a good place to @@ -51,67 +44,4 @@ public static void contributeApplicationDefaults( // the first locale name is the default when there's no reasonable match). configuration.add(SymbolConstants.SUPPORTED_LOCALES, "en"); } - - - /** - * This is a service definition, the service will be named "TimingFilter". The interface, - * RequestFilter, is used within the RequestHandler service pipeline, which is built from the - * RequestHandler service configuration. Tapestry IoC is responsible for passing in an - * appropriate Logger instance. Requests for static resources are handled at a higher level, so - * this filter will only be invoked for Tapestry related requests. - *

- *

- * Service builder methods are useful when the implementation is inline as an inner class - * (as here) or require some other kind of special initialization. In most cases, - * use the static bind() method instead. - *

- *

- * If this method was named "build", then the service id would be taken from the - * service interface and would be "RequestFilter". Since Tapestry already defines - * a service named "RequestFilter" we use an explicit service id that we can reference - * inside the contribution method. - */ - public RequestFilter buildTimingFilter(final Logger log) - { - return new RequestFilter() - { - public boolean service(Request request, Response response, RequestHandler handler) - throws IOException - { - long startTime = System.currentTimeMillis(); - - try - { - // The responsibility of a filter is to invoke the corresponding method - // in the handler. When you chain multiple filters together, each filter - // received a handler that is a bridge to the next filter. - - return handler.service(request, response); - } finally - { - long elapsed = System.currentTimeMillis() - startTime; - - log.info(String.format("Request time: %d ms", elapsed)); - } - } - }; - } - - /** - * This is a contribution to the RequestHandler service configuration. This is how we extend - * Tapestry using the timing filter. A common use for this kind of filter is transaction - * management or security. The @Local annotation selects the desired service by type, but only - * from the same module. Without @Local, there would be an error due to the other service(s) - * that implement RequestFilter (defined in other modules). - */ - public void contributeRequestHandler(OrderedConfiguration configuration, - @Local - RequestFilter filter) - { - // Each contribution to an ordered configuration has a name, When necessary, you may - // set constraints to precisely control the invocation order of the contributed filter - // within the pipeline. - - configuration.add("Timing", filter); - } } From 8f50d2af6dc9f324fcdb1ceca759c1e0666dcd16 Mon Sep 17 00:00:00 2001 From: "Howard M. Lewis Ship" Date: Thu, 28 Mar 2013 10:50:18 -0700 Subject: [PATCH 2/4] Update dependencies Had to guess a bit; based on what's in the README.md and the .classpath --- tapestry/hello/build.gradle | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/tapestry/hello/build.gradle b/tapestry/hello/build.gradle index 67f0363ef2f..3232dbb3376 100644 --- a/tapestry/hello/build.gradle +++ b/tapestry/hello/build.gradle @@ -3,6 +3,7 @@ description = "hello application" apply plugin: "war" apply plugin: "java" apply plugin: "jetty" +apply plugin: "idea" sourceCompatibility = "1.5" targetCompatibility = "1.5" @@ -15,15 +16,6 @@ repositories { // All things JBoss/Hibernate mavenRepo name: "JBoss", url: "http://repository.jboss.org/nexus/content/groups/public/" - - // For stable versions of the tapx libraries - mavenRepo name: "HLS", url: "http://howardlewisship.com/repository/" - - // For non-stable versions of the tapx libraries - mavenRepo name: "HLS Snapshots", url: "http://howardlewisship.com/snapshot-repository/" - - // For access to Apache Staging (Preview) packages - mavenRepo name: "Apache Staging", url: "https://repository.apache.org/content/groups/staging" } // This simulates Maven's "provided" scope, until it is officially supported by Gradle @@ -45,7 +37,10 @@ sourceSets { dependencies { - compile "org.apache.tapestry:tapestry-core:5.3.6" + compile "mysql:mysql-connector-java:5.1.19" + compile "org.hibernate:hibernate-core:3.6.3.Final" + compile "org.apache.tapestry:tapestry-hibernate:5.3.6" + compile "com.fasterxml.jackson.core:jackson-databind:2.1.4" // This adds automatic compression of JavaScript and CSS in production mode: compile "org.apache.tapestry:tapestry-yuicompressor:5.3.6" From 7f5b334189596d94e5d8954c5734140692407a65 Mon Sep 17 00:00:00 2001 From: "Howard M. Lewis Ship" Date: Thu, 28 Mar 2013 10:50:46 -0700 Subject: [PATCH 3/4] Remove unused imports --- tapestry/hello/src/main/java/hello/services/AppModule.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tapestry/hello/src/main/java/hello/services/AppModule.java b/tapestry/hello/src/main/java/hello/services/AppModule.java index 0d6e41fa782..43855472e59 100644 --- a/tapestry/hello/src/main/java/hello/services/AppModule.java +++ b/tapestry/hello/src/main/java/hello/services/AppModule.java @@ -1,8 +1,6 @@ package hello.services; -import java.io.IOException; - -import org.apache.tapestry5.*; +import org.apache.tapestry5.SymbolConstants; import org.apache.tapestry5.ioc.MappedConfiguration; import org.apache.tapestry5.ioc.ServiceBinder; From 5560d3908d75a818001719d8d3e484112c9efeb3 Mon Sep 17 00:00:00 2001 From: "Howard M. Lewis Ship" Date: Thu, 28 Mar 2013 10:52:10 -0700 Subject: [PATCH 4/4] Ignore IDEA files, Gradle build dir --- tapestry/hello/.gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tapestry/hello/.gitignore b/tapestry/hello/.gitignore index eb5a316cbd1..49958b906e6 100644 --- a/tapestry/hello/.gitignore +++ b/tapestry/hello/.gitignore @@ -1 +1,7 @@ target +build +.gradle +*.iml +*.ipr +*.iws +