New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business...

23
© 2010 Infosys Technologies Limited New Features in EJB 3.1 Sangeetha S E-Commerce Research Labs, Infosys Technologies Limited

Transcript of New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business...

Page 1: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited© 2010 Infosys Technologies Limited

New Features in EJB 3.1

Sangeetha S

E-Commerce Research Labs,

Infosys Technologies Limited

Page 2: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited

Agenda

• New Features in EJB 3.1• No Interface View• EJB Components in WAR• Singleton Beans• Asynchronous Session Bean• EJB Lite• Embeddable EJB

2

Page 3: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited

Enterprise JavaBeans

• Enterprise JavaBeans• Server side component technology• For creating, deploying, managing• Server side business components• That are highly scalable, transactional and multi-user secure….

3

Page 4: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited

EJB History

4

1992

1994

1996

1998

2000

2002

2004

2006

2008

2010

EJB 1.0 EJB 1.1 EJB 2.0 EJB 2.1 EJB 3.0 EJB 3.1

19981999

2001

2003

2006

2009

Specification Release Date

Page 5: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited

EJB 3.1 – New Features

• Simplified Local View – No Local Business interface• EJB Components in WAR file• Embeddable EJB API• Singleton Session Bean• Asynchronous Session Bean• EJB Lite• Update to EJB Timer service• Portable global JNDI syntax

5

Page 6: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited© 2010 Infosys Technologies Limited

EJB 3.1 – No Interface View

Page 7: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited

Removal of Local Business Interface

• Optional Business Interfaces• Session Beans are simple POJO like Message Driven Beans and JPA entities

@Statelesspublic class StockBean {

public double getStockPrice(String symbol) { if (symbol.equals(“INFY")) {

return 66.4; } if (symbol.equals(“ORCL")) {

return 28.7; } return 0.0; }

}

7

Page 8: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited© 2010 Infosys Technologies Limited

EJB 3.1 – EJB Components in WAR

Page 9: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited

EJB 3.0 – Packaging Structure

9

Page 10: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited

EJB 3.1 – Packaging Structure

• Simplified packaging mechanism for web applications including EJBs• EJB components can be directly placed in the WAR file (No need for creating

separate JAR file)• EJB components are placed under \WEB-INF\Classes directory along with

Servlet Classes in WAR file

10

Page 11: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited

EJB 3.1 – Packaging Structure

11

Page 12: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited© 2010 Infosys Technologies Limited

EJB 3.1 – Singleton Beans

Page 13: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited

Singleton Beans

• New type of bean, introduced from this release• Enables application wide data sharing and supports concurrent access• For Singleton beans, container guarantees a single instance per JVM• Singleton beans are POJOs, marked with @Singleton annotation (can be

marked as Singleton in deployment descriptor also…)• Like Stateless, but not pooled

@Singleton public class AccessCountBean { private int accessCount; public int getAccessCount() {

return accessCount++; } public void setAccessCount(int accessCount){

this.accessCount = accessCount; }}

13

Page 14: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited

Concurrency Support

• Provides flexible concurrency option• Concurrency

• Container managed - @ConcurrencyManagement(CONTAINER)• Bean managed - @ConcurrencyManagement(BEAN)

• Concurrency annotations for READ and WRITE operations• @Lock(READ)• @Lock(WRITE) @Singleton

public class AccessCountBean { private int accessCount;@Lock(READ) public int getAccessCount() {

return accessCount++; } @Lock(WRITE)public void setAccessCount(int accessCount){

this.accessCount = accessCount; }}

14

Page 15: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited© 2010 Infosys Technologies Limited

EJB 3.1 – Asynchronous Session Bean

Page 16: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited

Asynchronous Session Bean

• EJB 3.1 supports ‘Asynchronous Session Bean’• Session bean methods supports ‘Asynchronous’ invocations• Bean methods are marked with @Asynchronous annotation• Might have a return value or void• Return value is Future<V> object of the java.util.concurrent PI

public interface StockIntf {@AsynchronousFuture<Double> getRecentStock();

}

@Statelesspublic class StockDetails {

public Double getRecentStock();}

16

Page 17: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited© 2010 Infosys Technologies Limited

EJB 3.1 – EJB Lite

Page 18: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited

EJB Lite

• Minimal subset of EJB 3.1• Simple, lightweight and powerful• Applications created using EJB Lite can be deployed on any server that

supports EJB – EJB Full or EJB Lite• Has the following features:

• Session bean components• Stateless, Stateful and Singleton

• Supports only synchronous invocation• Transaction

• Container-managed as well as Bean-managed

• Security• Declarative as well as Programmatic

• Interceptors• Support for deployment descriptor (ejb-jar.xml)

18

Page 19: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited

EJB Full Vs EJB Lite

19

Page 20: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited© 2010 Infosys Technologies Limited

EJB 3.1 – Embeddable EJB

Page 21: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited

Embeddable EJB

• EJB 3.1 allows EJB to run in Java SE environment• Client and EJB run by the same JVM• Possible with the help of Embeddable EJB APIs and Embeddable EJB

container• Benefits:

• Better support for testing• Batch processing• Usage of EJB programming model in desktop applications

21

Page 22: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited

Resources

• EJB 3.1: The EJB Application Gets Simpler, More Flexible• http://www.developer.com/features/article.php/52691_3881841_1/EJB-

31-The-EJB-Application-Gets-Simpler-More-Flexible.htm

22

Page 23: New Features in EJB 3 · EJB 3.1 – New Features • Simplified Local View – No Local Business interface • EJB Components in WAR file • Embeddable EJB API • Singleton Session

© 2009 Infosys Technologies Limited© 2010 Infosys Technologies Limited

Thank You!