SlideShare a Scribd company logo
1 of 107
Download to read offline
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.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
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
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
@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
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
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
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
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
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
@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
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
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
ManagedExecutor
Default ManagedExectuor	


@Resource

ManagedExecutorService executor;

!


ManagedExecutorService executor = (ManagedExecutorService) !
ctx.lookup("java:comp/DefaultManagedExecutorService");!

#DV13-UniJavaEE7

@arungupta @agoncal
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
ManagedScheduledExecutor
Thread Scheduler in Java EE	


•  Managed version of ScheduledExecutorService
•  Submit delayed or periodic tasks	

@Resource

ManagedScheduledExecutorService executor;!

#DV13-UniJavaEE7

@arungupta @agoncal
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
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
ManagedThreadFactory

Extends ThreadFactory
	

 @Resource(name = DefaultManagedThreadFactory)

ManagedThreadFactory factory;


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

!

#DV13-UniJavaEE7

@arungupta @agoncal
ManagedThreadFactory
Extends ThreadFactory
	

 Thread thread = factory.newThread(new

MyTask());




!
((ManageableThread)thread).isShutdown();



!

#DV13-UniJavaEE7

@arungupta @agoncal
DynamicProxy
Dynamic proxies	


•  Create dynamic proxy objects, adds contextual information
• 

available for applications running in Java EE environment	

Classloading, JNDI, Security, …	


#DV13-UniJavaEE7

@arungupta @agoncal
DynamicProxy
Create contextual proxies	


@Resource

ContextService service;





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





Future f = executor.submit(proxy);!

#DV13-UniJavaEE7

@arungupta @agoncal
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


JPA 2.1 (JSR 338)
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
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!

#DV13-UniJavaEE7

@arungupta @agoncal
@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;!
...!
}!

#DV13-UniJavaEE7

@arungupta @agoncal
Unsynchronized Persistence Context
Persistence context not enlisted in any tx unless explicitly joined	


@PersistenceContext(synchronization =!
SynchronizationType.UNSYNCHRONIZED)!
private EntityManager em;!
...!
!
em.persist(book);!
!
...!
em.joinTransaction();!
!

#DV13-UniJavaEE7

@arungupta @agoncal
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 {...}!

#DV13-UniJavaEE7

@arungupta @agoncal
CDI in listeners

Injection is now possible into event listeners	

public class AgeCalculationListener {!
!
@Inject!
private AgeCalculator ageCalculator;!
!
@PostLoad!
@PostPersist!
@PostUpdate!
public void calculateAge(Customer c) {!
customer.setAge(ageCalculator.calc(c.getBirth));!
}!
}!

#DV13-UniJavaEE7

@arungupta @agoncal
Converters

Classes that convert between database and attributes	


@Converter!
public class CreditCardEnumConverter implements!
AttributeConverterCreditCard, String {!
!
public String convertToDatabaseColumn(CreditCard attr) {...}!
public CreditCard convertToEntityAttribute(String data){...}!
}!
!
@Entity!
public class Order {!
!
@Convert(converter = CreditCardEnumConverter.class)!
private CreditCard creditCard;!
}!

#DV13-UniJavaEE7

@arungupta @agoncal
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


JTA 1.2 (JSR 907)
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
@Transactional

TX 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) {...}!
}!

#DV13-UniJavaEE7

@arungupta @agoncal
@TransactionScoped

CDI scope whose lifecycle is scoped to the currently active JTA tx	

@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(); }}!

#DV13-UniJavaEE7

@arungupta @agoncal
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


EJB 3.2 (JSR 345)
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
Disable passivation of stateful

In some cases increases performance, scalability and robustness	

@Stateful(passivationCapable = false)!
public class ShoppingCart {!
...!
}!

#DV13-UniJavaEE7

@arungupta @agoncal
EJB-Lite: Async + Non-persistent timer
EJB Lite includes async invocations and non-persistent EJB Timer	

@Stateless!
public class OrderEJB {!
!
@Asynchronous!
public void sendEmail (Order order) {!
// Very Long task!
}!
!
@Schedule(hour=2, persistent=false)!
public void createDailyReport() {!
// ...!
}!
}!

#DV13-UniJavaEE7

@arungupta @agoncal
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


JMS 2.0 (JSR 343)
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
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);!

#DV13-UniJavaEE7

@arungupta @agoncal
Runtime Exceptions

A set of new unchecked exceptions have been created	

RuntimeException!
JMSRuntimeException!
IllegalStateRuntimeException!
InvalidClientIDRuntimeException!
InvalidDestinationRuntimeException!
InvalidSelectorRuntimeException!
JMSSecurityRuntimeException!
MessageFormatRuntimeException!
MessageNotWriteableRuntimeException!
ResourceAllocationRuntimeException!
TransactionInProgressRuntimeException!
TransactionRolledBackRuntimeException!

#DV13-UniJavaEE7

@arungupta @agoncal
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(q).receiveBody(String.class);!
}!
}!

#DV13-UniJavaEE7

@arungupta @agoncal
JMSConnectionFactoryDefinition
ConnectionFactory can be defined using an annotation	


@Stateless!
@JMSConnectionFactoryDefinition(!
name = java:app/jms/MyConnectionFactory,!
interfaceName = javax.jms.TopicConnectionFactory)!
!
!
!
public class ExpensiveOrderEJB {...}!

#DV13-UniJavaEE7

@arungupta @agoncal
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 {...}!

#DV13-UniJavaEE7

@arungupta @agoncal
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


Servlet 3.1 (JSR 340)
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
Non-blocking I/O
Non-blocking I/O in Servlets	


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) {

. . .

}

}

}!

#DV13-UniJavaEE7

@arungupta @agoncal
Non-blocking I/O

New methods to existing interfaces	


•  ServletInputStream
•  public
•  public
•  public

void setReadListener(ReadListener l);
boolean isFinished();
boolean isReady();

•  public
•  public

setWriteListener(WriteListener l);
boolean canWrite();

•  ServletOutputStream

#DV13-UniJavaEE7

@arungupta @agoncal
Non-blocking I/O
New interfaces	


public interface ReadListener extends EventListener {

public void onDataAvailable();

public void onAllDataRead();

public void onError();

}!
public interface WriteListener extends EventListener {

public void onWritePossible();

public void onError();

}!

#DV13-UniJavaEE7

@arungupta @agoncal
Non-blocking I/O

Only for Asynchronous Servlets	

AsyncContext context = request.startAsync();

ServletInputStream input = request.getInputStream();

input.setReadListener(new MyReadListener(input, context)); !

#DV13-UniJavaEE7

@arungupta @agoncal
Protocol Upgrade
New interface	


•  T
• 

extends HttpUpgradeHandler T
HttpServletRequest.upgrade(ClassT class)
throws IOException;
HttpUpgradeHandler

•  init(WebConnection
•  destroy();

#DV13-UniJavaEE7

wc);

@arungupta @agoncal
Protocol Upgrade
New interface	


public interface WebConnection {

ServletInputStream getInputStream();

ServletOutputStream getOutputStream();

}!

#DV13-UniJavaEE7

@arungupta @agoncal
Improved Security

Deny an HTTP method request for an uncovered HTTP method	

web-app . . . version=3.1 

web-resource-collection

url-pattern/account/*/url-pattern 

http-methodGET/http-method

/web-resource-collection

/web-app !
!

#DV13-UniJavaEE7

@arungupta @agoncal
Improved Security

Deny an HTTP method request for an uncovered HTTP method	

web-app . . . version=3.1 

deny-uncovered-http-methods/

web-resource-collection

url-pattern/account/*/url-pattern 

http-methodGET/http-method

/web-resource-collection

/web-app !

#DV13-UniJavaEE7

@arungupta @agoncal
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


Web Socket 1.0 (JSR 356)
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
Annotated server endpoint

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);!
}

}

}!

#DV13-UniJavaEE7

@arungupta @agoncal
Lifecycle callbacks
Connection lifecycle	


@javax.websocket.OnOpen

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



@javax.websocket.OnClose

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



@javax.websocket.OnError

public void error(Throwable t) { . . . }!

#DV13-UniJavaEE7

@arungupta @agoncal
Annotated client endpoint

Full-duplex bi-directional communication over single TCP connection	

@javax.websocket.ClientEndpoint

public class MyClient {

@javax.websocket.OnOpen

public void open(Session session) { … }



// Lifecycle callbacks

}!

#DV13-UniJavaEE7

@arungupta @agoncal
Annotated client endpoint

Full-duplex bi-directional communication over single TCP connection	

ContainerProvider

.getWebSocketContainer()

.connectToServer(

MyClient.class, 

URI.create(ws://. . .));!
!

#DV13-UniJavaEE7

@arungupta @agoncal
Programmatic endpoints
API of rendpoints	


public class ChatServer extends Endpoint {

@Override

public void onOpen(Session s, EndpointConfig ec) {

s.addMessageHandler(new MessageHandler.WholeString() {

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

}

}



@Override

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



//. . . 

}!

#DV13-UniJavaEE7

@arungupta @agoncal
Programmatic endpoints
API of rendpoints	


public class MyApplicationConfig implements
ServerApplicationConfig {

public SetServerEndpointConfig getEndpointConfigs(…) {
ServerEndpointConfig.Builder

.create(MyEndpoint.class, /websocket”)

.configurator(new MyConfig())

.build()

}

}!

#DV13-UniJavaEE7




@arungupta @agoncal
Programmatic endpoints
API of rendpoints	


public class MyConfig extends ServerEndpointConfig.Configurator{



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



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



. . .

}!

#DV13-UniJavaEE7

@arungupta @agoncal
Encoder and Decoder
Encodes and decodes messages	


@javax.websocket.server.ServerEndpoint(

value=/chat,

decoders=MyDecoder.class,

encoders=MyEncoder.class)

public class ChatServer {



@OnMessage

public String chat(ChatMessage name, Session session) {

. . . 

}

}!

#DV13-UniJavaEE7

@arungupta @agoncal
Encoder and Decoder
Encodes and decodes messages	


public class MyDecoder implements Decoder.TextChatMessage {

public ChatMessage decode(String s) {

// . . .

}



public boolean willDecode(String string) {

// . . .

}



//. . .

}!

#DV13-UniJavaEE7

@arungupta @agoncal
Encoder and Decoder
Encodes and decodes messages	


public class MyEncoder implements Encoder.TextChatMessage {



public String encode(ChatMessage chatMessage) {

// . . .

}

!
// . . .

}!

#DV13-UniJavaEE7

@arungupta @agoncal
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


Expression Language 3.0 (JSR 341)
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
ELProcessor

Use EL in a stand-alone environment	

ELProcessor el = new ELProcessor();!
!
assert ((Integer)el.eval(a = [1, 2]; a[1])) == 2;!
!
el.defineBean(employee, new Employee(John));!
assert (el.eval(employee.name)).equals(John);!
!

#DV13-UniJavaEE7

@arungupta @agoncal
Lambda expression
Use lambdas before Java SE 8	


ELProcessor el = new ELProcessor();!
!
assert ((Integer)(el.eval(((x,y) - x+y)(4, 5)))) == 9;!

#DV13-UniJavaEE7

@arungupta @agoncal
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


JSF 2.2 (JSR 344)
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
Faces Flow

Package reusable flows in JAR	

./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!

#DV13-UniJavaEE7

@arungupta @agoncal
Faces Flow
Use annotations	


Named

@FlowScoped(flow1)

public class Flow1Bean implements Serializable {

}!
!
@Produces @FlowDefinition

public Flow defineFlow(@FlowBuilderParameter FlowBuilder fb) {

String flowId = flow1;

//. . .

return fb.getFlow();

}!

#DV13-UniJavaEE7

@arungupta @agoncal
Faces Flow
Use flows in EL	


#{flowScope}: Local flow storage



#{facesContext.application.flowHandler.currentFlow}: Returns !
true if within a flow!

#DV13-UniJavaEE7

@arungupta @agoncal
Resource Library Contract

Apply templates in a reusable and interchangeable manner	

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!

#DV13-UniJavaEE7

@arungupta @agoncal
Resource Library Contract

Apply templates in a reusable and interchangeable manner	

f:view contracts=”red”

ui:composition template=/template.xhtml

. . .

/ui:composition

/f:view

!

#DV13-UniJavaEE7

@arungupta @agoncal
Pass-through Attributes
HTML5-Friendly Markup	


h:inputText type=email value=#{user.email}/ 

!
input type=text name=j_idt6:j_idt10/!
!
!
h:inputText p:type=email value=#{user.email}/ 



input type=email name=j_idt6:j_idt10/!

#DV13-UniJavaEE7

@arungupta @agoncal
File Upload Component
Upload files	


h:form enctype=multipart/form-data

h:inputFile value=#{fileUploadBean.file}/

h:commandButton value=Upload/

/h:form !
!
!
@Named @RequestScoped 

public class FileUploadBean {

private Part file;



//getter and setter

} !
!

#DV13-UniJavaEE7

@arungupta @agoncal
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


JAX-RS 2.0 (JSR 339)
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
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).get();!
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);!

#DV13-UniJavaEE7

@arungupta @agoncal
Async client

The client API also supports asynchronous invocation	

FutureString 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){!
...!
}!

