Sunday, May 19, 2019

JAXRS all-in-one

All annotations are summarized here https://dzone.com/articles/introduction-to-restful-web-service-a-jax-rs-speci

"Base URL for any web application is:

http://:/

Append tag from web.xml with Base URL that forms:

http://://

Append class-level @Path(“class-level”) annotation and then method-level @Path(“method-level”) annotation that forms:

http://:////"





https://dzone.com/articles/an-introduction-to-jax-rs-annotations-part-1

https://dzone.com/articles/what-are-jax-rs-annotations


https://readlearncode.com/java-ee/what-is-javax-ws-rs-core-context-httpservletresponse-and-httpservletrequest/


https://readlearncode.com/java-ee/what-are-the-jax-rs-annotations-get-post-path-applicationpath/


https://dzone.com/articles/what-is-javaxwsrscorecontext



@ApplicationPath("api")
extends Application

@Path("/books")

@GET
@Produces(MediaType.APPLICATION_JSON)

@POST
@Consumes(MediaType.APPLICATION_JSON)

@PUT
@HEAD

@DELETE

@Path("{isbn}")

@PathParam("isbn") String isbn

@QueryParam

@OPTIONS

@javax.ws.rs.HeaderParam
javax.ws.rs.core.Response

javax.ws.rs.core.SecurityContext



It's all very clear apart @Context... read here to understand @Context
https://readlearncode.com/java-ee/what-is-javax-ws-rs-core-context-httpheaders-and-uriinfo/

this for SecurityContext : https://readlearncode.com/java-ee/what-is-javax-ws-rs-core-context-securitycontext/


and some more coding examples here https://www.mkyong.com/webservices/jax-rs/get-http-header-in-jax-rs/




Friday, May 17, 2019

More interesting readings on quarkus and microprofiles

I reveive from my friend Rob:

This will soon overhaul Spring Boot. Look how they fast grow with integrating all enterprise patterns on Quarkus. This community is the driver https://smallrye.io/

Look at this suberb documentation

https://quarkus.io/guides/, almost covering everything you need

https://quarkus.io/guides/logging-guide
https://quarkus.io/guides/jwt-guide
https://quarkus.io/guides/transaction-guide

and then this amazing reactive streaming doc

https://quarkus.io/guides/kafka-guide


this will leave spring boot behind really soon


Worth reading is also https://www.baeldung.com/quarkus-io

Interesting also eclipse.microprofile https://www.baeldung.com/eclipse-microprofile running on Open Liberty



Thursday, May 16, 2019

Jooq and QueryDSL as alternatives to JPQL, Panache,

HQL (and JPQL) both suck because they are not statically typed..."lack of type safety and absence of static query checking" "concatenation of strings which is usually very unsafe "

"Criteria Query API ended up very verbose and practically unreadable. "


https://www.jooq.org/

"jOOQ generates Java code from your database and lets you build type safe SQL queries through its fluent API. "

So this is no ORM framework, it uses your DB as it is, it simply allows you to write safer SQL queries directly in a fluent Java API. No Hocus-Pocus, it's a 1-to-1 mapping between DB and Java.

Here some examples https://www.jooq.org/doc/3.11/manual-single-page/#jooq-in-7-steps



http://www.querydsl.com/

how to use it https://www.baeldung.com/querydsl-with-jpa-tutorial and https://www.baeldung.com/intro-to-querydsl



If you want to use Native SQL or JPQL in Spring: https://www.baeldung.com/spring-data-jpa-query


This is the horribly verbose JPA Criteria API https://www.baeldung.com/hibernate-criteria-queries
" the main and most hard-hitting advantage of Criteria queries over HQL is the nice, clean, Object Oriented API."