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

Support for configs polymorphism #14

Closed
andrus opened this issue Jan 19, 2016 · 2 comments
Closed

Support for configs polymorphism #14

andrus opened this issue Jan 19, 2016 · 2 comments
Milestone

Comments

@andrus
Copy link
Contributor

andrus commented Jan 19, 2016

Jackson supports polymorphic type resolution for configuration based on a value of a specific property in YAML (e.g. type: mytype). A supertype (or interface) is annotated with @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "xyz") and concrete subclasses - with @JsonTypeName("abc"). This is great for dynamic configurations where each possible subclass has different set of properties. (E.g. FileAppender vs. ConsoleAppender).

Current workaround is to use Map<String, String> and manually binding properties.

andrus added a commit that referenced this issue Feb 8, 2016
@andrus
Copy link
Contributor Author

andrus commented Feb 8, 2016

Added unit tests. The feature itself is built into Jackson, so not assigning this to any particular release.

@andrus andrus closed this as completed Feb 8, 2016
@andrus
Copy link
Contributor Author

andrus commented Feb 24, 2016

Reopening... Enumerating subclasses with @JsonSubTypes annotation is completely inflexible. Dropwizard has a rather ingenious approach - combining Jackson with ServiceLoader mechanism and a tag interface for all polymorphic factory classes. We should use something similar.

@andrus andrus reopened this Feb 24, 2016
@andrus andrus changed the title Support for configs polimorphism Support for configs polymorphism Feb 24, 2016
@andrus andrus added this to the 0.13 milestone Feb 25, 2016
@andrus andrus closed this as completed Feb 25, 2016
andrus added a commit that referenced this issue Feb 25, 2016
andrus added a commit that referenced this issue Feb 25, 2016
* unit tests for defaults
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