Author: hlship
Date: Sun Jan 20 13:58:04 2008
New Revision: 613686
URL: http://svn.apache.org/viewvc?rev=613686&view=rev
Log:
TAPESTRY-1377 NullPointerException invoking methods on the Request service
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/CheckForUpdatesFilter.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/CheckForUpdatesFilter.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/CheckForUpdatesFilter.java?rev=613686&r1=613685&r2=613686&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/CheckForUpdatesFilter.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/CheckForUpdatesFilter.java
Sun Jan 20 13:58:04 2008
@@ -26,10 +26,9 @@
import java.util.concurrent.TimeUnit;
/**
- * Implements a barrier that periodically asks the
- * [EMAIL PROTECTED] org.apache.tapestry.internal.services.UpdateListenerHub}
to check for updates to files.
- * The UpdateListenerHub is invoked from a write method, meaning that when it
is called, all other
- * threads will be blocked.
+ * Implements a barrier that periodically asks the [EMAIL PROTECTED]
org.apache.tapestry.internal.services.UpdateListenerHub} to
+ * check for updates to files. The UpdateListenerHub is invoked from a write
method, meaning that when it is called, all
+ * other threads will be blocked.
*/
public class CheckForUpdatesFilter implements RequestFilter
{
@@ -75,8 +74,8 @@
_updateTimeout = updateTimeout;
}
- public boolean service(final Request request, final Response response,
- final RequestHandler handler) throws IOException
+ public boolean service(final Request request, final Response response,
final RequestHandler handler)
+ throws IOException
{
final Holder<IOException> exceptionHolder = new Holder<IOException>();
@@ -106,10 +105,7 @@
boolean result = _barrier.withRead(invokable);
- IOException ex = exceptionHolder.get();
-
- if (ex != null)
- throw ex;
+ if (exceptionHolder.hasValue()) throw exceptionHolder.get();
return result;
}
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java?rev=613686&r1=613685&r2=613686&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
Sun Jan 20 13:58:04 2008
@@ -455,7 +455,10 @@
* <dt>ErrorFilter</dt> <dd>Catches request errors and lets the [EMAIL
PROTECTED] org.apache.tapestry.services.RequestExceptionHandler}
* handle them</dd> <dt>Localization</dt> <dd>Determines the locale for
the current request from header data or
* cookies in the request</dd> <dt>IgnoredPaths</dt> <dd>Forces Tapestry
to ignore paths, based on regular
- * expressions contributed to the IgnoredPathsFilter service. Ordered
after StaticFiles.</dd> </dl>
+ * expressions contributed to the IgnoredPathsFilter service. Ordered
after StaticFiles.</dd>
+ * <dt>StoreIntoGlobals</dt> <dd>Stores the request and response into the
[EMAIL PROTECTED]
+ * org.apache.tapestry.services.RequestGlobals} service (this is repeated
at the end of the pipeline, in case any
+ * filter substitutes the request or response). </dl>
*/
public void contributeRequestHandler(OrderedConfiguration<RequestFilter>
configuration, Context context,
@@ -476,8 +479,6 @@
{
RequestFilter staticFilesFilter = new StaticFilesFilter(context);
- configuration.add("StaticFiles", staticFilesFilter);
-
RequestFilter errorFilter = new RequestFilter()
{
public boolean service(Request request, Response response,
RequestHandler handler) throws IOException
@@ -503,14 +504,28 @@
}
};
- configuration.add("IgnoredPaths", ignoredPathsFilter,
"after:StaticFiles");
+ RequestFilter storeIntoGlobals = new RequestFilter()
+ {
+ public boolean service(Request request, Response response,
RequestHandler handler) throws IOException
+ {
+ _requestGlobals.store(request, response);
- configuration.add("ErrorFilter", errorFilter);
+ return handler.service(request, response);
+ }
+ };
configuration.add("CheckForUpdates",
new CheckForUpdatesFilter(_updateListenerHub,
checkInterval, updateTimeout), "before:*");
- configuration.add("Localization", new
LocalizationFilter(localizationSetter));
+ configuration.add("StaticFiles", staticFilesFilter);
+
+ configuration.add("IgnoredPaths", ignoredPathsFilter,
"after:StaticFiles");
+
+ configuration.add("ErrorFilter", errorFilter);
+
+ configuration.add("StoreIntoGlobals", storeIntoGlobals);
+
+ configuration.add("Localization", new
LocalizationFilter(localizationSetter), "after:ErrorFilter");
}
@@ -851,6 +866,7 @@
/**
* Initializes the application.
*/
+ @Marker(Primary.class)
public ApplicationInitializer build(Logger logger,
List<ApplicationInitializerFilter> configuration)
{
ApplicationInitializer terminator = new ApplicationInitializer()
@@ -867,16 +883,22 @@
public HttpServletRequestHandler build(Logger logger,
List<HttpServletRequestFilter> configuration,
- @InjectService("RequestHandler")
+ @Primary
final RequestHandler handler)
{
HttpServletRequestHandler terminator = new HttpServletRequestHandler()
{
- public boolean service(HttpServletRequest request,
HttpServletResponse response) throws IOException
+ public boolean service(HttpServletRequest servletRequest,
HttpServletResponse servletResponse)
+ throws IOException
{
- _requestGlobals.store(request, response);
+ _requestGlobals.store(servletRequest, servletResponse);
- return handler.service(new RequestImpl(request), new
ResponseImpl(response));
+ Request request = new RequestImpl(servletRequest);
+ Response response = new ResponseImpl(servletResponse);
+
+ // Transition from the Servlet API-based pipeline, to the
Tapestry-based pipeline.
+
+ return handler.service(request, response);
}
};
@@ -884,8 +906,11 @@
configuration, terminator);
}
- public RequestHandler build(Logger logger, List<RequestFilter>
configuration, @InjectService("MasterDispatcher")
- final Dispatcher masterDispatcher)
+ @Marker(Primary.class)
+ public RequestHandler build(Logger logger, List<RequestFilter>
configuration,
+
+ @Primary
+ final Dispatcher masterDispatcher)
{
RequestHandler terminator = new RequestHandler()
{
@@ -901,7 +926,8 @@
}
public ServletApplicationInitializer build(Logger logger,
List<ServletApplicationInitializerFilter> configuration,
-
@InjectService("ApplicationInitializer")
+
+ @Primary
final ApplicationInitializer
initializer)
{
ServletApplicationInitializer terminator = new
ServletApplicationInitializer()
@@ -1019,6 +1045,7 @@
/**
* Ordered contributions to the MasterDispatcher service allow different
URL matching strategies to occur.
*/
+ @Marker(Primary.class)
public Dispatcher buildMasterDispatcher(List<Dispatcher> configuration)
{
return _chainBuilder.build(Dispatcher.class, configuration);