Skip to content

Instantly share code, notes, and snippets.

@AdamBien
Last active April 11, 2016 15:31
Show Gist options
  • Save AdamBien/9a8ad5beec52199f1d13 to your computer and use it in GitHub Desktop.
Save AdamBien/9a8ad5beec52199f1d13 to your computer and use it in GitHub Desktop.
25thAirhacksQ&A.md

Ask questions and see you at 11th April at 6.PM. CET: http://www.ustream.tv/channel/adambien Also see archives: airhacks.tv

  1. Java EE 8 News
  2. 2 years of airhacks.tv celebration (now really 2 years)
  3. Do you think NetBeans is still a good IDE for JEE, Java, HTML, SPA, etc, development in 2016? I'm currently faced with a number of developers who seem to love IntelliJ, but I'd love a free alternative for some of our projects. We're currently using Eclipse (and STS), but that platform doesn't agree with me which is why I'm considering NetBeans. I know I should just make up my own mind about this, but I appreciate your work a lot and would love to hear your opinion.
  4. How to access the "other side" with afterburner.fx?:
@Service
public class Receiver {
    private long counter = 0;
    
    @PostConstruct
    public void init() {
        System.out.println("Receiver.init()");
    }
 
    @RabbitListener(queues = "hello")
    public void receiveMessage(Message message) {
     String s = new String(message.getBody());
//     msgRepository.save(new Msg(null, s));
     
        Platform.runLater(() -> {
         counter++;
         System.out.println("Received <" + s + ">" + counter);
         //I want to print this log to JavaFx Label
        });
    }
}
@viktorcitaku
Copy link

Hi Adam,

  • How would you manage in architectural aspect a huge system, would you stick with "just WARs" or probably you would choose EARs (WARs + JARs) instead? (I saw this http://www.adam-bien.com/roller/abien/entry/beans_with_both_views_local and in the examples you were using @Remote and @Local)
  • Do you think the new MVC action based specification is a bit late in Java EE 8, since now most of projects go with RESTful services?

And I have a request, where can I find videos from you, regarding JEE, FX, etc. (So far I searched and watched on YouTube), and another thing or question is, why you don't live stream on YouTube?

Best regards :-)

@iokhahon
Copy link

Hi Adam,
I am coding a JAX-RS resource class with several sub resource classes.
In your video "A little REST with JAX-RS 2.0 and JavaEE 7" you instantiated your sub resources like this :-

@get
@path("{first}-{last}")
public Developer developer(@PathParm("first") String first, @PathParm("last") String last) {
return new Developer(last, last);
}

Another similar example from another video :-
@context
ResourceContext rc;

@path("/chickens")
public ChickenResource chickenResource() :
return rc.initResource(new ChickenResource());
}

The problem is that these sub resource classes are instantiated with new, so CDI does not manage them.
Therefore, if these sub resource classes need instances of other control or entity classe(s) they cannot use @Inject.

One possible solution is to @Inject into the "parent" resource class instances of all the possible classes the sub resource classes might need, then pass references to them on the various constructors :-

@Inject
DeveloperStuff ds;

@Inject
ChickenStuff cs;

@Inject
DeveloperStuff ds;

@path("{first}-{last}")
public Developer developer(@PathParm("first") String first, @PathParm("last") String last) {
return new Developer(ds, last, last);
}

@path("/chickens")
public ChickenResource chickenResource() :
return rc.initResource(new ChickenResource(cs));
}

This seems highly inefficient since for a given request not all the possible instances are going to be required.
Is there is a way of deferring the instantiation or ChickenStuff and DeveloperStuff until we need them on the appropriate @path methods perhaps by using a scope?
Or, is another approach for @ChickenStuff and @developerstuff to use @produces which might somehow work around the fact CDI has disowned classes instantiated with new?

You insight would be greatly appreciated, keep up the great work, your Airhacks are very inspirational.
Mike

@enji7
Copy link

enji7 commented Apr 1, 2016

Hi Adam,

  • Other Java sources: Which other Java-related blogs / screencasts / periodicals can you recommend?
  • Screencast software: Which software do you use for recording your screencasts?
  • Reliable checkpoints in Java EE 7 Batch Processing (JSR 352): It appears that it is not specified how checkpoints are persisted by the application server. Hence, checkpoint data can be lost (e.g., due to a hard drive failure on the application server's machine). When the batch writes data to a database, checkpoint data must instead be written to the database using a custom implementation (which is unfortunate). Can you confirm this?
  • Asynchronous processing of client requests: What is the benefit of freeing the initially processing thread by passing over to another (asynchronous) thread instead? Does it make a difference if the pool for the initially processing threads is exhausted, or the pool for the async threads? One advantage I could think of is that separate pools allow us to define separate max counts for different parts of the application: If one function X of the application is currently overloaded, the application is still capable of serving requests to other functions.

Thanks & happy hacking,
Nenad

@gbourant
Copy link

gbourant commented Apr 3, 2016

Hey Adam,

  • Security
    I'm moving a PHP spaggeti Project into a JavaEE one, exposing REST Services.
    To secure the API i'm using Keycloak.
    Could you recommend me any other parts where i have to shield the App (except the exposed API)?
  • I had a class like the following
@Stateless
public class A {
@Inject
Clazz C;
}

after i implemented it with this way and Injection stopped working , to make it work i used @Local instead of @stateless , why it didn't work?

@Local
public class A implements B{
@Inject
Clazz C;
}
  • I want to share common fields and beheivor at all entities , how to achive something like the following ? (JPA doesn't save the extened fields).If possible the extended fields to be on the same table.
@Entity
public class A extends EntityLogger {
 @Id
 @GeneratedValue
 private Long ID;
 private String Name;
}

public class EntityLogger {

    @Temporal(TemporalType.TIMESTAMP)
    Date created;

    @Temporal(TemporalType.TIMESTAMP)
    Date updated;

    @PrePersist
    public void created() {
        created = new Date();
    }

    @PreUpdate
    public void updated() {
        updated = new Date();
    }
}

Thanks.

@masumcse1
Copy link

I have need a sample project that are build on java ee 7 with following criteria
JSF2.2 + Rest + Service (EJB/cdi) + JPA + any db

*** crud JSF2.2 with Rest client

@masumcse1
Copy link

i want to learn SAML with JAVA EE and implement my personal project .
SAML with java ee
please give me a idea how to do this one ?

@acll19
Copy link

acll19 commented Apr 7, 2016

When I face a new project, can I think of it in a microservice architecture way from the beginning, or it is just for "refactoring" a monolithic application?

@Chilis92
Copy link

Hi Adam,

I'm using JMS and i have one web application that works as a producer and I have another web application (Consumer) with an MDB, my MDB is implementing MessageListener interface so I'm getting the messages in the console properly. The problem is that I'm not able to send those messages to my JSF page. I tried to create an stateless EJB to get the messages and then send them to the JSF page but it does't work. So do you know if there is a way to call like a JSF back bean from MDB to display message on the view?

Thanks

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