-
Notifications
You must be signed in to change notification settings - Fork 20
Offering extended configuration #79
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
Conversation
|
This seems fine, but I wonder if it wouldn't be better for the trellis-over-cassandra-app to subclass |
|
You tell me-- I know as much about Dropwizard as I do about playing poker: nothing. Should I close this and try that instead? |
|
Nope, Java's bottom-of-the-barrel variance. |
|
Sorry-- misclick. |
|
A better approach might be to add a @JsonAnySetter
public void set(final String name, final String value) {
internalMap.put(name, value);
}
@JsonAnyGetter
public Map<String, String> any() {
return internalMap;
}That adds a simple extension point for any possible subclasses. |
|
Where is |
|
Yes, it's just some internal field. Call it whatever you'd like. |
|
I'm not much with JSON; what about |
|
I haven't ever used that precise construct with Jackson serializations, but I don't see why it wouldn't work. It should be trivial to set up a test -- just add some additional fields to one of the configuration files in |
|
Didn't work at all, not even with simple So maybe that works for Jackson's semantics, but not for Dropwizard's particular concrete processing code? |
|
Again, I know little about Dropwizard, but I'm beginning to suspect that we're running up against its intentional limits-- it seems to be for building single apps, not ecosystems. Extensible config is really not a concern if you are build a single app. |
|
Hang on-- I had a misconfig in my code. Testing further... |
|
Okay, how's that? |
|
incidentally, I tried going: => but all of the test classes exploded with: Not really sure what's going on there, but I think the issue is that |
|
@ajs6f I tried running the test and it works for me using IntelliJ. One side note is that the |
|
Thanks much @christopher-johnson ! I didn't actually write that test, just added a few limes to it, so I'll let @acoburn remove that annotation. Unless, @acoburn , you'd like me to do it here? |
acoburn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. There are some trivial checkstyle-related issues to be fixed before merging
|
|
||
| import static java.util.Collections.synchronizedMap; | ||
|
|
||
| import java.util.Collections; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't used and can be removed.
|
|
||
| import io.dropwizard.Configuration; | ||
|
|
||
| import static java.util.Collections.synchronizedMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move static imports to the top (before ordinary imports)
| private String baseUrl = null; | ||
|
|
||
| private String resourceLocation = null; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing whitespace
| assertEquals("my.cluster.node", config.any().get("cassandraAddress")); | ||
| assertEquals((Integer)245993, config.any().get("cassandraPort")); | ||
| @SuppressWarnings("unchecked") | ||
| Map<String, Object> extraConfig = (Map<String, Object>) config.any().get("extraConfigValues"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add final here.
| Map<String, Object> extraConfig = (Map<String, Object>) config.any().get("extraConfigValues"); | ||
| assertTrue((Boolean) extraConfig.get("one")); | ||
| @SuppressWarnings("unchecked") | ||
| List<String> list = (List<String>) extraConfig.get("two"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add final
|
I will fix those probs in two seconds, but just so you know-- I ran |
|
That's odd. It could be that running this without |
|
Okay, I'll keep an eye peeled. I might try making a few intentional faux pas and see which Gradle invocations catch them and which do not. |
Adds configuration for use with Trellis-Cassandra.