You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2007/01/26 20:21:22 UTC

svn commit: r500311 - in /tapestry/tapestry5/tapestry-simple/trunk/src: main/resources/META-INF/ main/resources/archetype-resources/ main/resources/archetype-resources/src/main/java/services/ main/resources/archetype-resources/src/main/resources/ site/...

Author: hlship
Date: Fri Jan 26 11:21:21 2007
New Revision: 500311

URL: http://svn.apache.org/viewvc?view=rev&rev=500311
Log:
Create an AppModule.

Added:
    tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/archetype-resources/src/main/java/services/
    tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/archetype-resources/src/main/java/services/AppModule.java
Modified:
    tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/META-INF/archetype.xml
    tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/archetype-resources/pom.xml
    tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/archetype-resources/src/main/resources/log4j.properties
    tapestry/tapestry5/tapestry-simple/trunk/src/site/apt/index.apt

Modified: tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/META-INF/archetype.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/META-INF/archetype.xml?view=diff&rev=500311&r1=500310&r2=500311
==============================================================================
--- tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/META-INF/archetype.xml (original)
+++ tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/META-INF/archetype.xml Fri Jan 26 11:21:21 2007
@@ -12,5 +12,6 @@
     </resources>
     <sources>
         <source>src/main/java/pages/Start.java</source>
+        <source>src/main/java/services/AppModule.java</source>
     </sources>
 </archetype>

Modified: tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/archetype-resources/pom.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/archetype-resources/pom.xml?view=diff&rev=500311&r1=500310&r2=500311
==============================================================================
--- tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/archetype-resources/pom.xml (original)
+++ tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/archetype-resources/pom.xml Fri Jan 26 11:21:21 2007
@@ -35,6 +35,9 @@
             <plugin> 
                 <groupId>org.mortbay.jetty</groupId> 
                 <artifactId>maven-jetty-plugin</artifactId>
+                <configuration>
+                    <requestLog implementation="org.mortbay.jetty.NCSARequestLog"/>
+                </configuration>
             </plugin>
         </plugins>
     </build>

Added: tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/archetype-resources/src/main/java/services/AppModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/archetype-resources/src/main/java/services/AppModule.java?view=auto&rev=500311
==============================================================================
--- tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/archetype-resources/src/main/java/services/AppModule.java (added)
+++ tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/archetype-resources/src/main/java/services/AppModule.java Fri Jan 26 11:21:21 2007
@@ -0,0 +1,61 @@
+package ${packageName}.services;
+
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.tapestry.ioc.MappedConfiguration;
+import org.apache.tapestry.ioc.OrderedConfiguration;
+import org.apache.tapestry.ioc.annotations.Contribute;
+import org.apache.tapestry.ioc.annotations.Id;
+import org.apache.tapestry.ioc.annotations.InjectService;
+import org.apache.tapestry.services.Request;
+import org.apache.tapestry.services.RequestFilter;
+import org.apache.tapestry.services.RequestHandler;
+import org.apache.tapestry.services.Response;
+
+@Id("app")
+public class AppModule
+{
+    @Contribute("tapestry.ioc.ApplicationDefaults")
+    public static void contributeApplicationDefaults(
+            MappedConfiguration<String, String> configuration)
+    {
+        configuration.add("tapestry.supported-locales", "en");
+    }
+    
+    // This may eventually be baked into tapestry-core:
+    
+    public RequestFilter buildTimingFilter(final Log log)
+    {
+        return new RequestFilter()
+        {
+            public boolean service(Request request, Response response, RequestHandler handler)
+                    throws IOException
+            {
+                long startTime = System.currentTimeMillis();
+
+                try
+                {
+                    return handler.service(request, response);
+                }
+                finally
+                {
+                    long elapsed = System.currentTimeMillis() - startTime;
+
+                    log.info(String.format("Request time: %d ms", elapsed));
+                }
+            }
+        };
+    }
+
+    @Contribute("tapestry.RequestHandler")
+    public void contributeRequestFilters(OrderedConfiguration<RequestFilter> configuration,
+            @InjectService("TimingFilter")
+            RequestFilter filter)
+    {
+        configuration.add("Timing", filter);
+    }
+
+
+
+}

Modified: tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/archetype-resources/src/main/resources/log4j.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/archetype-resources/src/main/resources/log4j.properties?view=diff&rev=500311&r1=500310&r2=500311
==============================================================================
--- tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/archetype-resources/src/main/resources/log4j.properties (original)
+++ tapestry/tapestry5/tapestry-simple/trunk/src/main/resources/archetype-resources/src/main/resources/log4j.properties Fri Jan 26 11:21:21 2007
@@ -12,6 +12,8 @@
 log4j.category.tapestry=error
 
 log4j.category.${packageName}=error
+log4j.category.app=error
+log4j.category.app.TimingFilter=info
 
 # Turning on debug mode for a page or component will show all of the code changes that occur when the
 # class is loaded.  Turning on debug mode for a page will enable verbose output about rendering

Modified: tapestry/tapestry5/tapestry-simple/trunk/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-simple/trunk/src/site/apt/index.apt?view=diff&rev=500311&r1=500310&r2=500311
==============================================================================
--- tapestry/tapestry5/tapestry-simple/trunk/src/site/apt/index.apt (original)
+++ tapestry/tapestry5/tapestry-simple/trunk/src/site/apt/index.apt Fri Jan 26 11:21:21 2007
@@ -85,7 +85,7 @@
   <This first time you try this, you'll probably see a huge amount of messages about Maven downloading stuff, in addition to what's above.>
 
   Maven has combined your information to form a new directory containing your application.  It has created a Maven pom.xml, a web.xml, a log4j.properties file, an index.html,
-  and a starting page (Start.html and Start.java) with each file in its correct location.
+  and a starting page (Start.html and Start.java) with each file in its correct location. It also creates a starter Tapestry IoC module for the application (AppModule.java).
   
   You can run the application directly, using the Jetty servlet container: