SlideShare a Scribd company logo
** Copyright © 2012, Oracle and/or its affiliates. All rights reserved.*
Red Hat and Oracle:
Delivering on the Promise of
Interoperability in Java EE 7
Petr Jiricka, Oracle
Max Andersen, Red Hat
* Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
The following is intended to outline our general product direction. It is intended
for information purposes only, and may not be incorporated into any contract.
It is not a commitment to deliver any material, code, or functionality, and
should not be relied upon in making purchasing decisions. The development,
release, and timing of any features or functionality described for Oracle’s
products remains at the sole discretion of Oracle.
* Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Program Agenda
■ History of vendor-specific J2EE/Java EE
■ Java EE 6
■ Java EE 7
■ JBoss and GlassFish interoperability
* Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Remember this?
* Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Maven
● Unifies dependency management
● Functional Java EE 7 API’s are now available in Maven Central
● Unified build
● Unified Examples
The thing to love or hate...
* Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JBoss Way - JavaEE Examples (and more)
http://www.jboss.org/developer/
* Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Oracle JavaEE 7 Examples
https://github.com/arun-gupta/javaee7-samples
* Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
The Example
KitchenSink - Java EE
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Java EE 7
WebSocket
JSON
Simplified JMS
Batch
Concurrency Utilities
CDI
JAX-RS
JPA
...and more
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JPA - Persistence.xml
<persistence version="2.1"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="primary">
<!-- If you are running in a production environment, add a managed
data source, this example data source is just for development and testing! -->
<properties>
<!-- Property for schema generation based on model -->
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
<!-- Property for batch loading data into database -->
<property name="javax.persistence.sql-load-script-source" value="import.sql"/>
</properties>
</persistence-unit>
</persistence>
● Default datasource
● Standard schema generation configuration
● sql-load scripting
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JSON - Parsing
URLConnection connection = new URL("https://api.github.com/search/users?q=" + member.getName()).
openConnection();
try(InputStream stream = connection.getInputStream()) {
JsonReader reader = Json.createReader(stream);
JsonObject jsonObject=reader.readObject();
if(jsonObject.containsKey("items")) {
JsonArray items = jsonObject.getJsonArray("items");
if(items.size()>0) {
avatar = items.getJsonObject(0).getString("avatar_url");
}
}
}
● Parsing of JSON
● Navigation of JSonObjects
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JSON - Writing
final JsonObjectBuilder builder = Json.createObjectBuilder();
builder.add("name", m.getName());
builder.add("email", m.getEmail());
builder.add("phoneNumber", m.getPhoneNumber());
try (JsonWriter jw = factory.createWriter(writer)) {
jw.writeObject(builder.build());
}
● Easily write out JSON structures
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Batch - Background Jobs
● Long running background jobs
● Fine vs Coarse grained setup
● Can be suspended by the Container
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Batch - Background Jobs
● On member registered
○ Start background job
○ Pull github for avatar images
○ Store image in map from id to avatar used in table
META-INF/batch-jobs/lookupgithub.xml:
<job id="lookupgithub" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">
<step id="findgithub" >
<batchlet ref="githubBatchlet"/>
</step>
</job>
@Named
public class GithubBatchlet extends AbstractBatchlet {
@Inject
private MemberRepository repository;
@Override
public String process() throws Exception {
...
}
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Batch - Background Jobs on Steroids...
● Long running background jobs
● Fine vs Coarse grained setup
● Can be suspended by the Container
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
WebSocket
■ Bi-directional communication over HTTP port
‒ Handshake to ensure both sides support WebSocket
‒ “Protocol upgrade” from HTTP
‒ Simple bidirectional messages, no headers
■ Server-side API for WebSocket in Java EE 7
‒ Server endpoint: @javax.websocket.server.ServerEndpoint
‒ Message encoders and decoders
■ Client-side API in JavaScript supported by modern browsers
■ In the KitchenSink example
‒ When a new member is registered, the server sends a WebSocket
notification about it to all clients who follow the “live log”
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
WebSocket - Server
@ServerEndpoint(
value = "/registration",
encoders = {MemberEncoder.class})
public class RegistrationEndpoint {
@OnMessage
public String onMessage(String message, Session s) {
System.out.println("received: " + message);
handleLoginRequest(s);
return "received!";
}
}
● ServerEndPoints registered via annotations
● Methods for close, open, message etc.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
WebSocket - Client
self.websocket = new WebSocket("ws://localhost/app/registration");
self.websocket.onopen = function (evt) {
console.log ('open');
window.mm.websocket.send("sending");
console.log('sent');
};
self.websocket.onmessage = function (evt) {
console.log(evt);
var m = new Member();
var dataobj = JSON.parse(evt.data);
m.name(dataobj.name);
m.email(dataobj.email);
m.phoneNumber(dataobj.phoneNumber);
window.mm.addItem(m);
};
● On Member created
○ receive message
○ refresh table livelog
*
Technology GlassFish implementation
JBoss (Wildfly)
implementation
JAX-RS Jersey RESTEasy
JPA EclipseLink Hibernate
Bundled database Derby H2
JSF Mojarra Mojarra
HTTP stack Grizzly Undertow
WebSocket Tyrus Undertow
Batch JBatch (IBM) JBaret
Implementation may be different...
… but both behave according to the specification
*
IDE support for Java EE 7 servers
Server Eclipse IDE NetBeans IDE
GlassFish GlassFish 4 (Java EE 7)
plugin by Oracle
GlassFish 4 (Java EE 7)
integration built in
JBoss JBoss Tools by RedHat
● JBoss 7 (Java EE 6)
supported now
● Wildfly 8 (Java EE 7)
early access
JBoss integration built in
● JBoss 7 (Java EE 6)
supported now
● Wildfly 8 (Java EE 7)
not supported yet
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Are we there yet ?
Java EE 7 makes it easier than ever, but…
Everything isn’t covered by spec
Software are written by humans
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Q & A
Example: https://github.com/maxandersen/jboss-as-
quickstart/tree/j1ee7
Arun Java EE 7 examples:
https://github.com/arun-gupta/javaee7-samples
JBoss Way Quickstarts:
http://www.jboss.org/developer/quickstarts.html
https://github.com/jboss-developer/jboss-eap-quickstarts

More Related Content

What's hot

Spring Boot & WebSocket
Spring Boot & WebSocketSpring Boot & WebSocket
Spring Boot & WebSocket
Ming-Ying Wu
 

What's hot (20)

Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)Web application development using Play Framework (with Java)
Web application development using Play Framework (with Java)
 
