Oracle talk 20131213

45
A new wave of JEE & JSF Arshal (@aforarsh) www.arshal.org

description

Slides of talk at Japan Java Users Group on 2013/12/13 on JEE7. Download source code at http://www.arshal.org/2013/12/talk-at-oracle.html

Transcript of Oracle talk 20131213

Page 1: Oracle talk 20131213

A new wave of

JEE & JSF Arshal (@aforarsh)

www.arshal.org

Page 2: Oracle talk 20131213

www.arshal.orgAgenda❖ JSF 2.2!

❖ CDI 1.1!

❖ Bean validation 1.1!

❖ Interceptors!

❖ JTA 1.2!

❖ EJB 3.2!

❖ Servlet 3.1!

❖ JPA!

❖ JMS 2.0!

❖ Web socket 1.1!

❖ Expression Language 3.0!

❖ JAX - RS 2.0!

❖ JSONP!

❖ Batch Processing

Page 3: Oracle talk 20131213

www.arshal.orgAgenda❖ JSF 2.2!

❖ CDI 1.1!

❖ Bean validation 1.1!

❖ Interceptors!

❖ JTA 1.2!

❖ EJB 3.2!

❖ Servlet 3.1!

❖ JPA!

❖ JMS 2.0!

❖ Web socket 1.1!

❖ Expression Language 3.0!

❖ JAX - RS 2.0!

❖ JSONP!

❖ Batch Processing

Page 4: Oracle talk 20131213

www.arshal.orgBefore we start !

Page 5: Oracle talk 20131213

www.arshal.orgBefore we start !

Page 6: Oracle talk 20131213

www.arshal.orgBefore we start !

Page 7: Oracle talk 20131213

www.arshal.orgBefore we start !

Page 8: Oracle talk 20131213

www.arshal.orgBefore we start !

Page 9: Oracle talk 20131213

www.arshal.orgBefore we start !

Page 10: Oracle talk 20131213

www.arshal.orgBefore we start !

Page 11: Oracle talk 20131213

www.arshal.orgBefore we start !

Page 12: Oracle talk 20131213

www.arshal.orgBefore we start !

Page 13: Oracle talk 20131213

www.arshal.orgBefore we start !

Page 14: Oracle talk 20131213

www.arshal.orgBefore we start !

Page 15: Oracle talk 20131213

www.arshal.orgBefore we start !

❖ Download code http://bit.ly/18FJHh7http://www.arshal.org/2013/12/talk-at-oracle.html

Page 16: Oracle talk 20131213

www.arshal.orgBefore we start !

Page 17: Oracle talk 20131213

www.arshal.orgComing back..❖ JSF 2.2!

❖ CDI 1.1!

❖ Bean validation 1.1!

❖ Interceptors!

❖ JTA 1.2!

❖ EJB 3.2!

❖ Servlet 3.1!

❖ JPA!

❖ JMS 2.0!

❖ Web socket 1.1!

❖ Expression Language 3.0!

❖ JAX - RS 2.0!

❖ JSONP!

❖ Batch Processing

Page 18: Oracle talk 20131213

www.arshal.orgAgenda❖ JSF 2.2!

❖ CDI 1.1!

❖ Bean validation 1.1!

❖ Interceptors!

❖ JTA 1.2!

❖ EJB 3.2!

❖ Servlet 3.1!

❖ JPA!

❖ JMS 2.0!

❖ Web socket 1.1!

❖ Expression Language 3.0!

❖ JAX - RS 2.0!

❖ JSONP!

❖ Batch Processing

Page 19: Oracle talk 20131213

www.arshal.orgJSF 2.2

❖ Pass through attributes!

❖ Flow scoped!

❖ Resource library contracts!

❖ File upload!

❖ Components!

❖ CSRF

Page 20: Oracle talk 20131213

www.arshal.orgJSF 2.2

❖ Pass through attributes!

❖ Flow scoped!

❖ Resource library contracts!

❖ File upload!

❖ Components!

❖ CSRF

<h:inputText value="#{passthroughBean.age}" p:type="number"/>

Page 21: Oracle talk 20131213

www.arshal.orgJSF 2.2

❖ Pass through attributes!

❖ Flow scoped!

❖ Resource library contracts!

❖ File upload!

❖ Components !

❖ CSRF

