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

Add Jackson annotations to be able to configure via JSON #16

Open
StFS opened this issue Nov 18, 2013 · 7 comments
Open

Add Jackson annotations to be able to configure via JSON #16

StFS opened this issue Nov 18, 2013 · 7 comments

Comments

@StFS
Copy link
Contributor

StFS commented Nov 18, 2013

I'm looking to use Lyra in the RabbitMQ integration of Druid (http://druid.io/). Druid uses Jackson (https://github.com/FasterXML/jackson) and it would greatly simplify the integration of Lyra if it did as well.

@StFS
Copy link
Contributor Author

StFS commented Nov 18, 2013

I'm looking into creating a pull request with this feature, but I'm new to Jackson so it may take some time. Any pointers and help would be greatly appreciated.

@Srinathc
Copy link

Makes perfect sense. I was trying to do something similar to this. The developer can just declare the hierarchy of connection, channel and associated exchanges and queues in an xml or json format and have the Config and ConnectionOptions generated out of it.

@jhalterman
Copy link
Owner

Feel free to post a better idea of what you think this should look like. My initial thought is that while this sounds cool, it might be out of scope for what Lyra is intended to be. I'd also be hesitant to add Jackson as a Lyra dependency (though there are workarounds for this).

@Srinathc
Copy link

Agree that this is not what Lyra was intended to be. Sometimes, having a lot of dependencies will deter the users from using it. This could as well be a separate wrapper library over Lyra.

If it so turns out that the wrapper library is not too heavy (few classes) we could merge it in. To reduce the dependency set, we could use JAXB (xml support) or just use Jackson as an optional maven dependency.

@StFS
Copy link
Contributor Author

StFS commented Nov 19, 2013

Well, I'm hoping that simply annotating the config classes correctly will enable this functionality. It's not a matter of implementing any code, but to provide Jackson with enough information so that it's able to instantiate the Lyra config from a JSON string.

The cool part is that the annotations do not add a runtime dependency on Jackson, you can run Lyra exactly as before but if you have a system that uses Jackson, it will be able to instantiate Lyra via JSON config files. There is an added dependency in maven but the scope for that is "provided" (and another one for testing only).

I've started my journey and I hope it won't be too long until I have something to show for it. I really hope you'll give it a chance. Having a wrapper library would "work" but it would be very hackish and error prone since most of the config classes in Lyra would have to be overridden for the sole purpose of adding the needed annotations.

@StFS
Copy link
Contributor Author

StFS commented Nov 19, 2013

Here is my first commit:
https://github.com/activitystream/lyra/commit/d34a4de332e91b415c3ff9076485324dd54ce0fc

Basically this enables the Duration class to be instantiated with a JSON file as you can see in the test case.

@jhalterman
Copy link
Owner

You could probably also use a custom Jackson deserializer that calls Duration.of to instantiate Duration objects.

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

3 participants