RESTful web apps with Apache Sling - 2013 version
RESTful web apps with Apache Sling - 2013 versionRESTful web apps with Apache Sling - 2013 version
RESTful web apps with Apache Sling - 2013 version
 
Migraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesMigraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sites
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
 
Play framework And Google Cloud Platform GCP.
Play framework And Google Cloud Platform GCP.Play framework And Google Cloud Platform GCP.
Play framework And Google Cloud Platform GCP.
 
Microservices with Spring Boot
Microservices with Spring BootMicroservices with Spring Boot
Microservices with Spring Boot
 
Choosing a Javascript Framework
Choosing a Javascript FrameworkChoosing a Javascript Framework
Choosing a Javascript Framework
 
[1D1]신개념 N스크린 웹 앱 프레임워크 PARS
[1D1]신개념 N스크린 웹 앱 프레임워크 PARS[1D1]신개념 N스크린 웹 앱 프레임워크 PARS
[1D1]신개념 N스크린 웹 앱 프레임워크 PARS
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
Using VueJS in front of Drupal 8
Using VueJS in front of Drupal 8Using VueJS in front of Drupal 8
Using VueJS in front of Drupal 8
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Maven
Maven Maven
Maven
 
Node JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web AppNode JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web App
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIWordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
 
Spring Boot and Microservices
Spring Boot and MicroservicesSpring Boot and Microservices
Spring Boot and Microservices
 
React Native in Production
React Native in ProductionReact Native in Production
React Native in Production
 
Improving build solutions dependency management with webpack
Improving build solutions  dependency management with webpackImproving build solutions  dependency management with webpack
Improving build solutions dependency management with webpack
 
Spring Boot & WebSocket
Spring Boot & WebSocketSpring Boot & WebSocket
Spring Boot & WebSocket
 

Similar to Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7

How Scala, Wicket, and Java EE Can Improve Web Development
How Scala, Wicket, and Java EE Can Improve Web DevelopmentHow Scala, Wicket, and Java EE Can Improve Web Development
How Scala, Wicket, and Java EE Can Improve Web Development
Bruno Borges
 
Java EE 7: Boosting Productivity and Embracing HTML5
Java EE 7: Boosting Productivity and Embracing HTML5Java EE 7: Boosting Productivity and Embracing HTML5
Java EE 7: Boosting Productivity and Embracing HTML5
Arun Gupta
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
Tuna Tore
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
Tuna Tore
 

Similar to Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7 (20)

Batch Applications for Java Platform 1.0: Java EE 7 and GlassFish
Batch Applications for Java Platform 1.0: Java EE 7 and GlassFishBatch Applications for Java Platform 1.0: Java EE 7 and GlassFish
Batch Applications for Java Platform 1.0: Java EE 7 and GlassFish
 
GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012
 
How Scala, Wicket, and Java EE Can Improve Web Development
How Scala, Wicket, and Java EE Can Improve Web DevelopmentHow Scala, Wicket, and Java EE Can Improve Web Development
How Scala, Wicket, and Java EE Can Improve Web Development
 
Java EE7
Java EE7Java EE7
Java EE7
 
Java ee7 1hour
Java ee7 1hourJava ee7 1hour
Java ee7 1hour
 
GlassFish REST Administration Backend
GlassFish REST Administration BackendGlassFish REST Administration Backend
GlassFish REST Administration Backend
 
Batch Applications for the Java Platform
Batch Applications for the Java PlatformBatch Applications for the Java Platform
Batch Applications for the Java Platform
 
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
 
Java EE 7 in practise - OTN Hyderabad 2014
Java EE 7 in practise - OTN Hyderabad 2014Java EE 7 in practise - OTN Hyderabad 2014
Java EE 7 in practise - OTN Hyderabad 2014
 
20151010 my sq-landjavav2a
20151010 my sq-landjavav2a20151010 my sq-landjavav2a
20151010 my sq-landjavav2a
 
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
 
Java EE 7: Boosting Productivity and Embracing HTML5
Java EE 7: Boosting Productivity and Embracing HTML5Java EE 7: Boosting Productivity and Embracing HTML5
Java EE 7: Boosting Productivity and Embracing HTML5
 
Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Have You Seen Java EE Lately?
Have You Seen Java EE Lately?
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
 
JAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesJAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web Services
 
Jsp and jstl
Jsp and jstlJsp and jstl
Jsp and jstl
 
Java EE7 Demystified
Java EE7 DemystifiedJava EE7 Demystified
Java EE7 Demystified
 
What's new in Java EE 7? From HTML5 to JMS 2.0
What's new in Java EE 7? From HTML5 to JMS 2.0What's new in Java EE 7? From HTML5 to JMS 2.0
What's new in Java EE 7? From HTML5 to JMS 2.0
 
Marcin Szałowicz - MySQL Workbench
Marcin Szałowicz - MySQL WorkbenchMarcin Szałowicz - MySQL Workbench
Marcin Szałowicz - MySQL Workbench
 

More from Max Andersen

JBoss Asylum Podcast Live from JUDCon 2010
JBoss Asylum Podcast Live from JUDCon 2010JBoss Asylum Podcast Live from JUDCon 2010
JBoss Asylum Podcast Live from JUDCon 2010
Max Andersen
 

More from Max Andersen (16)

Quarkus Denmark 2019
Quarkus Denmark 2019Quarkus Denmark 2019
Quarkus Denmark 2019
 
Docker Tooling for Eclipse
Docker Tooling for EclipseDocker Tooling for Eclipse
Docker Tooling for Eclipse
 
