SlideShare uma empresa Scribd logo
1 de 93
Baixar para ler offline
Java EE 7:

What’s New in the Java EE Platform
Masoud Kalali
@MasoudKalali
ORACLE

JDays 2013
Agenda
A look at some of the important
new features of Java EE 7

2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Java EE 7 Themes

MEETING
ENTERPRISE
DEMANDS

DEVELOPER
PRODUCTIVITY
Java EE 7

§  More annotated POJOs
§  Less boilerplate code
§  Cohesive integrated
platform

3

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

§ 
§ 
§ 
§ 

WebSockets
JSON
Servlet 3.1 NIO
REST

§  Batch
§  Concurrency
§  Simplified JMS
Java EE 7 JSRs
New or Updated
§  JPA 2.1

§  CDI 1.1

§  JAX-RS 2.0

§  Bean Validation 1.1

§  EJB 3.2

§  WebSocket 1.0

§  JMS 2.0

§  JSON 1.0

§  Servlet 3.1

§  Batch Applications 1.0

§  EL 3.0

§  Concurrency Utilities 1.0

§  JSF 2.2

4

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Java EE 7 Maintenance Releases
§  Common Annotations 1.2
§  JTA 1.2
§  Interceptors 1.2
§  Connector 1.7
§  JSP 2.3
§  JASPIC 1.2
§  JACC 1.4
§  JavaMail 1.5
§  Web Services 1.4
5

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JSON Processing 1.0

6

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JSON Processing 1.0

§  API to parse and generate JSON
§  Streaming API (javax.json.stream)
–  Low-level, efficient way to parse/generate JSON
–  Similar to StAX API in XML world

§  Object model API (javax.json)
–  Simple, easy to use high-level API
–  Similar to DOM API in XML world

7

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JSON Processing 1.0
Streaming API: Parsing
§  Created using
–  Json.createParser(…)
–  Json.createParserFactory().createParser(…)

§  Parses JSON in streaming way from input sources
Event event = parser.next(); //START_OBJECT
event = parser.next();

// KEY_NAME

event = parser.next();

// VALUE_STRING

§  Parser state events
–  START_OBJECT, END_OBJECT, START_ARRAY, END_ARRAY,

KEY_NAME, VALUE_STRING, VALUE_NUMBER, …
8

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JSON Processing 1.0
Streaming Parser
{
“firstName”: “John”, “lastName”: “Smith”, “age”: 25,
“phoneNumber”: [
{ “type”: “home”, “number”: “212 555-1234” },
{ “type”: “fax”, “number”: “646 555-4567” }
]
}

9

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JSON Processing 1.0
Streaming Parser
{

START_OBJECT

“firstName”: “John”, “lastName”: “Smith”, “age”: 25,
“phoneNumber”: [
{ “type”: “home”, “number”: “212 555-1234” },
{ “type”: “fax”, “number”: “646 555-4567” }
]
}

10

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JSON Processing 1.0
Streaming Parser
{

KEY_NAME

“firstName”: “John”, “lastName”: “Smith”, “age”: 25,
“phoneNumber”: [
{ “type”: “home”, “number”: “212 555-1234” },
{ “type”: “fax”, “number”: “646 555-4567” }
]
}

11

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JSON Processing 1.0
Streaming Parser
VALUE_STRING

{

“firstName”: “John”, “lastName”: “Smith”, “age”: 25,
“phoneNumber”: [
{ “type”: “home”, “number”: “212 555-1234” },
{ “type”: “fax”, “number”: “646 555-4567” }
]
}

12

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JSON Processing 1.0
Streaming Parser
VALUE_NUMBER

{

“firstName”: “John”, “lastName”: “Smith”, “age”: 25,
“phoneNumber”: [
{ “type”: “home”, “number”: “212 555-1234” },
{ “type”: “fax”, “number”: “646 555-4567” }
]
}

13

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JSON Processing 1.0
Streaming Parser
{
“firstName”: “John”, “lastName”: “Smith”, “age”: 25,
“phoneNumber”: [ START_ARRAY
{ “type”: “home”, “number”: “212 555-1234” },
{ “type”: “fax”, “number”: “646 555-4567” }
]
}

14

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JSON Processing 1.0
Streaming Parser
{
“firstName”: “John”, “lastName”: “Smith”, “age”: 25,
“phoneNumber”: [
{ “type”: “home”, “number”: “212 555-1234” },
{ “type”: “fax”, “number”: “646 555-4567” }
] END_ARRAY
}

15

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JSON Processing 1.0
Using Streaming API to generate JSON
JsonGenerator gen = Json.createGenerator…
.writeStartObject()
.write("firstName", "John")
.write("lastName", "Smith")
.write("age", 25)
.writeStartArray(“phones”)
.writeStartObject()
.write(“type", “home")
.write(“number”, “222 555-1234”))
.writeEnd()
.writeStartObject() … .writeEnd()
.writeEnd()
.writeEnd();
16

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

{ "firstName": "John", "lastName": "Smith", "age": 25,
“phones" : [
{ “type”: “home”, “number”: “ 222 555-1234” },
{ “type”: “fax”, “number”: “ 646 555-4567” }
]
}
JSON Processing 1.0
Object Model API
§  JsonObject/JsonArray – JSON object and array structures
–  JsonString and JsonNumber for string and number values

§  JSON builders – build JsonObject and JsonArray
§  JsonReader – reads JsonObject and JsonArray
§  JsonWriter – writes JsonObject and JsonArray

17

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JsonReader
§  Reads JsonObject and JsonArray from input source
§  Uses pluggable JsonParser

JsonReader reader = new JsonReader(io));
JsonObject obj = reader.readObject();

18

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JsonWriter
§  Writes JsonObject and JsonArray to output source
§  Uses pluggable JsonGenerator

JsonWriter writer = new JsonWriter(io));
writer.writeObject(obj);

19

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
WebSockets 1.0

20

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Java API for WebSocket 1.0
§  Bidirectional full-duplex messaging
–  Over a single TCP connection

§  Annotation-based or interface-based programming model
§  Server and Client WebSocket Endpoints
–  Annotated: @ServerEndpoint, @ClientEndpoint
–  Programmatic: Endpoint

§  Integrated with Java EE web container
§  Highly configurable
§  Simple packaging and deployment as wars or jars

21

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Java API for WebSocket 1.0
Main API classes
§  Endpoint
–  intercepts websocket lifecycle events

§  MessageHandler
–  handles incoming messages for endpoint

§  Session
–  represents the active conversation

§  RemoteEndpoint
–  represents the other end of the conversation

22

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
WebSocket Endpoints
Programmatic API
public class MyClient extends Endpoint {
public void onOpen(Session session, EndpointConfig ec) {
session.addMessageHandler(new MessageHandler.Whole<String>() {
public void onMessage(String text) {
System.out.println("Message came from the server : " + message”);
}
}
session.getBasicRemote().sendText("Hello!");
}
public void onClose(Session session, CloseReason closeReason) {
super.onClose(session, closeReason);
}
}
23

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
WebSocket Endpoints as POJOs
Annotated client endpoint
@ClientEndpoint
public class MyClient {
@OnOpen public void onOpen(Session session) {
session.getBasicRemote().sendText(“Hello”);
}
@OnMessage public void onMessage(String text, Session session) {
System.out.println("Message came from the server : " + message);
}
}

24

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
WebSocket Endpoints as POJOs
Annotated server endpoint
@ServerEndpoint("/chat") public class ChatServer {
static Set<Session> peers = Collections.synchronizedSet(…);
@OnOpen public void onOpen(Session peer) {
peers.add(peer);
}
@OnMessage public void onMessage (String message, Session client) {
for (Session peer : peers) {
peer.getBasicRemote().sendObject(message);
}
}
@OnClose public void onClose(Session peer) {
peers.remove(peer);
}
25

}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JAX-RS 2.0

26

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Java API for RESTful Web Services (JAX-RS) 2.0

§  Client API
§  Asynchronous Processing
§  Filters and Interceptors
§  Validation

27

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JAX-RS 1.1
Previous Client API
URL url = new URL("http://. . ./atm/balance");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
conn.setDoOutput(false);
conn.setRequestMethod("GET");
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
//. . .
}

28

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JAX-RS 2.0
JAX-RS 2.0 Client API

Client client = ClientFactory.newClient();
WebTarget webTarget= client.target(new URI(TARGET_URI)) ;
webTarget.request().post(Entity.text(message));

