tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r434112 - in /tapestry/tapestry5/tapestry-core/trunk: ./ src/main/java/org/apache/tapestry/ src/main/java/org/apache/tapestry/internal/ioc/ src/main/java/org/apache/tapestry/request/ src/main/java/org/apache/tapestry/services/ src/site/apt/...
Date Wed, 23 Aug 2006 18:15:25 GMT
Author: hlship
Date: Wed Aug 23 11:15:25 2006
New Revision: 434112

URL: http://svn.apache.org/viewvc?rev=434112&view=rev
Log:
Update pointers to latest Codehaus plugin repositories.
Re-enable the Cobetura code coverage report.

Added:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/ApplicationInitializer.java
Modified:
    tapestry/tapestry5/tapestry-core/trunk/pom.xml
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/TapestryFilter.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/IOCUtilities.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/HttpServletRequestFilter.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/HttpServletRequestHandler.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/RequestModule.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/WebRequestFilter.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/WebRequestHandler.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
    tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/provider.apt
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/IOCUtilitiesTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java

Modified: tapestry/tapestry5/tapestry-core/trunk/pom.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/pom.xml?rev=434112&r1=434111&r2=434112&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/pom.xml (original)
+++ tapestry/tapestry5/tapestry-core/trunk/pom.xml Wed Aug 23 11:15:25 2006
@@ -131,16 +131,14 @@
                     <stylesheetfile>${basedir}/src/site/resources/css/jdstyle.css</stylesheetfile>
                 </configuration>
             </plugin>
-            <!--
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>cobertura-maven-plugin</artifactId>
-            </plugin> -->
+            </plugin> 
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-report-plugin</artifactId>
-                <!--   <version>2.8-SNAPSHOT</version> -->
-            </plugin>
+             </plugin>
         </plugins>
     </reporting>
     <distributionManagement>

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/TapestryFilter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/TapestryFilter.java?rev=434112&r1=434111&r2=434112&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/TapestryFilter.java
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/TapestryFilter.java
Wed Aug 23 11:15:25 2006
@@ -22,10 +22,14 @@
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 import org.apache.tapestry.ioc.IOCUtilities;
 import org.apache.tapestry.ioc.Registry;
 import org.apache.tapestry.ioc.RegistryBuilder;
+import org.apache.tapestry.request.HttpServletRequestHandler;
+import org.apache.tapestry.services.ApplicationInitializer;
 import org.apache.tapestry.services.TapestryModule;
 
 /**
@@ -37,28 +41,74 @@
  */
 public class TapestryFilter implements Filter
 {
+    private FilterConfig _config;
+
     private Registry _registry;
 
-    public void init(FilterConfig filterConfig) throws ServletException
+    private HttpServletRequestHandler _handler;
+
+    /**
+     * Initializes the filter by building the {@link Registry}. The registry contains
+     * {@link org.apache.tapestry.ioc.services.TapestryIOCModule} and {@link TapestryModule},
any
+     * modules identified by {@link #addModules(RegistryBuilder)}, plus the application module.
+     * <p>
+     * The application module is optional.
+     * <p>
+     * The application module is identified as <em>package</em>.services.<em>Name</em>Module,
+     * where <em>package</em> is defined by the <code>tapestry.app-package</code>
filter init
+     * parameter and <em>Name</em> is the capitalization of the filter name (as
specified in
+     * web.xml).
+     */
+    public final void init(FilterConfig filterConfig) throws ServletException
     {
+        _config = filterConfig;
+
         RegistryBuilder builder = new RegistryBuilder();
 
         builder.add(TapestryModule.class);
 
+        String appPackage = _config.getInitParameter("tapestry.app-package");
+        String filterName = _config.getFilterName();
+
+        String className = appPackage + ".services."
+                + org.apache.tapestry.internal.ioc.IOCUtilities.capitalize(filterName) +
"Module";
+
+        try
+        {
+            // TapestryFilter is possibly loaded by a parent class loader of the application
class
+            // loader. The context class loader should have the approprite view to the module
class,
+            // if any.
+
+            Class moduleClass = Thread.currentThread().getContextClassLoader().loadClass(className);
+            builder.add(moduleClass);
+        }
+        catch (ClassNotFoundException ex)
+        {
+            // That's OK, not all applications will have a module class. Any
+            // non-trivial application will.
+        }
+
         addModules(builder);
 
         _registry = builder.build();
 
-        // Initialization code will go here.
+        ApplicationInitializer ai = _registry.getService(
+                "tapestry.ApplicationInitializer",
+                ApplicationInitializer.class);
+
+        ai.initializeApplication();
+
+        _handler = _registry.getService(
+                "tapestry.request.HTTPServletRequestHandler",
+                HttpServletRequestHandler.class);
     }
 
     /**
      * Adds additional modules to the builder. This implementation adds any modules identified
by
      * {@link IOCUtilities#addDefaultModules(RegistryBuilder)}. Most subclasses will invoke
this
-     * implementation, and add additional modules to the RegistryBuilder besides. Most applications
-     * will not need to override this method.
-     * <p>
-     * TODO: Check for an application module in some way.
+     * implementation, and add additional modules to the RegistryBuilder besides.
+     * {@link org.apache.tapestry.ioc.services.TapestryIOCModule} and {@link TapestryModule}
will
+     * already have been added, as will an application module if present.
      * 
      * @param builder
      */
@@ -67,16 +117,17 @@
         IOCUtilities.addDefaultModules(builder);
     }
 