OpenShift: Java EE in the clouds
OpenShift: Java EE in the cloudsOpenShift: Java EE in the clouds
OpenShift: Java EE in the clouds
 
Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...
Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...
Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...
 
Enterprise Maven Repository BOF
Enterprise Maven Repository BOFEnterprise Maven Repository BOF
Enterprise Maven Repository BOF
 
Google analytics for Eclipse Plugins
Google analytics for Eclipse PluginsGoogle analytics for Eclipse Plugins
Google analytics for Eclipse Plugins
 
JBoss Enterprise Maven Repository
JBoss Enterprise Maven RepositoryJBoss Enterprise Maven Repository
JBoss Enterprise Maven Repository
 
Ceylon - the language and its tools
Ceylon - the language and its toolsCeylon - the language and its tools
Ceylon - the language and its tools
 
Tycho - good, bad or ugly ?
Tycho - good, bad or ugly ?Tycho - good, bad or ugly ?
Tycho - good, bad or ugly ?
 
Making Examples Accessible
Making Examples AccessibleMaking Examples Accessible
Making Examples Accessible
 
OpenShift Express Intro
OpenShift Express IntroOpenShift Express Intro
OpenShift Express Intro
 
JBoss AS 7 from a user perspective
JBoss AS 7 from a user perspectiveJBoss AS 7 from a user perspective
JBoss AS 7 from a user perspective
 
How to be effective with JBoss Developer Studio
How to be effective with JBoss Developer StudioHow to be effective with JBoss Developer Studio
How to be effective with JBoss Developer Studio
 
JBoss Asylum Podcast Live from JUDCon 2010
JBoss Asylum Podcast Live from JUDCon 2010JBoss Asylum Podcast Live from JUDCon 2010
JBoss Asylum Podcast Live from JUDCon 2010
 
How To Make A Framework Plugin That Does Not Suck
How To Make A Framework Plugin That Does Not SuckHow To Make A Framework Plugin That Does Not Suck
How To Make A Framework Plugin That Does Not Suck
 
Kickstart Jpa
Kickstart JpaKickstart Jpa
Kickstart Jpa
 

Recently uploaded

