Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make configuration binding serializers generic #130

Open
elandau opened this issue May 19, 2014 · 0 comments
Open

Make configuration binding serializers generic #130

elandau opened this issue May 19, 2014 · 0 comments

Comments

@elandau
Copy link
Contributor

elandau commented May 19, 2014

ConfigurationProvider must currently be extended as new types are supported. A more extensible approach would be to have a generic PropertyBinder interface that can be installed as part of a multibinding. When mapping a configuration the ConfigurationProvider will iterate though the set of PropertyBinder's to determine the most appropriate binder. A new serializer can be added as a new binding without having to modify the ConfigurationProvider interface.

public interface PropertyBinder {
}

public class BinderModule extends BootstrapModule {
    public void configure(BootstrapBinder binder) {
        Multibinder<PropertyBinder> binders = Multibinder.newSetBinder(binder, PropertyBinder.class)
        binders.addBinding().to(StringPropertyBinder.class);
        binders.addBinding().to(DoublePropertyBinder.class);
        binders.addBinding().to(PropertiesPropertyBinder.class);
        binders.addBinding().to(ObjectPropertyBinder.class);
        binders.addBinding().to(IntegerPropertyBinder.class);
        binders.addBinding().to(BooleanPropertyBinder.class);
        binders.addBinding().to(InjectingPropertyBinder.class);
        ....
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant