50 New Features of Java EE 7 in 50 minutes

Arun Gupta
Arun GuptaArun Gupta
1
#javaland #javaee7
50 new features
of
Java EE 7
in
50 minutes
Antonio Goncalves, @agoncal
Arun Gupta, @arungupta
43
2
#javaland #javaee7
#NN: <spec>: <feature>
3
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
4
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
CDI 1.1 (JSR 346)
5
#javaland #javaee7
#01: CDI: Default enabling
Finer scanning control
§  Possible values: all, annotated, none!
§  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>!
6
#javaland #javaee7
#02: CDI: @Vetoed
Veto the processing of the class or package
@Vetoed!
public class NonProcessedBean {

...!
}!
!
package-info.java
@Vetoed!
package com.non.processed.package;!
7
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
Bean Validation 1.1 (JSR 349)
8
#javaland #javaee7
#03: Bean Validation: Method validation
Pre/post conditions on method and constructors
public class CardValidator {!
!
public CardValidator(@NotNull Algorithm algorithm) {!
this.algorithm = algorithm;!
}!
!
@AssertTrue!
public Boolean validate(@NotNull CreditCard creditCard) {!
return algorithm.validate(creditCard.getNumber());!
}!
}!
9
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
Interceptors 1.2 (JSR 318)
10
#javaland #javaee7
#04: 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) ... {!
// ...!
}!
}!
11
#javaland #javaee7
#05: Interceptors: @Priority
Prioritizing interceptor bindings
§  PLATFORM_BEFORE (0), LIBRARY_BEFORE (1000), APPLICATION
(2000), LIBRARY_AFTER (3000), PLATFORM_AFTER (4000)!
@Interceptor!
@Loggable!
@Priority(Interceptor.Priority.LIBRARY_BEFORE + 10)!
public class LoggingInterceptor {!
!
@AroundInvoke!
...!
}!
12
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
Concurrency utilities 1.0 (JSR 236)
13
#javaland #javaee7
#06: Concurrency: ManagedExecutor
§  User threads in Java EE applications
§  Support simple and advance concurrency design patterns
§  Extend Concurrency Utilities API from Java SE (JSR 166y)
–  java.util.concurrent package
14
#javaland #javaee7
#06: Concurrency: ManagedExecutor
@Resource

ManagedExecutorService executor;

!


ManagedExecutorService executor =
(ManagedExecutorService) ctx

.lookup("java:comp/DefaultManagedExecutorService");!
Default ManagedExectuor
15
#javaland #javaee7
#06: Concurrency: ManagedExecutor
<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>!
Specify in web.xml
16
#javaland #javaee7
#07: Concurrency: ManagedScheduledExecutor
§  Managed version of ScheduledExecutorService!
§  Submit delayed or periodic tasks
@Resource

ManagedScheduledExecutorService executor;!
17
#javaland #javaee7
#07: Concurrency: ManagedScheduledExecutor
InitialContext ctx = new InitialContext(); 



ManagedScheduledExecutorService executor =
(ManagedScheduledExecutorService)ctx.lookup(

"java:comp/DefaultManagedScheduledExecutorService");

!
§  Can be defined in web.xml as well
Access using JNDI
18
#javaland #javaee7
#07: 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);!
19
#javaland #javaee7
#08: Concurrency: ManagedThreadFactory
§  Extends ThreadFactory
@Resource(name = "DefaultManagedThreadFactory")

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

20
#javaland #javaee7
#08: Concurrency: ManagedThreadFactory
§  Thread thread = factory.newThread(new MyTask());
§  ((ManageableThread)thread).isShutdown();

21
#javaland #javaee7
#09: Concurrency: DynamicProxy
§  Create dynamic proxy objects, adds contextual information available
for applications running in Java EE environment
§  Classloading, JNDI, Security, …
22
#javaland #javaee7
#09: Concurrency: DynamicProxy
@Resource

ContextService service;





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





Future f = executor.submit(proxy);!
23
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
JPA 2.1 (JSR 338)
24
#javaland #javaee7
#10: JPA: Schema Generation
Standardized database schema generation
<persistence ... version="2.1">!
<persistence-unit ...>!
<properties>!
<property name="javax.persistence.schema-generation.scripts.action"!
value="drop-and-create"/>!
<property name="javax.persistence.schema-generation.scripts.create-target"
value="create.sql"/>!
<property name="javax.persistence.sql-load-script-source" !
value="insert.sql"/>!
</properties>!
</persistence-unit>!
25
#javaland #javaee7
#11: JPA: @Index
Defines additional indexes in schema generation
@Entity!
@Table(indexes = {!
@Index(columnList = "ISBN"),!
@Index(columnList = "NBOFPAGE")!
})!
public class Book {!
!
@Id @GeneratedValue!
private Long id;!
private String isbn;!
private Integer nbOfPage;!
...!
}!
26
#javaland #javaee7
#12: JPA: Unsynchronized Persistence Context
Persistence context is not enlisted in any tx unless explicitly joined
@PersistenceContext(synchronization =!
SynchronizationType.UNSYNCHRONIZED)
private EntityManager em;!
...!
!
em.persist(book);!
!
...!
em.joinTransaction();!
!
27
#javaland #javaee7
#13: JPA: Stored Procedure
Calling a stored procedure
@Entity!
@NamedStoredProcedureQuery(name = "archiveOldBooks", !
procedureName = "sp_archive_books",!
parameters = {!
@StoredProcedureParameter(name = ”date", mode = IN, !
type = Date.class),!
@StoredProcedureParameter(name = "warehouse", mode = IN, !
type = String.class)!
})!
public class Book {...}!
28
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
JTA 1.2 (JSR 907)
29
#javaland #javaee7
#14: JTA: @Transactional
Transaction management on Managed Beans as CDI interceptor binding
@Path("book")!
@Transactional(value = Transactional.TxType.REQUIRED,!
rollbackOn = {SQLException.class, JMSException.class},!
dontRollbackOn = SQLWarning.class)!
public class BookRestService {!
!
@PersistenceContext!
private EntityManager em;!
!
@POST!
@Consumes(MediaType.APPLICATION_XML)!
public Response createBook(Book book) {...}!
}!
30
#javaland #javaee7
#15: JTA: @TransactionScoped
CDI scope whose lifecycle is scoped to the currently active JTA
transaction
@TransactionScoped!
public class BookBean {...}!
!
@WebServlet!
public class TxServlet extends HttpServlet {!
@Inject UserTransaction tx;!
@Inject BookBean b1;!
@Inject BookBean b2;!
!
protected void processRequest(...) {!
tx.begin();!
s_out.println(b1.getReference());!
s_out.println(b2.getReference());!
tx.commit();!
}!
}!
31
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
EJB 3.2 (JSR 345)
32
#javaland #javaee7
#16: EJB: Disable passivation of stateful
In some cases increases performance, scalability and robustness
@Stateful(passivationCapable = false)!
public class ShoppingCart {!
...!
}!
33
#javaland #javaee7
#17: EJB-Lite: Async + Non-persistent timer
Extended the EJB Lite to include local asynchronous invocations and
non-persistent EJB Timer Service
@Stateless!
public class OrderEJB {!
!
@Asynchronous!
public void sendEmail (Order order) {!
// Very Long task!
}!
!
@Schedule(hour="2", persistent=false)!
public void createDailyReport() {!
// ...!
}!
}!
34
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
JMS 2.0 (JSR 343)
35
#javaland #javaee7
#18: JMS: JMSContext API
New simplified API to produce and consume messages
JMSContext ctx = connectionFactory.createContext()!
!
ctx.createProducer().send(queue, "Text message sent");!
!
ctx.createConsumer(queue).receiveBody(String.class);!
!
ctx.createProducer()!
.setPriority(2)!
.setTimeToLive(1000)!
.setDeliveryMode(DeliveryMode.NON_PERSISTENT)!
.send(queue, message);!
36
#javaland #javaee7
#19: JMS: Autocloseable
Several JMS interfaces implement Autocloseable
try (JMSContext ctx = connectionFactory.createContext()) {!
ctx.createProducer().send(queue, "Text message sent");!
}!
!
...!
!
try (JMSContext ctx = connectionFactory.createContext()) {!
while (true) {!
String s = ctx.createConsumer(queue).receiveBody(String.class);!
}!
}!
37
#javaland #javaee7
#20: JMS: JMSConnectionFactoryDefinition
A JMS ConnectionFactory can be defined using an annotation on a
container-managed class
@Stateless!
@JMSConnectionFactoryDefinition(!
name = "java:app/jms/MyConnectionFactory",!
interfaceName = "javax.jms.TopicConnectionFactory")!
!
!
!
public class ExpensiveOrderEJB {...}!
38
#javaland #javaee7
#21: JMS: JMSDestinationDefinition
A JMS queue or topic can be defined using an annotation
@Stateless!
@JMSConnectionFactoryDefinition(!
name = "java:app/jms/MyConnectionFactory",!
interfaceName = "javax.jms.TopicConnectionFactory")!
@JMSDestinationDefinition(!
name = "java:app/jms/MyTopic",!
interfaceName = "javax.jms.Topic")!
public class ExpensiveOrderEJB {...}!
39
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
Servlet 3.1 (JSR 340)
40
#javaland #javaee7
#22: Servlet: Non-blocking I/O
public class TestServlet extends HttpServlet

protected void doGet(HttpServletRequest request,

HttpServletResponse response) 

throws IOException, ServletException {

ServletInputStream input = request.getInputStream();

byte[] b = new byte[1024];

int len = -1;

while ((len = input.read(b)) != -1) {

. . .

}

}

}!
41
#javaland #javaee7
#22: Servlet: Non-blocking I/O
§  ServletInputStream!
–  public void setReadListener(ReadListener listener);!
–  public boolean isFinished();!
–  public boolean isReady();!
§  ServletOutputStream!
–  public setWriteListener(WriteListener listener);!
–  public boolean canWrite();!
New methods to existing interfaces
42
#javaland #javaee7
#22: Servlet: Non-blocking I/O
public interface ReadListener extends EventListener {

public void onDataAvailable();

pubic void onAllDataRead();

public void onError();

}!
public interface WriteListener extends EventListener {

public void onWritePossible();

public void onError();

}!
New interfaces
43
#javaland #javaee7
#22: Servlet: Non-blocking I/O
AsyncContext context = request.startAsync();

