Your SlideShare is downloading. ×
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

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

5,217
views

Published on

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

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,217
On Slideshare
0
From Embeds
0
Number of Embeds
20
Actions
Shares
0
Downloads
88
Comments
6
Likes
14
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Java EE 7 : What’s new in the Java EE Platform Arun Gupta Antonio Goncalves #DV13-UniJavaEE7 @arungupta @agoncal
  • 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. 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. 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. @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. 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. 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. 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. 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. 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. @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. 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. 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. ManagedExecutor Default ManagedExectuor @Resource
 ManagedExecutorService executor;
 ! 
 ManagedExecutorService executor = (ManagedExecutorService) ! ctx.lookup("java:comp/DefaultManagedExecutorService");! #DV13-UniJavaEE7 @arungupta @agoncal
  • 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. ManagedScheduledExecutor Thread Scheduler in Java EE •  Managed version of ScheduledExecutorService •  Submit delayed or periodic tasks @Resource
 ManagedScheduledExecutorService executor;! #DV13-UniJavaEE7 @arungupta @agoncal
  • 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. 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. ManagedThreadFactory Extends ThreadFactory

×