Hi,
Am 19.03.2014 18:37, schrieb Mike Grove:
> On Wed, Mar 19, 2014 at 1:32 PM, Philipp Wendler <
m...@philippwendler.de>wrote:
>> Am 19.03.2014 17:20, schrieb Mike Grove:
>>> I'd like to have some default implementation of an interface, and then
>> in a
>>> separate module, provide a new implementation which uses the old one, via
>>> the decorator pattern. And everywhere that should have gotten the
>> default,
>>> gets the overridden one, and the modified behavior.
>>
>> I had the same problem, and developed a solution that I described here:
>>
http://stackoverflow.com/q/7416974/396730
>
>
> Looks promising. Is the source for your annotation & utilities available
> anywhere?
So far no.
I ended up not using it for other reasons, and so I never added tests
etc. and made it available online. I could do so, but it would need some
time I guess.
If you have a hard-coded chain of decorators, you could probably leave
out the most complicated part (which is the overriding of bindings) and
just declare the bindings by hand:
A.class annotatedWith(InInstance(B.class)) to A.class
A.class to B.class
Maybe you need to use a common interface for A and B that is used as the
actual binding, not sure if the above works directly. With an interface
it looks like this:
I.class annotatedWith(InInstance(B.class)) to A.class
I.class to B.class
The InInstance annotation does not contain anything big, it is just a
regular annotation (you can take a look at the implementation of Named).
Greetings,
Philipp