50 features of Java EE 7 in 50 minutes at JavaZone 2014
-
Upload
arun-gupta -
Category
Technology
-
view
776 -
download
2
description
Transcript of 50 features of Java EE 7 in 50 minutes at JavaZone 2014
![Page 1: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/1.jpg)
1
50 new features of
Java EE 7 in
50 minutes
Arun Gupta, @arungupta Director, Developer Advocacy Sep 9, 2014
![Page 2: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/2.jpg)
2
#NN: <spec>: <feature>
![Page 3: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/3.jpg)
3
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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
![Page 4: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/4.jpg)
4
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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)
![Page 5: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/5.jpg)
5
#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>!
![Page 6: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/6.jpg)
6
#02: CDI: @Vetoed Veto the processing of the class or package
@Vetoed!
public class NonProcessedBean { ...!
}!
!
package-info.java
@Vetoed!
package com.non.processed.package;!
![Page 7: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/7.jpg)
7
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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)
![Page 8: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/8.jpg)
8
#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());! }!}!
![Page 9: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/9.jpg)
9
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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)
![Page 10: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/10.jpg)
10
#04: Interceptors: AroundConstruct Interceptor associated with a constructor
public class LoggingInterceptor {!! @AroundConstruct! private void init(InvocationContext ic) {! logger.fine("Entering constructor");! ic.proceed();! logger.fine("Exiting constructor");! }!! @AroundInvoke! public Object logMethod(InvocationContext ic) ... {! // ...! }!}!
![Page 11: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/11.jpg)
11
#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! ...!}!
![Page 12: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/12.jpg)
12
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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)
![Page 13: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/13.jpg)
13
#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
![Page 14: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/14.jpg)
14
#06: Concurrency: ManagedExecutor
@Resource ManagedExecutorService executor; !ManagedExecutorService executor = (ManagedExecutorService) ctx.lookup("java:comp/DefaultManagedExecutorService");!
Default ManagedExectuor
![Page 15: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/15.jpg)
15
#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
![Page 16: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/16.jpg)
16
#07: Concurrency: ManagedScheduledExecutor
Managed version of ScheduledExecutorService!Submit delayed or periodic tasks @Resource ManagedScheduledExecutorService executor;!
![Page 17: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/17.jpg)
17
#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
![Page 18: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/18.jpg)
18
#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);!
![Page 19: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/19.jpg)
19
#08: Concurrency: ManagedThreadFactory
Extends ThreadFactory @Resource(name = "DefaultManagedThreadFactory") ManagedThreadFactory factory; ManagedThreadFactory factory = (ManagedThreadFactory) ctx.lookup("java:comp/DefaultManagedThreadFactory");
![Page 20: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/20.jpg)
20
#08: Concurrency: ManagedThreadFactory
Thread thread = factory.newThread(new MyTask());
((ManageableThread)thread).isShutdown();
![Page 21: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/21.jpg)
21
#09: Concurrency: DynamicProxy
Create dynamic proxy objects, adds contextual information available for applications running in Java EE environment Classloading, JNDI, Security, …
![Page 22: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/22.jpg)
22
#09: Concurrency: DynamicProxy
@Resource ContextService service; Runnable proxy = service.createContextualProxy(new MyRunnable(), Runnable.class); Future f = executor.submit(proxy);!
![Page 23: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/23.jpg)
23
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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)
![Page 24: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/24.jpg)
24
#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>!
![Page 25: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/25.jpg)
25
#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;! ...!}!
![Page 26: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/26.jpg)
26
#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();!!
![Page 27: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/27.jpg)
27
#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 {...}!
![Page 28: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/28.jpg)
28
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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)
![Page 29: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/29.jpg)
29
#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) {...}!}!
![Page 30: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/30.jpg)
30
#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 BookBean b1;! @Inject BookBean b2;! @Transactional! protected void processRequest(...) {! s_out.println(b1.getReference());! s_out.println(b2.getReference());! }!}!
![Page 31: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/31.jpg)
31
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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)
![Page 32: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/32.jpg)
32
#16: EJB: Disable passivation of stateful In some cases increases performance, scalability and robustness
@Stateful(passivationCapable = false)!public class ShoppingCart {! ...!}!
![Page 33: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/33.jpg)
33
#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() {! // ...! }!}!
![Page 34: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/34.jpg)
34
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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)
![Page 35: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/35.jpg)
35
#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);!
![Page 36: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/36.jpg)
36
#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);! }!}!
![Page 37: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/37.jpg)
37
#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 {...}!
![Page 38: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/38.jpg)
38
#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 {...}!
![Page 39: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/39.jpg)
39
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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)
![Page 40: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/40.jpg)
40
#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) { . . . } } }!
![Page 41: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/41.jpg)
41
#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
![Page 42: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/42.jpg)
42
#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
![Page 43: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/43.jpg)
43
#22: Servlet: Non-blocking I/O
AsyncContext context = request.startAsync(); ServletInputStream input = request.getInputStream(); input.setReadListener( new MyReadListener(input, context)); !
Only for Asynchronous Servlets
![Page 44: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/44.jpg)
44
#23: Servlet: Protocol Upgrade
<T extends HttpUpgradeHandler> T HttpServletRequest.upgrade(Class<T> class) throws IOException; !
HttpUpgradeHandler!
init(WebConnection wc);!
destroy();!
![Page 45: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/45.jpg)
45
#23: Servlet: Protocol Upgrade
public interface WebConnection { ServletInputStream getInputStream(); ServletOutputStream getOutputStream(); }!
![Page 46: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/46.jpg)
46
#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> <auth-contraint> . . . </auth-contraint> </web-app> !
!
Deny an HTTP method request for an uncovered HTTP method
![Page 47: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/47.jpg)
47
#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> <auth-contraint> . . . </auth-contraint> </web-app> !
!
Deny an HTTP method request for an uncovered HTTP method
![Page 48: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/48.jpg)
48
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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)
![Page 49: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/49.jpg)
49
#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);! } } }!
![Page 50: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/50.jpg)
50
#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) { . . . }!
![Page 51: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/51.jpg)
51
#27: WebSocket: Annotated client endpoint
@javax.websocket.ClientEndpoint public class MyClient { @javax.websocket.OnOpen public void open(Session session) { … } // Lifecycle callbacks }!
![Page 52: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/52.jpg)
52
#27: WebSocket: Annotated client endpoint
ContainerProvider .getWebSocketContainer() .connectToServer( MyClient.class, URI.create("ws://. . ."));!
![Page 53: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/53.jpg)
53
#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) { . . . } //. . . }!
![Page 54: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/54.jpg)
54
#28: WebSocket: Programmatic endpoints
public class MyApplicationConfig implements ServerApplicationConfig { public Set<ServerEndpointConfig> getEndpointConfigs(…) { ServerEndpointConfig.Builder .create(MyEndpoint.class, "/websocket”) .configurator(new MyConfig()) .build() } }!
![Page 55: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/55.jpg)
55
#28: WebSocket: Programmatic endpoints
public class MyConfig extends ServerEndpointConfig.Configurator { public <T> T getEndpointInstance(. . .) { . . . } public void modifyHandshake(. . .) { . . . } . . . }!
![Page 56: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/56.jpg)
56
#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) { . . . } }!
![Page 57: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/57.jpg)
57
#29: WebSocket: Encoder and Decoder
public class MyDecoder implements Decoder.Text<ChatMessage> { public ChatMessage decode(String s) { // . . . } public boolean willDecode(String string) { // . . . } //. . . } !
![Page 58: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/58.jpg)
58
#29: WebSocket: Encoder and Decoder
public class MyEncoder implements Encoder.Text<ChatMessage> { public String encode(ChatMessage chatMessage) { // . . . } !
// . . . }!
![Page 59: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/59.jpg)
59
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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)
![Page 60: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/60.jpg)
60
#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");!
![Page 61: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/61.jpg)
61
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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)
![Page 62: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/62.jpg)
62
#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
![Page 63: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/63.jpg)
63
#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
![Page 64: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/64.jpg)
64
#31: JSF: Faces Flow Package reusable flows in JAR
#{flowScope}: Local flow storage #{facesContext.application.flowHandler.currentFlow}: Returns true if within a flow
![Page 65: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/65.jpg)
65
#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
![Page 66: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/66.jpg)
66
#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
![Page 67: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/67.jpg)
67
#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"/>!!
![Page 68: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/68.jpg)
68
#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 } !
![Page 69: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/69.jpg)
69
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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)
![Page 70: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/70.jpg)
70
#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);!
![Page 71: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/71.jpg)
71
#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) {...}!
![Page 72: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/72.jpg)
72
#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();! }}!
![Page 73: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/73.jpg)
73
#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!
![Page 74: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/74.jpg)
74
#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());! }!}!
![Page 75: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/75.jpg)
75
#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!
![Page 76: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/76.jpg)
76
#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();! }!}!
![Page 77: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/77.jpg)
77
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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)
![Page 78: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/78.jpg)
78
#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", "[email protected]")! .add("phoneNumber", "+44 1234 1234")! )! .build();!
![Page 79: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/79.jpg)
79
#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();!
}!
}!
![Page 80: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/80.jpg)
80
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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)
![Page 81: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/81.jpg)
81
#42: Batch: Chunk-style Processing Item-oriented Processing Style (primary)
![Page 82: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/82.jpg)
82
#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!}!!
![Page 83: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/83.jpg)
83
#43: Batch: Batchlet-style Processing Task-oriented processing style
<step id=”transferFile”>! <batchlet ref=“MyFileTransfer” />!</step>!
…implements Batchlet {!@Override public void process() { // Transfer file!}!!
![Page 84: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/84.jpg)
84
#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>!
!
![Page 85: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/85.jpg)
85
#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!
![Page 86: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/86.jpg)
86
#44: Batch: Job/Step/Chunk Listeners
@Named public class MyJobListener extends AbstractJobListener { @Override public void beforeJob() throws Exception { . . . } @Override public void afterJob() throws Exception { . . . } }!
![Page 87: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/87.jpg)
87
#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>!
![Page 88: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/88.jpg)
88
#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>!
![Page 89: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/89.jpg)
89
#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
![Page 90: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/90.jpg)
90
#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
![Page 91: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/91.jpg)
91
#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"! } !}!
![Page 92: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/92.jpg)
92
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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)
![Page 93: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/93.jpg)
93
#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;!
![Page 94: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/94.jpg)
94
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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)
![Page 95: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/95.jpg)
95
#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", )!
![Page 96: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/96.jpg)
96
JAX-RS 2.0
JSON-P 1.0 Web Socket
1.0 Servlet 3.1
JSF 2.2 EL 3.0 JSP JSTL
Bea
n Va
lidat
ion
1.1
Inte
rcep
tors
1.2
CD
I 1.1
Con
curr
ency
1.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)
![Page 97: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/97.jpg)
97
#49: Default Resources
JNDI name: java:comp/DefaultDataSource
Default Data Source
@Resource(lookup="java:comp/DefaultDataSource") DataSource myDS; !
@Resource DataSource myDS; !
![Page 98: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/98.jpg)
98
#49: Default Resources
JNDI name: java:comp/DefaultJMSConnectionFactory @Resource(lookup="java:comp/DefaultJMSConnectionFactory")
ConnectionFactory myCF; @Resource ConnectionFactory myCF;!
Default JMS Connection Factory
![Page 99: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/99.jpg)
99
#49: Default Resources
JNDI names java:comp/DefaultManagedExecutorService!
java:comp/DefaultManagedScheduledExecutorService!
java:comp/DefaultManagedThreadFactory!
java:comp/DefaultContextService!
Default Concurrency Utilities Objects
![Page 100: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/100.jpg)
100
#50: Buy our books!
![Page 101: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/101.jpg)
101
References
github.com/javaee-samples/javaee7-samples
![Page 102: 50 features of Java EE 7 in 50 minutes at JavaZone 2014](https://reader030.fdocuments.in/reader030/viewer/2022020206/5481d7405906b50a058b45ca/html5/thumbnails/102.jpg)
102