Topic: Tapestry开发的一个问题.

  Print this page

1.Tapestry开发的一个问题. Copy to clipboard
Posted by: leafgray
Posted on: 2004-08-10 11:50

有谁在Tapestry开发中,使用JUnit作过测试?

大虾都来介绍的经验吧.....

要是每改一点,发布一次...
估计会很痛苦.

谢谢!

2.Re:Tapestry开发的一个问题. [Re: leafgray] Copy to clipboard
Posted by: lcwling
Posted on: 2004-08-10 12:05

如果你更改只是Template或配置文档,就无需要重新发布,但记得一定要在Eclipse中首选项中选择修改时build,如果是修改Java File 则必须要Redeploy webapp,不过,你可以写一个ant target来Redeploy,不必要重新启动weblogic

3.Re:Tapestry开发的一个问题. [Re: leafgray] Copy to clipboard
Posted by: leafgray
Posted on: 2004-08-10 12:47

谢谢楼上的经验分享......

调试用的tomcat.Smile

4.Re:Tapestry开发的一个问题. [Re: leafgray] Copy to clipboard
Posted by: leafgray
Posted on: 2004-08-11 15:25



我试了一下,没能出现二楼所说的效果.

我不论改了什么东西,都要redeploy一下才能看到效果.
.......

Sad

5.Re:Tapestry开发的一个问题. [Re: leafgray] Copy to clipboard
Posted by: lcwling
Posted on: 2004-08-13 14:49

leafgray wrote:


我试了一下,没能出现二楼所说的效果.

我不论改了什么东西,都要redeploy一下才能看到效果.
.......

Sad


怪小的没有说清楚,分析一下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>Wink
* 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>Wink
* 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();
}
}

6.Re:Tapestry开发的一个问题. [Re: leafgray] Copy to clipboard
Posted by: leafgray
Posted on: 2004-08-13 16:10

在FAQ上有这么一个Q&A:

2.13. I have to restart my application to pick up changes to specifications and templates, how can I avoid this?
Start your servlet container with the JVM system parameter org.apache.tapestry.disable-caching set to true, i.e., -Dorg.apache.tapestry.disable-caching=true.

Tapestry will discard cached specifications and templates after each request. You application will run a bit slower, but changes to templates and specifications will show up immediately. This also tests that you are persisting server-side state correctly.

我用tomcat就startup -Dorg........

可还是没效果,也不知道那没对,还是理解的问题.....
Tapestry现在的人气好像还不是很高....
Sad
努力学习中.......

7.Re:Tapestry开发的一个问题. [Re: leafgray] Copy to clipboard
Posted by: lcwling
Posted on: 2004-08-13 16:56

leafgray wrote:
在FAQ上有这么一个Q&A:

2.13. I have to restart my application to pick up changes to specifications and templates, how can I avoid this?
Start your servlet container with the JVM system parameter org.apache.tapestry.disable-caching set to true, i.e., -Dorg.apache.tapestry.disable-caching=true.

Tapestry will discard cached specifications and templates after each request. You application will run a bit slower, but changes to templates and specifications will show up immediately. This also tests that you are persisting server-side state correctly.

我用tomcat就startup -Dorg........

可还是没效果,也不知道那没对,还是理解的问题.....
Tapestry现在的人气好像还不是很高....
Sad
努力学习中.......


其实分析上面的sourcecode,有两种方式是可以回答这个问题:
JVM para:
1.-Dorg.apache.tapestry.disable-caching=true
2.-Dorg.apache.tapestry.enable-reset-service=true
归根到底都是一样的,即cache enabled?
方式一的好处就如上面所述的一样:changes to templates and specifications will show up immediately,不足就是:页面每次show都会Reinstance
方式二,好出就是pool,麻烦就是changes,需要你reset service,比如:
http://localhost:7001/webapp/app?service=reset/Footer

以上,小的均测试过一遍

8.Re:Tapestry开发的一个问题. [Re: leafgray] Copy to clipboard
Posted by: leafgray
Posted on: 2004-08-18 15:49

受教了!

谢谢......

哪个论坛上,讨论Tapestry的人比较多呢?

看英文多了还是有点晕啊......
总觉得进步比较的慢.....

Sad


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923