Skip to content

Instantly share code, notes, and snippets.

@AdamBien
Created March 8, 2022 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdamBien/bbb339de1eaf5bb4fec337a2bf4b7673 to your computer and use it in GitHub Desktop.
Save AdamBien/bbb339de1eaf5bb4fec337a2bf4b7673 to your computer and use it in GitHub Desktop.
97thAirhacksQ&A.md

Ask questions and see you at April, 4th, 8.PM. CET: youtube.com/c/bienadam

Also checkout recent episode:

96 airhacks.tv

Please keep the questions Jakarta EE-stic. Means: as short and as concise as only possible. Feel free to ask several, shorter questions. Upcoming airhacks.tv events are also going to be announced at meetup.com/airhacks

@darioaxel
Copy link

Hi Adam,
I attended to the Airhacks at the München Airport several years ago. Since that my company started an Angular project and I stopped working with JavaEE. My question is: which language/framework would you recommend as a fine way to start creating an APIs that supports role based? JakartaEE? Django? Quarkus? .. Thanks

@dempile
Copy link

dempile commented Mar 27, 2022

Hi Adam,
I wanted tou use a Mapper Like MapStruct and Dozer in my project, than I found your post , https://www.adam-bien.com/roller/abien/entry/in_case_dozer_or_beanutils
Can you explain the use cases of when not to use these mappers, and we can avoid using them.
Thanks

@Endilicam
Copy link

Hello Adam,

in a REST architecture application with a web frontend, do you advise using JWT for authentication and using it as session data?

The problems I see are:

  • That token can be "stealed" and used from another computer, thus impersonate another user
  • Revoke the token, if I remove access to a user until the token expires, they will have access.

As alternatives I have seen the possibility of using Redis, if you recommend using it, the best way would be to filter the request and validate all requests against Redis?

Thank you very much.

@Endilicam
Copy link

I have to create a platform with many microservices with REST architecture in Java on-premise. Ideally they would be separate from each other in your Docker image, correct?

The customer want to use WildFly as an application server, so I see the following options:

  1. Use a WildFly per microservice and Docker image, I think it would be too heavy
  2. Use WildFly Bootable JAR, I haven't seen it used much either
  3. Use a WildFly for several microservices, separation between microservices is lost, but less heavy
  4. Use Quarkus to generate small images without using WildFly

What do you recommend in this situation?

Thank you very much.

@AdamBien
Copy link
Author

AdamBien commented Mar 28, 2022

Thoughts on "Tautological Tests": https://randycoulman.com/blog/2016/12/20/tautological-tests/ From:

B) I’ve also run into a particular flavor of pointless tests, where the test’s expected values are computed using the same code or a copy of the same code as the actual values. Recently I learned a term for these: Tautological Tests. https://t.co/wgk1yf8uKs

2/

— Stuart Marks (@StuartMarks) March 28, 2022

@thehpi
Copy link

thehpi commented Mar 30, 2022

I have an application running in payara which I can create orders which have a UUID as order id. I have several processes and background processes which do things with these orders.

When logging I always want to log this order id. Is there a way to do this without having to add logging code everywhere? Would it e.g be possible to annotate a parameter on e.g. a rest call method which then has as effect that every log statement logs that value?

My idea was to use CDI Decorators for every interface that has methods that receives the order id as parameter and in the decorator then store the order id in a @RequestScoped bean. But then I need to create a decorator for every (applicable) interface. And every decorator implementation does the same thing.

@mahimatics
Copy link

Hi Adam, I hope you're doing well.

When designing a JAX-RS API, do you have any specific best practices recommendation, like resource expansion, pagination, querying filtering, field selection etc? A lot API's implement their own solutions and there doesn't seem to be much standardization or convention over configuration. I came across Apache Olingo and OData which seems to address this issue, and I wanted to know your opinion about it, and if it was easy to integrate into a standard Jakarta EE + Microprofile app.

Thank you for all the resources you produce to help Jakarta EE + Microprofile beginners like me. 🙂

@AdamBien
Copy link
Author

AdamBien commented Apr 2, 2022

The return of Jakarta EE -> with v10

@AdamBien
Copy link
Author

AdamBien commented Apr 2, 2022

"Hi! I want to learn Jakarta stack, for take my first work. Can u advise for me an application server
P.S. I want start from server that have more specification then other": youtube comment from "Writing JSON Logs with Quarkus on AWS Lambda with Java's System.Logger": from https://youtu.be/WJj9r0gOPOA

