Turbine

Friday January 08, 2016

Using annotations in Turbine 4

The Milestone 2 release of Turbine 4 has added support for dependency injection into modules and valves using annotations. This can simplify your code a lot. Consider a screen template thats uses some Turbine service:

...
protected void doBuildTemplate(RunData data, Context context)
{
    // Get service instance
    MyService myservice = (MyService) TurbineServices
      .getInstance().getService(MyService.SERVICE_NAME);

    // do something
    myservice.doSomething(...)
    ... 
}

Looks a bit complicated, doesn't it? Now with Turbine annotations, you simply do

...
@TurbineService
private MyService myservice;

protected void doBuildTemplate(RunData data, Context context)
{
    // do something
    myservice.doSomething(...)
    ... 
}

In addition to services, the annotations @TurbineConfiguration and @TurbineLoader inject instances of the Turbine configuration or subsets of it and the Assembler loaders for a certain page, screen or action.

See the 

 for the documentation of these features.

Comments:

Post a Comment:
Comments are closed for this entry.

Calendar

Search

Hot Blogs (today's hits)

Tag Cloud

Categories

Feeds

Links

Navigation