0
Java EE 7 :
What’s new in the Java EE
Platform
Arun Gupta
Antonio Goncalves

#DV13-UniJavaEE7

@arungupta @agoncal
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


JSP JSTL	


EL 3.0	


Servlet 3.1	

JTA 1.2	


JSF 2...
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


CDI 1.1 (JSR 346)
JSP JSTL	


EL 3.0	


Servlet 3.1	...
Default enabling
Finer scanning control	


•  Possible values: all, annotated, none
•  all behaves like in Java EE 6 (defa...
@Vetoed

Veto the processing of the class or package	

@Vetoed!
public class NonProcessedBean {

...!
}!
!
package-info.ja...
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


Bean Validation 1.1 (JSR 349)
JSP JSTL	


EL 3.0	


...
Method validation

Pre/post conditions on method and constructors	

public class CardValidator {!
!
public CardValidator(@...
CDI in validators

Injection in validators is now possible	

public class ZipCodeValidator implements!
ConstraintValidator...
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


Interceptors 1.2 (JSR 318)
JSP JSTL	


EL 3.0	


Ser...
AroundConstruct

Interceptor associated with a constructor	

public class LoggingInterceptor {!
!
@AroundConstruct!
privat...
@Priority

Prioritizing interceptor bindings	


•  PLATFORM_BEFORE (0), LIBRARY_BEFORE (1000),
APPLICATION (2000), LIBRARY...
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


Concurrency utilities 1.0 (JSR 236)
JSP JSTL	


EL 3...
ManagedExecutor
Threads in Java EE	


•  User threads in Java EE applications	

•  Support simple and advance concurrency ...
ManagedExecutor
Default ManagedExectuor	


@Resource

ManagedExecutorService executor;

!


ManagedExecutorService executo...
ManagedExecutor
Specify in web.xml	


<web-app … version="3.1">!
<resource-env-ref>!
<resource-env-ref-name>!
concurrent/m...
ManagedScheduledExecutor
Thread Scheduler in Java EE	


•  Managed version of ScheduledExecutorService
•  Submit delayed o...
ManagedScheduledExecutor
Access using JNDI	


•  Can be defined in web.xml as well
InitialContext ctx = new InitialContext...
ManagedScheduledExecutor
Samples	


executor.schedule(new MyCallableTask(), 5, TimeUnit.SECONDS);!
!
executor.scheduleAtFi...
ManagedThreadFactory

Extends ThreadFactory
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Upcoming SlideShare
Loading in...5
×

Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013

5,329

Published on

Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013

Published in: Technology, Education
6 Comments
14 Likes
Statistics
Notes
No Downloads
Views
Total Views
5,329
On Slideshare
0
From Embeds
0
Number of Embeds
20
Actions
Shares
0
Downloads
89
Comments
6
Likes
14
Embeds 0
No embeds

No notes for slide

Transcript of "Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013"

  1. 1. Java EE 7 : What’s new in the Java EE Platform Arun Gupta Antonio Goncalves #DV13-UniJavaEE7 @arungupta @agoncal
  2. 2. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 JSP JSTL EL 3.0 Servlet 3.1 JTA 1.2 JSF 2.2 Web Socket 1.0 EJB 3.2 JPA 2.1 JMS 2.0 JAX-RS 2.0 JSON-P 1.0 Batch 1.0 JavaMail 1.5 JCA 1.7 Java EE 7 #DV13-UniJavaEE7 @arungupta @agoncal
  3. 3. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 CDI 1.1 (JSR 346) JSP JSTL EL 3.0 Servlet 3.1 JTA 1.2 JSF 2.2 Web Socket 1.0 EJB 3.2 JPA 2.1 JMS 2.0 JAX-RS 2.0 JSON-P 1.0 Batch 1.0 JavaMail 1.5 JCA 1.7 Java EE 7 #DV13-UniJavaEE7 @arungupta @agoncal
  4. 4. 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>! #DV13-UniJavaEE7 @arungupta @agoncal
  5. 5. @Vetoed Veto the processing of the class or package @Vetoed! public class NonProcessedBean {
 ...! }! ! package-info.java! @Vetoed! package com.non.processed.package;! #DV13-UniJavaEE7 @arungupta @agoncal
  6. 6. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 Bean Validation 1.1 (JSR 349) JSP JSTL EL 3.0 Servlet 3.1 JTA 1.2 JSF 2.2 Web Socket 1.0 EJB 3.2 JPA 2.1 JMS 2.0 JAX-RS 2.0 JSON-P 1.0 Batch 1.0 JavaMail 1.5 JCA 1.7 Java EE 7 #DV13-UniJavaEE7 @arungupta @agoncal
  7. 7. 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());! }! }! #DV13-UniJavaEE7 @arungupta @agoncal
  8. 8. CDI in validators Injection in validators is now possible public class ZipCodeValidator implements! ConstraintValidator<ZipCode, String> {! ! @Inject @USA! ZipCodeChecker checker = new ZipCodeChecker();! ! public boolean isValid(String value,! ConstraintValidatorContext context) {! ! return checker.isZipCodeValid(value);! }! }! #DV13-UniJavaEE7 @arungupta @agoncal
  9. 9. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 Interceptors 1.2 (JSR 318) JSP JSTL EL 3.0 Servlet 3.1 JTA 1.2 JSF 2.2 Web Socket 1.0 EJB 3.2 JPA 2.1 JMS 2.0 JAX-RS 2.0 JSON-P 1.0 Batch 1.0 JavaMail 1.5 JCA 1.7 Java EE 7 #DV13-UniJavaEE7 @arungupta @agoncal
  10. 10. 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) ... {! // ...! }! }! #DV13-UniJavaEE7 @arungupta @agoncal
  11. 11. @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! ...! }! #DV13-UniJavaEE7 @arungupta @agoncal
  12. 12. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 Concurrency utilities 1.0 (JSR 236) JSP JSTL EL 3.0 Servlet 3.1 JTA 1.2 JSF 2.2 Web Socket 1.0 EJB 3.2 JPA 2.1 JMS 2.0 JAX-RS 2.0 JSON-P 1.0 Batch 1.0 JavaMail 1.5 JCA 1.7 Java EE 7 #DV13-UniJavaEE7 @arungupta @agoncal
  13. 13. ManagedExecutor Threads in Java EE •  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 #DV13-UniJavaEE7 package @arungupta @agoncal
  14. 14. ManagedExecutor Default ManagedExectuor @Resource
 ManagedExecutorService executor;
 ! 
 ManagedExecutorService executor = (ManagedExecutorService) ! ctx.lookup("java:comp/DefaultManagedExecutorService");! #DV13-UniJavaEE7 @arungupta @agoncal
  15. 15. ManagedExecutor Specify in web.xml <web-app … version="3.1">! <resource-env-ref>! <resource-env-ref-name>! concurrent/myExecutor! </resource-env-ref-name>! <resource-env-ref-type>! javax.enterprise.concurrent.ManagedExecutorService! </resource-env-ref-type>! </resource-env-ref>! </web-app>! #DV13-UniJavaEE7 @arungupta @agoncal
  16. 16. ManagedScheduledExecutor Thread Scheduler in Java EE •  Managed version of ScheduledExecutorService •  Submit delayed or periodic tasks @Resource
 ManagedScheduledExecutorService executor;! #DV13-UniJavaEE7 @arungupta @agoncal
  17. 17. ManagedScheduledExecutor Access using JNDI •  Can be defined in web.xml as well InitialContext ctx = new InitialContext(); 
 
 ManagedScheduledExecutorService executor = (ManagedScheduledExecutorService)ctx.lookup(
 "java:comp/DefaultManagedScheduledExecutorService");
 ! #DV13-UniJavaEE7 @arungupta @agoncal
  18. 18. ManagedScheduledExecutor Samples executor.schedule(new MyCallableTask(), 5, TimeUnit.SECONDS);! ! executor.scheduleAtFixedRate(new MyRunnableTask(), 2, 3,! TimeUnit.SECONDS);! ! executor.scheduleWithFixedDelay(new MyRunnableTask(), 2, 3,! TimeUnit.SECONDS);! ! #DV13-UniJavaEE7 @arungupta @agoncal
  19. 19. ManagedThreadFactory Extends ThreadFactory
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×