Wiki Markup |
---|
{scrollbar} |
Object Providers
When you don't provide the @InjectService annotation on a parameter (to a service builder method or constructor), Tapestry will resolve the parameter automatically.
...
The Value annotation allows a literal value to be injected. When combined with symbols, they represent a way for parts of the overall service network to be spot-configured. For example:
Code Block | ||||
---|---|---|---|---|
| ||||
public MyService build(@Value("${max-seconds}") long maxSeconds)
{
return new MyServiceImpl(maxSeconds);
} |
...
This is closely related to the @Value annotation approach, except that the annotation directly specifies a symbol name.
Code Block | ||||
---|---|---|---|---|
| ||||
public MyService build(@Symbol("max-seconds") long maxSeconds)
{
return new MyServiceImpl(maxSeconds);
} |
...
Example:
Code Block | ||||
---|---|---|---|---|
| ||||
public void contributeMasterObjectProvider(OrderedConfiguration<ObjectProvider> configuration)
{
configuration.add("MyObject", new MyObjectProvider());
} |
...
Of course, this is a simplified example. In a real scenario, the provider is most likely a service with its own dependencies.
Wiki Markup |
---|
{scrollbar} |