Map storage entity implementations

18 weergaven
Naar het eerste ongelezen bericht

Hynek Mlnarik

ongelezen,
6 okt 2021, 05:50:4506-10-2021
aan Keycloak Dev
In order to simplify maintenance, base entity implementations in map storage will be generated automatically from interfaces ([1] is prototype for clients). This is beneficial for several reasons:

* There will be no chance for typos
* Thus there will be no maintenance cost
* Entity interfaces will adhere to the same standard on method naming
* Map entities need to be able to copy over their contents regardless of the underlying implementation which is done e.g. in caching. Nowadays, this is done manually, see e.g. [2], and such a cloner can be generated automatically.
* This opens up ability to similarly generate entity delegates which are ultimately needed by e.g. default values and tree storage

--Hynek

Pedro Igor Craveiro e Silva

ongelezen,
6 okt 2021, 08:16:3506-10-2021
aan Hynek Mlnarik, Keycloak Dev
Nice, it should help with a lot of boiler plate code.

Did you consider using jdeparser [1]. I know some projects here have been using it for source code generation.


--
You received this message because you are subscribed to the Google Groups "Keycloak Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keycloak-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/keycloak-dev/CAMvXD%3DFcODuuekCXL4ijnE6fGD%2Bmxg1GPOQHDrKiXOc7US7JtA%40mail.gmail.com.

Hynek Mlnarik

ongelezen,
7 okt 2021, 02:42:4107-10-2021
aan Pedro Igor Craveiro e Silva, Keycloak Dev
Thanks Pedro for the suggestion.

A few frameworks have been considered for the class generation, be it on source or byte-code level -  lombok, autovalue, or bytebuddy to name a few. They have proven to be unnecessarily heavy and also by adding extra dependencies, we'd add an extra maintenance cost.

I missed the jdeparser, and while it seems interesting for some use cases, it fits the same arguments. Good to have it on the radar though, thanks for the reference.

--Hynek


Thomas Darimont

ongelezen,
7 okt 2021, 04:53:3007-10-2021
aan Hynek Mlnarik, Pedro Igor Craveiro e Silva, Keycloak Dev
Hi, 

Another useful an mature library for this is javapoet by square:

Just for the sake of completeness :)

Cheers,
Thomas



Pedro Igor Craveiro e Silva

ongelezen,
7 okt 2021, 07:14:5807-10-2021
aan Hynek Mlnarik, Keycloak Dev
I see.

The main drawback of source code generation is that you are coupled with the project build. On the other hand, generating/transforming byte code should give us more flexibility.

For instance, we could potentially leverage byte-code for generating/transforming code for user extensions. Not sure if it fits here, but if it does it would also fit nicely with the re-augmentation phase in Dist.X. 

But I guess what you are doing does not benefit much from this model because the generated code is only internal and not supposed to change after being distributed.

Regards.
Pedro Igor
Allen beantwoorden
Auteur beantwoorden
Doorsturen
0 nieuwe berichten