@AdamBien
Copy link
Author

AdamBien commented Apr 2, 2022

"...Yep, that would be great! I started making my own collection of webcomponents following this approach too https://github.com/newk5/stak-components. I wish there were more components like this out there"

https://twitter.com/Carlos_matos56/status/1510161086129098752?s=20&t=dr2VTUKym5vf-OJzAKOsuw

@ylberi51
Copy link

ylberi51 commented Apr 3, 2022

Hi Adam,

I'm having difficulties understanding some concepts about request handling in Quarkus. Can you please explain differences of request handling in Quarkus when using:

  1. RESTEasy
  2. RESTEasy Reactive
  3. Reactive Routes.

I've read some "under the hood docs" of Quarkus architecture. It tells that request handling in Quarkus is by default "reactive" (using Vert.x). Okay till here. I mean, I thought now I understand how Quarkus works. But then I start reading more about how you can use RESTEasy Reactive extension and make your request handling "reactive". What "reactive"!!! Does not Quarkus by default handle requests "reactive" (vert.x)?? That's not all. I then read about Reactive Routes, how you can make Quarkus more "reactive" 😃 😕

Can you please explain (maybe with some simple drawings about request handling in Quarkus) how these three extensions make your application "reactive". What are IO and Worker thread and how Quarkus handle requests in these threads when using those three extensions.

What about Project Loom? I'm reading now about the "new virtual threads" that will come to Java. It says that Project Loom will "kill" reactive libraries. Can you talk something about this project and how it will replace or deprecate reactive libraries.

Sorry about my (long and maybe silly) question. I'm still a non-experience young man, who just graduated and I'm trying to understand more about JavaEE/JakartaEE and Quarkus and how some things work "under the hood".

Thank you so much for all the answers Adam

@ylberi51
Copy link

ylberi51 commented Apr 3, 2022

One more question Adam 😃

When using for e.g. Quarkus to build serverless lambda functions (aws), is it better and faster to always build native images using graalvm and deploy to lambda as native, or just deploy as standard jvm?

Are the native functions always faster than jvm functions, in terms of:
start time (better cold start),
throughput ->better response time

Thank you once again!

@billy-lgtm
Copy link

Hello Adam

Can you talk something about differences between Quarkus and Micronaut. They are both reflection-free, right? And while reading in Micronaut docs it says that Quarkus is not full reflection free.
From micronaut docs: "even Quarkus currently only implements reflection-free DI and not AOP"

So, when using @interceptor in Quarkus, does Quarkus use reflection, and if you use Micronaut AOP, everything is reflection-free.

And one question regarding the "famous topic - dependency injection type". Quarkus docs prefer the package-private field injection and Micronaut constructor injection. Any reason why so? Is it ok to use package-private fields in Micronaut also?

Can you please explain these, and maybe any other differences between the two frameworks? Which one do you prefer and why?

Thanks a lot

@Endilicam
Copy link

Hi Adam,

another question ;), is about security in an application with REST architecture and web frontend.

The initial approach is to use the groups of a JWT token and the @RolesAllowed annotation in the backend, but if I want to make it dynamic I have chosen to have a database table to configure the permissions and a RequestFilter where to perform the validations.

The first problem is maintenance, it would have to have the allowed groups/roles for each endpoint.

The second, that due to functional requirements, the possibility of a menu option being read-only is requested, the problem is the navigation between screens since it has to be inherited between screens, but being a REST architecture (stateless) I do not see how to do it without compromising security, I don't know if I explained myself well.

In the end, the goal is that a user, even if authenticated, cannot call all the endpoints, only those that have permissions, but without the management being so complicated, the only way I can think of is to put security per endpoint although it is difficult to maintain, is there any other approach?

@eimanavicius
Copy link

eimanavicius commented Apr 4, 2022

I have Struts 1.x application. I want to migrate to more modern framework.

One option is Struts 2.x. How would you execute such migration?

Is there a reason to migrate to MicroProfile application. What would that mean? What would be benefits? Would that mean rewrite of templates to SPA + API? How would you execute such migration if it is meaningful?

Is there any Java API spec that would help for easy maintaince or cheap upgrades to such systems?

Can you comment on Jakarta MVC as contract https://projects.eclipse.org/projects/ee4j.mvc ?

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