29

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JAX-RS 2.0
JAX-RS 2.0 Client API

Client client = ClientFactory.newClient();
String name= client.target("http://.../orders/{orderId}/customer")
.resolveTemplate(“orderId”, “10”)
.queryParam("pin", "9876")
.request()
.get(String.class);

30

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Async Processing
§  Server API support
–  Off-load I/O container threads
§  Long-running operations
–  Efficient asynchronous event processing
§  Suspend while waiting for an event
§  Resume when event arrives
–  Leverage Servlet 3.x async support (if available)
§  Client API support
–  Asynchronous request invocation API
§  Future<RESPONSE>, InvocationCallback<RESPONSE>	
  

31

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Async Processing: Server-side
@Path("/async/longRunning")
public class MyResource {
@GET
public void longRunningOp(@Suspended AsyncResponse ar) {
ar.setTimeoutHandler(new MyTimoutHandler());
ar.setTimeout(15, SECONDS);

}

32

}

Executors.newSingleThreadExecutor().submit(new Runnable() {
public void run() {
…
ar.resume(result);
}
});

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Async Processing: Client-side
WebTarget target = client.target("http://.../balance”)…
// Start async call and register callback
Future<?> handle = target.request().async().get(
new InvocationCallback<String>() {
void complete(String balance) { … }
void failed(InvocationException e) { … }
});
// After waiting for too long…
if (!handle.isDone()) handle.cancel(true);

33

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Filters & Interceptors
Motivation

§  Customize JAX-RS request/response processing
–  Use Cases: Logging, Compression, Security, Etc.

§  Introduced for client and server APIs
§  Replace existing proprietary support
–  Provided by most JAX-RS 1.x implementations
§  All using slightly different types or semantics

34

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Filters & Interceptors
Filter each incoming/outgoing message
§  Request è Request

§  Non-wrapping filter chain
–  Filters do not invoke next filter in

the chain directly
–  managed by the JAX-RS runtime

–  ContainerRequestFilter,	
  

ClientRequestFilter	
  
§  Response è Response
–  ContainerResponseFilter,	
  

ClientResponseFilter
§  Each filter decides to proceed or

break the chain

§  Server-side specialties
–  @PreMatching,	
  DynamicFeature

35

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Filters & Interceptors
A Logging Filter Example

public class RequestLoggingFilter implements ContainerRequestFilter {
@Override
public void filter(ContainerRequestContext requestContext) {
log(requestContext);
}
}

36

// non-wrapping => returns without invoking the next filter

...

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Filters & Interceptors
Intercept entity providers
§  Invoked ONLY when/if entity

reading/writing occurs

§  MessageBodyReader interceptor
–  ReaderInterceptor interface

–  Performance boost

§  Wrapping interceptor chain
–  Each interceptor invokes the next

one in the chain via
context.proceed()	
  

37

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

§  MessageBodyWriter interceptor
–  WriterInterceptor interface
Filters & Interceptors
A GZip Reader Interceptor Example

public class GzipInterceptor implements ReaderInterceptor {
@Override
Object aroundReadFrom(ReaderInterceptorContext ctx) {
InputStream old = ctx.getInputStream();
ctx.setInputStream(new GZIPInputStream(old));
// wrapping => invokes the next interceptor
Object entity = ctx.proceed();

}

38

}

ctx.setInputStream(old);
return entity;

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JAX-RS 2.0
Bean Validation
@Path("/")
class MyResourceClass {
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public void registerUser(
@NotNull @FormParam("firstName") String firstName,
@NotNull @FormParam("lastName") String lastName,
@Email @FormParam("email") String email) {
... }
…
}
39

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
CDI 1.1

40

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
CDI: Default enabling
Finer scanning control
§  Possible values: all, annotated, none
§  The annotated is set as the default, scan @*Scoped annotated
§  all behaves like in Java EE 6 (default if not set)

<beans ... version="1.1" bean-discovery-mode="all">!
<alternatives>!
<class>org.agoncal.book.MockGenerator</class>!
</alternatives>!
</beans>!

41

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
CDI: @Vetoed
Veto the processing of the class or package
@Vetoed!
public class NonProcessedBean {

...!
}!
!
package-info.java
@Vetoed!
package com.non.processed.package;!
42

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Interceptor 1.2

43

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Interceptors: AroundConstruct
Interceptor associated with a constructor

public class LoggingInterceptor {!
!
@AroundConstruct!
private void init(InvocationContext ic) throws Exception{
logger.fine("Entering constructor");!
ic.proceed();!
logger.fine("Exiting constructor");!
}!
!
@AroundInvoke!
public Object logMethod(InvocationContext ic) ... {!
// ...!
}!
}!
44

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Interceptors: @Priority
Prioritizing interceptor bindings
§  PLATFORM_BEFORE (0), LIBRARY_BEFORE (1000), APPLICATION

(2000), LIBRARY_AFTER (3000), PLATFORM_AFTER (4000)
§  Lower the priority, earlier the invocation!

@Interceptor!
@Loggable!
@Priority(Interceptor.Priority.LIBRARY_BEFORE + 10)!
public class LoggingInterceptor {!
!
@AroundInvoke!
...!
}!
45

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Default Resources

46

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Resource Definition Metadata

§  Specifies resources needed by application
–  Enhances configurability in Java EE 7 apps
–  Facilitates provisioning in cloud environments
–  Java EE 6 introduced DataSourceDefinition
@DataSourceDefinition (
name=“java:app/jdbc/myDB”,
className=“oracle.jdbc.pool.OracleDataSource”,
isolationLevel=TRANSACTION_REPEATABLE_READ,
initialPoolSize=5)
@Stateless public class MySessionBean {
@Resource(lookup=“java:app/jdbc/myDB”) DataSource my DB;
…
}
47

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Resource Definition Metadata

§  Java EE 7 adds:
–  JMSConnectionFactoryDefinition
–  JMSDestinationDefinition
–  MailSessionDefinition
–  ConnectionFactoryDefinition
–  AdministeredObjectDefinition

48

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Default Resources
Preconfigured resources for use by application
§  JDBC/JPA: java:comp/DefaultDataSource
§  JMS: java:comp/DefaultJMSConnectionFactory
§  Concurrency Utilities:
–  java: comp/DefaultManagedExecutorService
–  java: comp/DefaultManagedScheduledExecutorService
–  java: comp/DefaultManagedThreadFactory
–  java: comp/DefaultManagedContextService

49

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JMS 2.0

50

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Java Message Service 2.0
New JMS Simplified API targeted at ease of development
§  Less code, less boilerplate
§  Fewer objects to manage
§  Increased developer productivity
§  “Classic API” has also been improved

51

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JMS 2.0
Simplifications include….
§  New JMSContext interface
§  Use of CDI injection; new TransactionScope
§  AutoCloseable JMSContext, Connection, Session, …
§  Use of runtime exceptions
§  Method chaining on JMSProducer
§  Simplified message sending

52

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JMS 1.1: Sending a message
@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);
13 lines of
} finally {
code just
connection.close();
to send a
}
message
} catch (JMSException ex) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
}
}
53

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JMS 1.1: Sending a message
@Resource(lookup = "java:global/jms/demoConnectionFactory")
ConnectionFactory connectionFactory;
must create
@Resource(lookup = "java:global/jms/demoQueue")
Queue demoQueue;

several
intermediate
objects

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 {
connection.close();
}
} catch (JMSException ex) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
}
}
54

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JMS 1.1: Sending a message
@Resource(lookup = "java:global/jms/demoConnectionFactory")
ConnectionFactory connectionFactory;
@Resource(lookup = "java:global/jms/demoQueue")
Queue demoQueue;

boilerplate
code

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 {
connection.close();
}
} catch (JMSException ex) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
}
}
55

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JMS 1.1: Sending a message
@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);
must
} finally {
close
connection.close();
resources
}
} catch (JMSException ex) {
after use!
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
}
}
56

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JMS 1.1: Sending a message
@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);
all
} finally {
methods
connection.close();
throw
}
checked
} catch (JMSException ex) {
exceptions
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
}
}
57

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Simplifying the JMS API
Strategy
§  Simplify existing JMS 1.1 API where it won't break compatibility
§  Define new simplified API requiring fewer objects
–  JMSContext, JMSProducer, JMSConsumer

§  In Java EE, allow JMSContext to be injected and managed by the

container

