Blogs : Archives
|
|
| < Java standards complient HTML component hoax | Bytecode generation rocks > |
|
Below are the highlights of this release.
Purging authentication is now the default approachThe shipped authentication elements used a naming scheme that made the automated purging of outdated authentication sessions available through a specialized name. We noticed that people therefore never really looked further and used unpurged authentication schemes without realizing that purging has to be setup independently in that case. The element declarations have thus been renamed like this: rife/authenticated/database.xml becomes=> rife/authenticated/databaseunpurged.xml rife/authenticated/memory.xml becomes=> rife/authenticated/memoryunpurged.xml rife/authenticated/mixed.xml becomes=> rife/authenticated/mixedunpurged.xml rife/authenticated/databasepurging.xml becomes=> rife/authenticated/database.xml rife/authenticated/memorypurging.xml becomes=> rife/authenticated/memory.xml rife/authenticated/mixedpurging.xml becomes=> rife/authenticated/mixed.xml People that have been consciously using unpurged authentication have to change the names of the element declarations; and those that did it without knowing should do nothing. They will be using purging back-ends from now on without having to change anything. Major and incompatible changes to 'call' continuationsContinuations that used the Initially this seemed
like a good idea, but in practise it means that existing elements all have
to be rewritten to explicitly keep a continuation going by using
The automatic answer at the
end of For clarity, the simplest
possible public class Caller extends Element
{
public void processElement()
{
call("exit_to_callee");
}
}public class Callee extends Element
{
public void processElement()
{
answer();
}
}Support for URL localizationLocalizing content with RIFE is already very versatile, but it's not sufficient to create fully translated versions of applications. URLs are an important part of your web application and make it possible for people to remember and access distinct locations directly. The site structure has thus been extended to allow the usage of different URLs according to the default localization language. The default
localization language is ' Instead of regular URLs, you can now use the following definition in your site structure, for example: <element id="ROOT" file="root.xml" url="fr:/racine,nl:/wortel,/root"/> This will result in the following behaviour:
Template type-specific default resource bundlesWhen localizing an application, it's common practice to use a few resourcebundles that are shared by the whole application. Since it's tedious to have to explicitely add them to all the templates that are instantiated, and since sometimes templates are automatically instantiated by reusable elements, it's handy to be able to setup a collection of default resource bundles. You set this up in your configuration file and it's specific for each template factory type. The latter is important since it makes no sense to add content resource bundles to all SQL templates or Java templates. For example: <list name="TEMPLATE_DEFAULT_RESOURCEBUNDLES_ENGINEHTML">
<item>l10n/graphics</item>
<item>l10n/text</item>
</list>will result in executing the following Java code after
the instantiation of each template.addResourceBundle(Localization.getResourceBundle("l10n/graphics"));
template.addResourceBundle(Localization.getResourceBundle("l10n/text"));Alternate localization methodWhile resource bundles offer a good method to isolate
localized text snippets, it's sometimes interesting to be able to
conditionally display parts of templates with lots of markup. For this
purpose, resource bundles are actually awkward to use. Templates are
therefore now able to set blocks automatically to values, according to the
default localization language ( For example: <!--V 'LANG:value1'-->default<!--/V--> [!V 'LANG:value2'/] <!--B 'LANG:value1:nl'-->ja ja<!--/B--> [!B 'LANG:value2:fr']oui oui[!/B] [!B 'LANG:value2:en ']yes yes[!/B] will display this when the default
language is ' default yes yes or this when
the default language is ' default oui oui or
this when the default language is ' ja ja [!V 'LANG:value2'/] Deferred validation initializationBefore, it was recommended to initialize the static
bean validation rules and constraints in the default constructor of the
bean so that they were always available when needed. With large
collections of beans with a complex validation rules setup, this however
creates quite a performance and memory overhead. Therefore, you can now
optionally move all your validation initialization logic to the dedicated
It's thus recommended to transform this: public class Credentials extends Validation
{
private String mLogin = null;
private String mPassword = null;
private String mLanguage = null;
public Credentials()
{
addConstraint(new ConstrainedProperty("login").maxLength(6).notNull(true));
addConstraint(new ConstrainedProperty("password").maxLength(8).notNull(true));
addConstraint(new ConstrainedProperty("language").notNull(true));
}
/* ... accessors ... */
}into this: public class Credentials extends Validation
{
private String mLogin = null;
private String mPassword = null;
private String mLanguage = null;
public Credentials()
{
}
protected void activateValidation()
{
addConstraint(new ConstrainedProperty("login").maxLength(6).notNull(true));
addConstraint(new ConstrainedProperty("password").maxLength(8).notNull(true));
addConstraint(new ConstrainedProperty("language").notNull(true));
}
/* ... accessors ... */
}Support for more constraintsTwo new constraints have been added to the constraints facility: displayedRaw This indicates that the value of the property should be displayed as-is when it's being output. No encoding or transformation will be performed. A typical use of this is when you allow administrators to write HTML snippets, you don't want the actual HTML tags to be encoded and the source code to be displayed. Instead, you want to output the submitted data exactly as it was entered so that all HTML formatting does its usual work.By default, this is set to
editable This indicates that the value of the property can't be changed or edited by a user. A typical use of this is when you have a bean with a number of properties that should be filled in directly through a form, but with some other properties that are not allowed to be modified by the user (id, modification date, ...). If you use submission beans or input beans, you only want the application to accept values for the properties that can be edited and not for the others. Like this, you're sure that no malicious or accidental outside data modification can occur. By default, this is
set to Embedded element definitions can now provide valuesWhen embedding elements in templates, you can now access the default value from within the embedded elements. This is handy when you have modular embedded elements that have to be setup for different uses when they are inserted in the templates. For example, consider this template snippet: The element "<!--V 'ELEMENT:.SIMPLE'-->this is the value<!--/V-->" is being embedded. Inside
the SIMPLE element's implementation, you can now use the
this is the value Reworked database transactionsThe If you need to explicitly roll
back an active transaction, use the Since you sometimes use a transaction
without being interested in returning a result, you can use the
It's recommended to always use
transactions through the For example: final Insert insert = new Insert(mDatasource).into("valuelist").field("value", 232);
final DbQueryManager manager = new DbQueryManager(datasource);
manager.inTransaction(new DbTransactionUserWithoutResult() {
public void useTransactionWithoutResult()
throws InnerClassException
{
manager.executeUpdate(insert);
manager.executeUpdate(insert);
}
});
You can throw regular exceptions inside the transaction with the
Alternate site structure and element declaration methodsElement declarations and site structures have
up to now always been defined in one fixed XML format. A first step has
been made to enable the transparent integration of other declaration
methods. Each declaration method is identified through a unique identifier
which allows you to mix them freely. This identifier can be added in front
of the declaration name of the element or site (the file attribute in the
XML format). If no identifier is added, it defaults to the
' Here is a small example of how to declare an entire site structure with all the elements in Java only. You'll see this is the same as what's done by the 4 XML files in the basic numberguess example. /*
* file: src/tutorial/numberguess/Site.java
*/
package tutorial.numberguess;
import com.uwyn.rife.engine.SiteBuilder;
import com.uwyn.rife.rep.BlockingParticipant;
public class Site extends BlockingParticipant
{
private Object mSite = null;
protected void initialize()
{
SiteBuilder builder = new SiteBuilder("manual:numberguess", getResourceFinder());
builder
.setArrival("START")
.enterElement("manual:START")
.setImplementation("tutorial.numberguess.Start")
.setUrl("/start")
.addInput("gameid")
.addExit("started")
.addOutput("gameid")
.addFlowLink("started", "GUESS")
.addDataLink("gameid", "GUESS", "gameid")
.leaveElement()
.enterElement("manual:GUESS")
.setImplementation("tutorial.numberguess.Guess")
.setUrl("/guess")
.addInput("gameid")
.enterSubmission("perform_guess")
.addParameter("guess")
.leaveSubmission()
.addExit("start")
.addExit("success")
.addOutput("gameid")
.addFlowLink("start", "START")
.addDataLink("gameid", "START", "gameid")
.addFlowLink("success", "SUCCESS")
.addDataLink("gameid", "SUCCESS", "gameid")
.leaveElement()
.enterElement("manual:SUCCESS")
.setImplementation("tutorial.numberguess.Success")
.addInput("gameid")
.addExit("start")
.addFlowLink("start", "GUESS")
.leaveElement();
mSite = builder.getSite();
}
protected Object _getObject(Object key)
{
return mSite;
}
}<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
- file: classes/rep/participants.xml
-->
<!DOCTYPE rep SYSTEM "/dtd/rep.dtd">
<rep>
<participant name="ParticipantSite">tutorial.numberguess.Site</participant>
</rep>Major speed optimizationsSeveral areas of the framework have been profiled and reworked to get much better speed. Most notably, many standard collections that store primitives have been replaced by their primitive counterparts of PCJ (Primitive Collections for Java) and the StringUtils.encode* methods have been rewritten to get a 5x better encoding speed (which should affect almost all web applications). |
Comments |
Add a new comment |
| Comments on this blog entry have been closed. |
| < Java standards complient HTML component hoax | Bytecode generation rocks > |