#DV13-UniJavaEE7

@arungupta @agoncal
Async server

Asynchronous request processing on the server	

@Path(/async)!
public class AsyncResource {!
!
@GET!
public void asyncGet(@Suspended AsyncResponse resp){!
!
new Thread(new Runnable() {!
!
public void run() {!
String result = veryExpensiveOperation();!
resp.resume(result);!
}!
}).start();!
}}!

#DV13-UniJavaEE7

@arungupta @agoncal
Message Filter

Process incoming/outgoing request/response headers	


•  Filters on client side	


•  javax.ws.rs.client.ClientRequestFilter
•  javax.ws.rs.client.ClientResponseFilter

•  Filters on server side	


•  javax.ws.rs.container.ContainerRequestFilter
•  javax.ws.rs.container.ContainerResponseFilter

#DV13-UniJavaEE7

@arungupta @agoncal
Message Filter

Process incoming/outgoing request/response headers	

public class LogginFilter implements ClientRequestFilter{!
!
public void filter(ClientRequestContext ctx) ... {!
System.out.println(ctx.getMethod());!
System.out.println(ctx.getUri());!
}!
}!

#DV13-UniJavaEE7

@arungupta @agoncal
Entity Interceptors

Marshalling and unmarshalling HTTP message bodies	


•  Intercepts inbound stream (read from the “wire”)	

•  javax.ws.rs.ext.ReaderInterceptor

•  Intercepts outbound stream (written to the “wire”)	

•  javax.ws.rs.ext.WriterInterceptor

#DV13-UniJavaEE7

@arungupta @agoncal
Entity Interceptors

Marshalling and unmarshalling HTTP message bodies	

public class ZipInterceptor implements WriterInterceptor{!
!
public void aroundWriteTo(WriterInterceptorContext ctx){!
OutputStream os = ctx.getOutputStream();!
ctx.setOutputStream(new GZIPOutputStream(os));!
ctx.proceed();!
}!
}!

#DV13-UniJavaEE7

@arungupta @agoncal
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


JSON-P 1.0 (JSR 353)
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
JSON Builder

Builds an object model 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();!

#DV13-UniJavaEE7

@arungupta @agoncal
JSON Parser

Event-based parser reading 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();!
}!
}!

#DV13-UniJavaEE7

@arungupta @agoncal
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


Batch 1.0 (JSR 352)
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
Chunk-style Processing
Item-oriented Processing Style (primary)	


#DV13-UniJavaEE7

@arungupta @agoncal
Chunk-style Processing
Item-oriented Processing Style (primary)	


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!
}!

#DV13-UniJavaEE7

@arungupta @agoncal
Batchlet-style Processing
Task-oriented processing style	


step id=”transferFile”!
batchlet ref=“MyFileTransfer” /!
/step!

