Skip to content

Instantly share code, notes, and snippets.

@AdamBien
Last active April 3, 2017 15:35
Show Gist options
  • Save AdamBien/beae7dd8966a6d57b7225ba310b18abe to your computer and use it in GitHub Desktop.
Save AdamBien/beae7dd8966a6d57b7225ba310b18abe to your computer and use it in GitHub Desktop.
37thAirhacksQ&A.md
@deratzmann
Copy link

Hi Adam.
Imagine you are in a Team that maintains Master data, let's say purchase articles. The attributes of this articles change from time to time.
Other teams need this data and they want to receive deltas in an asynchronous way (in german I would call it "Datenschleuder"), to store it in their own database.
Which way do you prefer for this approach? Is Websockets technology suitable? Maybe JMS? Or other technology like apache kafka?

I know you like the synchronous way, but in this case, they force you (me also ;) ) to do it asynchronously.

thank you for your suggestions.

@jarryDk
Copy link

jarryDk commented Mar 21, 2017

Context

We have a JAX-RS with

Create : return 201 and id in the header field x-id
Read : return 200 and id in the header field x-id
Update : return 204 and id in the header field x-id
Delete : ... Not importen

I use the project CORS Support For JAX-RS 2.0 / JavaEE 7 to add Cors to my headers, but then I wanted to read the header field "x-id" from javascript (jquery) on a Create og Update it is not available.

I found a nice article Using CORS - HTML5 Rocks and found out that I needed to add the header "Access-Control-Expose-Headers".

Question
How do you handle this situation in your projects?

@padmanabann
Copy link

First of all, thanks for your great blog!

We have a Java EE web application that uses basic authentication (configured in web.xml). Now we are planning to expose some of the business logic through REST web service (to access via a mobile client). How can we implement Token based authentication (JWT / OAuth 2) for the REST webservice without affecting the current basic authentication mechanism for the web application?

@GADNT
Copy link

GADNT commented Mar 28, 2017

Hi Adam

For production what tool do you use to profile your application? this tool(s) does provide some metrics that can be pushed in elasticsearch in order to generate some graphics/some pretty UI and to not add some load to the application ?

Thank you

@dinolupo
Copy link

Hi Adam. Question about Java EE security and injecting the EntityManager based on current logged user. Let's suppose we have a DB with three schemas, security, data-en, data-de. security schema contains User, Roles and anything about security. User has also an attribute "tenant". After the login I want to inject the entity manager to all beans that need it based on the tenant attribute of the connected user, such as from that moment on, all entities will use the correct entity manager. data-en for english users, data-de for german users. How to model such solution? Thanks a lot.

@gersonZaragocin
Copy link

Hi Adam

I would like you to elaborate the options (pros and cons) we have to implement service discovery in a Java EE 7 microservices architectured project. Which is your opinion of products like Zookeper or SnoopEE, have you used them? Thanks in advance.

Greets from Ecuador.

@nmahoude
Copy link

nmahoude commented Mar 29, 2017

Hi Adam.
First of all, thanks for sharing so much with the community !
Secondly, as you request questions, here is a question i have which come from different patterns you talked about in airhacks episodes:

How do (/would) you handle HATEOAS links with jax-rs and json-p with respect to the methods (ctor(json) and toJson()) in the entity you described in previous episodes ?

I need to build some 'action' hyperlinks in my json object,
Respecting single responsability principle :
* the entity know how to build herself and which links to embed.
* the ReST endpoint know about ReST links and how to build them