ServletInputStream input = request.getInputStream();

input.setReadListener(

new MyReadListener(input, context)); !
Only for Asynchronous Servlets
44
#javaland #javaee7
#23: Servlet: Protocol Upgrade
§  <T extends HttpUpgradeHandler> T
HttpServletRequest.upgrade(Class<T> class) throws
IOException;





!
§  HttpUpgradeHandler!
–  init(WebConnection wc);!
–  destroy();!
45
#javaland #javaee7
#23: Servlet: Protocol Upgrade
public interface WebConnection {

ServletInputStream getInputStream();

ServletOutputStream getOutputStream();

}!
46
#javaland #javaee7
#24: Servlet: Improved Security
<web-app . . . version="3.1"> 

<web-resource-collection>

<url-pattern>/account/*</url-pattern> 

<http-method>GET</http-method>

</web-resource-collection>

</web-app> !
!
Deny an HTTP method request for an uncovered HTTP method
47
#javaland #javaee7
#24: Servlet: Improved Security
<web-app . . . version="3.1"> 

<deny-uncovered-http-methods/>

<web-resource-collection>

<url-pattern>/account/*</url-pattern> 

<http-method>GET</http-method>

</web-resource-collection>

</web-app> !
!
Deny an HTTP method request for an uncovered HTTP method
48
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
Web Socket 1.0 (JSR 356)
49
#javaland #javaee7
#25: WebSocket: Annotated server endpoint
§  Enables full-duplex bi-directional communication over single TCP
connection
@javax.websocket.server.ServerEndpoint("/chat")

public class ChatServer {



@OnMessage

public String chat(String name, Session session) {

for (Session peer : client.getOpenSessions()) {!
peer.getBasicRemote().sendObject(message);!
}

}

}!
50
#javaland #javaee7
#26: WebSocket: Lifecycle callbacks
@javax.websocket.OnOpen

public void open(Session s) { . . . }



@javax.websocket.OnClose

public void close(CloseReason c) { . . . }



@javax.websocket.OnError

public void error(Throwable t) { . . . }!
51
#javaland #javaee7
#27: WebSocket: Annotated client endpoint
@javax.websocket.ClientEndpoint

public class MyClient {

@javax.websocket.OnOpen

public void open(Session session) { … }



// Lifecycle callbacks

}!
52
#javaland #javaee7
#27: WebSocket: Annotated client endpoint
ContainerProvider

.getWebSocketContainer()

.connectToServer(

MyClient.class, 

URI.create("ws://. . ."));!
53
#javaland #javaee7
#28: WebSocket: Programmatic endpoints
public class ChatServer extends Endpoint {

@Override

public void onOpen(Session s, EndpointConfig ec) {

s.addMessageHandler(new MessageHandler.Whole<String>() {

public void onMessage(String text) { . . . }

}

}



@Override

public void onClose(Session s, CloseReason cr) { . . . }



//. . . 

}!
54
#javaland #javaee7
#28: WebSocket: Programmatic endpoints
public class MyApplicationConfig implements
ServerApplicationConfig {

public Set<ServerEndpointConfig> getEndpointConfigs(…) { 

ServerEndpointConfig.Builder

.create(MyEndpoint.class, "/websocket”)

.configurator(new MyConfig())

.build()

}

}!
55
#javaland #javaee7
#28: WebSocket: Programmatic endpoints
public class MyConfig extends ServerEndpointConfig.Configurator {



public <T> T getEndpointInstance(. . .) { . . . }



public void modifyHandshake(. . .) { . . . }



. . .

}!
56
#javaland #javaee7
#29: WebSocket: Encoder and Decoder
@javax.websocket.server.ServerEndpoint(

value="/chat",

decoders="MyDecoder.class",

encoders="MyEncoder.class")

public class ChatServer {



@OnMessage

public String chat(ChatMessage name, Session session) {

. . . 

}

}!
57
#javaland #javaee7
#29: WebSocket: Encoder and Decoder
public class MyDecoder implements Decoder.Text<ChatMessage> {

public ChatMessage decode(String s) {

// . . .

}



public boolean willDecode(String string) {

// . . .

}



//. . .

}



!
58
#javaland #javaee7
#29: WebSocket: Encoder and Decoder
public class MyEncoder implements Encoder.Text<ChatMessage> {



public String encode(ChatMessage chatMessage) {

// . . .

}

!
// . . .

}!
59
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
Expression Language 3.0 (JSR 341)
60
#javaland #javaee7
#30: Expression Langauge: ELProcessor
§  Use EL in a stand-alone environment
–  Evaluate EL expressions
–  Get/set bean properties
–  Defining a static method as an EL function
–  Defining an object instance as an EL name
ELProcessor elp = new ELProcessor();

elp.defineBean("employee", new Employee("Charlie Brown"));

String name = elp.eval("employee.name");!
61
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
JSF 2.2 (JSR 344)
62
#javaland #javaee7
#31: JSF: Faces Flow
./src/main/webapp/flow1

/flow1.xhtml

/flow1a.xhtml

/flow1b.xhtml

./src/main/webapp/flow2

/flow2-flow.xml

/flow2.xhtml

/flow2a.xhtml

/flow2b.xhtml

/index.xhtml!
Package reusable flows in JAR
63
#javaland #javaee7
#31: JSF: Faces Flow
@Named

@FlowScoped("flow1")

public class Flow1Bean implements Serializable {

}!
!
@Produces @FlowDefinition

public Flow defineFlow(@FlowBuilderParameter FlowBuilder fb) {

String flowId = "flow1";

//. . .

return fb.getFlow();

}!
Package reusable flows in JAR
64
#javaland #javaee7
#31: JSF: Faces Flow
Package reusable flows in JAR
#{flowScope}: Local flow storage
#{facesContext.application.flowHandler.currentFlow}: Returns true if
within a flow
65
#javaland #javaee7
#32: JSF: Resource Library Contract
index-blue.xhtml

index-red.xhtml

WEB-INF/lib/contracts-library-1.0-SNAPSHOT.jar

/META-INF/contracts/blue

/style.css

/javax.faces.contract.xml

/template.xhtml

/META-INF/contracts/red

/style.css

/javax.faces.contract.xml

/template.xhtml!
Apply templates in a reusable and interchangeable manner
66
#javaland #javaee7
#32: JSF: Resource Library Contract
<f:view contracts=”red”>

<ui:composition template="/template.xhtml">

. . .

</ui:composition>

</f:view>

!
Apply templates in a reusable and interchangeable manner
67
#javaland #javaee7
#33: JSF: Pass-through Attributes
<h:inputText type="email" value="#{user.email}"/> 

!
<input type="text" name="j_idt6:j_idt10"/>!
HTML5-Friendly Markup
<h:inputText p:type="email" value="#{user.email}"/> 



<input type="email" name="j_idt6:j_idt10"/>!
!
68
#javaland #javaee7
#34: JSF: File Upload Component
<h:form enctype="multipart/form-data">

<h:inputFile value="#{fileUploadBean.file}"/><br/>

<h:commandButton value="Upload"/><p/>

</h:form> !
@Named @RequestScoped 

public class FileUploadBean {

private Part file;



//getter and setter

} !
69
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
JAX-RS 2.0 (JSR 339)
70
#javaland #javaee7
#35: JAX-RS: Client API
New API to consume rest services
Client client = ClientBuilder.newClient();!
WebTarget target = client.target("http://www.foo.com/book");!
Invocation invocation = target.request(TEXT_PLAIN).buildGet()
Response response = invocation.invoke();!
!
Response response = ClientBuilder.newClient()!
.target("http://www.foo.com/book")!
.request(MediaType.TEXT_PLAIN)!
.get();!
!
String body = ClientBuilder.newClient()!
.target("http://www.foo.com/book")!
.request()!
.get(String.class);!
71
#javaland #javaee7
#36: JAX-RS: Async Client
The client API also supports asynchronous invocation
Future<String> future = ClientBuilder.newClient()!
.target("http://www.foo.com/book")!
.request()!
.async()!
.get(String.class);!
!
try {!
String body = future.get(1, TimeUnit.MINUTES);!
} catch (InterruptedException | ExecutionException e) {...}!
72
#javaland #javaee7
#37: JAX-RS: Async Server
Asynchronous request processing on the server
@Path("/async")!
public class AsyncResource {!
!
@GET!
public void asyncGet(@Suspended AsyncResponse asyncResp) {!
!
new Thread(new Runnable() {!
!
public void run() {!
String result = veryExpensiveOperation();!
asyncResp.resume(result);!
}!
}).start();!
}}!
73
#javaland #javaee7
#38: JAX-RS: Message Filter
Used to process incoming and outgoing request or response headers
§  Filters on client side
–  ClientRequestFilter!
–  ClientResponseFilter!
§  Filters on server side
–  ContainerRequestFilter!
–  ContainerResponseFilter!
74
#javaland #javaee7
#38: JAX-RS: Message Filter
Used to process incoming and outgoing request or response headers
public class LogginFilter implements ClientRequestFilter {!
!
public void filter(ClientRequestContext ctx) throws IOException {
System.out.println(ctx.getMethod());!
System.out.println(ctx.getUri());!
}!
}!
75
#javaland #javaee7
#39: JAX-RS: Entity Interceptors
Marshalling and unmarshalling HTTP message bodies
§  Intercepts inbound entity streams (reads from the “wire”)
–  ReaderInterceptor!
§  Intercepts outbound entity streams (writes to the “wire”)
–  WriterInterceptor!
76
#javaland #javaee7
#39: JAX-RS: Entity Interceptors
Marshalling and unmarshalling HTTP message bodies
public class GZipInterceptor implements WriterInterceptor {!
!
public void aroundWriteTo(WriterInterceptorContext ctx){!
OutputStream os = ctx.getOutputStream();!
ctx.setOutputStream(new GZIPOutputStream(os));!
ctx.proceed();!
}!
}!
77
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
JSON-P 1.0 (JSR 353)
78
#javaland #javaee7
#40: JSON-P: JSON Builder
Creates an object model (or an array) in memory by adding elements
JsonObject value = Json.createObjectBuilder()!
.add("id", "1234")!
.add("date", "19/09/2012")!
.add("total_amount", "93.48")!
.add("customer", Json.createObjectBuilder()!
.add("first_name", "James")!
.add("last_name", "Rorrison")!
.add("email", "j.rorri@me.com")!
.add("phoneNumber", "+44 1234 1234")!
)!
.build();!
79
#javaland #javaee7
#41: JSON-P: JsonParser
Event-based parser that can read JSON data from a stream
JsonParser parser = Json.createParser(new FileReader(“order.json"));!
while (parser.hasNext()) {!
JsonParser.Event event = parser.next();!
!
if (event.equals(JsonParser.Event.KEY_NAME) && !
parser.getString().matches("email")) {!
parser.next();!
email = parser.getString();!
}!
}!
80
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
Batch 1.0 (JSR 352)
81
#javaland #javaee7
#42: Batch: Chunk-style Processing
Item-oriented Processing Style (primary)
82
#javaland #javaee7
#42: Batch: Chunk-style Processing
<step id=”sendStatements”>!
<chunk item-count=“3”>

<reader ref=”accountReader”/>!
<processor ref=”accountProcessor”/>

<writer ref=”emailWriter”/>!
</step>!
…implements ItemReader {

public Object readItem() {

// read account using JPA!
}!
!
…implements ItemProcessor {!
public Object processItems(Object account) {

// read Account, return Statement!
}!
!
…implements ItemWriter {!
public void writeItems(List accounts) {

// use JavaMail to send email!
}!
!
83
#javaland #javaee7
#43: Batch: Batchlet-style Processing
Task-oriented processing style
<step id=”transferFile”>!
<batchlet ref=“MyFileTransfer” />!
</step>!
…implements Batchlet {!
@Override

public void process() {

// Transfer file!
}!
!
84
#javaland #javaee7
#44: Batch: Job/Step/Chunk Listeners
<job id="myJob" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0”>

<listeners>

<listener ref="myJobListener"/>

</listeners>

<step id="myStep" >

<listeners>

<listener ref="myStepListener"/>

<listener ref="myChunkListener"/>

<listener ref="myItemReadListener"/>

<listener ref="myItemProcessorListener"/>

<listener ref="myItemWriteListener"/>

</listeners>

<chunk item-count="3”>. . .</chunk>

</step>

</job>!
!
85
#javaland #javaee7
#44: Batch: Job/Step/Chunk Listeners
Interface Abstract Classes
JobListener! AbstractJobListener!
StepListener! AbstractStepListener!
ChunkListener! AbstractChunkListener!
ItemRead/Write/ProcessListener! AbstractItemRead/Write/ProcessListener!
SkipRead/Write/ProcessListener! AbstractSkipRead/Write/ProcessListener!
RetryRead/Write/ProcessListener! AbstractRetryRead/Write/
ProcessListener!
86
#javaland #javaee7
#44: Batch: Job/Step/Chunk Listeners
@Named

public class MyJobListener extends AbstractJobListener {



@Override

public void beforeJob() throws Exception { . . . }



@Override

public void afterJob() throws Exception { . . . }

}!
87
#javaland #javaee7
#45: Batch: Partition
<step>

<chunk item-count="3">

<reader ref="myItemReader">

<properties>

<property name="start" value="#{partitionPlan['start']}"/>

<property name="end" value="#{partitionPlan['end']}"/>

</properties> 

</reader>

. . .

</chunk>!
88
#javaland #javaee7
#45: Batch: Partition
<partition>

<plan partitions="2">

<properties partition="0">

<property name="start" value="1"/>

<property name="end" value="10"/>

</properties>

<properties partition="1">

<property name="start" value="11"/>

<property name="end" value="20"/>

</properties>

</plan>

</partition>

</step>!
89
#javaland #javaee7
#46: Batch: Creating Workflows
<flow id="flow1" next="step3">

<step id="step1" next="step2"> . . . </step>

<step id="step2"> . . . </step>

</flow>

<step id="step3"> . . . </step>!
Flow: Elements that execute together as a unit
90
#javaland #javaee7
#46: Batch: Creating Workflows
<split id="split1" next=" . . . ">

<flow id="flow1”>

<step id="step1”> . . . </step>

</flow>

<flow id="flow2”>

<step id="step2”> . . . </step>

</flow>

</split>!
Split: Concurrent execution of flows
91
#javaland #javaee7
#46: Batch: Creating Workflows
<step id="step1" next="decider1">. . .</step>

<decision id="decider1" ref="myDecider"> 

<next on="DATA_LOADED" to="step2"/> 

<end on="NOT_LOADED"/> </decision>

<step id="step2">. . .</step> !
!
Decision: Customized way of sequencing between steps, flows, splits
@Named

public class MyDecider implements Decider {

@Override

public String decide(StepExecution[] ses) throws Exception {

. . .

return "DATA_LOADED"; // or "NOT_LOADED"!
} !
}!
92
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
JavaMail 1.5 (JSR 919)
93
#javaland #javaee7
#47: JavaMail
@MailSessionDefinition(name = "java:comp/myMailSession",

properties = {

"mail.smtp.host=smtp.gmail.com",

"mail.smtp.ssl.enable=true",

"mail.smtp.auth=true",

"mail.transport.protocol=smtp",

"mail.debug=true"

})





@Resource(lookup = "java:comp/myMailSession")

Session session;!
94
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
JCA 1.7 (JSR 322)
95
#javaland #javaee7
#48: Java Connector Architecture
@ConnectionDefinition(

connection="MyConnection.class",

connectionImpl="MyConnectionImpl.class",

connectionFactory="MyConnectionFactory.class",

connectionFactoryImpl="MyConnectionFactoryImpl.class"

)

!
@AdministeredObjectDefinition(

className="MyQueueImpl.class",

name="java:comp/MyQueue",

resourceAdapter="myAdapter",

)!
96
#javaland #javaee7
JAX-RS 2.0
JSON-P 1.0
Web Socket 1.0Servlet 3.1
JSF 2.2EL 3.0
JSP
JSTLBeanValidation1.1
Interceptors1.2
CDI1.1
Concurrency1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
Batch 1.0
JCA 1.7
Java EE 7
JavaMail 1.5
Java EE 7 (JSR 342)
97
#javaland #javaee7
#49: Default Resources
JNDI name: java:comp/DefaultDataSource
Default Data Source
@Resource(lookup="java:comp/DefaultDataSource")

DataSource myDS;

!
@Resource

DataSource myDS; !
98
#javaland #javaee7
#49: Default Resources
JNDI name: java:comp/DefaultJMSConnectionFactory





@Resource(lookup="java:comp/DefaultJMSConnectionFactory") 

ConnectionFactory myCF;
@Resource

ConnectionFactory myCF;!
Default JMS Connection Factory
99
#javaland #javaee7
#49: Default Resources
JNDI names
§  java:comp/DefaultManagedExecutorService!
§  java:comp/DefaultManagedScheduledExecutorService!
§  java:comp/DefaultManagedThreadFactory!
§  java:comp/DefaultContextService!
Default Concurrency Utilities Objects
100
#javaland #javaee7
#50: Buy our books!
101
#javaland #javaee7
References
§  github.com/javaee-samples/javaee7-samples
102
#javaland #javaee7
1 of 102

Recommended

Getting Started with Java EE 7 by
Getting Started with Java EE 7Getting Started with Java EE 7
Getting Started with Java EE 7Arun Gupta
4.1K views36 slides
Java EE 8 by
Java EE 8Java EE 8
Java EE 8Ryan Cuprak
4.4K views68 slides
Java EE 8 Recipes by
Java EE 8 RecipesJava EE 8 Recipes
Java EE 8 RecipesJosh Juneau
3.8K views86 slides
Java EE Introduction by
Java EE IntroductionJava EE Introduction
Java EE Introductionejlp12
4.9K views22 slides
Java EE 7 (Hamed Hatami) by
Java EE 7 (Hamed Hatami)Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)Hamed Hatami
1.2K views52 slides
Java EE Revisits GoF Design Patterns by
Java EE Revisits GoF Design PatternsJava EE Revisits GoF Design Patterns
Java EE Revisits GoF Design PatternsMurat Yener
15.9K views46 slides

More Related Content

What's hot

What's New in WebLogic 12.1.3 and Beyond by
What's New in WebLogic 12.1.3 and BeyondWhat's New in WebLogic 12.1.3 and Beyond
What's New in WebLogic 12.1.3 and BeyondOracle
20.3K views16 slides
Building Java Desktop Apps with JavaFX 8 and Java EE 7 by
Building Java Desktop Apps with JavaFX 8 and Java EE 7Building Java Desktop Apps with JavaFX 8 and Java EE 7
Building Java Desktop Apps with JavaFX 8 and Java EE 7Bruno Borges
7.3K views21 slides
Enterprise Java Web Application Frameworks Sample Stack Implementation by
Enterprise Java Web Application Frameworks   Sample Stack ImplementationEnterprise Java Web Application Frameworks   Sample Stack Implementation
Enterprise Java Web Application Frameworks Sample Stack ImplementationMert Çalışkan
4.3K views39 slides
Java Enterprise Edition 6 Overview by
Java Enterprise Edition 6 OverviewJava Enterprise Edition 6 Overview
Java Enterprise Edition 6 OverviewEugene Bogaart
1.7K views72 slides
Java EE7 Demystified by
Java EE7 DemystifiedJava EE7 Demystified
Java EE7 DemystifiedAnkara JUG
1.5K views44 slides
Future of Java EE with Java SE 8 by
Future of Java EE with Java SE 8Future of Java EE with Java SE 8
Future of Java EE with Java SE 8Hirofumi Iwasaki
12.3K views55 slides

What's hot(19)

What's New in WebLogic 12.1.3 and Beyond by Oracle
What's New in WebLogic 12.1.3 and BeyondWhat's New in WebLogic 12.1.3 and Beyond
What's New in WebLogic 12.1.3 and Beyond
Oracle20.3K views
Building Java Desktop Apps with JavaFX 8 and Java EE 7 by Bruno Borges
Building Java Desktop Apps with JavaFX 8 and Java EE 7Building Java Desktop Apps with JavaFX 8 and Java EE 7
Building Java Desktop Apps with JavaFX 8 and Java EE 7
Bruno Borges7.3K views
Enterprise Java Web Application Frameworks Sample Stack Implementation by Mert Çalışkan
Enterprise Java Web Application Frameworks   Sample Stack ImplementationEnterprise Java Web Application Frameworks   Sample Stack Implementation
Enterprise Java Web Application Frameworks Sample Stack Implementation
Mert Çalışkan4.3K views
Java Enterprise Edition 6 Overview by Eugene Bogaart
Java Enterprise Edition 6 OverviewJava Enterprise Edition 6 Overview
Java Enterprise Edition 6 Overview
Eugene Bogaart1.7K views
Java EE7 Demystified by Ankara JUG
Java EE7 DemystifiedJava EE7 Demystified
Java EE7 Demystified
Ankara JUG1.5K views
Future of Java EE with Java SE 8 by Hirofumi Iwasaki
Future of Java EE with Java SE 8Future of Java EE with Java SE 8
Future of Java EE with Java SE 8
Hirofumi Iwasaki12.3K views
Java EE7 in action by Ankara JUG
Java EE7 in actionJava EE7 in action
Java EE7 in action
Ankara JUG947 views
5050 dev nation by Arun Gupta
5050 dev nation5050 dev nation
5050 dev nation
Arun Gupta2.1K views
jDays2015 - JavaEE vs. Spring Smackdown by Mert Çalışkan
jDays2015 - JavaEE vs. Spring SmackdownjDays2015 - JavaEE vs. Spring Smackdown
jDays2015 - JavaEE vs. Spring Smackdown
Mert Çalışkan3K views
Advance java Online Training in Hyderabad by Ugs8008
Advance java Online Training in HyderabadAdvance java Online Training in Hyderabad
Advance java Online Training in Hyderabad
Ugs8008503 views
Sun Java EE 6 Overview by sbobde
Sun Java EE 6 OverviewSun Java EE 6 Overview
Sun Java EE 6 Overview
sbobde2.6K views
Jdbc Complete Notes by Java Training Center (Som Sir) by Som Prakash Rai
Jdbc Complete Notes by Java Training Center (Som Sir)Jdbc Complete Notes by Java Training Center (Som Sir)
Jdbc Complete Notes by Java Training Center (Som Sir)
Som Prakash Rai1.9K views
JavaFX and JEE 7 by Vijay Nair
JavaFX and JEE 7JavaFX and JEE 7
JavaFX and JEE 7
Vijay Nair2K views
Overview of Java EE 6 by Roberto Chinnici at SFJUG by Marakana Inc.
Overview of Java EE 6 by Roberto Chinnici at SFJUGOverview of Java EE 6 by Roberto Chinnici at SFJUG
Overview of Java EE 6 by Roberto Chinnici at SFJUG
Marakana Inc.1.5K views
Lecture 6 Web Sockets by Fahad Golra
Lecture 6   Web SocketsLecture 6   Web Sockets
Lecture 6 Web Sockets
Fahad Golra1.1K views
Spring5 hibernate5 security5 lab step by step by Rajiv Gupta
Spring5 hibernate5 security5 lab step by stepSpring5 hibernate5 security5 lab step by step
Spring5 hibernate5 security5 lab step by step
Rajiv Gupta522 views

Viewers also liked

JavaEE & GlassFish UG - Digital JavaEE 7 New & Noteworthy by P.Pilgrim by
JavaEE & GlassFish UG - Digital JavaEE 7 New & Noteworthy by P.PilgrimJavaEE & GlassFish UG - Digital JavaEE 7 New & Noteworthy by P.Pilgrim
JavaEE & GlassFish UG - Digital JavaEE 7 New & Noteworthy by P.PilgrimPayara
1.3K views66 slides
AAI-1713 Introduction to Java EE 7 by
AAI-1713 Introduction to Java EE 7AAI-1713 Introduction to Java EE 7
AAI-1713 Introduction to Java EE 7WASdev Community
616 views38 slides
2012 04-09-v2-tdp-1167-cdi-bestpractices-final by
2012 04-09-v2-tdp-1167-cdi-bestpractices-final2012 04-09-v2-tdp-1167-cdi-bestpractices-final
2012 04-09-v2-tdp-1167-cdi-bestpractices-finalRohit Kelapure
4.6K views48 slides
Java EE 7: Boosting Productivity and Embracing HTML5 by
Java EE 7: Boosting Productivity and Embracing HTML5Java EE 7: Boosting Productivity and Embracing HTML5
Java EE 7: Boosting Productivity and Embracing HTML5Arun Gupta
6K views34 slides
Deploying Web Applications with WildFly 8 by
Deploying Web Applications with WildFly 8Deploying Web Applications with WildFly 8
Deploying Web Applications with WildFly 8Arun Gupta
1.4K views4 slides
50 features of Java EE 7 in 50 minutes at JavaZone 2014 by
50 features of Java EE 7 in 50 minutes at JavaZone 201450 features of Java EE 7 in 50 minutes at JavaZone 2014
50 features of Java EE 7 in 50 minutes at JavaZone 2014Arun Gupta
2.1K views102 slides

Viewers also liked(14)

JavaEE & GlassFish UG - Digital JavaEE 7 New & Noteworthy by P.Pilgrim by Payara
JavaEE & GlassFish UG - Digital JavaEE 7 New & Noteworthy by P.PilgrimJavaEE & GlassFish UG - Digital JavaEE 7 New & Noteworthy by P.Pilgrim
JavaEE & GlassFish UG - Digital JavaEE 7 New & Noteworthy by P.Pilgrim
Payara1.3K views
2012 04-09-v2-tdp-1167-cdi-bestpractices-final by Rohit Kelapure
2012 04-09-v2-tdp-1167-cdi-bestpractices-final2012 04-09-v2-tdp-1167-cdi-bestpractices-final
2012 04-09-v2-tdp-1167-cdi-bestpractices-final
Rohit Kelapure4.6K views
Java EE 7: Boosting Productivity and Embracing HTML5 by Arun Gupta
Java EE 7: Boosting Productivity and Embracing HTML5Java EE 7: Boosting Productivity and Embracing HTML5
Java EE 7: Boosting Productivity and Embracing HTML5
Arun Gupta6K views
Deploying Web Applications with WildFly 8 by Arun Gupta
Deploying Web Applications with WildFly 8Deploying Web Applications with WildFly 8
Deploying Web Applications with WildFly 8
Arun Gupta1.4K views
50 features of Java EE 7 in 50 minutes at JavaZone 2014 by Arun Gupta
50 features of Java EE 7 in 50 minutes at JavaZone 201450 features of Java EE 7 in 50 minutes at JavaZone 2014
50 features of Java EE 7 in 50 minutes at JavaZone 2014
Arun Gupta2.1K views
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014 by Arun Gupta
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 201450 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
Arun Gupta2.7K views
Agile Recruiting White Paper by Amber Grewal
Agile Recruiting White PaperAgile Recruiting White Paper
Agile Recruiting White Paper
Amber Grewal11.3K views
Package your Java EE Application using Docker and Kubernetes by Arun Gupta
Package your Java EE Application using Docker and KubernetesPackage your Java EE Application using Docker and Kubernetes
Package your Java EE Application using Docker and Kubernetes
Arun Gupta27.1K views
An Introduction to Kubernetes by Imesh Gunaratne
An Introduction to KubernetesAn Introduction to Kubernetes
An Introduction to Kubernetes
Imesh Gunaratne54.5K views
Strata SC 2014: Apache Mesos as an SDK for Building Distributed Frameworks by Paco Nathan
Strata SC 2014: Apache Mesos as an SDK for Building Distributed FrameworksStrata SC 2014: Apache Mesos as an SDK for Building Distributed Frameworks
Strata SC 2014: Apache Mesos as an SDK for Building Distributed Frameworks
Paco Nathan12.2K views
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R... by jaxLondonConference
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...
jaxLondonConference2.6K views

Similar to 50 New Features of Java EE 7 in 50 minutes

50 features of Java EE 7 in 50 minutes at Geecon 2014 by
50 features of Java EE 7 in 50 minutes at Geecon 201450 features of Java EE 7 in 50 minutes at Geecon 2014
50 features of Java EE 7 in 50 minutes at Geecon 2014Arun Gupta
2K views102 slides
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013 by
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
6.7K views107 slides
Fifty New Features of Java EE 7 in Fifty Minutes by
Fifty New Features of Java EE 7 in Fifty MinutesFifty New Features of Java EE 7 in Fifty Minutes
Fifty New Features of Java EE 7 in Fifty MinutesArun Gupta
6K views102 slides
Fifty Features of Java EE 7 in 50 Minutes by
Fifty Features of Java EE 7 in 50 MinutesFifty Features of Java EE 7 in 50 Minutes
Fifty Features of Java EE 7 in 50 Minutesglassfish
70.4K views102 slides
Deep Dive Hands-on in Java EE 6 - Oredev 2010 by
Deep Dive Hands-on in Java EE 6 - Oredev 2010Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010Arun Gupta
730 views113 slides
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ... by
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...Arun Gupta
1.8K views42 slides

Similar to 50 New Features of Java EE 7 in 50 minutes(20)

50 features of Java EE 7 in 50 minutes at Geecon 2014 by Arun Gupta
50 features of Java EE 7 in 50 minutes at Geecon 201450 features of Java EE 7 in 50 minutes at Geecon 2014
50 features of Java EE 7 in 50 minutes at Geecon 2014
Arun Gupta2K views
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013 by Arun Gupta
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
Arun Gupta6.7K views
Fifty New Features of Java EE 7 in Fifty Minutes by Arun Gupta
Fifty New Features of Java EE 7 in Fifty MinutesFifty New Features of Java EE 7 in Fifty Minutes
Fifty New Features of Java EE 7 in Fifty Minutes
Arun Gupta6K views
Fifty Features of Java EE 7 in 50 Minutes by glassfish
Fifty Features of Java EE 7 in 50 MinutesFifty Features of Java EE 7 in 50 Minutes
Fifty Features of Java EE 7 in 50 Minutes
glassfish70.4K views
Deep Dive Hands-on in Java EE 6 - Oredev 2010 by Arun Gupta
Deep Dive Hands-on in Java EE 6 - Oredev 2010Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010
Arun Gupta730 views
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ... by Arun Gupta
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Arun Gupta1.8K views
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3 by Skills Matter
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3 Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
Skills Matter659 views
Java EE 6 & GlassFish = Less Code + More Power at CEJUG by Arun Gupta
Java EE 6 & GlassFish = Less Code + More Power at CEJUGJava EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
Arun Gupta953 views
Java EE 6 = Less Code + More Power by Arun Gupta
Java EE 6 = Less Code + More PowerJava EE 6 = Less Code + More Power
Java EE 6 = Less Code + More Power
Arun Gupta676 views
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition by Arun Gupta
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionJava EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Arun Gupta1K views
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val... by Arun Gupta
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Arun Gupta746 views
50 new features of Java EE 7 in 50 minutes by Antonio Goncalves
50 new features of Java EE 7 in 50 minutes50 new features of Java EE 7 in 50 minutes
50 new features of Java EE 7 in 50 minutes
Antonio Goncalves22.9K views
Boston 2011 OTN Developer Days - Java EE 6 by Arun Gupta
Boston 2011 OTN Developer Days - Java EE 6Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6
Arun Gupta1.1K views
Java EE 7, what's in it for me? by Alex Soto
Java EE 7, what's in it for me?Java EE 7, what's in it for me?
Java EE 7, what's in it for me?
Alex Soto3.6K views
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012 by Arun Gupta
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
Arun Gupta2.5K views
Andrei Niculae - JavaEE6 - 24mai2011 by Agora Group
Andrei Niculae - JavaEE6 - 24mai2011Andrei Niculae - JavaEE6 - 24mai2011
Andrei Niculae - JavaEE6 - 24mai2011
Agora Group643 views
Евгений Капинос "Advanced JPA (Java Persistent API)" by Anna Shymchenko
Евгений Капинос "Advanced JPA (Java Persistent API)"Евгений Капинос "Advanced JPA (Java Persistent API)"
Евгений Капинос "Advanced JPA (Java Persistent API)"
Anna Shymchenko736 views
Java EE 6 workshop at Dallas Tech Fest 2011 by Arun Gupta
Java EE 6 workshop at Dallas Tech Fest 2011Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011
Arun Gupta1.2K views
Spark IT 2011 - Java EE 6 Workshop by Arun Gupta
Spark IT 2011 - Java EE 6 WorkshopSpark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 Workshop
Arun Gupta1.2K views

More from Arun Gupta

5 Skills To Force Multiply Technical Talents.pdf by
5 Skills To Force Multiply Technical Talents.pdf5 Skills To Force Multiply Technical Talents.pdf
5 Skills To Force Multiply Technical Talents.pdfArun Gupta
22 views54 slides
Machine Learning using Kubernetes - AI Conclave 2019 by
Machine Learning using Kubernetes - AI Conclave 2019Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubernetes - AI Conclave 2019Arun Gupta
718 views49 slides
Machine Learning using Kubeflow and Kubernetes by
Machine Learning using Kubeflow and KubernetesMachine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and KubernetesArun Gupta
2.3K views57 slides
Secure and Fast microVM for Serverless Computing using Firecracker by
Secure and Fast microVM for Serverless Computing using FirecrackerSecure and Fast microVM for Serverless Computing using Firecracker
Secure and Fast microVM for Serverless Computing using FirecrackerArun Gupta
1.3K views42 slides
Building Java in the Open - j.Day at OSCON 2019 by
Building Java in the Open - j.Day at OSCON 2019Building Java in the Open - j.Day at OSCON 2019
Building Java in the Open - j.Day at OSCON 2019Arun Gupta
780 views16 slides
Why Amazon Cares about Open Source by
Why Amazon Cares about Open SourceWhy Amazon Cares about Open Source
Why Amazon Cares about Open SourceArun Gupta
856 views5 slides

More from Arun Gupta(20)

5 Skills To Force Multiply Technical Talents.pdf by Arun Gupta
5 Skills To Force Multiply Technical Talents.pdf5 Skills To Force Multiply Technical Talents.pdf
5 Skills To Force Multiply Technical Talents.pdf
Arun Gupta22 views
Machine Learning using Kubernetes - AI Conclave 2019 by Arun Gupta
Machine Learning using Kubernetes - AI Conclave 2019Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubernetes - AI Conclave 2019
Arun Gupta718 views
Machine Learning using Kubeflow and Kubernetes by Arun Gupta
Machine Learning using Kubeflow and KubernetesMachine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and Kubernetes
Arun Gupta2.3K views
Secure and Fast microVM for Serverless Computing using Firecracker by Arun Gupta
Secure and Fast microVM for Serverless Computing using FirecrackerSecure and Fast microVM for Serverless Computing using Firecracker
Secure and Fast microVM for Serverless Computing using Firecracker
Arun Gupta1.3K views
Building Java in the Open - j.Day at OSCON 2019 by Arun Gupta
Building Java in the Open - j.Day at OSCON 2019Building Java in the Open - j.Day at OSCON 2019
Building Java in the Open - j.Day at OSCON 2019
Arun Gupta780 views
Why Amazon Cares about Open Source by Arun Gupta
Why Amazon Cares about Open SourceWhy Amazon Cares about Open Source
Why Amazon Cares about Open Source
Arun Gupta856 views
Machine learning using Kubernetes by Arun Gupta
Machine learning using KubernetesMachine learning using Kubernetes
Machine learning using Kubernetes
Arun Gupta354 views
Building Cloud Native Applications by Arun Gupta
Building Cloud Native ApplicationsBuilding Cloud Native Applications
Building Cloud Native Applications
Arun Gupta458 views
Chaos Engineering with Kubernetes by Arun Gupta
Chaos Engineering with KubernetesChaos Engineering with Kubernetes
Chaos Engineering with Kubernetes
Arun Gupta2.1K views
How to be a mentor to bring more girls to STEAM by Arun Gupta
How to be a mentor to bring more girls to STEAMHow to be a mentor to bring more girls to STEAM
How to be a mentor to bring more girls to STEAM
Arun Gupta470 views
Java in a World of Containers - DockerCon 2018 by Arun Gupta
Java in a World of Containers - DockerCon 2018Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018
Arun Gupta2.3K views
The Serverless Tidal Wave - SwampUP 2018 Keynote by Arun Gupta
The Serverless Tidal Wave - SwampUP 2018 KeynoteThe Serverless Tidal Wave - SwampUP 2018 Keynote
The Serverless Tidal Wave - SwampUP 2018 Keynote
Arun Gupta345 views
Introduction to Amazon EKS - KubeCon 2018 by Arun Gupta
Introduction to Amazon EKS - KubeCon 2018Introduction to Amazon EKS - KubeCon 2018
Introduction to Amazon EKS - KubeCon 2018
Arun Gupta3.5K views
Mastering Kubernetes on AWS - Tel Aviv Summit by Arun Gupta
Mastering Kubernetes on AWS - Tel Aviv SummitMastering Kubernetes on AWS - Tel Aviv Summit
Mastering Kubernetes on AWS - Tel Aviv Summit
Arun Gupta2.4K views
Top 10 Technology Trends Changing Developer's Landscape by Arun Gupta
Top 10 Technology Trends Changing Developer's LandscapeTop 10 Technology Trends Changing Developer's Landscape
Top 10 Technology Trends Changing Developer's Landscape
Arun Gupta2.5K views
Container Landscape in 2017 by Arun Gupta
Container Landscape in 2017Container Landscape in 2017
Container Landscape in 2017
Arun Gupta1.4K views
Java EE and NoSQL using JBoss EAP 7 and OpenShift by Arun Gupta
Java EE and NoSQL using JBoss EAP 7 and OpenShiftJava EE and NoSQL using JBoss EAP 7 and OpenShift
Java EE and NoSQL using JBoss EAP 7 and OpenShift
Arun Gupta1.5K views
Docker, Kubernetes, and Mesos recipes for Java developers by Arun Gupta
Docker, Kubernetes, and Mesos recipes for Java developersDocker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developers
Arun Gupta3.4K views
Thanks Managers! by Arun Gupta
Thanks Managers!Thanks Managers!
Thanks Managers!
Arun Gupta1.9K views
Migrate your traditional VM-based Clusters to Containers by Arun Gupta
Migrate your traditional VM-based Clusters to ContainersMigrate your traditional VM-based Clusters to Containers
Migrate your traditional VM-based Clusters to Containers
Arun Gupta2.9K views

Recently uploaded

The Power of Generative AI in Accelerating No Code Adoption.pdf by
The Power of Generative AI in Accelerating No Code Adoption.pdfThe Power of Generative AI in Accelerating No Code Adoption.pdf
The Power of Generative AI in Accelerating No Code Adoption.pdfSaeed Al Dhaheri
44 views18 slides
CryptoBotsAI by
CryptoBotsAICryptoBotsAI
CryptoBotsAIchandureddyvadala199
42 views5 slides
AI + Memoori = AIM by
AI + Memoori = AIMAI + Memoori = AIM
AI + Memoori = AIMMemoori
15 views9 slides
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading... by
Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading...The Digital Insurer
98 views52 slides
Measuring User on the web with the core web vitals - by @theafolayan.pptx by
Measuring User on the web with the core web vitals - by @theafolayan.pptxMeasuring User on the web with the core web vitals - by @theafolayan.pptx
Measuring User on the web with the core web vitals - by @theafolayan.pptxOluwaseun Raphael Afolayan
14 views13 slides
Discover Aura Workshop (12.5.23).pdf by
Discover Aura Workshop (12.5.23).pdfDiscover Aura Workshop (12.5.23).pdf
Discover Aura Workshop (12.5.23).pdfNeo4j
20 views55 slides

Recently uploaded(20)

The Power of Generative AI in Accelerating No Code Adoption.pdf by Saeed Al Dhaheri
The Power of Generative AI in Accelerating No Code Adoption.pdfThe Power of Generative AI in Accelerating No Code Adoption.pdf
The Power of Generative AI in Accelerating No Code Adoption.pdf
Saeed Al Dhaheri44 views
AI + Memoori = AIM by Memoori
AI + Memoori = AIMAI + Memoori = AIM
AI + Memoori = AIM
Memoori15 views
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading... by The Digital Insurer
Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading...
Discover Aura Workshop (12.5.23).pdf by Neo4j
Discover Aura Workshop (12.5.23).pdfDiscover Aura Workshop (12.5.23).pdf
Discover Aura Workshop (12.5.23).pdf
Neo4j20 views
Bronack Skills - Risk Management and SRE v1.0 12-3-2023.pdf by ThomasBronack
Bronack Skills - Risk Management and SRE v1.0 12-3-2023.pdfBronack Skills - Risk Management and SRE v1.0 12-3-2023.pdf
Bronack Skills - Risk Management and SRE v1.0 12-3-2023.pdf
ThomasBronack31 views
Measurecamp Brussels - Synthetic data.pdf by Human37
Measurecamp Brussels - Synthetic data.pdfMeasurecamp Brussels - Synthetic data.pdf
Measurecamp Brussels - Synthetic data.pdf
Human37 27 views
Mobile Core Solutions & Successful Cases.pdf by IPLOOK Networks
Mobile Core Solutions & Successful Cases.pdfMobile Core Solutions & Successful Cases.pdf
Mobile Core Solutions & Successful Cases.pdf
IPLOOK Networks16 views
Adopting Karpenter for Cost and Simplicity at Grafana Labs.pdf by MichaelOLeary82
Adopting Karpenter for Cost and Simplicity at Grafana Labs.pdfAdopting Karpenter for Cost and Simplicity at Grafana Labs.pdf
Adopting Karpenter for Cost and Simplicity at Grafana Labs.pdf
MichaelOLeary8213 views
Digital Personal Data Protection (DPDP) Practical Approach For CISOs by Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash171 views
What is Authentication Active Directory_.pptx by HeenaMehta35
What is Authentication Active Directory_.pptxWhat is Authentication Active Directory_.pptx
What is Authentication Active Directory_.pptx
HeenaMehta3515 views
Business Analyst Series 2023 - Week 4 Session 8 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8
DianaGray10180 views
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... by ShapeBlue
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
ShapeBlue209 views
PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」 by PC Cluster Consortium
PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」
PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」
Innovation & Entrepreneurship strategies in Dairy Industry by PervaizDar1
Innovation & Entrepreneurship strategies in Dairy IndustryInnovation & Entrepreneurship strategies in Dairy Industry
Innovation & Entrepreneurship strategies in Dairy Industry
PervaizDar139 views
The Role of Patterns in the Era of Large Language Models by Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li104 views
NTGapps NTG LowCode Platform by Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu474 views
"Node.js Development in 2024: trends and tools", Nikita Galkin by Fwdays
"Node.js Development in 2024: trends and tools", Nikita Galkin "Node.js Development in 2024: trends and tools", Nikita Galkin
"Node.js Development in 2024: trends and tools", Nikita Galkin
Fwdays37 views

50 New Features of Java EE 7 in 50 minutes

  • 1. 1 #javaland #javaee7 50 new features of Java EE 7 in 50 minutes Antonio Goncalves, @agoncal Arun Gupta, @arungupta 43
  • 3. 3 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5
  • 4. 4 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5 CDI 1.1 (JSR 346)
  • 5. 5 #javaland #javaee7 #01: CDI: Default enabling Finer scanning control §  Possible values: all, annotated, none! §  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>!
  • 6. 6 #javaland #javaee7 #02: CDI: @Vetoed Veto the processing of the class or package @Vetoed! public class NonProcessedBean {
 ...! }! ! package-info.java @Vetoed! package com.non.processed.package;!
  • 7. 7 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5 Bean Validation 1.1 (JSR 349)
  • 8. 8 #javaland #javaee7 #03: Bean Validation: Method validation Pre/post conditions on method and constructors public class CardValidator {! ! public CardValidator(@NotNull Algorithm algorithm) {! this.algorithm = algorithm;! }! ! @AssertTrue! public Boolean validate(@NotNull CreditCard creditCard) {! return algorithm.validate(creditCard.getNumber());! }! }!
  • 9. 9 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5 Interceptors 1.2 (JSR 318)
  • 10. 10 #javaland #javaee7 #04: 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) ... {! // ...! }! }!
  • 11. 11 #javaland #javaee7 #05: Interceptors: @Priority Prioritizing interceptor bindings §  PLATFORM_BEFORE (0), LIBRARY_BEFORE (1000), APPLICATION (2000), LIBRARY_AFTER (3000), PLATFORM_AFTER (4000)! @Interceptor! @Loggable! @Priority(Interceptor.Priority.LIBRARY_BEFORE + 10)! public class LoggingInterceptor {! ! @AroundInvoke! ...! }!
  • 12. 12 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5 Concurrency utilities 1.0 (JSR 236)
  • 13. 13 #javaland #javaee7 #06: Concurrency: ManagedExecutor §  User threads in Java EE applications §  Support simple and advance concurrency design patterns §  Extend Concurrency Utilities API from Java SE (JSR 166y) –  java.util.concurrent package
  • 14. 14 #javaland #javaee7 #06: Concurrency: ManagedExecutor @Resource
 ManagedExecutorService executor;
 ! 
 ManagedExecutorService executor = (ManagedExecutorService) ctx
 .lookup("java:comp/DefaultManagedExecutorService");! Default ManagedExectuor
  • 15. 15 #javaland #javaee7 #06: Concurrency: ManagedExecutor <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>! Specify in web.xml
  • 16. 16 #javaland #javaee7 #07: Concurrency: ManagedScheduledExecutor §  Managed version of ScheduledExecutorService! §  Submit delayed or periodic tasks @Resource
 ManagedScheduledExecutorService executor;!
  • 17. 17 #javaland #javaee7 #07: Concurrency: ManagedScheduledExecutor InitialContext ctx = new InitialContext(); 
 
 ManagedScheduledExecutorService executor = (ManagedScheduledExecutorService)ctx.lookup(
 "java:comp/DefaultManagedScheduledExecutorService");
 ! §  Can be defined in web.xml as well Access using JNDI
  • 18. 18 #javaland #javaee7 #07: 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);!
  • 19. 19 #javaland #javaee7 #08: Concurrency: ManagedThreadFactory §  Extends ThreadFactory @Resource(name = "DefaultManagedThreadFactory")
 ManagedThreadFactory factory; ManagedThreadFactory factory = (ManagedThreadFactory) ctx.lookup("java:comp/ DefaultManagedThreadFactory");

  • 20. 20 #javaland #javaee7 #08: Concurrency: ManagedThreadFactory §  Thread thread = factory.newThread(new MyTask()); §  ((ManageableThread)thread).isShutdown();

  • 21. 21 #javaland #javaee7 #09: Concurrency: DynamicProxy §  Create dynamic proxy objects, adds contextual information available for applications running in Java EE environment §  Classloading, JNDI, Security, …
  • 22. 22 #javaland #javaee7 #09: Concurrency: DynamicProxy @Resource
 ContextService service;
 
 
 Runnable proxy = service.createContextualProxy(new MyRunnable(), Runnable.class);
 
 
 Future f = executor.submit(proxy);!
  • 23. 23 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5 JPA 2.1 (JSR 338)
  • 24. 24 #javaland #javaee7 #10: JPA: Schema Generation Standardized database schema generation <persistence ... version="2.1">! <persistence-unit ...>! <properties>! <property name="javax.persistence.schema-generation.scripts.action"! value="drop-and-create"/>! <property name="javax.persistence.schema-generation.scripts.create-target" value="create.sql"/>! <property name="javax.persistence.sql-load-script-source" ! value="insert.sql"/>! </properties>! </persistence-unit>!
  • 25. 25 #javaland #javaee7 #11: JPA: @Index Defines additional indexes in schema generation @Entity! @Table(indexes = {! @Index(columnList = "ISBN"),! @Index(columnList = "NBOFPAGE")! })! public class Book {! ! @Id @GeneratedValue! private Long id;! private String isbn;! private Integer nbOfPage;! ...! }!
  • 26. 26 #javaland #javaee7 #12: JPA: Unsynchronized Persistence Context Persistence context is not enlisted in any tx unless explicitly joined @PersistenceContext(synchronization =! SynchronizationType.UNSYNCHRONIZED) private EntityManager em;! ...! ! em.persist(book);! ! ...! em.joinTransaction();! !
  • 27. 27 #javaland #javaee7 #13: JPA: Stored Procedure Calling a stored procedure @Entity! @NamedStoredProcedureQuery(name = "archiveOldBooks", ! procedureName = "sp_archive_books",! parameters = {! @StoredProcedureParameter(name = ”date", mode = IN, ! type = Date.class),! @StoredProcedureParameter(name = "warehouse", mode = IN, ! type = String.class)! })! public class Book {...}!
  • 28. 28 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5 JTA 1.2 (JSR 907)
  • 29. 29 #javaland #javaee7 #14: JTA: @Transactional Transaction management on Managed Beans as CDI interceptor binding @Path("book")! @Transactional(value = Transactional.TxType.REQUIRED,! rollbackOn = {SQLException.class, JMSException.class},! dontRollbackOn = SQLWarning.class)! public class BookRestService {! ! @PersistenceContext! private EntityManager em;! ! @POST! @Consumes(MediaType.APPLICATION_XML)! public Response createBook(Book book) {...}! }!
  • 30. 30 #javaland #javaee7 #15: JTA: @TransactionScoped CDI scope whose lifecycle is scoped to the currently active JTA transaction @TransactionScoped! public class BookBean {...}! ! @WebServlet! public class TxServlet extends HttpServlet {! @Inject UserTransaction tx;! @Inject BookBean b1;! @Inject BookBean b2;! ! protected void processRequest(...) {! tx.begin();! s_out.println(b1.getReference());! s_out.println(b2.getReference());! tx.commit();! }! }!
  • 31. 31 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5 EJB 3.2 (JSR 345)
  • 32. 32 #javaland #javaee7 #16: EJB: Disable passivation of stateful In some cases increases performance, scalability and robustness @Stateful(passivationCapable = false)! public class ShoppingCart {! ...! }!
  • 33. 33 #javaland #javaee7 #17: EJB-Lite: Async + Non-persistent timer Extended the EJB Lite to include local asynchronous invocations and non-persistent EJB Timer Service @Stateless! public class OrderEJB {! ! @Asynchronous! public void sendEmail (Order order) {! // Very Long task! }! ! @Schedule(hour="2", persistent=false)! public void createDailyReport() {! // ...! }! }!
  • 34. 34 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5 JMS 2.0 (JSR 343)
  • 35. 35 #javaland #javaee7 #18: JMS: JMSContext API New simplified API to produce and consume messages JMSContext ctx = connectionFactory.createContext()! ! ctx.createProducer().send(queue, "Text message sent");! ! ctx.createConsumer(queue).receiveBody(String.class);! ! ctx.createProducer()! .setPriority(2)! .setTimeToLive(1000)! .setDeliveryMode(DeliveryMode.NON_PERSISTENT)! .send(queue, message);!
  • 36. 36 #javaland #javaee7 #19: JMS: Autocloseable Several JMS interfaces implement Autocloseable try (JMSContext ctx = connectionFactory.createContext()) {! ctx.createProducer().send(queue, "Text message sent");! }! ! ...! ! try (JMSContext ctx = connectionFactory.createContext()) {! while (true) {! String s = ctx.createConsumer(queue).receiveBody(String.class);! }! }!
  • 37. 37 #javaland #javaee7 #20: JMS: JMSConnectionFactoryDefinition A JMS ConnectionFactory can be defined using an annotation on a container-managed class @Stateless! @JMSConnectionFactoryDefinition(! name = "java:app/jms/MyConnectionFactory",! interfaceName = "javax.jms.TopicConnectionFactory")! ! ! ! public class ExpensiveOrderEJB {...}!
  • 38. 38 #javaland #javaee7 #21: JMS: JMSDestinationDefinition A JMS queue or topic can be defined using an annotation @Stateless! @JMSConnectionFactoryDefinition(! name = "java:app/jms/MyConnectionFactory",! interfaceName = "javax.jms.TopicConnectionFactory")! @JMSDestinationDefinition(! name = "java:app/jms/MyTopic",! interfaceName = "javax.jms.Topic")! public class ExpensiveOrderEJB {...}!
  • 39. 39 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5 Servlet 3.1 (JSR 340)
  • 40. 40 #javaland #javaee7 #22: Servlet: Non-blocking I/O public class TestServlet extends HttpServlet
 protected void doGet(HttpServletRequest request,
 HttpServletResponse response) 
 throws IOException, ServletException {
 ServletInputStream input = request.getInputStream();
 byte[] b = new byte[1024];
 int len = -1;
 while ((len = input.read(b)) != -1) {
 . . .
 }
 }
 }!
  • 41. 41 #javaland #javaee7 #22: Servlet: Non-blocking I/O §  ServletInputStream! –  public void setReadListener(ReadListener listener);! –  public boolean isFinished();! –  public boolean isReady();! §  ServletOutputStream! –  public setWriteListener(WriteListener listener);! –  public boolean canWrite();! New methods to existing interfaces
  • 42. 42 #javaland #javaee7 #22: Servlet: Non-blocking I/O public interface ReadListener extends EventListener {
 public void onDataAvailable();
 pubic void onAllDataRead();
 public void onError();
 }! public interface WriteListener extends EventListener {
 public void onWritePossible();
 public void onError();
 }! New interfaces
  • 43. 43 #javaland #javaee7 #22: Servlet: Non-blocking I/O AsyncContext context = request.startAsync();
 ServletInputStream input = request.getInputStream();
 input.setReadListener(
 new MyReadListener(input, context)); ! Only for Asynchronous Servlets
  • 44. 44 #javaland #javaee7 #23: Servlet: Protocol Upgrade §  <T extends HttpUpgradeHandler> T HttpServletRequest.upgrade(Class<T> class) throws IOException;
 
 
 ! §  HttpUpgradeHandler! –  init(WebConnection wc);! –  destroy();!
  • 45. 45 #javaland #javaee7 #23: Servlet: Protocol Upgrade public interface WebConnection {
 ServletInputStream getInputStream();
 ServletOutputStream getOutputStream();
 }!
  • 46. 46 #javaland #javaee7 #24: Servlet: Improved Security <web-app . . . version="3.1"> 
 <web-resource-collection>
 <url-pattern>/account/*</url-pattern> 
 <http-method>GET</http-method>
 </web-resource-collection>
 </web-app> ! ! Deny an HTTP method request for an uncovered HTTP method
  • 47. 47 #javaland #javaee7 #24: Servlet: Improved Security <web-app . . . version="3.1"> 
 <deny-uncovered-http-methods/>
 <web-resource-collection>
 <url-pattern>/account/*</url-pattern> 
 <http-method>GET</http-method>
 </web-resource-collection>
 </web-app> ! ! Deny an HTTP method request for an uncovered HTTP method
  • 48. 48 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5 Web Socket 1.0 (JSR 356)
  • 49. 49 #javaland #javaee7 #25: WebSocket: Annotated server endpoint §  Enables full-duplex bi-directional communication over single TCP connection @javax.websocket.server.ServerEndpoint("/chat")
 public class ChatServer {
 
 @OnMessage
 public String chat(String name, Session session) {
 for (Session peer : client.getOpenSessions()) {! peer.getBasicRemote().sendObject(message);! }
 }
 }!
  • 50. 50 #javaland #javaee7 #26: WebSocket: Lifecycle callbacks @javax.websocket.OnOpen
 public void open(Session s) { . . . }
 
 @javax.websocket.OnClose
 public void close(CloseReason c) { . . . }
 
 @javax.websocket.OnError
 public void error(Throwable t) { . . . }!
  • 51. 51 #javaland #javaee7 #27: WebSocket: Annotated client endpoint @javax.websocket.ClientEndpoint
 public class MyClient {
 @javax.websocket.OnOpen
 public void open(Session session) { … }
 
 // Lifecycle callbacks
 }!
  • 52. 52 #javaland #javaee7 #27: WebSocket: Annotated client endpoint ContainerProvider
 .getWebSocketContainer()
 .connectToServer(
 MyClient.class, 
 URI.create("ws://. . ."));!
  • 53. 53 #javaland #javaee7 #28: WebSocket: Programmatic endpoints public class ChatServer extends Endpoint {
 @Override
 public void onOpen(Session s, EndpointConfig ec) {
 s.addMessageHandler(new MessageHandler.Whole<String>() {
 public void onMessage(String text) { . . . }
 }
 }
 
 @Override
 public void onClose(Session s, CloseReason cr) { . . . }
 
 //. . . 
 }!
  • 54. 54 #javaland #javaee7 #28: WebSocket: Programmatic endpoints public class MyApplicationConfig implements ServerApplicationConfig {
 public Set<ServerEndpointConfig> getEndpointConfigs(…) { 
 ServerEndpointConfig.Builder
 .create(MyEndpoint.class, "/websocket”)
 .configurator(new MyConfig())
 .build()
 }
 }!
  • 55. 55 #javaland #javaee7 #28: WebSocket: Programmatic endpoints public class MyConfig extends ServerEndpointConfig.Configurator {
 
 public <T> T getEndpointInstance(. . .) { . . . }
 
 public void modifyHandshake(. . .) { . . . }
 
 . . .
 }!
  • 56. 56 #javaland #javaee7 #29: WebSocket: Encoder and Decoder @javax.websocket.server.ServerEndpoint(
 value="/chat",
 decoders="MyDecoder.class",
 encoders="MyEncoder.class")
 public class ChatServer {
 
 @OnMessage
 public String chat(ChatMessage name, Session session) {
 . . . 
 }
 }!
  • 57. 57 #javaland #javaee7 #29: WebSocket: Encoder and Decoder public class MyDecoder implements Decoder.Text<ChatMessage> {
 public ChatMessage decode(String s) {
 // . . .
 }
 
 public boolean willDecode(String string) {
 // . . .
 }
 
 //. . .
 }
 
 !
  • 58. 58 #javaland #javaee7 #29: WebSocket: Encoder and Decoder public class MyEncoder implements Encoder.Text<ChatMessage> {
 
 public String encode(ChatMessage chatMessage) {
 // . . .
 }
 ! // . . .
 }!
  • 59. 59 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5 Expression Language 3.0 (JSR 341)
  • 60. 60 #javaland #javaee7 #30: Expression Langauge: ELProcessor §  Use EL in a stand-alone environment –  Evaluate EL expressions –  Get/set bean properties –  Defining a static method as an EL function –  Defining an object instance as an EL name ELProcessor elp = new ELProcessor();
 elp.defineBean("employee", new Employee("Charlie Brown"));
 String name = elp.eval("employee.name");!
  • 61. 61 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5 JSF 2.2 (JSR 344)
  • 62. 62 #javaland #javaee7 #31: JSF: Faces Flow ./src/main/webapp/flow1
 /flow1.xhtml
 /flow1a.xhtml
 /flow1b.xhtml
 ./src/main/webapp/flow2
 /flow2-flow.xml
 /flow2.xhtml
 /flow2a.xhtml
 /flow2b.xhtml
 /index.xhtml! Package reusable flows in JAR
  • 63. 63 #javaland #javaee7 #31: JSF: Faces Flow @Named
 @FlowScoped("flow1")
 public class Flow1Bean implements Serializable {
 }! ! @Produces @FlowDefinition
 public Flow defineFlow(@FlowBuilderParameter FlowBuilder fb) {
 String flowId = "flow1";
 //. . .
 return fb.getFlow();
 }! Package reusable flows in JAR
  • 64. 64 #javaland #javaee7 #31: JSF: Faces Flow Package reusable flows in JAR #{flowScope}: Local flow storage #{facesContext.application.flowHandler.currentFlow}: Returns true if within a flow
  • 65. 65 #javaland #javaee7 #32: JSF: Resource Library Contract index-blue.xhtml
 index-red.xhtml
 WEB-INF/lib/contracts-library-1.0-SNAPSHOT.jar
 /META-INF/contracts/blue
 /style.css
 /javax.faces.contract.xml
 /template.xhtml
 /META-INF/contracts/red
 /style.css
 /javax.faces.contract.xml
 /template.xhtml! Apply templates in a reusable and interchangeable manner
  • 66. 66 #javaland #javaee7 #32: JSF: Resource Library Contract <f:view contracts=”red”>
 <ui:composition template="/template.xhtml">
 . . .
 </ui:composition>
 </f:view>
 ! Apply templates in a reusable and interchangeable manner
  • 67. 67 #javaland #javaee7 #33: JSF: Pass-through Attributes <h:inputText type="email" value="#{user.email}"/> 
 ! <input type="text" name="j_idt6:j_idt10"/>! HTML5-Friendly Markup <h:inputText p:type="email" value="#{user.email}"/> 
 
 <input type="email" name="j_idt6:j_idt10"/>! !
  • 68. 68 #javaland #javaee7 #34: JSF: File Upload Component <h:form enctype="multipart/form-data">
 <h:inputFile value="#{fileUploadBean.file}"/><br/>
 <h:commandButton value="Upload"/><p/>
 </h:form> ! @Named @RequestScoped 
 public class FileUploadBean {
 private Part file;
 
 //getter and setter
 } !
  • 69. 69 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5 JAX-RS 2.0 (JSR 339)
  • 70. 70 #javaland #javaee7 #35: JAX-RS: Client API New API to consume rest services Client client = ClientBuilder.newClient();! WebTarget target = client.target("http://www.foo.com/book");! Invocation invocation = target.request(TEXT_PLAIN).buildGet() Response response = invocation.invoke();! ! Response response = ClientBuilder.newClient()! .target("http://www.foo.com/book")! .request(MediaType.TEXT_PLAIN)! .get();! ! String body = ClientBuilder.newClient()! .target("http://www.foo.com/book")! .request()! .get(String.class);!
  • 71. 71 #javaland #javaee7 #36: JAX-RS: Async Client The client API also supports asynchronous invocation Future<String> future = ClientBuilder.newClient()! .target("http://www.foo.com/book")! .request()! .async()! .get(String.class);! ! try {! String body = future.get(1, TimeUnit.MINUTES);! } catch (InterruptedException | ExecutionException e) {...}!
  • 72. 72 #javaland #javaee7 #37: JAX-RS: Async Server Asynchronous request processing on the server @Path("/async")! public class AsyncResource {! ! @GET! public void asyncGet(@Suspended AsyncResponse asyncResp) {! ! new Thread(new Runnable() {! ! public void run() {! String result = veryExpensiveOperation();! asyncResp.resume(result);! }! }).start();! }}!
  • 73. 73 #javaland #javaee7 #38: JAX-RS: Message Filter Used to process incoming and outgoing request or response headers §  Filters on client side –  ClientRequestFilter! –  ClientResponseFilter! §  Filters on server side –  ContainerRequestFilter! –  ContainerResponseFilter!
  • 74. 74 #javaland #javaee7 #38: JAX-RS: Message Filter Used to process incoming and outgoing request or response headers public class LogginFilter implements ClientRequestFilter {! ! public void filter(ClientRequestContext ctx) throws IOException { System.out.println(ctx.getMethod());! System.out.println(ctx.getUri());! }! }!
  • 75. 75 #javaland #javaee7 #39: JAX-RS: Entity Interceptors Marshalling and unmarshalling HTTP message bodies §  Intercepts inbound entity streams (reads from the “wire”) –  ReaderInterceptor! §  Intercepts outbound entity streams (writes to the “wire”) –  WriterInterceptor!
  • 76. 76 #javaland #javaee7 #39: JAX-RS: Entity Interceptors Marshalling and unmarshalling HTTP message bodies public class GZipInterceptor implements WriterInterceptor {! ! public void aroundWriteTo(WriterInterceptorContext ctx){! OutputStream os = ctx.getOutputStream();! ctx.setOutputStream(new GZIPOutputStream(os));! ctx.proceed();! }! }!
  • 77. 77 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5 JSON-P 1.0 (JSR 353)
  • 78. 78 #javaland #javaee7 #40: JSON-P: JSON Builder Creates an object model (or an array) in memory by adding elements JsonObject value = Json.createObjectBuilder()! .add("id", "1234")! .add("date", "19/09/2012")! .add("total_amount", "93.48")! .add("customer", Json.createObjectBuilder()! .add("first_name", "James")! .add("last_name", "Rorrison")! .add("email", "j.rorri@me.com")! .add("phoneNumber", "+44 1234 1234")! )! .build();!
  • 79. 79 #javaland #javaee7 #41: JSON-P: JsonParser Event-based parser that can read JSON data from a stream JsonParser parser = Json.createParser(new FileReader(“order.json"));! while (parser.hasNext()) {! JsonParser.Event event = parser.next();! ! if (event.equals(JsonParser.Event.KEY_NAME) && ! parser.getString().matches("email")) {! parser.next();! email = parser.getString();! }! }!
  • 80. 80 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5 Batch 1.0 (JSR 352)
  • 81. 81 #javaland #javaee7 #42: Batch: Chunk-style Processing Item-oriented Processing Style (primary)
  • 82. 82 #javaland #javaee7 #42: Batch: Chunk-style Processing <step id=”sendStatements”>! <chunk item-count=“3”>
 <reader ref=”accountReader”/>! <processor ref=”accountProcessor”/>
 <writer ref=”emailWriter”/>! </step>! …implements ItemReader {
 public Object readItem() {
 // read account using JPA! }! ! …implements ItemProcessor {! public Object processItems(Object account) {
 // read Account, return Statement! }! ! …implements ItemWriter {! public void writeItems(List accounts) {
 // use JavaMail to send email! }! !
  • 83. 83 #javaland #javaee7 #43: Batch: Batchlet-style Processing Task-oriented processing style <step id=”transferFile”>! <batchlet ref=“MyFileTransfer” />! </step>! …implements Batchlet {! @Override
 public void process() {
 // Transfer file! }! !
  • 84. 84 #javaland #javaee7 #44: Batch: Job/Step/Chunk Listeners <job id="myJob" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0”>
 <listeners>
 <listener ref="myJobListener"/>
 </listeners>
 <step id="myStep" >
 <listeners>
 <listener ref="myStepListener"/>
 <listener ref="myChunkListener"/>
 <listener ref="myItemReadListener"/>
 <listener ref="myItemProcessorListener"/>
 <listener ref="myItemWriteListener"/>
 </listeners>
 <chunk item-count="3”>. . .</chunk>
 </step>
 </job>! !
  • 85. 85 #javaland #javaee7 #44: Batch: Job/Step/Chunk Listeners Interface Abstract Classes JobListener! AbstractJobListener! StepListener! AbstractStepListener! ChunkListener! AbstractChunkListener! ItemRead/Write/ProcessListener! AbstractItemRead/Write/ProcessListener! SkipRead/Write/ProcessListener! AbstractSkipRead/Write/ProcessListener! RetryRead/Write/ProcessListener! AbstractRetryRead/Write/ ProcessListener!
  • 86. 86 #javaland #javaee7 #44: Batch: Job/Step/Chunk Listeners @Named
 public class MyJobListener extends AbstractJobListener {
 
 @Override
 public void beforeJob() throws Exception { . . . }
 
 @Override
 public void afterJob() throws Exception { . . . }
 }!
  • 87. 87 #javaland #javaee7 #45: Batch: Partition <step>
 <chunk item-count="3">
 <reader ref="myItemReader">
 <properties>
 <property name="start" value="#{partitionPlan['start']}"/>
 <property name="end" value="#{partitionPlan['end']}"/>
 </properties> 
 </reader>
 . . .
 </chunk>!
  • 88. 88 #javaland #javaee7 #45: Batch: Partition <partition>
 <plan partitions="2">
 <properties partition="0">
 <property name="start" value="1"/>
 <property name="end" value="10"/>
 </properties>
 <properties partition="1">
 <property name="start" value="11"/>
 <property name="end" value="20"/>
 </properties>
 </plan>
 </partition>
 </step>!
  • 89. 89 #javaland #javaee7 #46: Batch: Creating Workflows <flow id="flow1" next="step3">
 <step id="step1" next="step2"> . . . </step>
 <step id="step2"> . . . </step>
 </flow>
 <step id="step3"> . . . </step>! Flow: Elements that execute together as a unit
  • 90. 90 #javaland #javaee7 #46: Batch: Creating Workflows <split id="split1" next=" . . . ">
 <flow id="flow1”>
 <step id="step1”> . . . </step>
 </flow>
 <flow id="flow2”>
 <step id="step2”> . . . </step>
 </flow>
 </split>! Split: Concurrent execution of flows
  • 91. 91 #javaland #javaee7 #46: Batch: Creating Workflows <step id="step1" next="decider1">. . .</step>
 <decision id="decider1" ref="myDecider"> 
 <next on="DATA_LOADED" to="step2"/> 
 <end on="NOT_LOADED"/> </decision>
 <step id="step2">. . .</step> ! ! Decision: Customized way of sequencing between steps, flows, splits @Named
 public class MyDecider implements Decider {
 @Override
 public String decide(StepExecution[] ses) throws Exception {
 . . .
 return "DATA_LOADED"; // or "NOT_LOADED"! } ! }!
  • 92. 92 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5 JavaMail 1.5 (JSR 919)
  • 93. 93 #javaland #javaee7 #47: JavaMail @MailSessionDefinition(name = "java:comp/myMailSession",
 properties = {
 "mail.smtp.host=smtp.gmail.com",
 "mail.smtp.ssl.enable=true",
 "mail.smtp.auth=true",
 "mail.transport.protocol=smtp",
 "mail.debug=true"
 })
 
 
 @Resource(lookup = "java:comp/myMailSession")
 Session session;!
  • 94. 94 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5 JCA 1.7 (JSR 322)
  • 95. 95 #javaland #javaee7 #48: Java Connector Architecture @ConnectionDefinition(
 connection="MyConnection.class",
 connectionImpl="MyConnectionImpl.class",
 connectionFactory="MyConnectionFactory.class",
 connectionFactoryImpl="MyConnectionFactoryImpl.class"
 )
 ! @AdministeredObjectDefinition(
 className="MyQueueImpl.class",
 name="java:comp/MyQueue",
 resourceAdapter="myAdapter",
 )!
  • 96. 96 #javaland #javaee7 JAX-RS 2.0 JSON-P 1.0 Web Socket 1.0Servlet 3.1 JSF 2.2EL 3.0 JSP JSTLBeanValidation1.1 Interceptors1.2 CDI1.1 Concurrency1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 Batch 1.0 JCA 1.7 Java EE 7 JavaMail 1.5 Java EE 7 (JSR 342)
  • 97. 97 #javaland #javaee7 #49: Default Resources JNDI name: java:comp/DefaultDataSource Default Data Source @Resource(lookup="java:comp/DefaultDataSource")
 DataSource myDS;
 ! @Resource
 DataSource myDS; !
  • 98. 98 #javaland #javaee7 #49: Default Resources JNDI name: java:comp/DefaultJMSConnectionFactory
 
 
 @Resource(lookup="java:comp/DefaultJMSConnectionFactory") 
 ConnectionFactory myCF; @Resource
 ConnectionFactory myCF;! Default JMS Connection Factory
  • 99. 99 #javaland #javaee7 #49: Default Resources JNDI names §  java:comp/DefaultManagedExecutorService! §  java:comp/DefaultManagedScheduledExecutorService! §  java:comp/DefaultManagedThreadFactory! §  java:comp/DefaultContextService! Default Concurrency Utilities Objects