I'm building a service MasterFooProvider that takes contributions of type
FooProvider. I'd really love for one my FooProvider implementations,
ConfigurableFooProvider, to be able to take contributions of its own (of
type String), so its behavior can be customized.

My first stab at implementing this failed.

I made ConfigurableFooProvider a concrete class that implements FooProvider,
and I tried annotating it the class (not interface) with
@UsesConfiguration(String.class). Its constructor takes a List<String>param.

In my AppModule, I have:

contributeMasterFooProvider() ( OrderedConfiguration<FooProvider> config) {
    config.addInstance("ConfigurableFoo", ConfigurableFooProvider.class);
}

What wound up happening is that Tapestry fails to build MasterFooProvider
with an exception saying that a contribution of type
ConfigurableFooProvider is invalid, because MasterFooProvider expects
contributions of type String.

So I'm pretty sure one misstep I took was trying to make contributions to
an impl instead of an interface, but it's not clear to me if it would work.

To make matters more complicated, I have the need to sub-class
ConfigurableFooProvider, and I don't want the derived classes to share
configuration. In other words, I want to be able to configure/contribute to
each sub-class separately.

Is there a way to do what I'd like to do here, or do I need to change my
approach to making a configurable FooProvider?



John

Reply via email to