Registry Startup

Posted on Mittwoch, 16th Juni, 2010

In web applications it’s often necessary to execute extra logic at application startup. When your application is starting, you might want to schedule a task for one-time or repeated execution. A typical use case is the initialization of the database. Imagine you deliver a demo version of your application to a customer in order to convince him that you did a better job than your competitors. When the customer drops the WAR file into the servlet container, the application should be usable immediately. In this case you might want to create some demo data (e.g. demo accounts with default credentials) at start time.

In Tapestry you can execute some logic at Registry startup by making contributions to the RegistryStartup service configuration. The values contributed are Runnable objects. Here is an example:

public class AppModule {

  public static void contributeRegistryStartup(
         OrderedConfiguration<Runnable> configuration,
         final DatabaseStartup dbStartup) {

      configuration.add("DbStartup", new Runnable() {
         public void run() {
      }, "before:*");

Startup Methods in Tapestry 5.2

In Tapestry 5.2 the way of providing extra logic to be executed at Registry startup has been simplified. Instead of making contributions to the RegistryStartup service configuration you can provide startup methods inside your modules. As you can see in the following example you just annotate an arbitrary module method with @Startup annotation and that’s it. Tapestry will detect these methods and invoke them after the registry has been started.

public class AppModule {

  public static void initApplication(DatabaseStartup dbStartup) {

Note that RegistryStartup service configuration is ordered. Providing the order constraint it’s possible to control in what order the contributions are executed. In contrast the order of startup methods is determined by the alphabetical order of the method names. You should not rely on that. The alphabetical ordering of module methods is a part of the internal API and may be changed in the upcoming releases.


  1. Borut
  2. Igor Drobiazko
  3. Tony Giaccone
  4. Igor Drobiazko



Your name

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Tapestry 5 Blog - Copyright © 2009 - Eclectic Theme by Your Inspiration Web - Powered by WordPress