Recently uploaded (20)

Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 

Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7

  • 1. ** Copyright © 2012, Oracle and/or its affiliates. All rights reserved.*
  • 2. Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7 Petr Jiricka, Oracle Max Andersen, Red Hat
  • 3. * Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
  • 4. * Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Program Agenda ■ History of vendor-specific J2EE/Java EE ■ Java EE 6 ■ Java EE 7 ■ JBoss and GlassFish interoperability
  • 5. * Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Remember this?
  • 6. * Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Maven ● Unifies dependency management ● Functional Java EE 7 API’s are now available in Maven Central ● Unified build ● Unified Examples The thing to love or hate...
  • 7. * Copyright © 2012, Oracle and/or its affiliates. All rights reserved. JBoss Way - JavaEE Examples (and more) http://www.jboss.org/developer/
  • 8. * Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Oracle JavaEE 7 Examples https://github.com/arun-gupta/javaee7-samples
  • 9. * Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The Example KitchenSink - Java EE
  • 10. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Java EE 7 WebSocket JSON Simplified JMS Batch Concurrency Utilities CDI JAX-RS JPA ...and more
  • 11. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. JPA - Persistence.xml <persistence version="2.1" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_1.xsd"> <persistence-unit name="primary"> <!-- If you are running in a production environment, add a managed data source, this example data source is just for development and testing! --> <properties> <!-- Property for schema generation based on model --> <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/> <!-- Property for batch loading data into database --> <property name="javax.persistence.sql-load-script-source" value="import.sql"/> </properties> </persistence-unit> </persistence> ● Default datasource ● Standard schema generation configuration ● sql-load scripting
  • 12. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. JSON - Parsing URLConnection connection = new URL("https://api.github.com/search/users?q=" + member.getName()). openConnection(); try(InputStream stream = connection.getInputStream()) { JsonReader reader = Json.createReader(stream); JsonObject jsonObject=reader.readObject(); if(jsonObject.containsKey("items")) { JsonArray items = jsonObject.getJsonArray("items"); if(items.size()>0) { avatar = items.getJsonObject(0).getString("avatar_url"); } } } ● Parsing of JSON ● Navigation of JSonObjects
  • 13. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. JSON - Writing final JsonObjectBuilder builder = Json.createObjectBuilder(); builder.add("name", m.getName()); builder.add("email", m.getEmail()); builder.add("phoneNumber", m.getPhoneNumber()); try (JsonWriter jw = factory.createWriter(writer)) { jw.writeObject(builder.build()); } ● Easily write out JSON structures
  • 14. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Batch - Background Jobs ● Long running background jobs ● Fine vs Coarse grained setup ● Can be suspended by the Container
  • 15. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Batch - Background Jobs ● On member registered ○ Start background job ○ Pull github for avatar images ○ Store image in map from id to avatar used in table META-INF/batch-jobs/lookupgithub.xml: <job id="lookupgithub" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0"> <step id="findgithub" > <batchlet ref="githubBatchlet"/> </step> </job> @Named public class GithubBatchlet extends AbstractBatchlet { @Inject private MemberRepository repository; @Override public String process() throws Exception { ... } }
  • 16. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Batch - Background Jobs on Steroids... ● Long running background jobs ● Fine vs Coarse grained setup ● Can be suspended by the Container
  • 17. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. WebSocket ■ Bi-directional communication over HTTP port ‒ Handshake to ensure both sides support WebSocket ‒ “Protocol upgrade” from HTTP ‒ Simple bidirectional messages, no headers ■ Server-side API for WebSocket in Java EE 7 ‒ Server endpoint: @javax.websocket.server.ServerEndpoint ‒ Message encoders and decoders ■ Client-side API in JavaScript supported by modern browsers ■ In the KitchenSink example ‒ When a new member is registered, the server sends a WebSocket notification about it to all clients who follow the “live log”
  • 18. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. WebSocket - Server @ServerEndpoint( value = "/registration", encoders = {MemberEncoder.class}) public class RegistrationEndpoint { @OnMessage public String onMessage(String message, Session s) { System.out.println("received: " + message); handleLoginRequest(s); return "received!"; } } ● ServerEndPoints registered via annotations ● Methods for close, open, message etc.
  • 19. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. WebSocket - Client self.websocket = new WebSocket("ws://localhost/app/registration"); self.websocket.onopen = function (evt) { console.log ('open'); window.mm.websocket.send("sending"); console.log('sent'); }; self.websocket.onmessage = function (evt) { console.log(evt); var m = new Member(); var dataobj = JSON.parse(evt.data); m.name(dataobj.name); m.email(dataobj.email); m.phoneNumber(dataobj.phoneNumber); window.mm.addItem(m); }; ● On Member created ○ receive message ○ refresh table livelog
  • 20. * Technology GlassFish implementation JBoss (Wildfly) implementation JAX-RS Jersey RESTEasy JPA EclipseLink Hibernate Bundled database Derby H2 JSF Mojarra Mojarra HTTP stack Grizzly Undertow WebSocket Tyrus Undertow Batch JBatch (IBM) JBaret Implementation may be different... … but both behave according to the specification
  • 21. * IDE support for Java EE 7 servers Server Eclipse IDE NetBeans IDE GlassFish GlassFish 4 (Java EE 7) plugin by Oracle GlassFish 4 (Java EE 7) integration built in JBoss JBoss Tools by RedHat ● JBoss 7 (Java EE 6) supported now ● Wildfly 8 (Java EE 7) early access JBoss integration built in ● JBoss 7 (Java EE 6) supported now ● Wildfly 8 (Java EE 7) not supported yet
  • 22. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Are we there yet ? Java EE 7 makes it easier than ever, but… Everything isn’t covered by spec Software are written by humans
  • 23. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Q & A Example: https://github.com/maxandersen/jboss-as- quickstart/tree/j1ee7 Arun Java EE 7 examples: https://github.com/arun-gupta/javaee7-samples JBoss Way Quickstarts: http://www.jboss.org/developer/quickstarts.html https://github.com/jboss-developer/jboss-eap-quickstarts