Map storage entity implementations

14 views
Skip to first unread message

Hynek Mlnarik

unread,
Oct 6, 2021, 5:50:45 AMOct 6
to 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

unread,
Oct 6, 2021, 8:16:35 AMOct 6
to 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

unread,
Oct 7, 2021, 2:42:41 AMOct 7
to 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

unread,
Oct 7, 2021, 4:53:30 AMOct 7
to 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

unread,
Oct 7, 2021, 7:14:58 AMOct 7
to 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
Reply all
Reply to author
Forward
0 new messages