Adam Bien's Weblog

Friday Oct 31, 2014

Scheduler, DataSources, Microservices, JSF and JS, Beeing Optimismtic or Questions For the 8th airhacks.tv

Lets start with some news first: airhacks Q & A got a dedicated website http://airhacks.tv with an archive of the past shows.

Now to the questions for the November (3th November, Monday, 6 P.M. CET) edition of the http://airhacks.tv show:

  1. Question about ejb scheduler vs java ee batch processing. What are pros and cons when using batch processing over ejb scheduler ? Marek
  2. Question about multi datasource and EJB. What is the best way to deal with EJBs which need to use a specific database for caller/user? Should I use
    Interceptors? Should I use injection with request scoped? Wesley
  3. Statement: “You forgot to say one advantage of Spring over JEE. Spring you can deploy on any container.” Mauricio
  4. ‘How do you manage deployed microservices (status, healthchecks, restarting) locally and on servers?’ Tomek
  5. ’How do you use Docker (what setup) locally and on servers? Tomek
  6. Does JSF play well with JavaScript frameworks? [Edward]
  7. Why It Is Impossible To Automatically Handle javax.persistence.OptimisticLockException? “…I had even more finding on optimisticLockException. I had encounter this
    exception and my solution was pretty straight forward which was just retry and
    it works fine with my design and the data were good. The catch is, recently I added a new table which has a relationship to the row
    which was throwing the optimisticLockException. I noticed that the entry in the second table was not created because of this exception. However the record data consistency was maintained because of the retry. But I loose an important
    information in my related table. Does anyone have suggestion on what to do with this kind of scenario?…” [Anuj]
  8. can you share some updates on how to do high availability JEE apps in light of
    JEE7 and tackling session stored data Ahmed
  9. We will also cover the extensive gist comments

Do you have any additional questions? Ask now, or wait a month :-)

The best of all: you can ask the questions live, during the show using the chat: http://www.ustream.tv/channel/adambien, twitter (hashtag "#airhacks") or (the best option): using channel ##airhacks on http://freenode.net.

See also other screencasts at: http://tv.adam-bien.com or subscribe to http://www.youtube.com/user/bienadam.

See you at Java EE Workshops at Munich Airport, Terminal 2 or on demand and in a location very near you: airhacks.io!


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

Saturday Oct 25, 2014

Enterprise Nashorn with Java 8 at JavaOne 2014

See also other screencasts at: http://tv.adam-bien.com or subscribe to http://www.youtube.com/user/bienadam.

See you at Java EE Workshops at Munich Airport or on demand and in a location very near you: airhacks.io!


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

Friday Oct 24, 2014

JAX-RS: Returning A List Of Instances, Problem and Solution

Wrapping a list of instances with a Response:


    @GET
    public Response workshops() {
        List<Workshop> workshops = ...//a list of entities
        return Response.ok(workshops).build();
    }


Leads to a type loss carried by the Collection and the following (or similar) exception:


MessageBodyWriter not found for media type=application/json, type=class java.util.Arrays$ArrayList, 
genericType=class java.util.Arrays$ArrayList

JAX-RS comes with GenericEntity which carries the generic type. You only have to wrap the Collection with the GenericEntity to solve the problem:


import javax.ws.rs.core.GenericEntity;
//...
  @GET
    public Response workshops() {
        List<Workshop> workshops = ...//a list of entities
        GenericEntity<List<Workshop>> l
        ist = new GenericEntity<List<Workshop>>(workshops) {
        };
        return Response.ok(list).build();
    }

See you at Java EE Workshops at Munich Airport, particularly at: Effective Java EE 7!


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

Thursday Oct 23, 2014

Rethinking Packaging, Modularization, Interfaces with Plain Java EE 7: 33rd Degree Conference

See also other screencasts at: http://tv.adam-bien.com or subscribe to http://www.youtube.com/user/bienadam.

See you at Java EE Workshops at MUC Airport, particularly at the Java EE Architectures workshop!


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

Wednesday Oct 22, 2014

CLI, Docker and Lambdas: Nashorn ...and Java EE

Java 8 comes with fast JavaScript engine called "Nashorn". At this JavaDay 2014 session I'm presenting examples and ideas for using Nashorn in enterprise applications with less code and more flexibility. Command line automation, docker monitoring and bi-directional Java integration:

I wondered during this session, why the audience is so passive. After the session I was told about the deactivation of the wifi to ensure HD streaming quality :-).

See also other screencasts at: http://tv.adam-bien.com or subscribe to http://www.youtube.com/user/bienadam.

See you at Java EE Workshops at Munich Airport or on demand and in a location very near you: airhacks.io!


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

Tuesday Oct 21, 2014

Lazy Injection with javax.inject.Provider

javax.inject.Provider is the minimalistic version of the javax.enterprise.inject.Instance interface. In fact Instance inherits from Provider

For on-demand injection of components / resources inject them as Provider:


@Model
public class Index {

    @Inject
    Provider<Boundary> boundary;

    public String getMessage() {
        return boundary.get().message();
    }

}

The injected component is unaware about the laziness:


@Stateless
public class Boundary {

    public String message() {
        return "Good morning";
    }
}

Instance comes with additional functionality: see also Interfaces on Demand with CDI and EJB 3.1

[See also an in-depth discussion in the "Real World Java EE Patterns--Rethinking Best Practices" book (Second Iteration, "Green Book"), page 235 in, chapter "Plugin"]

See you at Java EE Workshops at Munich Airport, particularly at: Effective Java EE 7!


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

Monday Oct 20, 2014

JavaFX: A Composite View with WYSIWYG

Creating a composite view in JavaFX with Scene Builder and Dependency Injection:

See also: http://afterburner.adam-bien.com and see you at http://workshops.adam-bien.com/javaee-ui.htm.


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

Saturday Oct 18, 2014

Setting The Classpath For Nashorn Script in jjs / Java 8

The Java 8 jjs interpreter accepts the -cp / -classpath argument. After setting the classpath, all the classes become available from within the executable script.

A utility class com.airhacks.naslib.Inspector in the naslib.jar (this is an sample jar) becomes available for Nashorn after setting the jjs classpath:


#!/usr/bin/jjs -cp ./naslib/target/naslib.jar -fv
//built-in variable
var args = $ARG;

var Inspector = com.airhacks.naslib.Inspector;
//class from jar, calling a static method
Inspector.inspect(args);

In case this post looks a bit crazy to you, you would enjoy the Java 8 / Java EE 7 "More Power with Less Code" workshop :-).


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

Friday Oct 17, 2014

Java 8, Nashorn, Nanoservices, JavaFX On-Stage Hacking and Airhacks -- End Of Year Events

See also the the Java EE Microservices workshop in January 2014.


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

Wednesday Oct 15, 2014

Star 7 feat. James Gosling: The Origins of Java ...and iPhone?

Connected and portable touch devices and color screens in ...1992. Java's origins and probably the first appearance of the duke:


NEW workshop: Microservices with Java EE 7 and Java 8, January 26th, 2015, Airport Munich

A book about rethinking Java EE Patterns

realworldpatterns.com
...the last 150 posts
...the last 10 comments
License