58

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JMS 2.0
Sending a message using Simplified API and JMSContext
@Resource(lookup = “java:global/jms/myConnectionFactory”)
ConnectionFactory connectionFactory;
@Resource(lookup = “java:global/jms/myQueue”)
Queue queue;
public void sendMessage(String text) {
try (JMSContext context = connectionFactory.createContext();) {
context.createProducer().send(queue, text);
} catch (JMSRuntimeException ex) {
…
}
}

59

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JMS 2.0
Even simpler….
@Inject
@JMSConnectionFactory(““java:global/jms/myConnectionFactory”)
JMSContext context;
@Resource(lookup = “java:global/jms/myQueue”)
Queue queue;
public void sendMessage(String text) {
context.createProducer().send(queue, text);
}

60

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JMS 2.0
Even simpler still….
@Inject
JMSContext context;
@Resource(lookup = “java:global/jms/myQueue”)
Queue queue;
public void sendMessage(String text) {
context.createProducer().send(queue, text);
}

61

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JMS 2.0:
New API features

62

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Delivery delay
§  Allows a JMS client to schedule the future delivery of a message
§  New method on old MessageProducer

public void setDeliveryDelay(long deliveryDelay)
§  New method on the new JMSProducer

public JMSProducer setDeliveryDelay(long deliveryDelay)
§  Sets minimum time in ms from that a message should be retained by

the messaging system before delivery to a consumer
§  Why? If the business requires deferred processing, e.g. end of day

63

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Async send
§  Send a message and return immediately without blocking until an

acknowledgement has been received from the server.
§  Instead, when the acknowledgement is received, an asynchronous callback will be
invoked
§  New methods on MessageProducer

messageProducer.send(message,completionListener)
§  Feature also available on JMSProducer
§  Why? Allows thread to do other work whilst waiting for the acknowledgement

64

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Async send

§  Application specifies a CompletionListener instance
public interface CompletionListener {
void onCompletion(Message message);
void onException(Message message, Exception exception);
}

65

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Better handling of "poison" messages
Make JMSMXDeliveryCount mandatory
§  JMS 1.1 defines an optional JMS defined message property

JMSXDeliveryCount.
–  When used, this is set by the JMS provider when a message is received,

and is set to the number of times this message has been delivered
(including the first time). The first time is 1, the second time 2, etc
§  JMS 2.0 will make this mandatory
§  Why? Allows app servers and applications to handle "poisonous"

messages better
66

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Multiple consumers on a topic subscription
§  Allows scalable consumption of messages from a topic subscription
–  multiple threads, multiple JVMs

§  New methods needed for non-durable subscriptions
MessageConsumer messageConsumer=
session.createSharedConsumer(topic,sharedSubscriptionName);

§  Existing methods used for durable subscriptions
MessageConsumer messageConsumer=
session.createDurableConsumer(topic,durableSubscriptionName);

§  Also available on JMSContext

67

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Concurrency Utilities for Java EE 1.0

68

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Concurrency Utilities for Java EE 1.0
Provides asynchronous capabilities to Java EE components
§  Extension of Java SE Concurrency Utilities API
§  Provides managed objects for submitting tasks and obtaining managed

threads
–  ManagedExecutorService
–  ManagedScheduledExecutorService
–  ManagedThreadFactory
–  ContextService

69

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Concurrency: ManagedExecutor
Default ManagedExectuor
@Resource

ManagedExecutorService executor;

!


ManagedExecutorService executor =
(ManagedExecutorService) ctx

.lookup("java:comp/DefaultManagedExecutorService");!

70

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Concurrency: ManagedExecutor
Specify in web.xml
<web-app … version="3.1">!
<resource-env-ref>!
<resource-env-ref-name>!
concurrent/myExecutor!
</resource-env-ref-name>!
<resource-env-ref-type>!
javax.enterprise.concurrent.ManagedExecutorService!
</resource-env-ref-type>!
</resource-env-ref>!
</web-app>!

71

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Concurrency: ManagedScheduledExecutor

§  Managed version of ScheduledExecutorService!
§  Submit delayed or periodic tasks

@Resource

ManagedScheduledExecutorService executor;!

72

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Concurrency: ManagedScheduledExecutor
Access using JNDI
InitialContext ctx = new InitialContext(); 



ManagedScheduledExecutorService executor =
(ManagedScheduledExecutorService)ctx.lookup(

"java:comp/DefaultManagedScheduledExecutorService");

!
§  Can be defined in web.xml as well

73

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Concurrency: ManagedScheduledExecutor

§  executor.schedule(new MyCallableTask(), 5,

TimeUnit.SECONDS);!
§  executor.scheduleAtFixedRate(new MyRunnableTask(),

2, 3, TimeUnit.SECONDS);!
§  executor.scheduleWithFixedDelay(new
MyRunnableTask(), 2, 3, TimeUnit.SECONDS);!

74

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Concurrency: ManagedThreadFactory

§  Extends ThreadFactory

@Resource(name = "DefaultManagedThreadFactory")

ManagedThreadFactory factory;