…implements Batchlet {!
@Override

public void process() {

// Transfer file!
}!

#DV13-UniJavaEE7

@arungupta @agoncal
Job/Step/Chunk Listeners
Listeners	


job id=myJob xmlns=http://xmlns.jcp.org/xml/ns/javaee ...

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!
!
#DV13-UniJavaEE7
@arungupta @agoncal
Job/Step/Chunk Listeners
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!

#DV13-UniJavaEE7

@arungupta @agoncal
Job/Step/Chunk Listeners
Listeners	


@Named

public class MyJobListener extends AbstractJobListener {



@Override

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



@Override

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

}!

#DV13-UniJavaEE7

@arungupta @agoncal
Partition
Partitioning	


step

chunk item-count=3

reader ref=myItemReader

properties

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

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

/properties


/reader

. . .

/chunk!

#DV13-UniJavaEE7

@arungupta @agoncal
Partition
Partitioning	


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!

#DV13-UniJavaEE7

@arungupta @agoncal
Creating Workflows

Flow: Elements that execute together as a unit	

flow id=flow1 next=step3

step id=step1 next=step2 . . . /step

step id=step2 . . . /step

/flow

step id=step3 . . . /step!

#DV13-UniJavaEE7

@arungupta @agoncal
Creating Workflows
Split: Concurrent execution of flows	


split id=split1 next= . . . 

flow id=flow1”

step id=step1” . . . /step

/flow

flow id=flow2”

step id=step2” . . . /step

/flow

/split!

#DV13-UniJavaEE7

@arungupta @agoncal
Creating Workflows

Decision: Customized way of sequencing between steps, flows, splits	


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 !
!
@Named

public class MyDecider implements Decider {

@Override

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

. . .

return DATA_LOADED; // or NOT_LOADED!
} !
}!
!
#DV13-UniJavaEE7
@arungupta @agoncal
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


JavaMail 1.5 (JSR 919)
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
MailSessionDefinition

A mail session can be defined using an annotation	

@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;!

#DV13-UniJavaEE7

@arungupta @agoncal
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


JCA 1.7 (JSR 322)
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
Connector definition

A connector can be defined using an annotation	

@ConnectionDefinition(!
connection=MyConnection.class,!
connectionImpl=MyConnectionImpl.class,!
connectionFactory=MyConnectionFactory.class,!
connectionFactoryImpl=MyConnectionFactoryImpl.class!
)!
!
@AdministeredObjectDefinition(!
className=MyQueueImpl.class,!
name=java:comp/MyQueue,!
resourceAdapter=myAdapter,!
)!

#DV13-UniJavaEE7

@arungupta @agoncal
CDI 1.1	

Bean Validation 1.1	

Interceptors 1.2	

Concurrency 1.0	


Java EE 7 (JSR 342)
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
Default Resources
Default datasource	


@Resource(lookup=java:comp/DefaultDataSource)!
private DataSource myDS;!
!
@Resource!
private DataSource myDS; !

#DV13-UniJavaEE7

@arungupta @agoncal
Default Resources

Default JMS factory	

	

 @Resource(lookup=java:comp/DefaultJMSConnectionFactory)

!

private ConnectionFactory myCF; !
!
@Resource!
private ConnectionFactory myCF;!

#DV13-UniJavaEE7

@arungupta @agoncal
Default Resources

Default Concurrency Utilities objects	

@Resource(lookup=java:comp/DefaultManagedExecutorService) !
private ManagedExecutorService mes; !
@Resource(lookup=java:comp/DefaultManagedScheduledExecutorService) !
private ManagedScheduledExecutorService mses; !
@Resource(lookup=java:comp/DefaultManagedThreadFactory) !
private ManagedThreadFactory mtf; !
@Resource(lookup=java:comp/DefaultContextService) !
private ContextService cs; !
!
@Resource!
private ManagedExecutorService mes; !
@Resource!
private ManagedScheduledExecutorService mses; !
@Resource!
private ManagedThreadFactory mtf; !
@Resource!
private ContextService cs; !

#DV13-UniJavaEE7

@arungupta @agoncal
New namespaces
Bye bye Sun	


persistence 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!
version=2.1!
!
web-app xmlns=http://xmlns.jcp.org/xml/ns/javaee!
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance!
xsi:schemaLocation=http://xmlns.jcp.org/xml/ns/javaee !
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd!
version=3.1!
!

#DV13-UniJavaEE7

@arungupta @agoncal
Buy our books!

#DV13-UniJavaEE7

@arungupta @agoncal
Q/A
#DV13-UniJavaEE7

@arungupta @agoncal
Thank you
Arun Gupta
Antonio Goncalves

#DV13-UniJavaEE7

@arungupta @agoncal

More Related Content

What's hot

5050 dev nation
5050 dev nation5050 dev nation
5050 dev nation
Arun Gupta
 
Java EE 與 雲端運算的展望
Java EE 與 雲端運算的展望 Java EE 與 雲端運算的展望
Java EE 與 雲端運算的展望
javatwo2011
 
Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)
Hamed Hatami
 
Jdk(java) 7 - 6 기타기능
Jdk(java) 7 - 6 기타기능Jdk(java) 7 - 6 기타기능
Jdk(java) 7 - 6 기타기능
knight1128
 

What's hot (20)

5050 dev nation
5050 dev nation5050 dev nation
5050 dev nation
 
Indic threads pune12-java ee 7 platformsimplification html5
Indic threads pune12-java ee 7 platformsimplification html5Indic threads pune12-java ee 7 platformsimplification html5
Indic threads pune12-java ee 7 platformsimplification html5
 
Java EE 與 雲端運算的展望
Java EE 與 雲端運算的展望 Java EE 與 雲端運算的展望
Java EE 與 雲端運算的展望
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
Java EE 7 overview
Java EE 7 overviewJava EE 7 overview
Java EE 7 overview
 
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUGThe Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
The Java EE 7 Platform: Productivity &amp; HTML5 at San Francisco JUG
 
Testing Your Application On Google App Engine
Testing Your Application On Google App EngineTesting Your Application On Google App Engine
Testing Your Application On Google App Engine
 
Spring 4 final xtr_presentation
Spring 4 final xtr_presentationSpring 4 final xtr_presentation
Spring 4 final xtr_presentation
 
Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)Java EE 7 (Hamed Hatami)
Java EE 7 (Hamed Hatami)
 
