Map storage entity implementations

Skip to first unread message

Hynek Mlnarik

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


Pedro Igor Craveiro e Silva

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
To view this discussion on the web visit

Hynek Mlnarik

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.


Thomas Darimont

Oct 7, 2021, 4:53:30 AMOct 7
to Hynek Mlnarik, Pedro Igor Craveiro e Silva, Keycloak Dev

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

Just for the sake of completeness :)


Pedro Igor Craveiro e Silva

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.

Pedro Igor
Reply all
Reply to author
0 new messages