Tapestry 5.2.0 represents nearly a year of work past the prior stable release, 5.1.0.5. For the most part, the upgrade is quite straight forward, but please
read the notes below carefully.
Live Service Reloading
Tapestry 5.2.0 extends Tapestry's concept of live reloading of Java code into the service layer. In most cases, service implementations of your
application will now live reload, seamlessly. See the FAQ for some additional notes about live reloading.
Pages No Longer Pooled
This is a huge change from Tapestry 5.1 to 5.2; Tapestry no longer pools page instances. It creates one instance of each page (per supported
locale). Tapestry rewrites your component classes so that all mutable state is stored in a per-thread HashMap. This will greatly reduce Tapestry's
memory footprint, especially on heavily loaded sites.
This change makes it easier to share objects between threads, which is problematic when the objects are not thread-safe. For example:
Code Block | ||
---|---|---|
| ||
@Inject
private Locale locale;
private final DateFormat format = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
public String getCurrentTimeFormatted()
{
return format.format(new Date());
}
|
In the above code, under 5.1, the DateFormat object was not shared between threads, as each thread would operate with
a different instance of the containing page. Under 5.2, the final field will be shared across threads, which is problematic
as DateFormat is not thread safe. The code should be rewritten as:
Code Block | ||
---|---|---|
| ||
@Inject
private Locale locale;
public String getCurrentTimeFormatted()
{
DateFormat format = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
return format.format(new Date());
}
|
Service Id Injection
In prior releases of Tapestry, a constructor parameter of type String was assumed to be the service id.
In the many cases where these was not the case (such as using the @Value or @Symbol annotation), the parameter
needed to be annotated with the @Inject annotation.
...