Spring 4 advanced final_xtr_presentation
Spring 4 advanced final_xtr_presentationSpring 4 advanced final_xtr_presentation
Spring 4 advanced final_xtr_presentation
 
What's new in JMS 2.0 - OTN Bangalore 2013
What's new in JMS 2.0 - OTN Bangalore 2013What's new in JMS 2.0 - OTN Bangalore 2013
What's new in JMS 2.0 - OTN Bangalore 2013
 
To inject or not to inject: CDI is the question
To inject or not to inject: CDI is the questionTo inject or not to inject: CDI is the question
To inject or not to inject: CDI is the question
 
Java EE 7 for Real Enterprise Systems
Java EE 7 for Real Enterprise SystemsJava EE 7 for Real Enterprise Systems
Java EE 7 for Real Enterprise Systems
 
The Java EE 7 Platform: Productivity++ & Embracing HTML5
The Java EE 7 Platform: Productivity++ & Embracing HTML5The Java EE 7 Platform: Productivity++ & Embracing HTML5
The Java EE 7 Platform: Productivity++ & Embracing HTML5
 
What's New in Java 8
What's New in Java 8What's New in Java 8
What's New in Java 8
 
DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)
 
Java Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAXJava Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAX
 
Jdk(java) 7 - 6 기타기능
Jdk(java) 7 - 6 기타기능Jdk(java) 7 - 6 기타기능
Jdk(java) 7 - 6 기타기능
 
Java Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom TagsJava Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom Tags
 
Java EE Introduction
Java EE IntroductionJava EE Introduction
Java EE Introduction
 

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

Similar to Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013 (20)

50 features of Java EE 7 in 50 minutes at JavaZone 2014
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
 
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
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
 
50 features of Java EE 7 in 50 minutes at Geecon 2014
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
 
Fifty New Features of Java EE 7 in Fifty Minutes
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
 
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?
Java EE 7, what's in it for me?
 
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
 
Vaadin 7 - Java Enterprise Edition integration
Vaadin 7 - Java Enterprise Edition integrationVaadin 7 - Java Enterprise Edition integration
Vaadin 7 - Java Enterprise Edition integration
 
The Java EE 7 Platform: Productivity & HTML5 at JavaOne Latin America 2012
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
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
Overview of Java EE 6 by Roberto Chinnici at SFJUG
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
 
What's new in Java EE 6
What's new in Java EE 6What's new in Java EE 6
What's new in Java EE 6
 
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
Arun Gupta: London Java Community: Java EE 6 and GlassFish 3
 
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 ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
 
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
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
 
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
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
 
Java EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerJava EE 6 = Less Code + More Power
Java EE 6 = Less Code + More Power
 
Javaee6 Overview
Javaee6 OverviewJavaee6 Overview
Javaee6 Overview
 
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...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
 
Deep Dive Hands-on in Java EE 6 - Oredev 2010
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
 
PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBoot
 

More from Arun Gupta

More from Arun Gupta (20)

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

Recently uploaded

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
FIDO Alliance
 

