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

Improve extensibility of model server formats and codecs #60

Closed
martin-fleck-at opened this issue Jan 12, 2021 · 3 comments
Closed

Improve extensibility of model server formats and codecs #60

martin-fleck-at opened this issue Jan 12, 2021 · 3 comments

Comments

@martin-fleck-at
Copy link
Contributor

martin-fleck-at commented Jan 12, 2021

As reported on Spectrum, the model server does not provide any way to add custom codecs or replace existing ones. The main reason for this is that we have a single Codecs class that has the two by-default supported formats (XMI, JSON) hard-coded.

The goal of this task it to improve on that situation by allowing the user to register/bind new codecs or replace existing ones.

As a suggestion: Make the codecs configurable with DI:

  • Support binding codecs using their interface in the the ModelServerModule. For this the interface could be enhanced with the extension/format the codec handles and a priority if necessary. It should be easily possible to register multiple codecs. The DefaultModelServerModule should at least bind the two default codecs.
  • Add a binding for a manager (CompoundCodec, CodecManager or something similar) that reads out the list of bound codecs and offers query methods similar to what the Codecs class offers now. The manager is then injected where necessary but might also be overwritten/rebound in a custom module.
@vhemery
Copy link
Contributor

vhemery commented Jan 12, 2021

In the submitted PR, the Codecs class keeps a backward compatibility, because I am afraid it may be used by Model Server users.
So I've kept the Codecs class and do not offer the possibility to easily override it.

The codecs and formats can be easily overridden in ModelServerModule with a map, and also a String for telling the preferred format. (explained in javadoc)

The Codecs manager class is now intended to be injected, and its default constructor is now deprecated, only kept for legacy behavior.

I, Vincent HEMERY, have the authorization of my employer, CS GROUP, to make this contribution under the appropriate licenses conditions.

Note I have updated impacted tests as far as I could tell they needed. There may be additional test updates needed which didn't work before in my environment, but I think I'm missing some information here...

martin-fleck-at pushed a commit that referenced this issue Jan 15, 2021
* Improve extensibility of model server formats and codecs #60

Use Map binding for codecs and format. Also give the possibility to
specify a preferred format (json by default).
The Model Server Client now has overrideable methods so that it can
change the accepteable formats when necessary.
Changes review : let user the possibility to override Codecs
implementation.

Signed-off-by: vhemery <vincent.hemery@csgroup.eu>
@martin-fleck-at
Copy link
Contributor Author

Thank you for your change, I merged it and we can consider this issue closed.

@vhemery
Copy link
Contributor

vhemery commented Jan 15, 2021

Thank you @martin-fleck-at for your implication and open-minded spirit.

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

2 participants