Skip to content

Instantly share code, notes, and snippets.

@AdamBien
Last active December 3, 2023 12:57
Show Gist options
  • Save AdamBien/24c8c38937cfa43c25676076c231896c to your computer and use it in GitHub Desktop.
Save AdamBien/24c8c38937cfa43c25676076c231896c to your computer and use it in GitHub Desktop.
117thAirhacksQ&A.md

Ask questions and see you at December, 3rd (Sunday this time, collides with: https://www.meetup.com/airhacks/events/297554282/) 8 pm CET: youtube.com/c/bienadam

Also checkout recent episode:

116th airhacks.tv

Please keep the questions as short and as concise as only possible. Feel free to ask several, shorter questions. I will also cover some questions in my "shorts" youtube.com/@bienadam/shorts between the shows.

Upcoming airhacks.tv events are also going to be announced at meetup.com/airhacks

New: the airhacks.tv discord server: discord.gg/airhacks

@grimly
Copy link

grimly commented Nov 28, 2023

Hello Adam,

I follow your podcast and your first question to all your attendees is "What was your first computer ?". But I never recall you answering your own question so here it is :

What was your first computer ?

@AdamBien
Copy link
Author

"can i ask you to tell me a little more about your experience with the lambda snapshot option, i have seen your videos, i mean project experience. I made a snapstart lambda that takes 1 record from postgres, and I have quite large numbers of both initialization and invocation (1+ sec for each of them), I added quarkus-preload-classes.txt but I wouldn't say that it helped much"

(from https://discord.gg/airhacks 👉 https://discord.com/channels/1042522430876438549/1042522430876438552/1179142759198765066)

@scrmtrey91
Copy link

Hi Adam.

Application:
Frontend is Vaadin 23 with CDI, JavaEE 8 backend + jax-rs web services (without spring boot) - multi module maven project
The service (interface) for getting data and bussines logic is injected (injected from BL jar module) directly into UI classes or views. The scope is @Local for service and @stateless for control.
User log in and get JWT. We can pack information about locale into JWT no problem.

As of now we set default locale in JVM. So getting translations from frontend, backend and JPA validation was not a problem because of locale.getDefault accesible everywhere in the code.

But now the requirment has changed to per user locale.

User can choose its own locale in the UI settings. Translation for the UI components like button caption etc its not a problem.

We also have *.properties (resource bundle) for translation strings by key..

Structure:

  • BL module jar
  • Data module jar
  • Localization module jar (properties files and get translation helpers)
  • UI vaadin module war

Problem #1:
How to get locale from UI user to backend (in fancy way, maybe with context or somehow) ? Also how to get translation for enums (static methods etc...) ?

We can do as new parameter to each method but that would be a lot of work for every method call in the application (not that small app).

Problem #2:
How to get JPA validation based on user locale ? On the frontend we use binder (bean validation directly from jpa entities) from vaadin most of the time for forms and such.

Problem #2:
External usage of web services (with JWT), we can pack information about locale into JWT no problem. But then the #1 and #2 problems occurs again.

I hope i provided enough information. If not maybe in next one with additional information.

Thanks for your answer. Keep up the goor work.

@AdamBien
Copy link
Author

AdamBien commented Dec 3, 2023

Discussion:

Resource interface -> Resource Impl -> Service Interface -> Service -> Repository Interface -> Repository Impl - 6 layers of abstractions and half of them is useless. I hate this pattern
I am glad that in microservice world less and less projects are using this approach

[from https://discord.gg/airhacks
/ https://discord.com/channels/1042522430876438549/1042522430876438552/1180139279180116068]

...and https://www.adam-bien.com/roller/abien/entry/service_s_new_serviceimpl_why

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment