leafgray wrote:
嗯
我试了一下,没能出现二楼所说的效果.
我不论改了什么东西,都要redeploy一下才能看到效果.
.......
怪小的没有说清楚,分析一下Tapestry source code你就明白原因何在了?
package org.apache.tapestry.engine;
import java.io.Externalizable;
import ...
public abstract class AbstractEngine
implements IEngine, IEngineServiceView, Externalizable, HttpSessionBindingListener
{
...
/**
* If true (set from JVM system parameter
* <code>org.apache.tapestry.enable-reset-service</code>
* then the reset service will be enabled, allowing
* the cache of pages, specifications and template
* to be cleared on demand.
*
**/
private static final boolean _resetServiceEnabled =
Boolean.getBoolean("org.apache.tapestry.enable-reset-service");
/**
* If true (set from the JVM system parameter
* <code>org.apache.tapestry.disable-caching</code>
* then the cache of pages, specifications and template
* will be cleared after each request.
*
**/
private static final boolean _disableCaching =
Boolean.getBoolean("org.apache.tapestry.disable-caching");
.....................................................................................
/**
* Returns true if the reset service is curently enabled.
*
**/
public boolean isResetServiceEnabled()
{
return _resetServiceEnabled;
}
.........................................................................................
/**
* Delegate method for the servlet. Services the request.
*
**/
public boolean service(RequestContext context) throws ServletException, IOException
{
ApplicationServlet servlet = context.getServlet();
IRequestCycle cycle = null;
ResponseOutputStream output = null;
IMonitor monitor = null;
if (LOG.isDebugEnabled())
LOG.debug("Begin service " + context.getRequestURI());
if (_specification == null)
_specification = servlet.getApplicationSpecification();
// The servlet invokes setLocale() before invoking service(). We want
// to ignore that setLocale() ... that is, not force a cookie to be
// written.
_localeChanged = false;
if (_resolver == null)
_resolver = servlet.getResourceResolver();
try
{
setupForRequest(context);
monitor = getMonitor(context);
output = new ResponseOutputStream(context.getResponse());
}
catch (Exception ex)
{
reportException(Tapestry.getMessage("AbstractEngine.unable-to-begin-request"), ex);
throw new ServletException(ex.getMessage(), ex);
}
IEngineService service = null;
try
{
try
{
String serviceName;
try
{
serviceName = extractServiceName(context);
if (Tapestry.isBlank(serviceName))
serviceName = Tapestry.HOME_SERVICE;
// Must have a service to create the request cycle.
// Must have a request cycle to report an exception.
service = getService(serviceName);
}
catch (Exception ex)
{
service = getService(Tapestry.HOME_SERVICE);
cycle = createRequestCycle(context, service, monitor);
throw ex;
}
cycle = createRequestCycle(context, service, monitor);
monitor.serviceBegin(serviceName, context.getRequestURI());
// Invoke the service, which returns true if it may have changed
// the state of the engine (most do return true).
service.service(this, cycle, output);
// Return true only if the engine is actually dirty. This cuts down
// on the number of times the engine is stored into the
// session unceccesarily.
return _dirty;
}
catch (PageRedirectException ex)
{
handlePageRedirectException(ex, cycle, output);
}
catch (RedirectException ex)
{
handleRedirectException(cycle, ex);
}
catch (StaleLinkException ex)
{
handleStaleLinkException(ex, cycle, output);
}
catch (StaleSessionException ex)
{
handleStaleSessionException(ex, cycle, output);
}
}
catch (Exception ex)
{
monitor.serviceException(ex);
// Discard any output (if possible). If output has already been sent to
// the client, then things get dicey. Note that this block
// gets activated if the StaleLink or StaleSession pages throws
// any kind of exception.
// Attempt to switch to the exception page. However, this may itself fail
// for a number of reasons, in which case a ServletException is thrown.
output.reset();
if (LOG.isDebugEnabled())
LOG.debug("Uncaught exception", ex);
activateExceptionPage(cycle, output, ex);
}
finally
{
if (service != null)
monitor.serviceEnd(service.getName());
try
{
cycle.cleanup();
// Closing the buffered output closes the underlying stream as well.
if (output != null)
output.forceFlush();
cleanupAfterRequest(cycle);
}
catch (Exception ex)
{
reportException(Tapestry.getMessage("AbstractEngine.exception-during-cleanup"), ex);
}
if (_disableCaching)
{
try
{
clearCachedData();
}
catch (Exception ex)
{
reportException(
Tapestry.getMessage("AbstractEngine.exception-during-cache-clear"),
ex);
}
}
if (LOG.isDebugEnabled())
LOG.debug("End service");
}
return _dirty;
}
..........................................................................................
/**
* Discards all cached pages, component specifications and templates.
* Subclasses who override this method should invoke this implementation
* as well.
*
* @since 1.0.1
*
**/
public void clearCachedData()
{
_pool.clear();
_pageSource.reset();
_specificationSource.reset();
_templateSource.reset();
_scriptSource.reset();
_stringsSource.reset();
_enhancer.reset();
}
}