SlideShare une entreprise Scribd logo
1  sur  69
JEE.next()
Kuba Marchwicki
@kubem
Gdańsk, 26.09.2013
Perfection is achieved, not when
there is nothing more to add,
but when there is nothing left to
take away.
Antoine de Saint-Exupery
J2EE 1.2
Servlet, JSP,
EJB, JMS,
RMI
1999
J2EE 1.3
CMP, Connec
tor
Architecture
2001
J2EE 1.4
Web
Services,
Deployment,
Async
Connector
2003
JEE 5
Prunning
EJB
3.0, JPA, JSF,
JAXB,
JAX-WS, StAX
2006
Web profile
Servlet 3.0
EJB 3.1 Lite
2009
Web profile
JAX-RS 2.0
2013
JEE 6
Prunning
CDI,
JAX-RS
JEE 7
Prunning
JMS 2.0,
Batch,
JSON,
Web sockets
Servlet 3.0
JSF 2.0
EJB 3.1
JPA 2.0
JSP
CDI
JTA
Bean
Validation
JAX-WS
JAX-RPC
JAXR
SAAJ
JAX-RS
JAXB
JMS
JAAS
JASPIC
JACC
JCA
JavaMail
JSR 88
JSR 77
RMI
JNDI
Web profile
Full profile
Java EE6 profiles
JSP 2.2 JSF 2.2
JAX-RS
2.0
EL 3.0
Servlet 3.1
Portable
extensions
CDI 1.1 Interceptors 1.1
Common
Annotations 1.1
Managed Beans 1.0 EJB 3.2
Connector
1.6
JPA 2.1 JTA 1.2 JMS 2.0 BeanValidation1.1
Concurrency Utilities
(JSR 236)
Batch Applications
(JSR 352)
Java API for JSON
(JSR 353)
Java API for Websockets
(JSR 356)
Java EE7
JSP 2.2 JSF 2.2
JAX-RS
2.0
EL 3.0
Servlet 3.1
Portable
extensions
CDI 1.1 Interceptors 1.1
Common
Annotations 1.1
Managed Beans 1.0 EJB 3.2
Connector
1.6
JPA 2.1 JTA 1.2 JMS 2.0 BeanValidation1.1
Concurrency Utilities
(JSR 236)
Batch Applications
(JSR 352)
Java API for JSON
(JSR 353)
Java API for Websockets
(JSR 356)
Java EE7 deep dive
Java EE7 deep dive
• JMS 2.0
• JPA 2.1
• Bean Validation 1.1
• JAX-RS 2.0
• Java API for JSON
• Java API for Websockets
• Batch Application
• Concurrency Utilities
Before we start
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
Java EE7 deep dive
• JMS 2.0
• JPA 2.1
• Bean Validation 1.1
• JAX-RS 2.0
• Java API for JSON
• Java API for Websockets
• Batch Application
• Concurrency Utilities
JMS 2.0
Configuration - Old API
??
JMS 2.0
Configuration - Old API
<subsystem xmlns="urn:jboss:domain:messaging:1.1">
<hornetq-server>
<jms-destinations>
<jms-queue name="testQueue">
<entry name="queue/test"/>
</jms-queue>
<jms-topic name="testTopic">
<entry name="topic/test"/>
</jms-topic>
</jms-destinations>
</hornetq-server>
</subsystem>
JMS 2.0
Configuration – New API
@JMSConnectionFactoryDefinition(
name = "java:global/jms/demoConnectionFactory",
className = "javax.jms.ConnectionFactory")
@JMSDestinationDefinition(
name = "java:global/jms/demoQueue",
interfaceName = "javax.jms.Queue",
destinationName = "demoQueue")
public class JmsConfiguration {
}
JMS 2.0
Send message – Old API
@Stateless
public class SendMessageService {
@Resource(lookup = "java:global/jms/demoConnectionFactory")
ConnectionFactory connectionFactory;
@Resource(lookup = "java:global/jms/demoQueue")
Queue demoQueue;
public void sendMessage(String payload) {
try {
Connection connection = connectionFactory.createConnection();
try {
Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
MessageProducer messageProducer = session
.createProducer(demoQueue);
TextMessage textMessage = session.createTextMessage(payload);
messageProducer.send(textMessage);
} finally {
//...
JMS 2.0
Send message – New API
@Stateless
public class MessageService {
@Inject
private JMSContext context;
@Resource(mappedName = "jms/inboundQueue")
private Queue inboundQueue;
public void sendMessage(String payload) {
context.createProducer().send(inboundQueue, payload);
}
}
JMS 2.0
Receive message – New API
@MessageDriven(mappedName="global/jms/demoQueue")
public class MessageConsumer implements MessageListener {
@Override
public void onMessage(Message msg) {
try {
//No casting!!!
String payload = msg.getBody(String.class);
} catch (JMSException e) {
e.printStackTrace();
}
}
}
Java EE7 deep dive
• JMS 2.0
• JPA 2.1
• Bean Validation 1.1
• JAX-RS 2.0
• Java API for JSON
• Java API for Websockets
• Batch Application
• Concurrency Utilities
JPA 2.1
Old API - persistence.xml
<persistence-unit>
<properties>
<property name="hibernate.connection.driver_class"
value="org.apache.derby.jdbc.ClientDriver" />
<property name="hibernate.connection.url"
value="jdbc:derby://localhost:1527/sample;create=true" />
<property name="hibernate.connection.username" value="user" />
<property name="hibernate.connection.password" value="pass" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.use_sql_comments" value="true" />
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQL5Dialect" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
</properties>
</persistence-unit>
JPA 2.1
Old API - persistence.xml
<persistence-unit>
<properties>
<property name="eclipselink.jdbc.driver"
value="org.apache.derby.jdbc.ClientDriver" />
<property name="eclipselink.jdbc.url"
value="jdbc:derby://localhost:1527/sample;create=true" />
<property name="eclipselink.jdbc.user" value="user" />
<property name="eclipselink.jdbc.password" value="pass" />
<property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.target-database"
value="org.eclipse.persistence.platform.database.MySQLPlatform" />
<property name="eclipselink.ddl-generation"
value="drop-and-create-tables" />
<property name="eclipselink.ddl-generation.output-mode"
value="database" />
</properties>
</persistence-unit>
JPA 2.1
New API - persistence.xml
<persistence-unit>
<properties>
<property name="javax.persistence.jdbc.driver"
value="org.apache.derby.jdbc.ClientDriver" />
<property name="javax.persistence.jdbc.url"
value="jdbc:derby://localhost:1527/sample;create=true" />
<property name="javax.persistence.jdbc.user" value="user" />
<property name="javax.persistence.jdbc.password" value="pass" />
<property name="javax.persistence.schema-generation.database.action"
value="drop-and-create" />
<property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.target-database"
value="org.eclipse.persistence.platform.database.MySQLPlatform" />
</properties>
</persistence-unit>
JPA 2.1
Old API – Converters
public enum UseSex {
MALE, FEMALE;
}
@Entity
public class User {
@Id
private long id;
@Enumerated(EnumType.ORDINAL)
private UserSex sex;
//..
}
JPA 2.1
Old API – Converters
public enum UseSex {
MALE, FEMALE;
}
@Entity
public class User {
@Id
private long id;
@Enumerated(EnumType.STRING)
private UserSex sex;
//..
}
JPA 2.1
Old API – Converters
@Entity
public class User {
@Transient
private UserSex sex;
private String db_sex;
@PostLoad
public void afterLoad() {
switch(db_sex){
case "M": sex = UserSex.MALE;
case "F": sex = UserSex.FEMALE;
default: throw new IllegalArgumentException();
}
}
JPA 2.1
Old API – Converters
@PrePersist
public void beforePersit() {
switch(sex){
case MALE: db_sex = "M";
case FEMALE: db_sex = "F";
default: throw new IllegalArgumentException();
}
}
JPA 2.1
New API
@Entity
public class User {
@Id
private long id;
@Convert(converter = SexConverter.class)
private UserSex sex;
//..
}
JPA 2.1
New API
@Converter
public class SexConverter implements AttributeConverter<UserSex, String>{
public String convertToDatabaseColumn(UserSex arg0) {
switch(arg0){
case MALE: return "M";
case FEMALE: return "F";
default: throw new IllegalArgumentException();
}
}
public UserSex convertToEntityAttribute(String arg0) {
switch(arg0){
case "M": return UserSex.MALE;
case "F": return UserSex.FEMALE;
default: throw new IllegalArgumentException();
}
}
}
JPA 2.1
New API – stored procedures
@Table(indexes = @Index(columnList = "name"))
@Entity
@NamedQuery(name = User.FIND_USER_BY_NAME,
query = "from User u where name = ?")
@NamedStoredProcedureQuery(name = User. REFRESH_USERS,
procedureName = "USR_STRD_PRCR_CALL")
public class User {
public final static String FIND_USER_BY_NAME = "User.findByName";
public final static String REFRESH_USERS = "User.doSomething";
//..
}
Java EE7 deep dive
• JMS 2.0
• JPA 2.1
• Bean Validation 1.1
• JAX-RS 2.0
• Java API for JSON
• Java API for Websockets
• Batch Application
• Concurrency Utilities
Bean Validation 1.1
Old API
@Interceptors(ValidationInterceptor.class)
public void addAuthor(@Size(min=5) String name,
String surename) {
Author a = new Author();
a.setName(name);
a.setSurename(surename);
em.persist(a);
}
Bean Validation 1.1
Old API
public Object validateMethodInvocation
(InvocationContext ctx) throws Exception {
MethodValidator validator = validatorFactory.getValidator()
.unwrap(MethodValidator.class);
Set<MethodConstraintViolation<Object>> violations =
validator.validateAllParameters(
ctx.getTarget(),
ctx.getMethod(),
ctx.getParameters());
}
Bean Validation 1.1
New API
public void addAuthor(@Size(min=5) String name,
String surename) {
Author a = new Author();
a.setName(name);
a.setSurename(surename);
em.persist(a);
}
Bean Validation 1.1
New API
@Path("/hello")
public class HelloWorld {
@Path("/{name}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public JsonObject sayHello(
@NotEmpty @PathParam("name") String name) {
//..
}
}
Java EE7 deep dive
• JMS 2.0
• JPA 2.1
• Bean Validation 1.1
• JAX-RS 2.0
• Java API for JSON
• Java API for Websockets
• Batch Application
• Concurrency Utilities
JAX-RS 2.0
Configuration - Old API
??
JAX-RS 2.0
Configuration - Old API
<servlet>
<servlet-name>JAX-RS Servlet</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS Servlet</servlet-name>
<url-pattern>/jax-rs/*</url-pattern>
</servlet-mapping>
JAX-RS 2.0
Configuration – New API
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/rs")
public class RestApp extends Application {
}
JAX-RS 2.0
Client - Old API
HttpURLConnection connection =
(HttpURLConnection)serverAddress.openConnection();
connection.setRequestMethod("GET");
connection.setDoOutput(true);
connection.setReadTimeout(10000);
BufferedReader rd = new BufferedReader(
new InputStreamReader(connection.getInputStream()));
StringBuilder sb = new StringBuilder();
while ((line = rd.readLine()) != null) {
sb.append(line + 'n');
}
System.out.println(sb.toString());
JAX-RS 2.0
Client - Old API
<dependency>
<groupId>com.github.kevinsawicki</groupId>
<artifactId>http-request</artifactId>
<version>5.4.1</version>
</dependency>
HttpRequest request = HttpRequest.get(baseURL)
.receive(output);
System.out.println(request.toString());
JAX-RS 2.0
New API
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
Client client = ClientBuilder.newBuilder().build();
WebTarget target = client.target(uri.toString());
Response response = target.request().get();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(target.request().get(String.class))
.isEqualTo("{}");
Java EE7 deep dive
• JMS 2.0
• JPA 2.1
• Bean Validation 1.1
• JAX-RS 2.0
• Java API for JSON
• Java API for Websockets
• Batch Application
• Concurrency Utilities
Java API for JSON Processing
{
"data": [
"Hello Jakub",
"Guten Tag Jakub"
]
}
Java API for JSON Processing
Old API
??
Java API for JSON Processing
New API – streaming API
JsonParser parser = Json.
createParser(new StringReader(string)));
event = parser.next();
assertThat(event).is(new Condition<Object>() {
public boolean matches(Object value) {
return value instanceof Event
&& value == Event.VALUE_STRING;
}
});
assertThat(parser.getString()).isEqualTo("Hello Jakub");
Java API for JSON Processing
New API – object API
JsonReader reader = Json.
createReader(new StringReader(string));
JsonObject obj = reader.readObject();
assertThat(obj.containsKey("data")).isTrue();
JsonArray results = obj.getJsonArray("data");
assertThat(results.size()).isEqualTo(2);
assertThat(results.getString(0)).isEqualTo("Hello Jakub");
assertThat(results.getString(1)).isEqualTo("Guten tag Jakub");
Java API for JSON Processing
New API – builder
import javax.json.Json;
import javax.json.JsonObject;
@Path("/simple/{name}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public JsonObject saySimpleHello(@PathParam("name") String name) {
return Json.createObjectBuilder()
.add("data", Json.createArrayBuilder()
.add("Hello " + name)
.add("Guten tag " + name)
.build())
.build();
}
Java EE7 deep dive
• JMS 2.0
• JPA 2.1
• Bean Validation 1.1
• JAX-RS 2.0
• Java API for JSON
• Java API for Websockets
• Batch Application
• Concurrency Utilities
Java API for Websockets
Old API #1
@WebServlet(urlPatterns = "/ping")
public class FeedNotifierWebSocket extends WebSocketServlet {
protected StreamInbound createWebSocketInbound(
String subprotocol,
HttpServletRequest req) {
//..
}
}
Java API for Websockets
Old API #1
class NotificationInbound extends MessageInbound {
private WsOutbound outbound;
protected void onOpen(WsOutbound outbound) {
this.outbound = outbound;
}
protected void onBinaryMessage(ByteBuffer m) {
outbound.writeBinaryMessage(message);
}
protected void onTextMessage(CharBuffer m) {
outbound.writeTextMessage(message);
}
}
Java API for Websockets
Old API #2
@Singleton
@WebSocketEndpoint(path=”/chat”)
public class ChatServer {
Set<Session> peers = new HashSet<>();
@WebSocketOpen
public void onOpen(Session peer) {
peers.add(session);
}
@WebSocketClose
public void onClose(Session session) {
peers.remove(session);
}
...
Java API for Websockets
Old API #2
@WebSocketMessage
public void message(String message, Session client)
throws IOException {
for (Session session : peers) {
if (!session.equals(client)) {
session.getRemote().sendObject(message);
}
}
}
Java API for Websockets
New API
@Singleton
@ServerEndpoint("/ping")
public class NotificationServer {
Set<Session> sessions = new HashSet<>();
@OnOpen
public void onOpen(Session s) throws IOException {
sessions.add(s);
}
@OnClose
public void onClose(Session s) throws IOException {
sessions.remove(s);
}
...
Java API for Websockets
New API
@OnMessage
public void message(String m, Session client)
throws IOException {
for (Session s: sessions) {
if (s == client) continue;
try {
s.getBasicRemote().sendText(m);
} catch (Exception e) {
onClose(s);
}
}
}
}
Java EE7 deep dive
• JMS 2.0
• JPA 2.1
• Bean Validation 1.1
• JAX-RS 2.0
• Java API for JSON
• Java API for Websockets
• Batch Application
• Concurrency Utilities
Batch Applications
Old API
??
Batch Applications
Item Reader
Item Processor
Item Writer
Jobs Repository
Job
Operator
Job Step
1 *
1
1
1
1
11
Batch Applications
Job Repository
holds information about jobs current running
and jobs that run in the past. JobOperator
provides access to this repository.
Job Operator
an interface to manage all aspects of job
processing, including operational commands,
such as start, restart, and stop, retrieval of job
and step executions.
Batch Applications
Job
encapsulates an entire batch process
<job id="myJob" xmlns="http://batch.jsr352/jsl">
<step id="myStep" >
<chunk reader="MyItemReader"
writer="MyItemWriter"
processor="MyItemProcessor"
buffer-size="5"
checkpoint-policy="item"
commit-interval="10" />
</step>
</job>
Batch Applications
Chunks
@ItemReader
public class MyItemReader {
//...
}
@ItemProcessor
public class MyItemProcessor {
//...
}
@ItemWriter
public class MyItemWriter {
//...
}
Java EE7 deep dive
• JMS 2.0
• JPA 2.1
• Bean Validation 1.1
• JAX-RS 2.0
• Java API for JSON
• Java API for Websockets
• Batch Application
• Concurrency Utilities
The enterprise bean must not
attempt to manage threads. The
enterprise bean must not attempt
to start, stop, suspend, or resume a
thread, or to change a thread’s
priority or name. The enterprise
bean must not attempt to manage
thread groups.
21.2.2. Programming restrictions
@Asynchronous
Old API
@Stateless
public class EventWatcher {
@Asynchronous
public void method(FeedEvent event) {
System.out.println(event);
}
}
Asynchronous Servlets
Old API
@WebServlet(urlPatterns = "/somepath", asyncSupported = true)
public class AsyncServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
//..
}
}
ManagedThreadFactory
New API
@Named
public class ThreadManager {
@Resource
ManagedThreadFactory mtf;
public ExecutorService getThreadManager() {
return new ThreadPoolExecutor(5,10, 10,
TimeUnit.SECONDS,
new ArrayBlockingQueue<Runnable>(100),
mtf);
}
}
ManagedThreadFactory
New API
@Named
public class ProcessingService {
public void doMuchStuff(ExecutorService executor) {
for (int i = 0; i < 50; i++) {
Runnable worker = new WorkerThread("" + i);
executor.execute(worker);
}
executor.shutdown();
}
}
Java EE8 ??
• JSON-B (JSON binding)
• JCache (JSR 107)
• Adopt JSR
• Open TCK (??)
• More JSP (+ templates), less JSF
• no more EARs (??)
twitter: @kubem
http://github.com/kubamarchwicki/jee7-examples
http://www.slideshare.net/kubamarchwicki/jeenext
In case you ask – we are hiring

Contenu connexe

Tendances

Java EE 與 雲端運算的展望
Java EE 與 雲端運算的展望 Java EE 與 雲端運算的展望
Java EE 與 雲端運算的展望 javatwo2011
 
Fifty Features of Java EE 7 in 50 Minutes
Fifty Features of Java EE 7 in 50 MinutesFifty Features of Java EE 7 in 50 Minutes
Fifty Features of Java EE 7 in 50 Minutesglassfish
 
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013Arun Gupta
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/ServletSunil OS
 
Java9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadJava9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadDavid Gómez García
 
Distributed Objects and JAVA
Distributed Objects and JAVADistributed Objects and JAVA
Distributed Objects and JAVAelliando dias
 
Java rmi example program with code
Java rmi example program with codeJava rmi example program with code
Java rmi example program with codekamal kotecha
 
Workshop 19: ReactJS Introduction
Workshop 19: ReactJS IntroductionWorkshop 19: ReactJS Introduction
Workshop 19: ReactJS IntroductionVisual Engineering
 
Spring 4 final xtr_presentation
Spring 4 final xtr_presentationSpring 4 final xtr_presentation
Spring 4 final xtr_presentationsourabh aggarwal
 
Creating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat ApplicationCreating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat ApplicationMicha Kops
 
50 new features of Java EE 7 in 50 minutes
50 new features of Java EE 7 in 50 minutes50 new features of Java EE 7 in 50 minutes
50 new features of Java EE 7 in 50 minutesAntonio Goncalves
 
React Native: JS MVC Meetup #15
React Native: JS MVC Meetup #15React Native: JS MVC Meetup #15
React Native: JS MVC Meetup #15Rob Gietema
 
Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1Michał Orman
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with SpringJoshua Long
 
OpenDMS - the first 2 weeks
OpenDMS - the first 2 weeksOpenDMS - the first 2 weeks
OpenDMS - the first 2 weeksJPC Hanson
 

Tendances (20)

Java EE 與 雲端運算的展望
Java EE 與 雲端運算的展望 Java EE 與 雲端運算的展望
Java EE 與 雲端運算的展望
 
Fifty Features of Java EE 7 in 50 Minutes
Fifty Features of Java EE 7 in 50 MinutesFifty Features of Java EE 7 in 50 Minutes
Fifty Features of Java EE 7 in 50 Minutes
 
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
 
Java9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidadJava9 Beyond Modularity - Java 9 más allá de la modularidad
Java9 Beyond Modularity - Java 9 más allá de la modularidad
 
Distributed Objects and JAVA
Distributed Objects and JAVADistributed Objects and JAVA
Distributed Objects and JAVA
 
Java rmi example program with code
Java rmi example program with codeJava rmi example program with code
Java rmi example program with code
 
Workshop 19: ReactJS Introduction
Workshop 19: ReactJS IntroductionWorkshop 19: ReactJS Introduction
Workshop 19: ReactJS Introduction
 
Spring 4 final xtr_presentation
Spring 4 final xtr_presentationSpring 4 final xtr_presentation
Spring 4 final xtr_presentation
 
Best Of Jdk 7
Best Of Jdk 7Best Of Jdk 7
Best Of Jdk 7
 
Tech talk
Tech talkTech talk
Tech talk
 
Java jdbc
Java jdbcJava jdbc
Java jdbc
 
Spring 4 Web App
Spring 4 Web AppSpring 4 Web App
Spring 4 Web App
 
Creating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat ApplicationCreating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat Application
 
50 new features of Java EE 7 in 50 minutes
50 new features of Java EE 7 in 50 minutes50 new features of Java EE 7 in 50 minutes
50 new features of Java EE 7 in 50 minutes
 
11-DWR-and-JQuery
11-DWR-and-JQuery11-DWR-and-JQuery
11-DWR-and-JQuery
 
React Native: JS MVC Meetup #15
React Native: JS MVC Meetup #15React Native: JS MVC Meetup #15
React Native: JS MVC Meetup #15
 
Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with Spring
 
OpenDMS - the first 2 weeks
OpenDMS - the first 2 weeksOpenDMS - the first 2 weeks
OpenDMS - the first 2 weeks
 

Similaire à JEE.next()

The First Contact with Java EE 7
The First Contact with Java EE 7The First Contact with Java EE 7
The First Contact with Java EE 7Roberto Cortez
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
Testing in android
Testing in androidTesting in android
Testing in androidjtrindade
 
Java ee 7 New Features
Java ee 7   New FeaturesJava ee 7   New Features
Java ee 7 New FeaturesShahzad Badar
 
PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootJosué Neis
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasyJBug Italy
 
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Codemotion
 
Module design pattern i.e. express js
Module design pattern i.e. express jsModule design pattern i.e. express js
Module design pattern i.e. express jsAhmed Assaf
 
Jax ws
Jax wsJax ws
Jax wsF K
 
node.js practical guide to serverside javascript
node.js practical guide to serverside javascriptnode.js practical guide to serverside javascript
node.js practical guide to serverside javascriptEldar Djafarov
 
Laurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationLaurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationAjax Experience 2009
 
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 2014Jagadish Prasath
 
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfCreating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfShaiAlmog1
 
Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)Hamed Hatami
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stackTomáš Kypta
 
What's new in JMS 2.0 - OTN Bangalore 2013
What's new in JMS 2.0 - OTN Bangalore 2013What's new in JMS 2.0 - OTN Bangalore 2013
What's new in JMS 2.0 - OTN Bangalore 2013Jagadish Prasath
 

Similaire à JEE.next() (20)

Codemotion appengine
Codemotion appengineCodemotion appengine
Codemotion appengine
 
The First Contact with Java EE 7
The First Contact with Java EE 7The First Contact with Java EE 7
The First Contact with Java EE 7
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
Testing in android
Testing in androidTesting in android
Testing in android
 
Java ee 7 New Features
Java ee 7   New FeaturesJava ee 7   New Features
Java ee 7 New Features
 
PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBoot
 
RESTEasy
RESTEasyRESTEasy
RESTEasy
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasy
 
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
 
Module design pattern i.e. express js
Module design pattern i.e. express jsModule design pattern i.e. express js
Module design pattern i.e. express js
 
Jax ws
Jax wsJax ws
Jax ws
 
node.js practical guide to serverside javascript
node.js practical guide to serverside javascriptnode.js practical guide to serverside javascript
node.js practical guide to serverside javascript
 
Laurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationLaurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus Presentation
 
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
 
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfCreating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdf
 
Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)
 
JDBC Tutorial
JDBC TutorialJDBC Tutorial
JDBC Tutorial
 
Brief Intro To Jax Rs
Brief Intro To Jax RsBrief Intro To Jax Rs
Brief Intro To Jax Rs
 
Modern Android app library stack
Modern Android app library stackModern Android app library stack
Modern Android app library stack
 
What's new in JMS 2.0 - OTN Bangalore 2013
What's new in JMS 2.0 - OTN Bangalore 2013What's new in JMS 2.0 - OTN Bangalore 2013
What's new in JMS 2.0 - OTN Bangalore 2013
 

Plus de Jakub Marchwicki

Test with Spock like the first officer
Test with Spock like the first officerTest with Spock like the first officer
Test with Spock like the first officerJakub Marchwicki
 
Design principles 4 hackers - tech3camp (28142014)
Design principles 4 hackers - tech3camp (28142014)Design principles 4 hackers - tech3camp (28142014)
Design principles 4 hackers - tech3camp (28142014)Jakub Marchwicki
 
[PL] Jak programować aby nie zwariować
[PL] Jak programować aby nie zwariować[PL] Jak programować aby nie zwariować
[PL] Jak programować aby nie zwariowaćJakub Marchwicki
 
GeeCON 2013 - EJB application guided by tests
GeeCON 2013 - EJB application guided by testsGeeCON 2013 - EJB application guided by tests
GeeCON 2013 - EJB application guided by testsJakub Marchwicki
 
[PL] Jak programować aby nie zwariować?
[PL] Jak programować aby nie zwariować?[PL] Jak programować aby nie zwariować?
[PL] Jak programować aby nie zwariować?Jakub Marchwicki
 
GeeCON 2012 hurdle run through ejb testing
GeeCON 2012 hurdle run through ejb testingGeeCON 2012 hurdle run through ejb testing
GeeCON 2012 hurdle run through ejb testingJakub Marchwicki
 
[PL] Metadane - dane o danych
[PL] Metadane - dane o danych[PL] Metadane - dane o danych
[PL] Metadane - dane o danychJakub Marchwicki
 
[PL] O klasycznej, programistycznej elegancji
[PL] O klasycznej, programistycznej elegancji[PL] O klasycznej, programistycznej elegancji
[PL] O klasycznej, programistycznej elegancjiJakub Marchwicki
 

Plus de Jakub Marchwicki (8)

Test with Spock like the first officer
Test with Spock like the first officerTest with Spock like the first officer
Test with Spock like the first officer
 
Design principles 4 hackers - tech3camp (28142014)
Design principles 4 hackers - tech3camp (28142014)Design principles 4 hackers - tech3camp (28142014)
Design principles 4 hackers - tech3camp (28142014)
 
[PL] Jak programować aby nie zwariować
[PL] Jak programować aby nie zwariować[PL] Jak programować aby nie zwariować
[PL] Jak programować aby nie zwariować
 
GeeCON 2013 - EJB application guided by tests
GeeCON 2013 - EJB application guided by testsGeeCON 2013 - EJB application guided by tests
GeeCON 2013 - EJB application guided by tests
 
[PL] Jak programować aby nie zwariować?
[PL] Jak programować aby nie zwariować?[PL] Jak programować aby nie zwariować?
[PL] Jak programować aby nie zwariować?
 
GeeCON 2012 hurdle run through ejb testing
GeeCON 2012 hurdle run through ejb testingGeeCON 2012 hurdle run through ejb testing
GeeCON 2012 hurdle run through ejb testing
 
[PL] Metadane - dane o danych
[PL] Metadane - dane o danych[PL] Metadane - dane o danych
[PL] Metadane - dane o danych
 
[PL] O klasycznej, programistycznej elegancji
[PL] O klasycznej, programistycznej elegancji[PL] O klasycznej, programistycznej elegancji
[PL] O klasycznej, programistycznej elegancji
 

Dernier

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Dernier (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

JEE.next()

  • 2. Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery
  • 3. J2EE 1.2 Servlet, JSP, EJB, JMS, RMI 1999 J2EE 1.3 CMP, Connec tor Architecture 2001 J2EE 1.4 Web Services, Deployment, Async Connector 2003 JEE 5 Prunning EJB 3.0, JPA, JSF, JAXB, JAX-WS, StAX 2006 Web profile Servlet 3.0 EJB 3.1 Lite 2009 Web profile JAX-RS 2.0 2013 JEE 6 Prunning CDI, JAX-RS JEE 7 Prunning JMS 2.0, Batch, JSON, Web sockets
  • 4. Servlet 3.0 JSF 2.0 EJB 3.1 JPA 2.0 JSP CDI JTA Bean Validation JAX-WS JAX-RPC JAXR SAAJ JAX-RS JAXB JMS JAAS JASPIC JACC JCA JavaMail JSR 88 JSR 77 RMI JNDI Web profile Full profile Java EE6 profiles
  • 5. JSP 2.2 JSF 2.2 JAX-RS 2.0 EL 3.0 Servlet 3.1 Portable extensions CDI 1.1 Interceptors 1.1 Common Annotations 1.1 Managed Beans 1.0 EJB 3.2 Connector 1.6 JPA 2.1 JTA 1.2 JMS 2.0 BeanValidation1.1 Concurrency Utilities (JSR 236) Batch Applications (JSR 352) Java API for JSON (JSR 353) Java API for Websockets (JSR 356) Java EE7
  • 6. JSP 2.2 JSF 2.2 JAX-RS 2.0 EL 3.0 Servlet 3.1 Portable extensions CDI 1.1 Interceptors 1.1 Common Annotations 1.1 Managed Beans 1.0 EJB 3.2 Connector 1.6 JPA 2.1 JTA 1.2 JMS 2.0 BeanValidation1.1 Concurrency Utilities (JSR 236) Batch Applications (JSR 352) Java API for JSON (JSR 353) Java API for Websockets (JSR 356) Java EE7 deep dive
  • 7.
  • 8. Java EE7 deep dive • JMS 2.0 • JPA 2.1 • Bean Validation 1.1 • JAX-RS 2.0 • Java API for JSON • Java API for Websockets • Batch Application • Concurrency Utilities
  • 10. Java EE7 deep dive • JMS 2.0 • JPA 2.1 • Bean Validation 1.1 • JAX-RS 2.0 • Java API for JSON • Java API for Websockets • Batch Application • Concurrency Utilities
  • 12. JMS 2.0 Configuration - Old API <subsystem xmlns="urn:jboss:domain:messaging:1.1"> <hornetq-server> <jms-destinations> <jms-queue name="testQueue"> <entry name="queue/test"/> </jms-queue> <jms-topic name="testTopic"> <entry name="topic/test"/> </jms-topic> </jms-destinations> </hornetq-server> </subsystem>
  • 13. JMS 2.0 Configuration – New API @JMSConnectionFactoryDefinition( name = "java:global/jms/demoConnectionFactory", className = "javax.jms.ConnectionFactory") @JMSDestinationDefinition( name = "java:global/jms/demoQueue", interfaceName = "javax.jms.Queue", destinationName = "demoQueue") public class JmsConfiguration { }
  • 14. JMS 2.0 Send message – Old API @Stateless public class SendMessageService { @Resource(lookup = "java:global/jms/demoConnectionFactory") ConnectionFactory connectionFactory; @Resource(lookup = "java:global/jms/demoQueue") Queue demoQueue; public void sendMessage(String payload) { try { Connection connection = connectionFactory.createConnection(); try { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer messageProducer = session .createProducer(demoQueue); TextMessage textMessage = session.createTextMessage(payload); messageProducer.send(textMessage); } finally { //...
  • 15. JMS 2.0 Send message – New API @Stateless public class MessageService { @Inject private JMSContext context; @Resource(mappedName = "jms/inboundQueue") private Queue inboundQueue; public void sendMessage(String payload) { context.createProducer().send(inboundQueue, payload); } }
  • 16. JMS 2.0 Receive message – New API @MessageDriven(mappedName="global/jms/demoQueue") public class MessageConsumer implements MessageListener { @Override public void onMessage(Message msg) { try { //No casting!!! String payload = msg.getBody(String.class); } catch (JMSException e) { e.printStackTrace(); } } }
  • 17.
  • 18. Java EE7 deep dive • JMS 2.0 • JPA 2.1 • Bean Validation 1.1 • JAX-RS 2.0 • Java API for JSON • Java API for Websockets • Batch Application • Concurrency Utilities
  • 19. JPA 2.1 Old API - persistence.xml <persistence-unit> <properties> <property name="hibernate.connection.driver_class" value="org.apache.derby.jdbc.ClientDriver" /> <property name="hibernate.connection.url" value="jdbc:derby://localhost:1527/sample;create=true" /> <property name="hibernate.connection.username" value="user" /> <property name="hibernate.connection.password" value="pass" /> <property name="hibernate.show_sql" value="true" /> <property name="hibernate.format_sql" value="true" /> <property name="hibernate.use_sql_comments" value="true" /> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" /> <property name="hibernate.hbm2ddl.auto" value="create-drop" /> </properties> </persistence-unit>
  • 20. JPA 2.1 Old API - persistence.xml <persistence-unit> <properties> <property name="eclipselink.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver" /> <property name="eclipselink.jdbc.url" value="jdbc:derby://localhost:1527/sample;create=true" /> <property name="eclipselink.jdbc.user" value="user" /> <property name="eclipselink.jdbc.password" value="pass" /> <property name="eclipselink.logging.level" value="FINE" /> <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.MySQLPlatform" /> <property name="eclipselink.ddl-generation" value="drop-and-create-tables" /> <property name="eclipselink.ddl-generation.output-mode" value="database" /> </properties> </persistence-unit>
  • 21. JPA 2.1 New API - persistence.xml <persistence-unit> <properties> <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver" /> <property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/sample;create=true" /> <property name="javax.persistence.jdbc.user" value="user" /> <property name="javax.persistence.jdbc.password" value="pass" /> <property name="javax.persistence.schema-generation.database.action" value="drop-and-create" /> <property name="eclipselink.logging.level" value="FINE" /> <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.MySQLPlatform" /> </properties> </persistence-unit>
  • 22. JPA 2.1 Old API – Converters public enum UseSex { MALE, FEMALE; } @Entity public class User { @Id private long id; @Enumerated(EnumType.ORDINAL) private UserSex sex; //.. }
  • 23. JPA 2.1 Old API – Converters public enum UseSex { MALE, FEMALE; } @Entity public class User { @Id private long id; @Enumerated(EnumType.STRING) private UserSex sex; //.. }
  • 24. JPA 2.1 Old API – Converters @Entity public class User { @Transient private UserSex sex; private String db_sex; @PostLoad public void afterLoad() { switch(db_sex){ case "M": sex = UserSex.MALE; case "F": sex = UserSex.FEMALE; default: throw new IllegalArgumentException(); } }
  • 25. JPA 2.1 Old API – Converters @PrePersist public void beforePersit() { switch(sex){ case MALE: db_sex = "M"; case FEMALE: db_sex = "F"; default: throw new IllegalArgumentException(); } }
  • 26. JPA 2.1 New API @Entity public class User { @Id private long id; @Convert(converter = SexConverter.class) private UserSex sex; //.. }
  • 27. JPA 2.1 New API @Converter public class SexConverter implements AttributeConverter<UserSex, String>{ public String convertToDatabaseColumn(UserSex arg0) { switch(arg0){ case MALE: return "M"; case FEMALE: return "F"; default: throw new IllegalArgumentException(); } } public UserSex convertToEntityAttribute(String arg0) { switch(arg0){ case "M": return UserSex.MALE; case "F": return UserSex.FEMALE; default: throw new IllegalArgumentException(); } } }
  • 28. JPA 2.1 New API – stored procedures @Table(indexes = @Index(columnList = "name")) @Entity @NamedQuery(name = User.FIND_USER_BY_NAME, query = "from User u where name = ?") @NamedStoredProcedureQuery(name = User. REFRESH_USERS, procedureName = "USR_STRD_PRCR_CALL") public class User { public final static String FIND_USER_BY_NAME = "User.findByName"; public final static String REFRESH_USERS = "User.doSomething"; //.. }
  • 29. Java EE7 deep dive • JMS 2.0 • JPA 2.1 • Bean Validation 1.1 • JAX-RS 2.0 • Java API for JSON • Java API for Websockets • Batch Application • Concurrency Utilities
  • 30. Bean Validation 1.1 Old API @Interceptors(ValidationInterceptor.class) public void addAuthor(@Size(min=5) String name, String surename) { Author a = new Author(); a.setName(name); a.setSurename(surename); em.persist(a); }
  • 31. Bean Validation 1.1 Old API public Object validateMethodInvocation (InvocationContext ctx) throws Exception { MethodValidator validator = validatorFactory.getValidator() .unwrap(MethodValidator.class); Set<MethodConstraintViolation<Object>> violations = validator.validateAllParameters( ctx.getTarget(), ctx.getMethod(), ctx.getParameters()); }
  • 32. Bean Validation 1.1 New API public void addAuthor(@Size(min=5) String name, String surename) { Author a = new Author(); a.setName(name); a.setSurename(surename); em.persist(a); }
  • 33. Bean Validation 1.1 New API @Path("/hello") public class HelloWorld { @Path("/{name}") @GET @Produces(MediaType.APPLICATION_JSON) public JsonObject sayHello( @NotEmpty @PathParam("name") String name) { //.. } }
  • 34. Java EE7 deep dive • JMS 2.0 • JPA 2.1 • Bean Validation 1.1 • JAX-RS 2.0 • Java API for JSON • Java API for Websockets • Batch Application • Concurrency Utilities
  • 36. JAX-RS 2.0 Configuration - Old API <servlet> <servlet-name>JAX-RS Servlet</servlet-name> <servlet-class> com.sun.jersey.spi.container.servlet.ServletContainer </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>JAX-RS Servlet</servlet-name> <url-pattern>/jax-rs/*</url-pattern> </servlet-mapping>
  • 37. JAX-RS 2.0 Configuration – New API import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; @ApplicationPath("/rs") public class RestApp extends Application { }
  • 38. JAX-RS 2.0 Client - Old API HttpURLConnection connection = (HttpURLConnection)serverAddress.openConnection(); connection.setRequestMethod("GET"); connection.setDoOutput(true); connection.setReadTimeout(10000); BufferedReader rd = new BufferedReader( new InputStreamReader(connection.getInputStream())); StringBuilder sb = new StringBuilder(); while ((line = rd.readLine()) != null) { sb.append(line + 'n'); } System.out.println(sb.toString());
  • 39. JAX-RS 2.0 Client - Old API <dependency> <groupId>com.github.kevinsawicki</groupId> <artifactId>http-request</artifactId> <version>5.4.1</version> </dependency> HttpRequest request = HttpRequest.get(baseURL) .receive(output); System.out.println(request.toString());
  • 40. JAX-RS 2.0 New API import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; Client client = ClientBuilder.newBuilder().build(); WebTarget target = client.target(uri.toString()); Response response = target.request().get(); assertThat(response.getStatus()).isEqualTo(200); assertThat(target.request().get(String.class)) .isEqualTo("{}");
  • 41. Java EE7 deep dive • JMS 2.0 • JPA 2.1 • Bean Validation 1.1 • JAX-RS 2.0 • Java API for JSON • Java API for Websockets • Batch Application • Concurrency Utilities
  • 42. Java API for JSON Processing { "data": [ "Hello Jakub", "Guten Tag Jakub" ] }
  • 43. Java API for JSON Processing Old API ??
  • 44. Java API for JSON Processing New API – streaming API JsonParser parser = Json. createParser(new StringReader(string))); event = parser.next(); assertThat(event).is(new Condition<Object>() { public boolean matches(Object value) { return value instanceof Event && value == Event.VALUE_STRING; } }); assertThat(parser.getString()).isEqualTo("Hello Jakub");
  • 45. Java API for JSON Processing New API – object API JsonReader reader = Json. createReader(new StringReader(string)); JsonObject obj = reader.readObject(); assertThat(obj.containsKey("data")).isTrue(); JsonArray results = obj.getJsonArray("data"); assertThat(results.size()).isEqualTo(2); assertThat(results.getString(0)).isEqualTo("Hello Jakub"); assertThat(results.getString(1)).isEqualTo("Guten tag Jakub");
  • 46. Java API for JSON Processing New API – builder import javax.json.Json; import javax.json.JsonObject; @Path("/simple/{name}") @GET @Produces(MediaType.APPLICATION_JSON) public JsonObject saySimpleHello(@PathParam("name") String name) { return Json.createObjectBuilder() .add("data", Json.createArrayBuilder() .add("Hello " + name) .add("Guten tag " + name) .build()) .build(); }
  • 47. Java EE7 deep dive • JMS 2.0 • JPA 2.1 • Bean Validation 1.1 • JAX-RS 2.0 • Java API for JSON • Java API for Websockets • Batch Application • Concurrency Utilities
  • 48. Java API for Websockets Old API #1 @WebServlet(urlPatterns = "/ping") public class FeedNotifierWebSocket extends WebSocketServlet { protected StreamInbound createWebSocketInbound( String subprotocol, HttpServletRequest req) { //.. } }
  • 49. Java API for Websockets Old API #1 class NotificationInbound extends MessageInbound { private WsOutbound outbound; protected void onOpen(WsOutbound outbound) { this.outbound = outbound; } protected void onBinaryMessage(ByteBuffer m) { outbound.writeBinaryMessage(message); } protected void onTextMessage(CharBuffer m) { outbound.writeTextMessage(message); } }
  • 50. Java API for Websockets Old API #2 @Singleton @WebSocketEndpoint(path=”/chat”) public class ChatServer { Set<Session> peers = new HashSet<>(); @WebSocketOpen public void onOpen(Session peer) { peers.add(session); } @WebSocketClose public void onClose(Session session) { peers.remove(session); } ...
  • 51. Java API for Websockets Old API #2 @WebSocketMessage public void message(String message, Session client) throws IOException { for (Session session : peers) { if (!session.equals(client)) { session.getRemote().sendObject(message); } } }
  • 52. Java API for Websockets New API @Singleton @ServerEndpoint("/ping") public class NotificationServer { Set<Session> sessions = new HashSet<>(); @OnOpen public void onOpen(Session s) throws IOException { sessions.add(s); } @OnClose public void onClose(Session s) throws IOException { sessions.remove(s); } ...
  • 53. Java API for Websockets New API @OnMessage public void message(String m, Session client) throws IOException { for (Session s: sessions) { if (s == client) continue; try { s.getBasicRemote().sendText(m); } catch (Exception e) { onClose(s); } } } }
  • 54. Java EE7 deep dive • JMS 2.0 • JPA 2.1 • Bean Validation 1.1 • JAX-RS 2.0 • Java API for JSON • Java API for Websockets • Batch Application • Concurrency Utilities
  • 56. Batch Applications Item Reader Item Processor Item Writer Jobs Repository Job Operator Job Step 1 * 1 1 1 1 11
  • 57. Batch Applications Job Repository holds information about jobs current running and jobs that run in the past. JobOperator provides access to this repository. Job Operator an interface to manage all aspects of job processing, including operational commands, such as start, restart, and stop, retrieval of job and step executions.
  • 58. Batch Applications Job encapsulates an entire batch process <job id="myJob" xmlns="http://batch.jsr352/jsl"> <step id="myStep" > <chunk reader="MyItemReader" writer="MyItemWriter" processor="MyItemProcessor" buffer-size="5" checkpoint-policy="item" commit-interval="10" /> </step> </job>
  • 59. Batch Applications Chunks @ItemReader public class MyItemReader { //... } @ItemProcessor public class MyItemProcessor { //... } @ItemWriter public class MyItemWriter { //... }
  • 60. Java EE7 deep dive • JMS 2.0 • JPA 2.1 • Bean Validation 1.1 • JAX-RS 2.0 • Java API for JSON • Java API for Websockets • Batch Application • Concurrency Utilities
  • 61. The enterprise bean must not attempt to manage threads. The enterprise bean must not attempt to start, stop, suspend, or resume a thread, or to change a thread’s priority or name. The enterprise bean must not attempt to manage thread groups. 21.2.2. Programming restrictions
  • 62. @Asynchronous Old API @Stateless public class EventWatcher { @Asynchronous public void method(FeedEvent event) { System.out.println(event); } }
  • 63. Asynchronous Servlets Old API @WebServlet(urlPatterns = "/somepath", asyncSupported = true) public class AsyncServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //.. } }
  • 64. ManagedThreadFactory New API @Named public class ThreadManager { @Resource ManagedThreadFactory mtf; public ExecutorService getThreadManager() { return new ThreadPoolExecutor(5,10, 10, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(100), mtf); } }
  • 65. ManagedThreadFactory New API @Named public class ProcessingService { public void doMuchStuff(ExecutorService executor) { for (int i = 0; i < 50; i++) { Runnable worker = new WorkerThread("" + i); executor.execute(worker); } executor.shutdown(); } }
  • 66.
  • 67. Java EE8 ?? • JSON-B (JSON binding) • JCache (JSR 107) • Adopt JSR • Open TCK (??) • More JSP (+ templates), less JSF • no more EARs (??)
  • 69. In case you ask – we are hiring