Skip to content

Instantly share code, notes, and snippets.

@AdamBien
Last active October 14, 2017 15:47
Show Gist options
  • Save AdamBien/ec94900a3efd5d621bf4f00cc8a0dbac to your computer and use it in GitHub Desktop.
Save AdamBien/ec94900a3efd5d621bf4f00cc8a0dbac to your computer and use it in GitHub Desktop.
43rdAirhacksQ&A.md
@chamisf
Copy link

chamisf commented Sep 13, 2017

Hi adam,
You sample codes uploaded to http://kenai.com/projects/javaee-patterns is not available now. Any alternative place to see them?

Best regards
Chaminda

@matafe
Copy link

matafe commented Sep 13, 2017

Hi Adam, How do you achieve a dynamic creation on Message Listener in JEE7? (The MDB listen only a queue/topic!) I want to create dynamic Listeners for queues read from a file. My queues are configured in a remote server standalone (Artemis) not in Wildfly configuration file (xml). With Spring I can dynamic create DefaultMessageListenerContainer and set some Message Listeners for this list of queues. Do you have any ideia? I don want deploy a new version of the application every time I add a new queue in my standalone server. Is like the @JMSDestinationDefinitions but programatically.
Thanks

@Programmercito
Copy link

Hi Adam i have a cuestión i implement Java rest app web, i need implementación session time out , sso( single sign on), with tokens , i can implement with REDIS for tokens validación, session y session time out ? But Jwt is not a solution. How web app normal works

@vmiharia
Copy link

vmiharia commented Sep 18, 2017

Hi Adam,

Thanks a ton for doing the AirHack QA! It provides practical answers to all the "real life" questions, putting aside all the hype.

I have a lot of questions and they can be all over the place, but please bear with me:

  • What factors do you consider before choosing server-side rendering frameworks like JSF or JS frameworks like React?
  • Are the patterns in your JEE pattern book, 'JAVA EE Patterns'(written for JEE 6) still hold true for JEE7 and upcoming JEE8?
  • Your JAVA image for Docker containers uses openJDK instead of Oracle JDK. Any particular reason?

I have more questions, but I will give others a chance to ask few as well :)

@gbourant
Copy link

gbourant commented Sep 20, 2017

Hello Adam,

Congratulations on the new WebStandards Online Workshop.

  1. When you are using keycloak , how do you handle additional user properties?

    • Would you bother editing keycloak configuration to provide additional properties , or would you have a 'users' microservice (with it's own database) that communicates with keycloak (another microservice) and you would map each user from 'users' microservice with Keycloak User's ID ?
  2. Which is the best way to handle 'money/currency ' variable in Java(BigDecimal ?) and which SQL data type to choose ?

    • I'm using JPA - Hibernate and PostgresQL
  3. How to do test JAX-RS resources behind Keycloak as security mechanism ?

Thanks in advance.

@amihaiemil
Copy link

amihaiemil commented Sep 22, 2017

Hey Adam,

EJB question here:
I have 2 .ears deployed on the same JBOSS, each containing a .jar with EJBs (same .jar, maybe different versions of it).

When a resource in .ear A uses an EJB (simply injects it with @EJB, nothing else), where will it take the EJB from? From its own .jar, which it has as a dependency, or from the .jar which comes as a dependency to .ear B?

I think another way of putting the question is: Is the EJB container local, per application, or global, per server? Because if it's global, then for sure the scenario above poses a problem: we may have 2 versions of the same EJB and not knowing which one is going to be used when.

Br,
Mihai

@dsurendran
Copy link

dsurendran commented Sep 24, 2017

Hello Adam,

  1. How much of logging you advise for an application.
  2. How to convince Architects that JSF is faster and can be used in typical enterprise application. (Everyone thinks JSF is dead and no one is using it)
    Thank You.

@robertBrem
Copy link

Hy Adam,
I use your toJson/Constructor(JsonObject) approach and are really happy because I can avoid a lot of trouble caused by magically generated json. One thing I don't like is the following: Null Values in JsonObjectBuilder I use the suggested Decorator workaround but asking myself if there isn't a better way to solve this?
An example would be an entity Person with a bunch of optional fields like phoneNumber, middleName... The fields are used by the frontend and not just baggage :-)

Thx!

@giates
Copy link

giates commented Sep 28, 2017

Hi Adam,

I've 3 questions for you:

  1. What is the best practice to increment/auto-increment the release version on Java EE maven projects ? At the moment I manually increment the version number then I call clean and build from Netbeans or mvn compile package from terminal, do you have some suggestions to automate the release and versioning processes ?

  2. Speaking about friendly url in Java EE projects, I've already used ocpsoft-rewrite and I was very happy with it, now I'm considering to switch to MVC (Ozark), what do you think ? Does it ready for production uses ? What do you use to handle friendly urls on pure Java EE projects (JSF pages) ?

  3. In this post http://adambien.blog/roller/abien/entry/why_it_is_impossible_to you explain very well why it is impossible to automatically handle optimistic locking exception, but if the OptimisticLockException is thrown at the end of transactions (when the code exits from transaction scope) how can I handle the exception ? I have to insert a try/catch(OptimistickLockingException e) in a method that calls the business method annotated with @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) ? In real world Java EE applications what do you prefer to use, optmistic or pessimistic locking handling ?

Many thanks !!!

@chermehdi
Copy link

Hi Adam

  • in a attempt to understand how the CDI spec works behind the scences , i started to work on a little pet project to implement a simple Ioc Container, Could You provide some ideas on how i might be able to implement some features such as Qualifiers, and Producers . also i'm currently keeping the created objects inConcurrentHashMap and I am thinking to implement something more sophisticated such as an ObjectPool Could You you Provide some Advice about this matter ?
    big fan Mehdi .