Recently uploaded (20)

Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Your enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4jYour enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4j
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 

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

  • 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 @Resource(name = DefaultManagedThreadFactory)
 ManagedThreadFactory factory; ManagedThreadFactory factory = (ManagedThreadFactory) ctx.lookup(java:comp/DefaultManagedThreadFactory);
 ! #DV13-UniJavaEE7 @arungupta @agoncal
  • 20. ManagedThreadFactory Extends ThreadFactory Thread thread = factory.newThread(new MyTask());
 
 ! ((ManageableThread)thread).isShutdown();
 
 ! #DV13-UniJavaEE7 @arungupta @agoncal
  • 21. DynamicProxy Dynamic proxies •  Create dynamic proxy objects, adds contextual information •  available for applications running in Java EE environment Classloading, JNDI, Security, … #DV13-UniJavaEE7 @arungupta @agoncal
  • 22. DynamicProxy Create contextual proxies @Resource
 ContextService service;
 
 
 Runnable proxy = service.createContextualProxy(! new MyRunnable(), Runnable.class);
 
 
 Future f = executor.submit(proxy);! #DV13-UniJavaEE7 @arungupta @agoncal
  • 23. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 JPA 2.1 (JSR 338) 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
  • 24. 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! #DV13-UniJavaEE7 @arungupta @agoncal
  • 25. @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;! ...! }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 26. Unsynchronized Persistence Context Persistence context not enlisted in any tx unless explicitly joined @PersistenceContext(synchronization =! SynchronizationType.UNSYNCHRONIZED)! private EntityManager em;! ...! ! em.persist(book);! ! ...! em.joinTransaction();! ! #DV13-UniJavaEE7 @arungupta @agoncal
  • 27. 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 {...}! #DV13-UniJavaEE7 @arungupta @agoncal
  • 28. CDI in listeners Injection is now possible into event listeners public class AgeCalculationListener {! ! @Inject! private AgeCalculator ageCalculator;! ! @PostLoad! @PostPersist! @PostUpdate! public void calculateAge(Customer c) {! customer.setAge(ageCalculator.calc(c.getBirth));! }! }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 29. Converters Classes that convert between database and attributes @Converter! public class CreditCardEnumConverter implements! AttributeConverterCreditCard, String {! ! public String convertToDatabaseColumn(CreditCard attr) {...}! public CreditCard convertToEntityAttribute(String data){...}! }! ! @Entity! public class Order {! ! @Convert(converter = CreditCardEnumConverter.class)! private CreditCard creditCard;! }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 30. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 JTA 1.2 (JSR 907) 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
  • 31. @Transactional TX 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) {...}! }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 32. @TransactionScoped CDI scope whose lifecycle is scoped to the currently active JTA tx @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(); }}! #DV13-UniJavaEE7 @arungupta @agoncal
  • 33. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 EJB 3.2 (JSR 345) 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
  • 34. Disable passivation of stateful In some cases increases performance, scalability and robustness @Stateful(passivationCapable = false)! public class ShoppingCart {! ...! }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 35. EJB-Lite: Async + Non-persistent timer EJB Lite includes async invocations and non-persistent EJB Timer @Stateless! public class OrderEJB {! ! @Asynchronous! public void sendEmail (Order order) {! // Very Long task! }! ! @Schedule(hour=2, persistent=false)! public void createDailyReport() {! // ...! }! }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 36. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 JMS 2.0 (JSR 343) 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
  • 37. 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);! #DV13-UniJavaEE7 @arungupta @agoncal
  • 38. Runtime Exceptions A set of new unchecked exceptions have been created RuntimeException! JMSRuntimeException! IllegalStateRuntimeException! InvalidClientIDRuntimeException! InvalidDestinationRuntimeException! InvalidSelectorRuntimeException! JMSSecurityRuntimeException! MessageFormatRuntimeException! MessageNotWriteableRuntimeException! ResourceAllocationRuntimeException! TransactionInProgressRuntimeException! TransactionRolledBackRuntimeException! #DV13-UniJavaEE7 @arungupta @agoncal
  • 39. 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(q).receiveBody(String.class);! }! }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 40. JMSConnectionFactoryDefinition ConnectionFactory can be defined using an annotation @Stateless! @JMSConnectionFactoryDefinition(! name = java:app/jms/MyConnectionFactory,! interfaceName = javax.jms.TopicConnectionFactory)! ! ! ! public class ExpensiveOrderEJB {...}! #DV13-UniJavaEE7 @arungupta @agoncal
  • 41. 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 {...}! #DV13-UniJavaEE7 @arungupta @agoncal
  • 42. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 Servlet 3.1 (JSR 340) 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
  • 43. Non-blocking I/O Non-blocking I/O in Servlets 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) {
 . . .
 }
 }
 }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 44. Non-blocking I/O New methods to existing interfaces •  ServletInputStream •  public •  public •  public void setReadListener(ReadListener l); boolean isFinished(); boolean isReady(); •  public •  public setWriteListener(WriteListener l); boolean canWrite(); •  ServletOutputStream #DV13-UniJavaEE7 @arungupta @agoncal
  • 45. Non-blocking I/O New interfaces public interface ReadListener extends EventListener {
 public void onDataAvailable();
 public void onAllDataRead();
 public void onError();
 }! public interface WriteListener extends EventListener {
 public void onWritePossible();
 public void onError();
 }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 46. Non-blocking I/O Only for Asynchronous Servlets AsyncContext context = request.startAsync();
 ServletInputStream input = request.getInputStream();
 input.setReadListener(new MyReadListener(input, context)); ! #DV13-UniJavaEE7 @arungupta @agoncal
  • 47. Protocol Upgrade New interface •  T •  extends HttpUpgradeHandler T HttpServletRequest.upgrade(ClassT class) throws IOException; HttpUpgradeHandler •  init(WebConnection •  destroy(); #DV13-UniJavaEE7 wc); @arungupta @agoncal
  • 48. Protocol Upgrade New interface public interface WebConnection {
 ServletInputStream getInputStream();
 ServletOutputStream getOutputStream();
 }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 49. Improved Security Deny an HTTP method request for an uncovered HTTP method web-app . . . version=3.1 
 web-resource-collection
 url-pattern/account/*/url-pattern 
 http-methodGET/http-method
 /web-resource-collection
 /web-app ! ! #DV13-UniJavaEE7 @arungupta @agoncal
  • 50. Improved Security Deny an HTTP method request for an uncovered HTTP method web-app . . . version=3.1 
 deny-uncovered-http-methods/
 web-resource-collection
 url-pattern/account/*/url-pattern 
 http-methodGET/http-method
 /web-resource-collection
 /web-app ! #DV13-UniJavaEE7 @arungupta @agoncal
  • 51. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 Web Socket 1.0 (JSR 356) 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
  • 52. Annotated server endpoint 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);! }
 }
 }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 53. Lifecycle callbacks Connection lifecycle @javax.websocket.OnOpen
 public void open(Session s) { . . . }
 
 @javax.websocket.OnClose
 public void close(CloseReason c) { . . . }
 
 @javax.websocket.OnError
 public void error(Throwable t) { . . . }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 54. Annotated client endpoint Full-duplex bi-directional communication over single TCP connection @javax.websocket.ClientEndpoint
 public class MyClient {
 @javax.websocket.OnOpen
 public void open(Session session) { … }
 
 // Lifecycle callbacks
 }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 55. Annotated client endpoint Full-duplex bi-directional communication over single TCP connection ContainerProvider
 .getWebSocketContainer()
 .connectToServer(
 MyClient.class, 
 URI.create(ws://. . .));! ! #DV13-UniJavaEE7 @arungupta @agoncal
  • 56. Programmatic endpoints API of rendpoints public class ChatServer extends Endpoint {
 @Override
 public void onOpen(Session s, EndpointConfig ec) {
 s.addMessageHandler(new MessageHandler.WholeString() {
 public void onMessage(String text) { . . . }
 }
 }
 
 @Override
 public void onClose(Session s, CloseReason cr) { . . . }
 
 //. . . 
 }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 57. Programmatic endpoints API of rendpoints public class MyApplicationConfig implements ServerApplicationConfig {
 public SetServerEndpointConfig getEndpointConfigs(…) { ServerEndpointConfig.Builder
 .create(MyEndpoint.class, /websocket”)
 .configurator(new MyConfig())
 .build()
 }
 }! #DV13-UniJavaEE7 
 @arungupta @agoncal
  • 58. Programmatic endpoints API of rendpoints public class MyConfig extends ServerEndpointConfig.Configurator{
 
 public T T getEndpointInstance(. . .) { . . . }
 
 public void modifyHandshake(. . .) { . . . }
 
 . . .
 }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 59. Encoder and Decoder Encodes and decodes messages @javax.websocket.server.ServerEndpoint(
 value=/chat,
 decoders=MyDecoder.class,
 encoders=MyEncoder.class)
 public class ChatServer {
 
 @OnMessage
 public String chat(ChatMessage name, Session session) {
 . . . 
 }
 }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 60. Encoder and Decoder Encodes and decodes messages public class MyDecoder implements Decoder.TextChatMessage {
 public ChatMessage decode(String s) {
 // . . .
 }
 
 public boolean willDecode(String string) {
 // . . .
 }
 
 //. . .
 }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 61. Encoder and Decoder Encodes and decodes messages public class MyEncoder implements Encoder.TextChatMessage {
 
 public String encode(ChatMessage chatMessage) {
 // . . .
 }
 ! // . . .
 }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 62. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 Expression Language 3.0 (JSR 341) 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
  • 63. ELProcessor Use EL in a stand-alone environment ELProcessor el = new ELProcessor();! ! assert ((Integer)el.eval(a = [1, 2]; a[1])) == 2;! ! el.defineBean(employee, new Employee(John));! assert (el.eval(employee.name)).equals(John);! ! #DV13-UniJavaEE7 @arungupta @agoncal
  • 64. Lambda expression Use lambdas before Java SE 8 ELProcessor el = new ELProcessor();! ! assert ((Integer)(el.eval(((x,y) - x+y)(4, 5)))) == 9;! #DV13-UniJavaEE7 @arungupta @agoncal
  • 65. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 JSF 2.2 (JSR 344) 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
  • 66. Faces Flow Package reusable flows in JAR ./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! #DV13-UniJavaEE7 @arungupta @agoncal
  • 67. Faces Flow Use annotations Named
 @FlowScoped(flow1)
 public class Flow1Bean implements Serializable {
 }! ! @Produces @FlowDefinition
 public Flow defineFlow(@FlowBuilderParameter FlowBuilder fb) {
 String flowId = flow1;
 //. . .
 return fb.getFlow();
 }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 68. Faces Flow Use flows in EL #{flowScope}: Local flow storage
 
 #{facesContext.application.flowHandler.currentFlow}: Returns ! true if within a flow! #DV13-UniJavaEE7 @arungupta @agoncal
  • 69. Resource Library Contract Apply templates in a reusable and interchangeable manner 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! #DV13-UniJavaEE7 @arungupta @agoncal
  • 70. Resource Library Contract Apply templates in a reusable and interchangeable manner f:view contracts=”red”
 ui:composition template=/template.xhtml
 . . .
 /ui:composition
 /f:view
 ! #DV13-UniJavaEE7 @arungupta @agoncal
  • 71. Pass-through Attributes HTML5-Friendly Markup h:inputText type=email value=#{user.email}/ 
 ! input type=text name=j_idt6:j_idt10/! ! ! h:inputText p:type=email value=#{user.email}/ 
 
 input type=email name=j_idt6:j_idt10/! #DV13-UniJavaEE7 @arungupta @agoncal
  • 72. File Upload Component Upload files h:form enctype=multipart/form-data
 h:inputFile value=#{fileUploadBean.file}/
 h:commandButton value=Upload/
 /h:form ! ! ! @Named @RequestScoped 
 public class FileUploadBean {
 private Part file;
 
 //getter and setter
 } ! ! #DV13-UniJavaEE7 @arungupta @agoncal
  • 73. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 JAX-RS 2.0 (JSR 339) 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
  • 74. 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).get();! 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);! #DV13-UniJavaEE7 @arungupta @agoncal
  • 75. Async client The client API also supports asynchronous invocation FutureString 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){! ...! }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 76. Async server Asynchronous request processing on the server @Path(/async)! public class AsyncResource {! ! @GET! public void asyncGet(@Suspended AsyncResponse resp){! ! new Thread(new Runnable() {! ! public void run() {! String result = veryExpensiveOperation();! resp.resume(result);! }! }).start();! }}! #DV13-UniJavaEE7 @arungupta @agoncal
  • 77. Message Filter Process incoming/outgoing request/response headers •  Filters on client side •  javax.ws.rs.client.ClientRequestFilter •  javax.ws.rs.client.ClientResponseFilter •  Filters on server side •  javax.ws.rs.container.ContainerRequestFilter •  javax.ws.rs.container.ContainerResponseFilter #DV13-UniJavaEE7 @arungupta @agoncal
  • 78. Message Filter Process incoming/outgoing request/response headers public class LogginFilter implements ClientRequestFilter{! ! public void filter(ClientRequestContext ctx) ... {! System.out.println(ctx.getMethod());! System.out.println(ctx.getUri());! }! }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 79. Entity Interceptors Marshalling and unmarshalling HTTP message bodies •  Intercepts inbound stream (read from the “wire”) •  javax.ws.rs.ext.ReaderInterceptor •  Intercepts outbound stream (written to the “wire”) •  javax.ws.rs.ext.WriterInterceptor #DV13-UniJavaEE7 @arungupta @agoncal
  • 80. Entity Interceptors Marshalling and unmarshalling HTTP message bodies public class ZipInterceptor implements WriterInterceptor{! ! public void aroundWriteTo(WriterInterceptorContext ctx){! OutputStream os = ctx.getOutputStream();! ctx.setOutputStream(new GZIPOutputStream(os));! ctx.proceed();! }! }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 81. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 JSON-P 1.0 (JSR 353) 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
  • 82. JSON Builder Builds an object model 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();! #DV13-UniJavaEE7 @arungupta @agoncal
  • 83. JSON Parser Event-based parser reading 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();! }! }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 84. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 Batch 1.0 (JSR 352) 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
  • 85. Chunk-style Processing Item-oriented Processing Style (primary) #DV13-UniJavaEE7 @arungupta @agoncal
  • 86. Chunk-style Processing Item-oriented Processing Style (primary) 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! }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 87. Batchlet-style Processing Task-oriented processing style step id=”transferFile”! batchlet ref=“MyFileTransfer” /! /step! …implements Batchlet {! @Override
 public void process() {
 // Transfer file! }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 88. Job/Step/Chunk Listeners Listeners job id=myJob xmlns=http://xmlns.jcp.org/xml/ns/javaee ...
 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! ! #DV13-UniJavaEE7 @arungupta @agoncal
  • 90. Job/Step/Chunk Listeners Listeners @Named
 public class MyJobListener extends AbstractJobListener {
 
 @Override
 public void beforeJob() throws Exception { . . . }
 
 @Override
 public void afterJob() throws Exception { . . . }
 }! #DV13-UniJavaEE7 @arungupta @agoncal
  • 91. Partition Partitioning step
 chunk item-count=3
 reader ref=myItemReader
 properties
 property name=start value=#{partitionPlan['start']}/
 property name=end value=#{partitionPlan['end']}/
 /properties 
 /reader
 . . .
 /chunk! #DV13-UniJavaEE7 @arungupta @agoncal
  • 92. Partition Partitioning 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! #DV13-UniJavaEE7 @arungupta @agoncal
  • 93. Creating Workflows Flow: Elements that execute together as a unit flow id=flow1 next=step3
 step id=step1 next=step2 . . . /step
 step id=step2 . . . /step
 /flow
 step id=step3 . . . /step! #DV13-UniJavaEE7 @arungupta @agoncal
  • 94. Creating Workflows Split: Concurrent execution of flows split id=split1 next= . . . 
 flow id=flow1”
 step id=step1” . . . /step
 /flow
 flow id=flow2”
 step id=step2” . . . /step
 /flow
 /split! #DV13-UniJavaEE7 @arungupta @agoncal
  • 95. Creating Workflows Decision: Customized way of sequencing between steps, flows, splits 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 ! ! @Named
 public class MyDecider implements Decider {
 @Override
 public String decide(StepExecution[] ses) throws Exception {
 . . .
 return DATA_LOADED; // or NOT_LOADED! } ! }! ! #DV13-UniJavaEE7 @arungupta @agoncal
  • 96. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 JavaMail 1.5 (JSR 919) 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
  • 97. MailSessionDefinition A mail session can be defined using an annotation @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;! #DV13-UniJavaEE7 @arungupta @agoncal
  • 98. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 JCA 1.7 (JSR 322) 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
  • 99. Connector definition A connector can be defined using an annotation @ConnectionDefinition(! connection=MyConnection.class,! connectionImpl=MyConnectionImpl.class,! connectionFactory=MyConnectionFactory.class,! connectionFactoryImpl=MyConnectionFactoryImpl.class! )! ! @AdministeredObjectDefinition(! className=MyQueueImpl.class,! name=java:comp/MyQueue,! resourceAdapter=myAdapter,! )! #DV13-UniJavaEE7 @arungupta @agoncal
  • 100. CDI 1.1 Bean Validation 1.1 Interceptors 1.2 Concurrency 1.0 Java EE 7 (JSR 342) 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
  • 101. Default Resources Default datasource @Resource(lookup=java:comp/DefaultDataSource)! private DataSource myDS;! ! @Resource! private DataSource myDS; ! #DV13-UniJavaEE7 @arungupta @agoncal
  • 102. Default Resources Default JMS factory @Resource(lookup=java:comp/DefaultJMSConnectionFactory) ! private ConnectionFactory myCF; ! ! @Resource! private ConnectionFactory myCF;! #DV13-UniJavaEE7 @arungupta @agoncal
  • 103. Default Resources Default Concurrency Utilities objects @Resource(lookup=java:comp/DefaultManagedExecutorService) ! private ManagedExecutorService mes; ! @Resource(lookup=java:comp/DefaultManagedScheduledExecutorService) ! private ManagedScheduledExecutorService mses; ! @Resource(lookup=java:comp/DefaultManagedThreadFactory) ! private ManagedThreadFactory mtf; ! @Resource(lookup=java:comp/DefaultContextService) ! private ContextService cs; ! ! @Resource! private ManagedExecutorService mes; ! @Resource! private ManagedScheduledExecutorService mses; ! @Resource! private ManagedThreadFactory mtf; ! @Resource! private ContextService cs; ! #DV13-UniJavaEE7 @arungupta @agoncal
  • 104. New namespaces Bye bye Sun persistence 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! version=2.1! ! web-app xmlns=http://xmlns.jcp.org/xml/ns/javaee! xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance! xsi:schemaLocation=http://xmlns.jcp.org/xml/ns/javaee ! http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd! version=3.1! ! #DV13-UniJavaEE7 @arungupta @agoncal
  • 107. Thank you Arun Gupta Antonio Goncalves #DV13-UniJavaEE7 @arungupta @agoncal