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

Microprofile Config Support #1106

Open
alexander-dammeier opened this issue Oct 13, 2019 · 4 comments
Open

Microprofile Config Support #1106

alexander-dammeier opened this issue Oct 13, 2019 · 4 comments

Comments

@alexander-dammeier
Copy link

alexander-dammeier commented Oct 13, 2019

Hi,

i am using Eclipse Microprofile Config API on Payara Micro 5.193.1 with OpenJDK11 and i tried to load json objects from my configuration file and let them automatically parse to my immutable.org type. Because of the missing converter it throws an exception.
Since there is already a json integration and even a jax-rs integration, I would be very happy if there would be an integration for Eclipse Microprofile Config API too.

expected outcome

The following injection will automatically parse my configvalue to MyEntity.

APIEndpoint.java:

@Inject
@ConfigProperty(name="de.dammeier.immutables.mpconfigrequest.initentity")
MyEntity entity;

META-INF/microprofile-config.properties

de.dammeier.immutables.mpconfigrequest.initentity={"failures":[],"on":false}

Reproducer

I created a minimal reproducer for this with a simple converter using immutables.org´s gson integration. There is also a little REST-API to get the entity.

The reproducer is based on the official documentation(page 11) of the eclipse microprofile Config API.

There is one little problem left with my code. The boolean value is always parsed as false by gson. This seems to be a known problem.

@elucash
Copy link
Member

elucash commented Oct 19, 2019

Can it be related to the wrong json syntax in properties file, i.e. capitalized true True?

de.dammeier.immutables.mpconfigrequest.initentity={"active":True,"items":["a", "b", "c"]}

If you absolutely must have uppercase or other custom boolean, you can add type adapter to GsonBuilder which can do it your way. But then for primitives it might not work so Boolean wrapper types might be necessary as much as I against wrapper types in general, but here it can trigger request to custom adapter, not so much for primitive.

@alexander-dammeier
Copy link
Author

oh, the capitalized true was a test which was committed accidential to the reproducer. My first attempt was with an lowercase true but it also didnt work. But this is not the reason why i opened the issue.
I hope for an integration of microprofile specs into immutables.org if microprofile can be found in classpath or something similar. The reproducer is the simpliest way to implement this and thats the main reason i uploaded it for you. Its not highly complicated but it would create new possibilities for all users of microprofile.
I think Immutables are a key feature for microservices in general, so i love to combine your framework with microprofile but i strumbled over this little problem with mp-config (and some others as well).

@jeusdi
Copy link

jeusdi commented Dec 3, 2019

@alexander-dammeier You commented there is an jax-rs integretation. does it mean I'm able to receive all my forms on my jaxrs method? Could you provide me any helping snippet code over there or documentation?

@elucash
Copy link
Member

elucash commented Dec 3, 2019

@jeusdi Immutables have an implementation of GsonMessageBodyProvider for reading request - response bodies as JSON. AFAIK it will not work for forms as it works for "beans/pojos" annotated with @BeanParam (with nested @FormParam etc). I've been far from this stuff in a while so, probably, don't know precisely how that can be integrated

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

No branches or pull requests

3 participants