Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Scrollbar

...

The StrategyBuilder Service provides a convenient way to create an implementation of the Strategy design pattern.

Div
stylefloat:right
titleRelated Articles
classaui-label
Content by Label
showLabelsfalse
showSpacefalse
titleRelated Articles
cqllabel = "service-builders" and space = currentSpace()

Strategy Pattern

Wiki Markup
{float:right|background=#eee} {contentbylabel:title=Related Articles|showLabels=false|showSpace=false|space=@self|labels=service-builders} {float}

Another of the Gang Of Four patterns, the strategy pattern as implemented in Tapestry IoC is a kind of late binding.

...

The StrategyBuilder service (API) creates a service implementation around a strategy registry.

Code Block
java
java

public interface StrategyBuilder
{
    <S> S build(StrategyRegistry<S> registry);
}

...

You convert the configuration into a StrategyRegistry, and use that to build the final service:

{scrollbar}
Code Block
java
java

  public static MyStrategyService build(Map<Class, MyStrategyService> configuration,
    @InjectService("StrategyBuilder")
    StrategyBuilder builder)
  {
     StategyRegistry<MyStrategyService> registry = StrategyRegistry.newInstance(MyStrategyService.class, configuration);
  
     return builder.build(registry);
  }
Wiki Markup

 

Scrollbar