...
...
The StrategyBuilder Service provides a convenient way to create an implementation of the Strategy design pattern.
Div |
---|
style | float:right |
---|
title | Related Articles |
---|
class | aui-label |
---|
|
Content by Label |
---|
showLabels | false |
---|
showSpace | false |
---|
title | Related Articles |
---|
cql | label = "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 |
---|
|
public interface StrategyBuilder
{
<S> S build(StrategyRegistry<S> registry);
} |
...
You convert the configuration into a StrategyRegistry, and use that to build the final service:
Code Block |
---|
|
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}