ManagedThreadFactory factory =
(ManagedThreadFactory) ctx.lookup("java:comp/
DefaultManagedThreadFactory");


75

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Concurrency: ManagedThreadFactory

§  Thread thread = factory.newThread(new MyTask());

§  ((ManageableThread)thread).isShutdown();


76

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Concurrency: DynamicProxy

§  Create dynamic proxy objects, adds contextual information available

for applications running in Java EE environment
§  Classloading, JNDI, Security, …

77

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Concurrency: DynamicProxy

@Resource

ContextService service;





Runnable proxy = service.createContextualProxy(new
MyRunnable(), Runnable.class);





Future f = executor.submit(proxy);!

78

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Batch Applications for the Java Platform 1.0

79

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Batch Applications for the Java Platform 1.0

§  Designed for non-interactive, bulk-oriented and long-running tasks
§  Sequential, parallel, and/or decision-based batch execution
§  Processing styles
–  Item-oriented: ItemReader, ItemProcessor, ItemWriter interfaces
–  Task-oriented: Batchlet interfaces

80

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Batch 1.0
Key concepts
§  Job: entire batch process
–  Defined through XML Job Specification Language

§  Step: independent, sequential phase of a job
§  JobOperator: interface for managing job processing
§  JobRepository: information about past and present jobs
Job Operator

Job

Step

ItemReader
ItemWriter

Job Repository
81

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

ItemProcessor
Batch 1.0
Job steps
§  Chunked step: Item-oriented processing
–  ItemReader/ItemProcessor/ItemWriter pattern
–  Configurable checkpointing and transactions

§  Batchlet: Task-oriented processing
–  Roll-your-own batch pattern
–  Runs to completion and exits

§  Job can include both types of steps

82

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Batch 1.0
Job specification language
<job id="myJob" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">
<step id="step1" next="step2">
<chunk item-count="3">
<reader ref="myItemReader"></reader>
<processor ref="myItemProcessor"></processor>
<writer ref="myItemWriter"></writer>
</chunk>
</step>
<step id="step2" next=“step3”>
<batchlet ref="myBatchlet"/>
</step>
<step id="step3" >
<chunk item-count="3">
<reader ref="myOtherItemReader"></reader>
<processor ref="myOtherItemProcessor"></processor>
<writer ref="myOtherItemWriter"></writer>
</chunk>
</step>
</job>

83

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
EJB 3.2

84

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
EJB 3.2 new features and improvments

§ Singleton Session Beans
§ EJB 3.1 Lite:
§  Includes non-persisted TimerService
§  Local asynchronous invocation of session beans

85

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Java Persistence API 2.1

86

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Java Persistence API 2.1
Schema generation
§  Generation of database tables, indexes, constraints, etc.
§  Designed for flexibility
–  Scenarios: (iterative) prototyping; production; provisioning environments
–  Generate from object/relational metadata (annotations and/or XML)
–  Generate from bundled SQL DDL scripts; also SQL load scripts
–  Generate directly into database
–  Generate into SQL DDL scripts

§  Process controlled by metadata or runtime properties

87

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JPA 2.1
Schema generation into scripts
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/
XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/
ns/persistence/persistence_2_1.xsd">
<persistence-unit name=“samplePU" transaction-type="JTA">
<jta-data-source>jdbc/mypu</jta-data-source>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="none" />
<property name="javax.persistence.schema-generation.scripts.action" value=“drop-and-create"/>
<property name="javax.persistence.schema-generation.scripts.create-target" value=”//temp/create.sql"/
>
<property name="javax.persistence.schema-generation.scripts.drop-target" value=“/temp/drop.sql"/>
</properties>
</persistence-unit>
</persistence>

88

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JPA 2.1
Schema generation from scripts
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/
XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/
persistence/persistence_2_1.xsd">
<persistence-unit name=“samplePU" transaction-type="JTA">
<jta-data-source>jdbc/mypu</jta-data-source>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="javax.persistence.schema-generation.create-source" value="script"/>
<property name="javax.persistence.schema-generation.drop-source" value="script"/>
<property name="javax.persistence.schema-generation.create-script-source" value="META-INF/create.sql"/>
<property name="javax.persistence.schema-generation.drop-script-source" value="META-INF/drop.sql"/>
<property name="javax.persistence.sql-load-script-source" value="META-INF/load.sql"/>
</properties>
</persistence-unit>
</persistence>

89

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
JPA 2.1
Some more features
§  Stored procedure support: @NamedStoredProcedureQuery
§  Dynamically Defining Named Queries
§  Enhancements To Queries
§  @Converter and @Convert(…)

90

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Java EE 7 Summary

MEETING
ENTERPRISE
DEMANDS

DEVELOPER
PRODUCTIVITY
Java EE 7

§  More annotated POJOs
§  Less boilerplate code
§  Cohesive integrated
platform

91

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

§ 
§ 
§ 
§ 

WebSockets
JSON
Servlet 3.1 NIO
REST

§  Batch
§  Concurrency
§  Simplified JMS
DOWNLOAD
Java EE 7 SDK

oracle.com/javaee
GlassFish 4.0
Full Platform or Web Profile

glassfish.org

92

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Questions…

?
93

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Mais conteúdo relacionado

Mais procurados

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 ServicesArun Gupta
 
The Java EE 7 Platform: Productivity++ & Embracing HTML5
The Java EE 7 Platform: Productivity++ & Embracing HTML5The Java EE 7 Platform: Productivity++ & Embracing HTML5
The Java EE 7 Platform: Productivity++ & Embracing HTML5Arun Gupta
 
Spring 3.1: a Walking Tour
Spring 3.1: a Walking TourSpring 3.1: a Walking Tour
Spring 3.1: a Walking TourJoshua Long
 
Java Summit Chennai: JAX-RS 2.0
Java Summit Chennai: JAX-RS 2.0Java Summit Chennai: JAX-RS 2.0
Java Summit Chennai: JAX-RS 2.0Arun Gupta
 
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUGThe Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUGArun Gupta
 
5050 dev nation
5050 dev nation5050 dev nation
5050 dev nationArun Gupta
 
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
 
Best Way to Write SQL in Java
Best Way to Write SQL in JavaBest Way to Write SQL in Java
Best Way to Write SQL in JavaGerger
 
A Walking Tour of (almost) all of Springdom
A Walking Tour of (almost) all of Springdom A Walking Tour of (almost) all of Springdom
A Walking Tour of (almost) all of Springdom Joshua Long
 
Java EE 7 and HTML5: Developing for the Cloud
Java EE 7 and HTML5: Developing for the CloudJava EE 7 and HTML5: Developing for the Cloud
Java EE 7 and HTML5: Developing for the CloudArun Gupta
 
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012Arun Gupta
 
Running your Java EE 6 applications in the Cloud
Running your Java EE 6 applications in the CloudRunning your Java EE 6 applications in the Cloud
Running your Java EE 6 applications in the CloudArun Gupta
 
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 2012Arun Gupta
 
Introducing WebLogic 12c OTN Tour 2012
Introducing WebLogic 12c OTN Tour 2012Introducing WebLogic 12c OTN Tour 2012
Introducing WebLogic 12c OTN Tour 2012Bruno Borges
 
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
 

Mais procurados (17)

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
 
The Java EE 7 Platform: Productivity++ & Embracing HTML5
The Java EE 7 Platform: Productivity++ & Embracing HTML5The Java EE 7 Platform: Productivity++ & Embracing HTML5
The Java EE 7 Platform: Productivity++ & Embracing HTML5
 
Java ee7 1hour
Java ee7 1hourJava ee7 1hour
Java ee7 1hour
 
Spring 3.1: a Walking Tour
Spring 3.1: a Walking TourSpring 3.1: a Walking Tour
Spring 3.1: a Walking Tour
 
Java Summit Chennai: JAX-RS 2.0
Java Summit Chennai: JAX-RS 2.0Java Summit Chennai: JAX-RS 2.0
Java Summit Chennai: JAX-RS 2.0
 
Websocket 1.0
Websocket 1.0Websocket 1.0
Websocket 1.0
 
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUGThe Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
 
5050 dev nation
5050 dev nation5050 dev nation
5050 dev nation
 
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
 
Best Way to Write SQL in Java
Best Way to Write SQL in JavaBest Way to Write SQL in Java
Best Way to Write SQL in Java
 
A Walking Tour of (almost) all of Springdom
A Walking Tour of (almost) all of Springdom A Walking Tour of (almost) all of Springdom
A Walking Tour of (almost) all of Springdom
 
Java EE 7 and HTML5: Developing for the Cloud
Java EE 7 and HTML5: Developing for the CloudJava EE 7 and HTML5: Developing for the Cloud
Java EE 7 and HTML5: Developing for the Cloud
 
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
 
Running your Java EE 6 applications in the Cloud
Running your Java EE 6 applications in the CloudRunning your Java EE 6 applications in the Cloud
Running your Java EE 6 applications in the Cloud
 
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
 
Introducing WebLogic 12c OTN Tour 2012
Introducing WebLogic 12c OTN Tour 2012Introducing WebLogic 12c OTN Tour 2012
Introducing WebLogic 12c OTN Tour 2012
 
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
 

Semelhante a Java EE 7 overview

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...jaxLondonConference
 
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 HTML5Arun Gupta
 
Java EE7
Java EE7Java EE7
Java EE7Jay Lee
 
WebSocket JSON Hackday
WebSocket JSON HackdayWebSocket JSON Hackday
WebSocket JSON HackdaySomay Nakhal
 
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Red Hat Developers
 
112815 java ee8_davidd
112815 java ee8_davidd112815 java ee8_davidd
112815 java ee8_daviddTakashi Ito
 
Java ee 7 New Features
Java ee 7   New FeaturesJava ee 7   New Features
Java ee 7 New FeaturesShahzad Badar
 
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX LondonJAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX LondonArun Gupta
 
JAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun Gupta
JAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun GuptaJAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun Gupta
JAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun GuptaJAX London
 
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.0Bruno Borges
 
What's coming in Java EE 8
What's coming in Java EE 8What's coming in Java EE 8
What's coming in Java EE 8David Delabassee
 
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Max Andersen
 
MySQL Tech Café #8: MySQL 8.0 for Python Developers
MySQL Tech Café #8: MySQL 8.0 for Python DevelopersMySQL Tech Café #8: MySQL 8.0 for Python Developers
MySQL Tech Café #8: MySQL 8.0 for Python DevelopersFrederic Descamps
 
Java EE 7 - Novidades e Mudanças
Java EE 7 - Novidades e MudançasJava EE 7 - Novidades e Mudanças
Java EE 7 - Novidades e MudançasBruno Borges
 
Aplicações HTML5 com Java EE 7 e NetBeans
Aplicações HTML5 com Java EE 7 e NetBeansAplicações HTML5 com Java EE 7 e NetBeans
Aplicações HTML5 com Java EE 7 e NetBeansBruno Borges
 
OTN Tour 2013: What's new in java EE 7
OTN Tour 2013: What's new in java EE 7OTN Tour 2013: What's new in java EE 7
OTN Tour 2013: What's new in java EE 7Bruno Borges
 
Java EE 8 - An instant snapshot
Java EE 8 - An instant snapshotJava EE 8 - An instant snapshot
Java EE 8 - An instant snapshotDavid Delabassee
 
Getting Started with WebSocket and Server-Sent Events in Java
Getting Started with WebSocket and Server-Sent Events in JavaGetting Started with WebSocket and Server-Sent Events in Java
Getting Started with WebSocket and Server-Sent Events in JavaArun Gupta
 
What’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new StrategyWhat’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new StrategyMohamed Taman
 
Project Helidon Overview (Japanese)
Project Helidon Overview (Japanese)Project Helidon Overview (Japanese)
Project Helidon Overview (Japanese)Logico
 

Semelhante a Java EE 7 overview (20)

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
 
Java EE7
Java EE7Java EE7
Java EE7
 
WebSocket JSON Hackday
WebSocket JSON HackdayWebSocket JSON Hackday
WebSocket JSON Hackday
 
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
 
112815 java ee8_davidd
112815 java ee8_davidd112815 java ee8_davidd
112815 java ee8_davidd
 
Java ee 7 New Features
Java ee 7   New FeaturesJava ee 7   New Features
Java ee 7 New Features
 
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX LondonJAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
 
JAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun Gupta
JAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun GuptaJAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun Gupta
JAX-RS 2.0: New and Noteworthy in RESTful Web Services API - Arun Gupta
 
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
 
What's coming in Java EE 8
What's coming in Java EE 8What's coming in Java EE 8
What's coming in Java EE 8
 
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
 
MySQL Tech Café #8: MySQL 8.0 for Python Developers
MySQL Tech Café #8: MySQL 8.0 for Python DevelopersMySQL Tech Café #8: MySQL 8.0 for Python Developers
MySQL Tech Café #8: MySQL 8.0 for Python Developers
 
Java EE 7 - Novidades e Mudanças
Java EE 7 - Novidades e MudançasJava EE 7 - Novidades e Mudanças
Java EE 7 - Novidades e Mudanças
 
Aplicações HTML5 com Java EE 7 e NetBeans
Aplicações HTML5 com Java EE 7 e NetBeansAplicações HTML5 com Java EE 7 e NetBeans
Aplicações HTML5 com Java EE 7 e NetBeans
 
OTN Tour 2013: What's new in java EE 7
OTN Tour 2013: What's new in java EE 7OTN Tour 2013: What's new in java EE 7
OTN Tour 2013: What's new in java EE 7
 
Java EE 8 - An instant snapshot
Java EE 8 - An instant snapshotJava EE 8 - An instant snapshot
Java EE 8 - An instant snapshot
 
Getting Started with WebSocket and Server-Sent Events in Java
Getting Started with WebSocket and Server-Sent Events in JavaGetting Started with WebSocket and Server-Sent Events in Java
Getting Started with WebSocket and Server-Sent Events in Java
 
What’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new StrategyWhat’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new Strategy
 
Project Helidon Overview (Japanese)
Project Helidon Overview (Japanese)Project Helidon Overview (Japanese)
Project Helidon Overview (Japanese)
 

Mais de Masoud Kalali

Real world RESTful service development problems and solutions
Real world RESTful service development problems and solutionsReal world RESTful service development problems and solutions
Real world RESTful service development problems and solutionsMasoud Kalali
 
CON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EE
CON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EECON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EE
CON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EEMasoud Kalali
 
BOF 2193 - How to work from home effectively
BOF 2193 - How to work from home effectivelyBOF 2193 - How to work from home effectively
BOF 2193 - How to work from home effectivelyMasoud Kalali
 
Real-World RESTful Service Development Problems and Solutions
Real-World RESTful Service Development Problems and SolutionsReal-World RESTful Service Development Problems and Solutions
Real-World RESTful Service Development Problems and SolutionsMasoud Kalali
 
How to avoid top 10 security risks in Java EE applications and how to avoid them
How to avoid top 10 security risks in Java EE applications and how to avoid themHow to avoid top 10 security risks in Java EE applications and how to avoid them
How to avoid top 10 security risks in Java EE applications and how to avoid themMasoud Kalali
 
Confess 2013: OWASP Top 10 and Java EE security in practice
Confess 2013: OWASP Top 10 and Java EE security in practiceConfess 2013: OWASP Top 10 and Java EE security in practice
Confess 2013: OWASP Top 10 and Java EE security in practiceMasoud Kalali
 
Utilize the Full Power of GlassFish Server and Java EE Security
Utilize the Full Power of GlassFish Server and Java EE SecurityUtilize the Full Power of GlassFish Server and Java EE Security
Utilize the Full Power of GlassFish Server and Java EE SecurityMasoud Kalali
 
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!Masoud Kalali
 
Slides for the #JavaOne Session ID: CON11881
Slides for the #JavaOne Session ID: CON11881Slides for the #JavaOne Session ID: CON11881
Slides for the #JavaOne Session ID: CON11881Masoud Kalali
 
Security in java ee platform: what is included, what is missing
Security in java ee platform: what is included, what is missingSecurity in java ee platform: what is included, what is missing
Security in java ee platform: what is included, what is missingMasoud Kalali
 
An Overview of RUP methodology
An Overview of RUP methodologyAn Overview of RUP methodology
An Overview of RUP methodologyMasoud Kalali
 
An overview of software development methodologies.
An overview of software development methodologies.An overview of software development methodologies.
An overview of software development methodologies.Masoud Kalali
 
NIO.2, the I/O API for the future
NIO.2, the I/O API for the futureNIO.2, the I/O API for the future
NIO.2, the I/O API for the futureMasoud Kalali
 

Mais de Masoud Kalali (13)

Real world RESTful service development problems and solutions
Real world RESTful service development problems and solutionsReal world RESTful service development problems and solutions
Real world RESTful service development problems and solutions
 
CON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EE
CON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EECON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EE
CON 2107- Think Async: Embrace and Get Addicted to the Asynchronicity of EE
 
BOF 2193 - How to work from home effectively
BOF 2193 - How to work from home effectivelyBOF 2193 - How to work from home effectively
BOF 2193 - How to work from home effectively
 
Real-World RESTful Service Development Problems and Solutions
Real-World RESTful Service Development Problems and SolutionsReal-World RESTful Service Development Problems and Solutions
Real-World RESTful Service Development Problems and Solutions
 
How to avoid top 10 security risks in Java EE applications and how to avoid them
How to avoid top 10 security risks in Java EE applications and how to avoid themHow to avoid top 10 security risks in Java EE applications and how to avoid them
How to avoid top 10 security risks in Java EE applications and how to avoid them
 
Confess 2013: OWASP Top 10 and Java EE security in practice
Confess 2013: OWASP Top 10 and Java EE security in practiceConfess 2013: OWASP Top 10 and Java EE security in practice
Confess 2013: OWASP Top 10 and Java EE security in practice
 
Utilize the Full Power of GlassFish Server and Java EE Security
Utilize the Full Power of GlassFish Server and Java EE SecurityUtilize the Full Power of GlassFish Server and Java EE Security
Utilize the Full Power of GlassFish Server and Java EE Security
 
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!
 
Slides for the #JavaOne Session ID: CON11881
Slides for the #JavaOne Session ID: CON11881Slides for the #JavaOne Session ID: CON11881
Slides for the #JavaOne Session ID: CON11881
 
Security in java ee platform: what is included, what is missing
Security in java ee platform: what is included, what is missingSecurity in java ee platform: what is included, what is missing
Security in java ee platform: what is included, what is missing
 
An Overview of RUP methodology
An Overview of RUP methodologyAn Overview of RUP methodology
An Overview of RUP methodology
 
An overview of software development methodologies.
An overview of software development methodologies.An overview of software development methodologies.
An overview of software development methodologies.
 
NIO.2, the I/O API for the future
NIO.2, the I/O API for the futureNIO.2, the I/O API for the future
NIO.2, the I/O API for the future
 

Último

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
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
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
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
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Último (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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
 
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...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Java EE 7 overview

  • 1. Java EE 7: What’s New in the Java EE Platform Masoud Kalali @MasoudKalali ORACLE JDays 2013
  • 2. Agenda A look at some of the important new features of Java EE 7 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 3. Java EE 7 Themes MEETING ENTERPRISE DEMANDS DEVELOPER PRODUCTIVITY Java EE 7 §  More annotated POJOs §  Less boilerplate code §  Cohesive integrated platform 3 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. §  §  §  §  WebSockets JSON Servlet 3.1 NIO REST §  Batch §  Concurrency §  Simplified JMS
  • 4. Java EE 7 JSRs New or Updated §  JPA 2.1 §  CDI 1.1 §  JAX-RS 2.0 §  Bean Validation 1.1 §  EJB 3.2 §  WebSocket 1.0 §  JMS 2.0 §  JSON 1.0 §  Servlet 3.1 §  Batch Applications 1.0 §  EL 3.0 §  Concurrency Utilities 1.0 §  JSF 2.2 4 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 5. Java EE 7 Maintenance Releases §  Common Annotations 1.2 §  JTA 1.2 §  Interceptors 1.2 §  Connector 1.7 §  JSP 2.3 §  JASPIC 1.2 §  JACC 1.4 §  JavaMail 1.5 §  Web Services 1.4 5 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 6. JSON Processing 1.0 6 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 7. JSON Processing 1.0 §  API to parse and generate JSON §  Streaming API (javax.json.stream) –  Low-level, efficient way to parse/generate JSON –  Similar to StAX API in XML world §  Object model API (javax.json) –  Simple, easy to use high-level API –  Similar to DOM API in XML world 7 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 8. JSON Processing 1.0 Streaming API: Parsing §  Created using –  Json.createParser(…) –  Json.createParserFactory().createParser(…) §  Parses JSON in streaming way from input sources Event event = parser.next(); //START_OBJECT event = parser.next(); // KEY_NAME event = parser.next(); // VALUE_STRING §  Parser state events –  START_OBJECT, END_OBJECT, START_ARRAY, END_ARRAY, KEY_NAME, VALUE_STRING, VALUE_NUMBER, … 8 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 9. JSON Processing 1.0 Streaming Parser { “firstName”: “John”, “lastName”: “Smith”, “age”: 25, “phoneNumber”: [ { “type”: “home”, “number”: “212 555-1234” }, { “type”: “fax”, “number”: “646 555-4567” } ] } 9 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 10. JSON Processing 1.0 Streaming Parser { START_OBJECT “firstName”: “John”, “lastName”: “Smith”, “age”: 25, “phoneNumber”: [ { “type”: “home”, “number”: “212 555-1234” }, { “type”: “fax”, “number”: “646 555-4567” } ] } 10 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 11. JSON Processing 1.0 Streaming Parser { KEY_NAME “firstName”: “John”, “lastName”: “Smith”, “age”: 25, “phoneNumber”: [ { “type”: “home”, “number”: “212 555-1234” }, { “type”: “fax”, “number”: “646 555-4567” } ] } 11 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 12. JSON Processing 1.0 Streaming Parser VALUE_STRING { “firstName”: “John”, “lastName”: “Smith”, “age”: 25, “phoneNumber”: [ { “type”: “home”, “number”: “212 555-1234” }, { “type”: “fax”, “number”: “646 555-4567” } ] } 12 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 13. JSON Processing 1.0 Streaming Parser VALUE_NUMBER { “firstName”: “John”, “lastName”: “Smith”, “age”: 25, “phoneNumber”: [ { “type”: “home”, “number”: “212 555-1234” }, { “type”: “fax”, “number”: “646 555-4567” } ] } 13 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 14. JSON Processing 1.0 Streaming Parser { “firstName”: “John”, “lastName”: “Smith”, “age”: 25, “phoneNumber”: [ START_ARRAY { “type”: “home”, “number”: “212 555-1234” }, { “type”: “fax”, “number”: “646 555-4567” } ] } 14 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 15. JSON Processing 1.0 Streaming Parser { “firstName”: “John”, “lastName”: “Smith”, “age”: 25, “phoneNumber”: [ { “type”: “home”, “number”: “212 555-1234” }, { “type”: “fax”, “number”: “646 555-4567” } ] END_ARRAY } 15 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 16. JSON Processing 1.0 Using Streaming API to generate JSON JsonGenerator gen = Json.createGenerator… .writeStartObject() .write("firstName", "John") .write("lastName", "Smith") .write("age", 25) .writeStartArray(“phones”) .writeStartObject() .write(“type", “home") .write(“number”, “222 555-1234”)) .writeEnd() .writeStartObject() … .writeEnd() .writeEnd() .writeEnd(); 16 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. { "firstName": "John", "lastName": "Smith", "age": 25, “phones" : [ { “type”: “home”, “number”: “ 222 555-1234” }, { “type”: “fax”, “number”: “ 646 555-4567” } ] }
  • 17. JSON Processing 1.0 Object Model API §  JsonObject/JsonArray – JSON object and array structures –  JsonString and JsonNumber for string and number values §  JSON builders – build JsonObject and JsonArray §  JsonReader – reads JsonObject and JsonArray §  JsonWriter – writes JsonObject and JsonArray 17 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 18. JsonReader §  Reads JsonObject and JsonArray from input source §  Uses pluggable JsonParser JsonReader reader = new JsonReader(io)); JsonObject obj = reader.readObject(); 18 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 19. JsonWriter §  Writes JsonObject and JsonArray to output source §  Uses pluggable JsonGenerator JsonWriter writer = new JsonWriter(io)); writer.writeObject(obj); 19 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 20. WebSockets 1.0 20 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 21. Java API for WebSocket 1.0 §  Bidirectional full-duplex messaging –  Over a single TCP connection §  Annotation-based or interface-based programming model §  Server and Client WebSocket Endpoints –  Annotated: @ServerEndpoint, @ClientEndpoint –  Programmatic: Endpoint §  Integrated with Java EE web container §  Highly configurable §  Simple packaging and deployment as wars or jars 21 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 22. Java API for WebSocket 1.0 Main API classes §  Endpoint –  intercepts websocket lifecycle events §  MessageHandler –  handles incoming messages for endpoint §  Session –  represents the active conversation §  RemoteEndpoint –  represents the other end of the conversation 22 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 23. WebSocket Endpoints Programmatic API public class MyClient extends Endpoint { public void onOpen(Session session, EndpointConfig ec) { session.addMessageHandler(new MessageHandler.Whole<String>() { public void onMessage(String text) { System.out.println("Message came from the server : " + message”); } } session.getBasicRemote().sendText("Hello!"); } public void onClose(Session session, CloseReason closeReason) { super.onClose(session, closeReason); } } 23 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 24. WebSocket Endpoints as POJOs Annotated client endpoint @ClientEndpoint public class MyClient { @OnOpen public void onOpen(Session session) { session.getBasicRemote().sendText(“Hello”); } @OnMessage public void onMessage(String text, Session session) { System.out.println("Message came from the server : " + message); } } 24 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 25. WebSocket Endpoints as POJOs Annotated server endpoint @ServerEndpoint("/chat") public class ChatServer { static Set<Session> peers = Collections.synchronizedSet(…); @OnOpen public void onOpen(Session peer) { peers.add(peer); } @OnMessage public void onMessage (String message, Session client) { for (Session peer : peers) { peer.getBasicRemote().sendObject(message); } } @OnClose public void onClose(Session peer) { peers.remove(peer); } 25 } Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 26. JAX-RS 2.0 26 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 27. Java API for RESTful Web Services (JAX-RS) 2.0 §  Client API §  Asynchronous Processing §  Filters and Interceptors §  Validation 27 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 28. JAX-RS 1.1 Previous Client API URL url = new URL("http://. . ./atm/balance"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoInput(true); conn.setDoOutput(false); conn.setRequestMethod("GET"); BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; while ((line = br.readLine()) != null) { //. . . } 28 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 29. JAX-RS 2.0 JAX-RS 2.0 Client API Client client = ClientFactory.newClient(); WebTarget webTarget= client.target(new URI(TARGET_URI)) ; webTarget.request().post(Entity.text(message)); 29 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 30. JAX-RS 2.0 JAX-RS 2.0 Client API Client client = ClientFactory.newClient(); String name= client.target("http://.../orders/{orderId}/customer") .resolveTemplate(“orderId”, “10”) .queryParam("pin", "9876") .request() .get(String.class); 30 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 31. Async Processing §  Server API support –  Off-load I/O container threads §  Long-running operations –  Efficient asynchronous event processing §  Suspend while waiting for an event §  Resume when event arrives –  Leverage Servlet 3.x async support (if available) §  Client API support –  Asynchronous request invocation API §  Future<RESPONSE>, InvocationCallback<RESPONSE>   31 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 32. Async Processing: Server-side @Path("/async/longRunning") public class MyResource { @GET public void longRunningOp(@Suspended AsyncResponse ar) { ar.setTimeoutHandler(new MyTimoutHandler()); ar.setTimeout(15, SECONDS); } 32 } Executors.newSingleThreadExecutor().submit(new Runnable() { public void run() { … ar.resume(result); } }); Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 33. Async Processing: Client-side WebTarget target = client.target("http://.../balance”)… // Start async call and register callback Future<?> handle = target.request().async().get( new InvocationCallback<String>() { void complete(String balance) { … } void failed(InvocationException e) { … } }); // After waiting for too long… if (!handle.isDone()) handle.cancel(true); 33 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 34. Filters & Interceptors Motivation §  Customize JAX-RS request/response processing –  Use Cases: Logging, Compression, Security, Etc. §  Introduced for client and server APIs §  Replace existing proprietary support –  Provided by most JAX-RS 1.x implementations §  All using slightly different types or semantics 34 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 35. Filters & Interceptors Filter each incoming/outgoing message §  Request è Request §  Non-wrapping filter chain –  Filters do not invoke next filter in the chain directly –  managed by the JAX-RS runtime –  ContainerRequestFilter,   ClientRequestFilter   §  Response è Response –  ContainerResponseFilter,   ClientResponseFilter §  Each filter decides to proceed or break the chain §  Server-side specialties –  @PreMatching,  DynamicFeature 35 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 36. Filters & Interceptors A Logging Filter Example public class RequestLoggingFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) { log(requestContext); } } 36 // non-wrapping => returns without invoking the next filter ... Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 37. Filters & Interceptors Intercept entity providers §  Invoked ONLY when/if entity reading/writing occurs §  MessageBodyReader interceptor –  ReaderInterceptor interface –  Performance boost §  Wrapping interceptor chain –  Each interceptor invokes the next one in the chain via context.proceed()   37 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. §  MessageBodyWriter interceptor –  WriterInterceptor interface
  • 38. Filters & Interceptors A GZip Reader Interceptor Example public class GzipInterceptor implements ReaderInterceptor { @Override Object aroundReadFrom(ReaderInterceptorContext ctx) { InputStream old = ctx.getInputStream(); ctx.setInputStream(new GZIPInputStream(old)); // wrapping => invokes the next interceptor Object entity = ctx.proceed(); } 38 } ctx.setInputStream(old); return entity; Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 39. JAX-RS 2.0 Bean Validation @Path("/") class MyResourceClass { @POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public void registerUser( @NotNull @FormParam("firstName") String firstName, @NotNull @FormParam("lastName") String lastName, @Email @FormParam("email") String email) { ... } … } 39 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 40. CDI 1.1 40 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 41. CDI: Default enabling Finer scanning control §  Possible values: all, annotated, none §  The annotated is set as the default, scan @*Scoped annotated §  all behaves like in Java EE 6 (default if not set) <beans ... version="1.1" bean-discovery-mode="all">! <alternatives>! <class>org.agoncal.book.MockGenerator</class>! </alternatives>! </beans>! 41 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 42. CDI: @Vetoed Veto the processing of the class or package @Vetoed! public class NonProcessedBean {
 ...! }! ! package-info.java @Vetoed! package com.non.processed.package;! 42 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 43. Interceptor 1.2 43 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 44. Interceptors: AroundConstruct Interceptor associated with a constructor public class LoggingInterceptor {! ! @AroundConstruct! private void init(InvocationContext ic) throws Exception{ logger.fine("Entering constructor");! ic.proceed();! logger.fine("Exiting constructor");! }! ! @AroundInvoke! public Object logMethod(InvocationContext ic) ... {! // ...! }! }! 44 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 45. Interceptors: @Priority Prioritizing interceptor bindings §  PLATFORM_BEFORE (0), LIBRARY_BEFORE (1000), APPLICATION (2000), LIBRARY_AFTER (3000), PLATFORM_AFTER (4000) §  Lower the priority, earlier the invocation! @Interceptor! @Loggable! @Priority(Interceptor.Priority.LIBRARY_BEFORE + 10)! public class LoggingInterceptor {! ! @AroundInvoke! ...! }! 45 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 46. Default Resources 46 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 47. Resource Definition Metadata §  Specifies resources needed by application –  Enhances configurability in Java EE 7 apps –  Facilitates provisioning in cloud environments –  Java EE 6 introduced DataSourceDefinition @DataSourceDefinition ( name=“java:app/jdbc/myDB”, className=“oracle.jdbc.pool.OracleDataSource”, isolationLevel=TRANSACTION_REPEATABLE_READ, initialPoolSize=5) @Stateless public class MySessionBean { @Resource(lookup=“java:app/jdbc/myDB”) DataSource my DB; … } 47 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 48. Resource Definition Metadata §  Java EE 7 adds: –  JMSConnectionFactoryDefinition –  JMSDestinationDefinition –  MailSessionDefinition –  ConnectionFactoryDefinition –  AdministeredObjectDefinition 48 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 49. Default Resources Preconfigured resources for use by application §  JDBC/JPA: java:comp/DefaultDataSource §  JMS: java:comp/DefaultJMSConnectionFactory §  Concurrency Utilities: –  java: comp/DefaultManagedExecutorService –  java: comp/DefaultManagedScheduledExecutorService –  java: comp/DefaultManagedThreadFactory –  java: comp/DefaultManagedContextService 49 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 50. JMS 2.0 50 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 51. Java Message Service 2.0 New JMS Simplified API targeted at ease of development §  Less code, less boilerplate §  Fewer objects to manage §  Increased developer productivity §  “Classic API” has also been improved 51 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 52. JMS 2.0 Simplifications include…. §  New JMSContext interface §  Use of CDI injection; new TransactionScope §  AutoCloseable JMSContext, Connection, Session, … §  Use of runtime exceptions §  Method chaining on JMSProducer §  Simplified message sending 52 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 53. JMS 1.1: Sending a message @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); 13 lines of } finally { code just connection.close(); to send a } message } catch (JMSException ex) { Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex); } } 53 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 54. JMS 1.1: Sending a message @Resource(lookup = "java:global/jms/demoConnectionFactory") ConnectionFactory connectionFactory; must create @Resource(lookup = "java:global/jms/demoQueue") Queue demoQueue; several intermediate objects 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 { connection.close(); } } catch (JMSException ex) { Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex); } } 54 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 55. JMS 1.1: Sending a message @Resource(lookup = "java:global/jms/demoConnectionFactory") ConnectionFactory connectionFactory; @Resource(lookup = "java:global/jms/demoQueue") Queue demoQueue; boilerplate code 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 { connection.close(); } } catch (JMSException ex) { Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex); } } 55 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 56. JMS 1.1: Sending a message @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); must } finally { close connection.close(); resources } } catch (JMSException ex) { after use! Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex); } } 56 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 57. JMS 1.1: Sending a message @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); all } finally { methods connection.close(); throw } checked } catch (JMSException ex) { exceptions Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex); } } 57 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 58. Simplifying the JMS API Strategy §  Simplify existing JMS 1.1 API where it won't break compatibility §  Define new simplified API requiring fewer objects –  JMSContext, JMSProducer, JMSConsumer §  In Java EE, allow JMSContext to be injected and managed by the container 58 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 59. JMS 2.0 Sending a message using Simplified API and JMSContext @Resource(lookup = “java:global/jms/myConnectionFactory”) ConnectionFactory connectionFactory; @Resource(lookup = “java:global/jms/myQueue”) Queue queue; public void sendMessage(String text) { try (JMSContext context = connectionFactory.createContext();) { context.createProducer().send(queue, text); } catch (JMSRuntimeException ex) { … } } 59 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 60. JMS 2.0 Even simpler…. @Inject @JMSConnectionFactory(““java:global/jms/myConnectionFactory”) JMSContext context; @Resource(lookup = “java:global/jms/myQueue”) Queue queue; public void sendMessage(String text) { context.createProducer().send(queue, text); } 60 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 61. JMS 2.0 Even simpler still…. @Inject JMSContext context; @Resource(lookup = “java:global/jms/myQueue”) Queue queue; public void sendMessage(String text) { context.createProducer().send(queue, text); } 61 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 62. JMS 2.0: New API features 62 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 63. Delivery delay §  Allows a JMS client to schedule the future delivery of a message §  New method on old MessageProducer public void setDeliveryDelay(long deliveryDelay) §  New method on the new JMSProducer public JMSProducer setDeliveryDelay(long deliveryDelay) §  Sets minimum time in ms from that a message should be retained by the messaging system before delivery to a consumer §  Why? If the business requires deferred processing, e.g. end of day 63 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 64. Async send §  Send a message and return immediately without blocking until an acknowledgement has been received from the server. §  Instead, when the acknowledgement is received, an asynchronous callback will be invoked §  New methods on MessageProducer messageProducer.send(message,completionListener) §  Feature also available on JMSProducer §  Why? Allows thread to do other work whilst waiting for the acknowledgement 64 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 65. Async send §  Application specifies a CompletionListener instance public interface CompletionListener { void onCompletion(Message message); void onException(Message message, Exception exception); } 65 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 66. Better handling of "poison" messages Make JMSMXDeliveryCount mandatory §  JMS 1.1 defines an optional JMS defined message property JMSXDeliveryCount. –  When used, this is set by the JMS provider when a message is received, and is set to the number of times this message has been delivered (including the first time). The first time is 1, the second time 2, etc §  JMS 2.0 will make this mandatory §  Why? Allows app servers and applications to handle "poisonous" messages better 66 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 67. Multiple consumers on a topic subscription §  Allows scalable consumption of messages from a topic subscription –  multiple threads, multiple JVMs §  New methods needed for non-durable subscriptions MessageConsumer messageConsumer= session.createSharedConsumer(topic,sharedSubscriptionName); §  Existing methods used for durable subscriptions MessageConsumer messageConsumer= session.createDurableConsumer(topic,durableSubscriptionName); §  Also available on JMSContext 67 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 68. Concurrency Utilities for Java EE 1.0 68 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 69. Concurrency Utilities for Java EE 1.0 Provides asynchronous capabilities to Java EE components §  Extension of Java SE Concurrency Utilities API §  Provides managed objects for submitting tasks and obtaining managed threads –  ManagedExecutorService –  ManagedScheduledExecutorService –  ManagedThreadFactory –  ContextService 69 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 70. Concurrency: ManagedExecutor Default ManagedExectuor @Resource
 ManagedExecutorService executor;
 ! 
 ManagedExecutorService executor = (ManagedExecutorService) ctx
 .lookup("java:comp/DefaultManagedExecutorService");! 70 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 71. Concurrency: ManagedExecutor Specify in web.xml <web-app … version="3.1">! <resource-env-ref>! <resource-env-ref-name>! concurrent/myExecutor! </resource-env-ref-name>! <resource-env-ref-type>! javax.enterprise.concurrent.ManagedExecutorService! </resource-env-ref-type>! </resource-env-ref>! </web-app>! 71 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 72. Concurrency: ManagedScheduledExecutor §  Managed version of ScheduledExecutorService! §  Submit delayed or periodic tasks @Resource
 ManagedScheduledExecutorService executor;! 72 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 73. Concurrency: ManagedScheduledExecutor Access using JNDI InitialContext ctx = new InitialContext(); 
 
 ManagedScheduledExecutorService executor = (ManagedScheduledExecutorService)ctx.lookup(
 "java:comp/DefaultManagedScheduledExecutorService");
 ! §  Can be defined in web.xml as well 73 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 74. Concurrency: ManagedScheduledExecutor §  executor.schedule(new MyCallableTask(), 5, TimeUnit.SECONDS);! §  executor.scheduleAtFixedRate(new MyRunnableTask(), 2, 3, TimeUnit.SECONDS);! §  executor.scheduleWithFixedDelay(new MyRunnableTask(), 2, 3, TimeUnit.SECONDS);! 74 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 75. Concurrency: ManagedThreadFactory §  Extends ThreadFactory @Resource(name = "DefaultManagedThreadFactory")
 ManagedThreadFactory factory; ManagedThreadFactory factory = (ManagedThreadFactory) ctx.lookup("java:comp/ DefaultManagedThreadFactory");
 75 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 76. Concurrency: ManagedThreadFactory §  Thread thread = factory.newThread(new MyTask()); §  ((ManageableThread)thread).isShutdown();
 76 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 77. Concurrency: DynamicProxy §  Create dynamic proxy objects, adds contextual information available for applications running in Java EE environment §  Classloading, JNDI, Security, … 77 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 78. Concurrency: DynamicProxy @Resource
 ContextService service;
 
 
 Runnable proxy = service.createContextualProxy(new MyRunnable(), Runnable.class);
 
 
 Future f = executor.submit(proxy);! 78 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 79. Batch Applications for the Java Platform 1.0 79 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 80. Batch Applications for the Java Platform 1.0 §  Designed for non-interactive, bulk-oriented and long-running tasks §  Sequential, parallel, and/or decision-based batch execution §  Processing styles –  Item-oriented: ItemReader, ItemProcessor, ItemWriter interfaces –  Task-oriented: Batchlet interfaces 80 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 81. Batch 1.0 Key concepts §  Job: entire batch process –  Defined through XML Job Specification Language §  Step: independent, sequential phase of a job §  JobOperator: interface for managing job processing §  JobRepository: information about past and present jobs Job Operator Job Step ItemReader ItemWriter Job Repository 81 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. ItemProcessor
  • 82. Batch 1.0 Job steps §  Chunked step: Item-oriented processing –  ItemReader/ItemProcessor/ItemWriter pattern –  Configurable checkpointing and transactions §  Batchlet: Task-oriented processing –  Roll-your-own batch pattern –  Runs to completion and exits §  Job can include both types of steps 82 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 83. Batch 1.0 Job specification language <job id="myJob" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0"> <step id="step1" next="step2"> <chunk item-count="3"> <reader ref="myItemReader"></reader> <processor ref="myItemProcessor"></processor> <writer ref="myItemWriter"></writer> </chunk> </step> <step id="step2" next=“step3”> <batchlet ref="myBatchlet"/> </step> <step id="step3" > <chunk item-count="3"> <reader ref="myOtherItemReader"></reader> <processor ref="myOtherItemProcessor"></processor> <writer ref="myOtherItemWriter"></writer> </chunk> </step> </job> 83 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 84. EJB 3.2 84 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 85. EJB 3.2 new features and improvments § Singleton Session Beans § EJB 3.1 Lite: §  Includes non-persisted TimerService §  Local asynchronous invocation of session beans 85 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 86. Java Persistence API 2.1 86 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 87. Java Persistence API 2.1 Schema generation §  Generation of database tables, indexes, constraints, etc. §  Designed for flexibility –  Scenarios: (iterative) prototyping; production; provisioning environments –  Generate from object/relational metadata (annotations and/or XML) –  Generate from bundled SQL DDL scripts; also SQL load scripts –  Generate directly into database –  Generate into SQL DDL scripts §  Process controlled by metadata or runtime properties 87 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 88. JPA 2.1 Schema generation into scripts <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/ XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ ns/persistence/persistence_2_1.xsd"> <persistence-unit name=“samplePU" transaction-type="JTA"> <jta-data-source>jdbc/mypu</jta-data-source> <properties> <property name="javax.persistence.schema-generation.database.action" value="none" /> <property name="javax.persistence.schema-generation.scripts.action" value=“drop-and-create"/> <property name="javax.persistence.schema-generation.scripts.create-target" value=”//temp/create.sql"/ > <property name="javax.persistence.schema-generation.scripts.drop-target" value=“/temp/drop.sql"/> </properties> </persistence-unit> </persistence> 88 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 89. JPA 2.1 Schema generation from scripts <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/ XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/ persistence/persistence_2_1.xsd"> <persistence-unit name=“samplePU" transaction-type="JTA"> <jta-data-source>jdbc/mypu</jta-data-source> <properties> <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/> <property name="javax.persistence.schema-generation.create-source" value="script"/> <property name="javax.persistence.schema-generation.drop-source" value="script"/> <property name="javax.persistence.schema-generation.create-script-source" value="META-INF/create.sql"/> <property name="javax.persistence.schema-generation.drop-script-source" value="META-INF/drop.sql"/> <property name="javax.persistence.sql-load-script-source" value="META-INF/load.sql"/> </properties> </persistence-unit> </persistence> 89 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 90. JPA 2.1 Some more features §  Stored procedure support: @NamedStoredProcedureQuery §  Dynamically Defining Named Queries §  Enhancements To Queries §  @Converter and @Convert(…) 90 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 91. Java EE 7 Summary MEETING ENTERPRISE DEMANDS DEVELOPER PRODUCTIVITY Java EE 7 §  More annotated POJOs §  Less boilerplate code §  Cohesive integrated platform 91 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. §  §  §  §  WebSockets JSON Servlet 3.1 NIO REST §  Batch §  Concurrency §  Simplified JMS
  • 92. DOWNLOAD Java EE 7 SDK oracle.com/javaee GlassFish 4.0 Full Platform or Web Profile glassfish.org 92 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 93. Questions… ? 93 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.