Shadow Services
Wiki Markup |
---|
{float:right|background=#eee}
{contentbylabel:title=Related Articles|showLabels=false|showSpace=false|space=@self|labels=service-builders}
{float} |
The PropertyShadowBuilder service The ShadowBuilder service (see the PropertyShadowBuilder API) is used to build a special, delegating kind of service implementation .Effectively, it is used to allow that, essentially, allows a property of another service to be exposed as its own service.
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() |
---|
|
|
For example, the tapestry-core module provides a Request property as a shadow of the RequestGlobals service's request property:
Code Block |
---|
|
public Request build()
{
return shadowBuilder.build(requestGlobals, "request", Request.class);
} |
...
This can be thought of as similar to:
Code Block |
---|
|
public Request build()
{
return requestGlobals.getRequest();
} |
...
A typical method is implemented as (approximately):
Code Block |
---|
|
private final RequestGlobals source;
public String getParameter(String name)
{
return source.getRequest().getParameter(name);
} |
That is, the shadow implementation holds onto the target object (in the above example, the RequestGlobals service) and invokes a method on it directly, not using reflection, no differently than you would if you wrote the code yourself.