AppModule Class Reference

This module is automatically included as part of the Tapestry IoC Registry, it's a good place to configure and extend Tapestry, or to place your own service definitions. More...

List of all members.


Public Member Functions

void contributeHibernateSessionSource (Configuration< String > cfg)
RequestFilter buildTimingFilter (final Log log)
 This is a service definition, the service will be named "TimingFilter".
void contributeRequestHandler (OrderedConfiguration< RequestFilter > configuration,@InjectService("TimingFilter") RequestFilter filter)
 This is a contribution to the RequestHandler service configuration.

Static Public Member Functions

static void contributeApplicationDefaults (MappedConfiguration< String, String > configuration)

Detailed Description

This module is automatically included as part of the Tapestry IoC Registry, it's a good place to configure and extend Tapestry, or to place your own service definitions.

Definition at line 20 of file AppModule.java.


Member Function Documentation

void contributeHibernateSessionSource ( Configuration< String >  cfg  ) 

Definition at line 23 of file AppModule.java.

00023                                                                             {
00024         cfg.add("cedar.hepdata.model");
00025     }

static void contributeApplicationDefaults ( MappedConfiguration< String, String >  configuration  )  [static]

Definition at line 40 of file AppModule.java.

00042     {
00043         // Contributions to ApplicationDefaults will override any contributions to
00044         // FactoryDefaults (with the same key). Here we're restricting the supported
00045         // locales to just "en" (English). As you add localised message catalogs and other assets,
00046         // you can extend this list of locales (it's a comma seperated series of locale names;
00047         // the first locale name is the default when there's no reasonable match).
00048 
00049         configuration.add("tapestry.supported-locales", "en");
00050     }

RequestFilter buildTimingFilter ( final Log  log  ) 

This is a service definition, the service will be named "TimingFilter".

The interface, RequestFilter, is used within the RequestHandler service pipeline, which is built from the RequestHandler service configuration. Tapestry IoC is responsible for passing in an appropriate Log instance. Requests for static resources are handled at a higher level, so this filter will only be invoked for Tapestry related requests.

Service builder methods are useful when the implementation is inline as an inner class (as here) or require some other kind of special initialization. In most cases, use the static bind() method instead.

If this method was named "build", then the service id would be taken from the service interface and would be "RequestFilter". Since Tapestry already defines a service named "RequestFilter" we use an explicit service id that we can reference inside the contribution method.

Definition at line 71 of file AppModule.java.

00072     {
00073         return new RequestFilter()
00074         {
00075             public boolean service(Request request, Response response, RequestHandler handler)
00076                     throws IOException
00077             {
00078                 long startTime = System.currentTimeMillis();
00079 
00080                 try
00081                 {
00082                     // The reponsibility of a filter is to invoke the corresponding method
00083                     // in the handler. When you chain multiple filters together, each filter
00084                     // received a handler that is a bridge to the next filter.
00085 
00086                     return handler.service(request, response);
00087                 }
00088                 finally
00089                 {
00090                     long elapsed = System.currentTimeMillis() - startTime;
00091 
00092                     log.info(String.format("Request time: %d ms", elapsed));
00093                 }
00094             }
00095         };
00096     }

void contributeRequestHandler ( OrderedConfiguration< RequestFilter >  configuration,
@InjectService("TimingFilter") RequestFilter  filter 
)

This is a contribution to the RequestHandler service configuration.

This is how we extend Tapestry using the timing filter. A common use for this kind of filter is transaction management or security.

Definition at line 103 of file AppModule.java.

00106     {
00107         // Each contribution to an ordered configuration has a name, When necessary, you may
00108         // set constraints to precisely control the invocation order of the contributed filter
00109         // within the pipeline.
00110 
00111         configuration.add("Timing", filter);
00112     }


The documentation for this class was generated from the following file:


Generated on Tue Apr 21 15:55:06 2009 for HepData Web servlets by  doxygen 1.5.5