atm, I something have like this (and I don't like it)
class Image {
....
public JsonObject toJson(UriBuilder imageUrlBuilder) {
return Json.createObjectBuilder()
.add("id", getId())
.add("name", getName())
.add("description", getDescription())
.add("imageUrl", imageUrlBuilder.build(getId()).toString())
.build();
}
}
Thanks,
Nicolas.

@joaoyuki
Copy link

Hi Adam, first of all thanks for share your knowledge with us, plase continue with this.

My question is, I have been working with Java EE for 4 years, using JSF, jpa, primefaces and a little bit of rest.
What would recomend me to study to improve in my career? As there are tons of subjects I got lost every time.

Thanks for your support.

@rmpestano
Copy link

Hi Adam,

What solution are you using for mobile applications in your projects? A JavaEE backend and native mobile app or webview (pure cordova or ionic) or something else?

Thank you!

@sergioverde90
Copy link

sergioverde90 commented Mar 30, 2017

Hi Adam, three questions:

  • What is the real usage of javax.ws.rs.ext.ContextResolver? Searching in Google I only see examples about ObjectMapper, can you give us other real useful example?
  • About Docker, ECS and microservices, in your videos you show us how to make a Rest call between microservices using the name of the container, but in ECS (or other cloud provider) when I have a load balancer and multiple containers, what is the name that I should use? How can I refer to this balancer?
  • In the 34thAirhacksQ&A I ask you about how can I have my own CMT transaction and you answer me with javax.transaction.Transactional annotation and CDI. This was very useful for me but how it is implemented a JTA transaction under the hood? Something like Bitronix or JOTM.

Thanks you very much Adam.

@johnhogan
Copy link

johnhogan commented Mar 31, 2017

Hello Adam.

Can you tell us a little about what changes to JEE security we can expect to see in JEE 8 with JSR-375? I see your listed on as a member of the expert group at the JCP. I'm especially interested to know what will become of JAAS, and will it be going away, ...? Thank you.

John Hogan

@jpraet
Copy link

jpraet commented Apr 1, 2017

Hi Adam,

Most of our applications are currently hybrid applications with spring and Java EE mixed together. We are migrating from WebSphere Application Server to a JBoss EAP docker environment (OpenShift), and would like to apply your proposed best practices for the docker deployment model with pure Java EE thin wars and as little 3rd party dependencies as possible.

There are certain areas where we find it difficult to get rid of spring though:

  • spring-security: seems more flexible and straightforward than Java EE security
  • spring-batch: yes, there is JSR352, but this is basically the same as spring-batch without the extensive library of reader/processor/writer component implementations
  • support for the new Java8 Optional and Date API types: in spring this works out of the box. In Java EE 7 you need to write custom converter classes if you want to use these types with JPA / JAX-RS / JAXB / JSF. Will Java EE 8 bring full support for these Java8 types? (I could only find confirmation for JSF 2.3)

What are your thoughts on these?

Thank you!

@MikeEdgar
Copy link

Adam,
I like the idea you have presented of using JsonObject/JsonArray as DTOs in a JAX-RS API, but one downside is the apparent loss of declarative validation. You recently demonstrated using a custom validator for JSON which made use of the programmatic bean validation API. Do you have any suggestions for how one might make use of declarative validation with JSON objects?

Thanks

@davidsoles
Copy link

Hi Adam,
Microservices theory says that each service needs its own database. This statement refers to:

  • One microservice must have one DBMS instance and database.
    screen shot 2017-04-02 at 2 55 00 pm
  • Multiple microservices can share one DBMS instance and every one of then has their own database.
    screen shot 2017-04-02 at 2 54 49 pm
    Thanks.

@AdamBien
Copy link
Author

AdamBien commented Apr 2, 2017

Plain Java SE without Java EE -- is it viable in real world?

(a question from a conference attendee)

@sebargarcia
Copy link

Hi Adam, we are starting a new project with the following stack: JPA + CDI + JAX-RS (for the backend), Angular 2 (maybe with prime-ng) for the client side.
My question is if we have to have all in a single war project (backend + client side) or have two projects one for backend (single war) + other project with all angular stufff.

I see there are some maven plugins to automate all the build process of the angular stuff, but I am not sure if it is good to have all in a single war.

Thanks in advance.

@jcrochavera
Copy link

Hi Audam, could you talk us about your experience with java EE and high performance IOT applications?? (Tips, tricks, most used NoSql databases in your projects,etc)

@walnikster
Copy link

Hi Adam,
Thanks for your blog containing very interesting JEE stuff.
I want to secure my REST API in my JEE application with keycloak. Can you please give a short example of how to integrate keycloak client adapter into payara. I was looking for a client adapter as for wildfly but I was unable to find one for payara.
Thank you
Niki

@kg6zvp
Copy link

kg6zvp commented Apr 3, 2017

Thanks so much for fitting in my student project. I'm building an SDK for Jax-RS microservices.

I've got several entities, corresponding EJBs to work with the entitymanagers and a request filter that needs to be put into an SDK for other students to use to create wars with microservices in them. I'm trying to create a war with a Time microservice that tells time to develop and test the SDK with, but I can't seem to get the SDK inclusion steps down to just declaring a maven dependency. (currently it requires declaring lib/ssauthclient-1.0.5-SNAPSHOT.jar in the Time service in order to avoid an 'org.hibernate.UnknownEntityTypeException', but this results in two persistence modules) What am I doing wrong?

SDK Source: http://gitlab.wmapp.mccollum.enterprises/wmapp/ssauthclient.git

Further detail if you need it:
The request filter and custom Principal classes work just fine, but the JPA entities persisted aren't discovered without using the directive in the persistence.xml of the Timeservice project. I've tried building the beans.xml and persistence.xml files into the SDK jar in Maven, then including them in Timeservice via the pom.xml, which results in two persistence units, but this throws the error 'org.hibernate.UnknownEntityTypeException: Unable to locate persister: edu.westmont.UserToken' when a call is made to a Jax-RS endpoint. The only way I get it to work is by requiring the person creating a microservice to add a directive, but this seems like the wrong solution. Ideally, the included jar would be able to expose it's custom Principal class and Jax-RS filter to the microservice without exposing its entities.

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