When you put @Local on a service injection Tapestry looks for a service
match in the local (current) module only. That means you can override,
say, RequestExceptionHandler without having to qualify your injection.
Without @Local:
public static void bind(ServiceBinder binder) {
binder.bind(MyRequestExceptionHandler.class).withId("MyRequestExceptionHandler");
}
public static void
contributeAliasOverride(Configuration<AliasContribution> configuration,
@InjectService("MyRequestExceptionHandler")
RequestExceptionHandler
myRequestExceptionHandler) {
configuration.add(AliasContribution.create(RequestExceptionHandler.class,
myRequestExceptionHandler));
}
With @Local:
public static void bind(ServiceBinder binder) {
binder.bind(MyRequestExceptionHandler.class).withId("MyRequestExceptionHandler");
}
public static void
contributeAliasOverride(Configuration<AliasContribution> configuration,
@Local
RequestExceptionHandler myRequestExceptionHandler) {
configuration.add(AliasContribution.create(RequestExceptionHandler.class,
myRequestExceptionHandler));
}
So it saves you some typing, provided there's only one matching service
in the module.
-Filip
Michael Gerzabek skrev:
Now I don't understand exactly what that means.
In my case I have two modules. Module one ships with an interface and a
default implementation that is preconfigured. As a user of module one,
in my module two, I contributeAlias(..) to override the preconfigured
default implementation. The application as whole will now use the
service configured and 'implemented' in module two.
What would be the usecase of @Local? When I have only one module and
want to override via an AliasContribution ..? Why would I d that?
Howard Lewis Ship schrieb:
Looks good to me too.
I'm working on adding @Local which will make it easier to contribute
Alias contributions that are services from within the same module.
But often you can get by, as you did, with just an instance.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]