@FlowScoped(“flow1")!@FlowDefinition!flow.xml

Page 22: Oracle talk 20131213

www.arshal.orgJSF 2.2

❖ Pass through attributes!

❖ Flow scoped!

❖ Resource library contracts!

❖ File upload!

❖ Components!

❖ CSRF

<f:view contracts="#{contractsBean.contract}">

Page 23: Oracle talk 20131213

www.arshal.orgJSF 2.2

❖ Pass through attributes!

❖ Flow scoped!

❖ Resource library contracts!

❖ File upload!

❖ Components!

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

Page 24: Oracle talk 20131213

www.arshal.orgJSF 2.2

❖ Pass through attributes!

❖ Flow scoped!

❖ Resource library contracts!

❖ File upload!

❖ Components!

❖ CSRF

!

Page 25: Oracle talk 20131213

www.arshal.orgJSF 2.2

❖ Pass through attributes!

❖ Flow scoped!

❖ Resource library contracts!

❖ File upload!

❖ Components!

❖ CSRF!<protected-views>! <url-pattern>/jsf/file/index.xhtml</url-pattern>! </protected-views>

Page 26: Oracle talk 20131213

www.arshal.orgAgenda❖ JSF 2.2!

❖ CDI 1.1!

❖ Bean validation 1.1!

❖ Interceptors!

❖ JTA 1.2!

❖ EJB 3.2!

❖ Servlet 3.1!

❖ JPA!

❖ JMS 2.0!

❖ Web socket 1.1!

❖ Expression Language 3.0!

❖ JAX - RS 2.0!

❖ JSONP!

❖ Batch Processing

Page 27: Oracle talk 20131213

www.arshal.orgCDI 1.1

❖ Bean discovery mode!

❖ Vetoed beans

Page 28: Oracle talk 20131213

www.arshal.orgCDI 1.1

❖ Bean discovery mode!

❖ Vetoed beans

bean-discovery-mode=“all"!bean-discovery-mode=“annotated”!bean-discovery-mode="none"

Page 29: Oracle talk 20131213

www.arshal.orgCDI 1.1

❖ Bean discovery mode!

❖ Vetoed beans @Vetoed

Page 30: Oracle talk 20131213

www.arshal.orgAgenda❖ JSF 2.2!

❖ CDI 1.1!

❖ Bean validation 1.1!

❖ Interceptors!

❖ JTA 1.2!

❖ EJB 3.2!

❖ Servlet 3.1!

❖ JPA!

❖ JMS 2.0!

❖ Web socket 1.1!

❖ Expression Language 3.0!

❖ JAX - RS 2.0!

❖ JSONP!

❖ Batch Processing

Page 31: Oracle talk 20131213

www.arshal.orgBean Validation 1.1

❖ Custom constraints!

!

❖ Method validation

@NotNull(message = "{org.sample.zipcode.cannot_be_null}")!public @interface ZipCode {

public String saveZip(@ZipCode String zip)

Page 32: Oracle talk 20131213

www.arshal.orgAgenda❖ JSF 2.2!

❖ CDI 1.1!

❖ Bean validation 1.1!

❖ Interceptors!

❖ JTA 1.2!

❖ EJB 3.2!

❖ Servlet 3.1!

❖ JPA!

❖ JMS 2.0!

❖ Web socket 1.1!

❖ Expression Language 3.0!

❖ JAX - RS 2.0!

❖ JSONP!

❖ Batch Processing

Page 33: Oracle talk 20131213

Interceptors❖ InterceptorBinding!

❖ @AroundConstruct!

❖ Prioritisation standard!

❖ @Priority(Interceptor.Priority.APPLICATION+10), @Interceptors

www.arshal.org

Page 34: Oracle talk 20131213

www.arshal.orgAgenda❖ JSF 2.2!

❖ CDI 1.1!

❖ Bean validation 1.1!

❖ Interceptors!

❖ JTA 1.2!

❖ EJB 3.2!

❖ Servlet 3.1!

❖ JPA!

❖ JMS 2.0!

❖ Web socket 1.1!

❖ Expression Language 3.0!

❖ JAX - RS 2.0!

❖ JSONP!

❖ Batch Processing

Page 35: Oracle talk 20131213

www.arshal.org`

❖ Transactional scoped beans!

❖ @TransactionScoped!

❖ Transactional methods!

❖ @Transactional(value=Transactional.txType.Required, rollbackOn={SQLException.class, JMSException.class},  dontRollbackOn=SQLWarning.class)

Page 36: Oracle talk 20131213

www.arshal.orgAgenda❖ JSF 2.2!

❖ CDI 1.1!

❖ Bean validation 1.1!

❖ Interceptors!

❖ JTA 1.2!

❖ EJB 3.2!

❖ Servlet 3.1!

❖ JPA!

❖ JMS 2.0!

❖ Web socket 1.1!

❖ Expression Language 3.0!

❖ JAX - RS 2.0!

❖ JSONP!

❖ Batch Processing

Page 37: Oracle talk 20131213

www.arshal.orgEJB 3.2❖ Asynchronous bean!

❖ @Asynchronous!

❖ Non persistent timer service!

❖ @Schedule(hour="*", minute="*", second="*/5", info = "Every 5 second timer", persistent = false) !

❖ Passivation capable!

❖ @PrePassivate

Page 38: Oracle talk 20131213

www.arshal.orgAgenda❖ JSF 2.2!

❖ CDI 1.1!

❖ Bean validation 1.1!

❖ Interceptors!

❖ JTA 1.2!

❖ EJB 3.2!

❖ Servlet 3.1!

❖ JPA!

❖ JMS 2.0!

❖ Web socket 1.1!

❖ Expression Language 3.0!

❖ JAX - RS 2.0!

❖ JSONP!

❖ Batch Processing

Page 39: Oracle talk 20131213

www.arshal.org

• Non blocking I/O: Check for resource availability before trying for it. while (input.isReady() && (len = input.read(b)) != -1) { String data = new String(b, 0, len); System.out.println("--> " + data)}!

• Improved security!• Async supported

@WebServlet(urlPatterns="/async", asyncSupported=true)!

Agenda❖ JSF 2.2!

❖ CDI 1.1!

❖ Bean validation 1.1!

❖ Interceptors!

❖ JTA 1.2!

❖ EJB 3.2!

❖ Servlet 3.1!

❖ JPA!

❖ JMS 2.0!

❖ Web socket 1.1!

❖ Expression Language 3.0!

❖ JAX - RS 2.0!

❖ JSONP!

❖ Batch Processing

Page 40: Oracle talk 20131213

www.arshal.orgAgenda❖ JSF 2.2!

❖ CDI 1.1!

❖ Bean validation 1.1!

❖ Interceptors!

❖ JTA 1.2!

❖ EJB 3.2!

❖ Servlet 3.1!

❖ JPA!

❖ JMS 2.0!

❖ Web socket 1.1!

❖ Expression Language 3.0!

❖ JAX - RS 2.0!

❖ JSONP!

❖ Batch Processing

Page 41: Oracle talk 20131213

www.arshal.org

• Schema generation! <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/ XMLSchema-instance" xsi:schemaLocation=“http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/ persistence/persistence_2_1.xsd"> <persistence-unit name="myPU" transaction-type="JTA"> <properties> <property name=“javax.persistence.schema-generation.database.action" value="drop-and-create"/> <property name=“javax.persistence.schema-generation.create-source" value="script"/> <property name=“javax.persistence.schema-generation.drop-source" value="script"/> <property name=“javax.persistence.schema-generation.create-script-source" value="META-INF/create.sql"/> <property name=“javax.persistence.schema-generation.drop-script-source" value="META-INF/drop.sql"/> <property name=“javax.persistence.sql-load-script-source" value="META-INF/load.sql"/> </properties> </persistence-unit> </persistence>

• Bulk update/delete using criteria API CriteriaBuilder builder = em.getCriteriaBuilder();!

CriteriaDelete deleteCriteria = builder.createCriteriaDelete(Student.class); Root<Student> updateRoot = deleteCriteria.from(Student.class); deleteCriteria.where(builder.equal(updateRoot.get(Student_.id), "1234")); Query q = em.createQuery(deleteCriteria); q.executeUpdate(); !• Unsynchronized persistence contexts

@PersistenceContext(synchronization=SynchronizationType.UNSYNCHRONIZED)!

Agenda❖ JSF 2.2!

❖ CDI 1.1!

❖ Bean validation 1.1!

❖ Interceptors!

❖ JTA 1.2!

❖ EJB 3.2!

❖ Servlet 3.1!

❖ JPA!

❖ JMS 2.0!

❖ Web socket 1.1!

❖ Expression Language 3.0!

❖ JAX - RS 2.0!

❖ JSONP!

❖ Batch Processing

Page 42: Oracle talk 20131213

www.arshal.org

• Simplified!• Easier resource configuration!• JMS resource definition annotations.

Agenda❖ JSF 2.2!

❖ CDI 1.1!

❖ Bean validation 1.1!

❖ Interceptors!

❖ JTA 1.2!

❖ EJB 3.2!

❖ Servlet 3.1!

❖ JPA!

❖ JMS 2.0!

❖ Expression Language 3.0!

❖ Web socket 1.1!

❖ JAX - RS 2.0!

❖ JSONP!

❖ Batch Processing

Page 43: Oracle talk 20131213

www.arshal.org

• Lambda expression support

Agenda❖ JSF 2.2!

❖ CDI 1.1!

❖ Bean validation 1.1!

❖ Interceptors!

❖ JTA 1.2!

❖ EJB 3.2!

❖ Servlet 3.1!

❖ JPA!

❖ JMS 2.0!

❖ Web socket 1.1!

❖ Expression Language 3.0!

❖ JAX - RS 2.0!

❖ JSONP!

❖ Batch Processing

Page 44: Oracle talk 20131213

www.arshal.orgQ & A

❖ Contact Info!

❖ e-mail: [email protected]!

❖ Twitter: @aforarsh!

❖ Web: www.arshal.org

Page 45: Oracle talk 20131213

“ Good code is its own best documentation. As you're about to add a comment, ask yourself,

"How can I improve the code so that this comment isn't needed?" Improve the code and then

document it to make it even clearer.”