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
@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