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

Allow convenient addition of custom Converter types against ConfigurableEnvironment / ConfigurablePropertyResolver [SPR-8389] #13036

Closed
spring-projects-issues opened this issue Jun 1, 2011 · 1 comment
Labels
type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Chris Beams opened SPR-8389 and commented

Excerpt from email conversation with Dave Syer:

Incidentally, how can I register
the FooConverter for the above use case?

Good question. You can do it through the Environment API as well. Technically, you can do it at any point in the lifecycle, but it would be most correct to do it pre-refresh(). There is a convenience issue here, in that the ConfigurableEnvironment interface exposes a ConversionService getConversionService(); method, but does not expose a method returning a ConverterRegistry. This means that the user would need to cast:

((ConverterRegistry)env.getConversionService()).addConverter(FooConverter.class);

We can certainly consider making that more convenient.


Attachments:

Referenced from: commits 8227cb6

@spring-projects-issues
Copy link
Collaborator Author

Chris Beams commented

Introduce ConfigurableConversionService interface

Consolidates ConversionService and ConverterRegistry interfaces;
implemented by GenericConversionService.

ConfigurablePropertyResolver#getConversionService now returns this
new type (hence so too does
ConfigurableEnvironment#getConversionService). This allows for
convenient addition / removal of Converter instances from Environment's
existing ConversionService.  For example:

    ConfigurableApplicationContext ctx = new ...
    ConfigurableEnvironment env = ctx.getEnvironment();
    env.getConversionService().addConverter(new FooConverter());

Issue: SPR-8389

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant