This interface contains all the methods that a class must implement to
become an element for the web engine.
For convenience, you can also extend the abstract
Element class
which gives you the benefit of having local access to all its methods and
having no abstract methods to implement.
Elements are the smallest logical building blocks of a RIFE web
application. They are declared in the site structure and when a request
arrives that maps to an element declaration, a new instance of the
implementation is created. Element instances are thus never shared amongst
requests, unless you are into a continuation tree that is set up to not
clone its variable stack. This makes the logic inside elements fully
thread-safe.
The
ElementAware.processElement method is the default entry point and will
be called when a request arrives.
You're free to add any other method to this class. RIFE provides a
convention syntax for methods that are supposed to handle submissions. The
name of the submission is capitalized and the "do " literal is
prepended. RIFE then looks for a method with that name, the public
void modifiers and no arguments. When such a method is found, it is
executed instead of processElement() . Nothing prevents you
however from handling submissions conditionally in the
processElement() method though, without isolating the logic in
a separate method. For example, when a submission arrives with the name "storeUser ",
RIFE will look for the method:
public void doStoreUser()
If it's present, it will be called instead of processElement() .
Often you want to initialize common data structures, both for regular
requests as for submissions. The
ElementSupport.initialize method
can be used for that. It will be the first element's method that is called
in a fully setup element context. When extending
Element , the
easiest is to simply overload the
ElementSupport.initialize method, otherwise an
ElementInitializer has to be registered in the
ElementAware.noticeElement method.
RIFE also supports setter-based dependency injection for element
properties, inputs, global variables and submission parameters. If setter
methods are present that correspond to declared variable names, they will
be automatically invoked with the available values. Of course, you can
always retrieve values through the dedicated ElementSupport methods for
ElementSupport.getProperty properties ,
ElementSupport.getInput inputs and
ElementSupport.getParametersubmission parameters .
author: Geert Bevin (gbevin[remove] at uwyn dot com) version: $Revision: 3634 $ since: 1.0 |