-    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+    public final void doFilter(ServletRequest request, ServletResponse response, FilterChain
chain)
             throws IOException, ServletException
     {
         try
         {
-            // This is temporary, much more to do in the future. This allows ordinary content
to be
-            // accessed. We need to delegate to the tapestry.request.HTTPServletRequestHandler
-            // pipeline.
+            boolean handled = _handler.service(
+                    (HttpServletRequest) request,
+                    (HttpServletResponse) response);
 
-            chain.doFilter(request, response);
+            if (!handled)
+                chain.doFilter(request, response);
         }
         finally
         {
@@ -85,11 +136,13 @@
     }
 
     /** Shuts down and discards the registry. */
-    public void destroy()
+    public final void destroy()
     {
         _registry.shutdown();
 
         _registry = null;
+        _config = null;
+        _handler = null;
     }
 
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/IOCUtilities.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/IOCUtilities.java?rev=434112&r1=434111&r2=434112&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/IOCUtilities.java
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/ioc/IOCUtilities.java
Wed Aug 23 11:15:25 2006
@@ -200,4 +200,13 @@
     {
         throw new IllegalStateException(IOCMessages.registryShutdown(serviceId));
     }
+
+    /** Capitalizes a string, converting the first character to uppercase. */
+    public static String capitalize(String input)
+    {
+        if (input.length() == 0)
+            return input;
+
+        return input.substring(0, 1).toUpperCase() + input.substring(1);
+    }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/HttpServletRequestFilter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/HttpServletRequestFilter.java?rev=434112&r1=434111&r2=434112&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/HttpServletRequestFilter.java
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/HttpServletRequestFilter.java
Wed Aug 23 11:15:25 2006
@@ -30,11 +30,8 @@
      * delegate to the handler. It may perform operations before or after invoking the handler,
and
      * may modify the request and response passed in to the handler.
      * 
-     * @param request
-     * @param response
-     * @param handler
-     * @throws IOException
+     * @return true if the request has been handled, false otherwise
      */
-    void service(HttpServletRequest request, HttpServletResponse response,
+    boolean service(HttpServletRequest request, HttpServletResponse response,
             HttpServletRequestHandler handler) throws IOException;
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/HttpServletRequestHandler.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/HttpServletRequestHandler.java?rev=434112&r1=434111&r2=434112&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/HttpServletRequestHandler.java
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/HttpServletRequestHandler.java
Wed Aug 23 11:15:25 2006
@@ -27,5 +27,6 @@
  */
 public interface HttpServletRequestHandler
 {
-    void service(HttpServletRequest request, HttpServletResponse response) throws IOException;
+    /** Returns true if the request was handled, false otherwise. */
+    boolean service(HttpServletRequest request, HttpServletResponse response) throws IOException;
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/RequestModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/RequestModule.java?rev=434112&r1=434111&r2=434112&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/RequestModule.java
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/RequestModule.java
Wed Aug 23 11:15:25 2006
@@ -66,7 +66,7 @@
     {
         HttpServletRequestHandler terminator = new HttpServletRequestHandler()
         {
-            public void service(HttpServletRequest request, HttpServletResponse response)
+            public boolean service(HttpServletRequest request, HttpServletResponse response)
                     throws IOException
             {
                 _requestGlobals.store(request, response);
@@ -74,7 +74,7 @@
                 WebRequest wrequest = new WebRequestImpl(request);
                 WebResponse wresponse = new WebResponseImpl(response);
 
-                webRequestHandler.service(wrequest, wresponse);
+                return webRequestHandler.service(wrequest, wresponse);
             }
         };
 
@@ -90,15 +90,14 @@
     {
         WebRequestHandler terminator = new WebRequestHandler()
         {
-            public void service(WebRequest request, WebResponse response) throws IOException
+            public boolean service(WebRequest request, WebResponse response) throws IOException
             {
                 _requestGlobals.store(request, response);
 
-                // But after that, who knows?
+                // Much more to come from here in!
 
-                throw new UnsupportedOperationException("Not yet implemented.");
+                return false;
             }
-
         };
 
         return _pipelineBuilder.build(

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/WebRequestFilter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/WebRequestFilter.java?rev=434112&r1=434111&r2=434112&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/WebRequestFilter.java
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/WebRequestFilter.java
Wed Aug 23 11:15:25 2006
@@ -23,7 +23,10 @@
  */
 public interface WebRequestFilter
 {
-    void service(WebRequest request, WebResponse response, WebRequestHandler handler)
+    /**
+     * Returns true if the request has been handled, false otherwise.
+     */
+    boolean service(WebRequest request, WebResponse response, WebRequestHandler handler)
             throws IOException;
 
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/WebRequestHandler.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/WebRequestHandler.java?rev=434112&r1=434111&r2=434112&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/WebRequestHandler.java
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/request/WebRequestHandler.java
Wed Aug 23 11:15:25 2006
@@ -23,5 +23,6 @@
  */
 public interface WebRequestHandler
 {
-    void service(WebRequest request, WebResponse response) throws IOException;
+    /** Returns true if the request has been handled, false otherwise. */
+    boolean service(WebRequest request, WebResponse response) throws IOException;
 }

Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/ApplicationInitializer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/ApplicationInitializer.java?rev=434112&view=auto
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/ApplicationInitializer.java
(added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/ApplicationInitializer.java
Wed Aug 23 11:15:25 2006
@@ -0,0 +1,12 @@
+package org.apache.tapestry.services;
+
+/**
+ * Service interface for initializing Tapestry for the application.
+ * 
+ * @author Howard M. Lewis Ship
+ */
+public interface ApplicationInitializer
+{
+    /** TODO: Determine what parameters are appropriate here. */
+    void initializeApplication();
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java?rev=434112&r1=434111&r2=434112&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
Wed Aug 23 11:15:25 2006
@@ -15,6 +15,7 @@
 package org.apache.tapestry.services;
 
 import java.util.Collection;
+import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.tapestry.MarkupWriter;
@@ -25,11 +26,13 @@
 import org.apache.tapestry.ioc.Configuration;
 import org.apache.tapestry.ioc.MappedConfiguration;
 import org.apache.tapestry.ioc.ObjectProvider;
+import org.apache.tapestry.ioc.OrderedConfiguration;
 import org.apache.tapestry.ioc.ServiceResources;
 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.ioc.annotations.SubModule;
+import org.apache.tapestry.ioc.services.ChainBuilder;
 import org.apache.tapestry.request.RequestModule;
 import org.apache.tapestry.transform.TransformModule;
 
@@ -43,6 +46,14 @@
 { TransformModule.class, InternalModule.class, RequestModule.class })
 public final class TapestryModule
 {
+    private final ChainBuilder _chainBuilder;
+
+    public TapestryModule(@InjectService("tapestry.ioc.ChainBuilder")
+    ChainBuilder chainBuilder)
+    {
+        _chainBuilder = chainBuilder;
+    }
+
     public Infrastructure buildInfrastructure(Log log,
             Collection<InfrastructureContribution> configuration)
     {
@@ -115,5 +126,28 @@
                 return componentName;
             }
         };
+    }
+
+    /** Initialized the application. */
+    public ApplicationInitializer buildApplicationInitializer(Log log,
+            List<ApplicationInitializer> configuration)
+    {
+        return _chainBuilder.build(ApplicationInitializer.class, configuration);
+    }
+
+    public void contributeApplicationInitializer(
+            OrderedConfiguration<ApplicationInitializer> configuration,
+            @InjectService("Infrastructure")
+            final Infrastructure infrastructure)
+    {
+        ApplicationInitializer contribution = new ApplicationInitializer()
+        {
+            public void initializeApplication()
+            {
+                infrastructure.setMode("html");
+            }
+        };
+
+        configuration.add("SetInfrastructureMode", contribution, "before:*.*");
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/provider.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/provider.apt?rev=434112&r1=434111&r2=434112&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/provider.apt (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/apt/ioc/provider.apt Wed Aug 23 11:15:25
2006
@@ -54,11 +54,13 @@
   The following table identifies the properties that are available via the infrastructure
provider
   by default:
   
-*---------------------+-----------------------------------------------------------------------------------------+
-| <<Property>>        | <<Default Service or Implementation>>   
                                               |
-*---------------------+-----------------------------------------------------------------------------------------+
-| request             | {{{../apidocs/org/apache/tapestry/request/WebRequest.html}tapestry.request.WebRequest}}
|
-*---------------------+-----------------------------------------------------------------------------------------+
+*-----------------------+--------------------------------------------------------------------------------------------------------+
+| <<Property>>          | <<Default Service or Implementation>> 
                                                                |
+*-----------------------+--------------------------------------------------------------------------------------------------------+
+| componentNameExpander | {{{../apidocs/org/apache/tapestry/services/ComponentNameExpander.html}tapestry.ComponentNameExpander}}
|
+*-----------------------+--------------------------------------------------------------------------------------------------------+
+| request               | {{{../apidocs/org/apache/tapestry/request/WebRequest.html}tapestry.request.WebRequest}}
               |
+*-----------------------+--------------------------------------------------------------------------------------------------------+
 Default properties available via the infrastructure object provider
   
   

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/IOCUtilitiesTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/IOCUtilitiesTest.java?rev=434112&r1=434111&r2=434112&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/IOCUtilitiesTest.java
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/ioc/IOCUtilitiesTest.java
Wed Aug 23 11:15:25 2006
@@ -21,6 +21,7 @@
 
 import org.apache.tapestry.test.TestBase;
 import org.apache.tapestry.util.CollectionFactory;
+import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
 /**
@@ -73,5 +74,23 @@
         List<String> output = IOCUtilities.toList(e);
 
         assertEquals(output, Arrays.asList("barney", "fred", "wilma"));
+    }
+
+    @Test(dataProvider = "capitalizeInputs")
+    public void capitalize(String input, String expected)
+    {
+        assertEquals(IOCUtilities.capitalize(input), expected);
+    }
+
+    @DataProvider(name = "capitalizeInputs")
+    public Object[][] capitalize_inputs()
+    {
+        return new Object[][]
+        {
+        { "hello", "Hello" },
+        { "Goodbye", "Goodbye" },
+        { "", "" },
+        { "a", "A" },
+        { "A", "A" } };
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java?rev=434112&r1=434111&r2=434112&view=diff
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/ioc/IntegrationTest.java
Wed Aug 23 11:15:25 2006
@@ -250,6 +250,8 @@
     {
         Registry r = buildRegistry(PerThreadModule.class);
 
+        r.cleanupThread();
+        
         StringHolder holder = r.getService(StringHolder.class);
 
         assertNull(holder.getValue());



Mime
View raw message