@Mario-StoneAndWater
Copy link

Hi Adam,

  • How do you handle datasource configuration in a docker environment? Currently I'm using your Wildfly image and apply an additional script that will be executed when the wildfly is up and running. Since the wildfly needs to be restarted after its configured this can take a couple of seconds. Are there any better ways to handle this?

@omega09
Copy link

omega09 commented Oct 3, 2017

Hi Adam,

Is it possible to use a @RequestScope injection in a JAX-RS class that has a method with @Suspended async response? The problem is that the request scope exists when the request arrives, but then the idea of async is to run it in a new thread and release the I/O thread where the request scope was. This results in problems because there is no injected proxy available inside the new thread. Some solution?

Thanks!

@nikosit
Copy link

nikosit commented Oct 3, 2017

Hi Adam,

what would be the best way or maybe better your way of implementing a batch job, which reads over a million of data rows from a database, filters them, maps them to entities(or DTOs?), stores them into the corresponding tables and transforms them into specified interface files? How often has to be called a commit? Best practices to achieve performance and transaction control?

Thank you in advance!

@fnh
Copy link

fnh commented Oct 5, 2017

Hi Adam,
could you explain, why the serialization of JAX-RS works differently for a JsonObject, when it is wrapped in a POJO, as compared to a JsonObject serialized directly?

When I post some object like {"a": "b"} and return a JsonObject as entity of the Response, it resembles the object. When I return a POJO which wraps the JsonObject, the serialized JSON looks like this:

{ 
 "wrapped": {
  "a": {
   "string": "b",
   "valueType": "STRING",
   "chars":"b"
  }
 }
}

while I would have expected something like {"wrapped": {"a": "b"}}

@POST
@Path("echo-json")
@Produces(MediaType.APPLICATION_JSON)
public Response echo2(JsonObject someJson) {
    return Response.ok().entity(someJson).build();
}

@POST
@Path("echo-wrapped")
@Produces(MediaType.APPLICATION_JSON)
public Response echo(JsonObject someJson) {
    return Response.ok().entity(new WrappedJsonObject(someJson)).build();
}


/*************************************/

public class WrappedJsonObject {
    private JsonObject wrapped;

    public WrappedJsonObject(JsonObject toBeWrapped) {
        this.wrapped = toBeWrapped;
    }
// getter + setter
}

Is there something to achieve the expected serialization of the wrapped object using only the Java EE API? Am I getting something about JAX-RS fundamentally wrong?

Thank you very much!

@victorroeder
Copy link

Hey Adam,

I have a question regarding qualifier instantiation for CDI.current().select(....)

Given the following qualifier (MyQualifier):

@Qualifier
@Target({TYPE, METHOD, PARAMETER, FIELD})
@Retention(RUNTIME)
public @interface MyQualifier {
     String value() default "";
}

Now, to be able to instantiate it to use it along with CDI.current().select() (or Instance.select()), there are two ways:

1.) Letting the annotation class inherit from AnnotationLiteral. Example:

public class MyQualifierLiteral extends AnnotationLiteral<MyQualifier> implements MyQualifier {

    String value = "";

    public MyQualifierLiteral(String value) {
        this.value = value;
    }

   @Override
    public String value() {
        return value;
    }
}

2.) Directly implement the qualifier interface (without extension of AnnotationLiteral). Example:

public class MyQualifierInstance implements MyQualifier {

    String value = "";

    public MyQualifierLiteral(String value) {
        this.value = value;
    }

   @Override
    public String value() {
        return value;
    }

    @Override
    public Class<? extends Annotation> annotationType() {
        return MyQualifier.class;
    }
}

Now both can be used the same way:

With the Literal class:

MyQualifiedImplementation a = myImplementations.select(new MyQualifierLiteral("hello"));

or with the Instance class:

MyQualifiedImplementation a = myImplementations.select(new MyQualifierInstance("hello"));

What is the difference between them? Is there a reasonable one?

Many many thanks!

Victor

@bilelovitch
Copy link

Dear Adam,

I have a question about security in Java EE applications, in fact we are currently limited to securing only the web pages, so the security of the data is linked to the role (because each role = well defined pages) and no control is performed before the loading of the data. For me this means, that we are just securing the access to the application and not the access to the data.

My question is what is the best approach to secure access to the data of a Java EE application ?

In an another application that contains sensitive data, the client wants to encrypt the data at the database level, for that we have used a listener (javax.persistence.PostPersist; javax.persistence.PostLoad; javax.persistence.PostUpdate;) for the control but it failed. According to you what is the best approach to encrypt and decrypted the data with a Java EE application ?

@danilopiazza
Copy link

Hi Adam,

In the WebStandards Igniter online workshop (which I strongly recommend!), you have been using bind in JavaScript functions passed to event handlers.

What is the difference between bind and the widely used var self = this pattern? Which one is preferred?

@dempile
Copy link

dempile commented Oct 9, 2017

Hi Adam,
1- From the definition a microservices must be independent and autonom, so is that means that he must carry the database with him? if Yes how we could manage such situation.
2- Do you think JEE 8 can be used in production ?

thanks

@j-ibarra
Copy link

j-ibarra commented Oct 9, 2017

Hi Adam
which is the best method for microservices for endpoints in different docker containers, using a proxy as nginx or point to different ports, for when a course on vimeo ondeman Jenkins + java 9 + java EE 8

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