Skip to content

Commit 44a91be

Browse files
author
TechEmpower
committed
Merge pull request #11 from hlship/master
Minor fixes
2 parents 4258c8f + 5560d39 commit 44a91be

File tree

3 files changed

+12
-83
lines changed

3 files changed

+12
-83
lines changed

tapestry/hello/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
target
2+
build
3+
.gradle
4+
*.iml
5+
*.ipr
6+
*.iws
7+

tapestry/hello/build.gradle

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ description = "hello application"
33
apply plugin: "war"
44
apply plugin: "java"
55
apply plugin: "jetty"
6+
apply plugin: "idea"
67

78
sourceCompatibility = "1.5"
89
targetCompatibility = "1.5"
@@ -15,15 +16,6 @@ repositories {
1516

1617
// All things JBoss/Hibernate
1718
mavenRepo name: "JBoss", url: "http://repository.jboss.org/nexus/content/groups/public/"
18-
19-
// For stable versions of the tapx libraries
20-
mavenRepo name: "HLS", url: "http://howardlewisship.com/repository/"
21-
22-
// For non-stable versions of the tapx libraries
23-
mavenRepo name: "HLS Snapshots", url: "http://howardlewisship.com/snapshot-repository/"
24-
25-
// For access to Apache Staging (Preview) packages
26-
mavenRepo name: "Apache Staging", url: "https://repository.apache.org/content/groups/staging"
2719
}
2820

2921
// This simulates Maven's "provided" scope, until it is officially supported by Gradle
@@ -45,7 +37,10 @@ sourceSets {
4537

4638
dependencies {
4739

48-
compile "org.apache.tapestry:tapestry-core:5.3.6"
40+
compile "mysql:mysql-connector-java:5.1.19"
41+
compile "org.hibernate:hibernate-core:3.6.3.Final"
42+
compile "org.apache.tapestry:tapestry-hibernate:5.3.6"
43+
compile "com.fasterxml.jackson.core:jackson-databind:2.1.4"
4944

5045
// This adds automatic compression of JavaScript and CSS in production mode:
5146
compile "org.apache.tapestry:tapestry-yuicompressor:5.3.6"
Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
package hello.services;
22

3-
import java.io.IOException;
4-
5-
import org.apache.tapestry5.*;
3+
import org.apache.tapestry5.SymbolConstants;
64
import org.apache.tapestry5.ioc.MappedConfiguration;
7-
import org.apache.tapestry5.ioc.OrderedConfiguration;
85
import org.apache.tapestry5.ioc.ServiceBinder;
9-
import org.apache.tapestry5.ioc.annotations.Local;
10-
import org.apache.tapestry5.services.Request;
11-
import org.apache.tapestry5.services.RequestFilter;
12-
import org.apache.tapestry5.services.RequestHandler;
13-
import org.apache.tapestry5.services.Response;
14-
import org.slf4j.Logger;
156

167
/**
178
* This module is automatically included as part of the Tapestry IoC Registry, it's a good place to
@@ -51,67 +42,4 @@ public static void contributeApplicationDefaults(
5142
// the first locale name is the default when there's no reasonable match).
5243
configuration.add(SymbolConstants.SUPPORTED_LOCALES, "en");
5344
}
54-
55-
56-
/**
57-
* This is a service definition, the service will be named "TimingFilter". The interface,
58-
* RequestFilter, is used within the RequestHandler service pipeline, which is built from the
59-
* RequestHandler service configuration. Tapestry IoC is responsible for passing in an
60-
* appropriate Logger instance. Requests for static resources are handled at a higher level, so
61-
* this filter will only be invoked for Tapestry related requests.
62-
* <p/>
63-
* <p/>
64-
* Service builder methods are useful when the implementation is inline as an inner class
65-
* (as here) or require some other kind of special initialization. In most cases,
66-
* use the static bind() method instead.
67-
* <p/>
68-
* <p/>
69-
* If this method was named "build", then the service id would be taken from the
70-
* service interface and would be "RequestFilter". Since Tapestry already defines
71-
* a service named "RequestFilter" we use an explicit service id that we can reference
72-
* inside the contribution method.
73-
*/
74-
public RequestFilter buildTimingFilter(final Logger log)
75-
{
76-
return new RequestFilter()
77-
{
78-
public boolean service(Request request, Response response, RequestHandler handler)
79-
throws IOException
80-
{
81-
long startTime = System.currentTimeMillis();
82-
83-
try
84-
{
85-
// The responsibility of a filter is to invoke the corresponding method
86-
// in the handler. When you chain multiple filters together, each filter
87-
// received a handler that is a bridge to the next filter.
88-
89-
return handler.service(request, response);
90-
} finally
91-
{
92-
long elapsed = System.currentTimeMillis() - startTime;
93-
94-
log.info(String.format("Request time: %d ms", elapsed));
95-
}
96-
}
97-
};
98-
}
99-
100-
/**
101-
* This is a contribution to the RequestHandler service configuration. This is how we extend
102-
* Tapestry using the timing filter. A common use for this kind of filter is transaction
103-
* management or security. The @Local annotation selects the desired service by type, but only
104-
* from the same module. Without @Local, there would be an error due to the other service(s)
105-
* that implement RequestFilter (defined in other modules).
106-
*/
107-
public void contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration,
108-
@Local
109-
RequestFilter filter)
110-
{
111-
// Each contribution to an ordered configuration has a name, When necessary, you may
112-
// set constraints to precisely control the invocation order of the contributed filter
113-
// within the pipeline.
114-
115-
configuration.add("Timing", filter);
116-
}
11745
}

0 commit comments

Comments
 (0)