Académique Documents
Professionnel Documents
Culture Documents
0 Technology
Work in Progress
Linda DeMichiel EJB Specification Lead Sun Microsystems java.sun.com/j2ee
1 | 2004 JavaOne Conference | Session TS-1861
SM
java.sun.com/javaone/sf
SM
Agenda Goals of EJB 3.0 Technology Overview of the Simplified EJB API Technology Drill Down Java Metadata Interface Software Session Bean Simplifications Access to the Environment Entity Beans Summary and Current Status Where to Get More Info at JavaOneSM Conference
3 | 2004 JavaOne Conference | Session TS-1861
SM
SM
Focus on most common cases Ensure EJB 2.0/2.1 APIs always available for
more complex scenarios
Simplifications/enhancements to improve use of these APIs as well
5 | 2004 JavaOne Conference | Session TS-1861
SM
SAP: Harald Mueller SAS Institute: Rob Saccoccio SeeBeyond: Ugo Corda Sun Microsystems: Linda DeMichiel Sybase: Evan Ireland Tibco: Shivajee Samdarshi Tmax Soft: JaeW oong Chung, W oo Jin Kim Individuals: David Blevins Scott Crawford Olivier Ihns Richard Monson-Haefel Suneet Shah
Configuration by exception
Specification of defaults, including for metadata Reduce need to specify common, expected behaviors and requirements on container
SM
SM
SM
10
SM
11
SM
Agenda Goals of EJB 3.0 Technology Overview of Simplified EJB API Drill Down Java Metadata Interface Session Bean Simplifications Access to the Environment Entity Beans Summary and Current Status Where to Get More Info at JavaOneSM Conference
12 | 2004 JavaOne Conference | Session TS-1861
SM
Can: generate new files/classes Cannot: alter source files or class files, inject base classes, interfaces, alter bytecodes, etc.
13 | 2004 JavaOne Conference | Session TS-1861
SM
14
Session Beans
15
SM
16
SM
17
18
SM
Create doesnt create Remove doesnt remove javax.ejb.SessionBean methods all unneeded here Add to code clutter Awkward to produce Contains redundant information Structure doesnt conform to that of bean classes Etc.
SM
Deployment descriptor
public int subtract (int a, int b) { return a b; } } public interface Calculator { int add (int a, int b); int subtract (int a, int b); }
20 | 2004 JavaOne Conference | Session TS-1861
SM
21
SM
22
SM
Deployment Descriptor
23
SM
Bean can implement it or it can be generated Bean can have more than one business interface Can support remote access EJB(Local)Object removed from client view RemoteExceptions are removed from programmer and client view
25
SM
interfaces either Stateful Session Bean create is really initialization from programmer's point of view Stateful Session Bean remove is important
However, metadata can be used instead
26
SM
27
Under Evaluation
GenericSessionBean, GenericEntityBean,
Have convenience methods Have callback methods stubbed out More useful for beans written to classic API
28 | 2004 JavaOne Conference | Session TS-1861
SM
Techniques/mechanisms
1) Declarative expression of dependencies in metadata 2) Container injection of resource entries, etc. 3) Simple programmatic lookup mechanisms
Example
@Stateless public class MySessionBean { @Resource(name=myDB) public DataSource customerDB; public void myMethod (String myString){ try { Connection conn = customerDB.getConnection(); ... } catch (Exception ex) {...} } }
30 | 2004 JavaOne Conference | Session TS-1861
SM
@Inject
@Stateless public class MySessionBean { private DataSource customerDB; @Inject public void setCustomerDB(DataSource customerDB) { this.customerDB = customerDB; } public void myMethod (String myString){ ... Connection conn = customerDB.getConnection(); ... }
32 | 2004 JavaOne Conference | Session TS-1861
SM
Injection
33
Dynamic Lookup
Adding lookup() method to ejbContext Can use injection to get ejbContext Useful for stateful session beans
... @Inject private void setSessionContext(SessionContext ctx) { this.ctx = ctx; } ... myShoppingCart = (ShoppingCart)ctx.lookup (shoppingCart);
34 | 2004 JavaOne Conference | Session TS-1861
SM
Client View
Homes eliminated
With metadata, injection, easy lookup(), etc., Homes not needed for session beans (either stateless or stateful) Stateless SessionBean homes not very useful anyway
35
SM
Make instances usable outside the container Facilitate testability Remove need for data transfer objects (DTOs) BMP currently a non-goal
Will probably get minor improvements: use of metadata, etc.
Looked at options and technologies Sorted out priorities Identified items that most need fixed
Complexity Lack of testability outside the container Need for improved modelingand querying capabilities DTO issues
37
SM
38
SM
No exposure of instance variables outside bean class Use Collection interfaces for relationships Usable outside the EJB container
Means we needed to sacrifice CMRs
39 | 2004 JavaOne Conference | Session TS-1861
SM
Lifecycle Operations
Lifecycle operations
new() create() remove() Detached instances
instances that exist outside of original transaction context serialized to other tiers merge() merges them back
40 | 2004 JavaOne Conference | Session TS-1861
SM
42
SM
43
SM
Client View
@Stateless public class OrderEntryBean { private EntityManager em; @Inject void setEntityManager(EntityManager em) { this.em = em; } public void enterOrder(int custID, Order newOrder){ Customer c = em.find(Customer, custID); c.getOrders().add(newOrder); newOrder.setCustomer(c); } // other business methods }
SM
44
EJB QL Enhancements
Bulk update and delete operations Projection list (SELECT clause) Group by, Having Subqueries (correlated and not) Additional SQL functions
UPPER, LOWER, TRIM, CURRENT_DATE, ...
45
SM
46
SM
EJB 3.0 Technology and Its Implications for EJB Technology Evolution
47
POJO-centric view of all enterprise beans POJIs required for session beans only Simplification of environment access Simplification of entity beans
Clear O/R mapping orientation Improvement of query language capabilities
Metadata is major enabling technology Interesting implications for the future Specification Early Draft is now available
48 | 2004 JavaOne Conference | Session TS-1861
SM
TS-2836
EJB 3.0: Simplifying and Enhancing the Persistence Model TS-2836 will also cover the new query language features weve added
BOF-1864
Enterprise JavaBeans 3.0 Technology Community Discussion Come and meet members of the EJB 3.0 Technology Expert Group
49
SM
Q&A
50 | 2004 JavaOne Conference | Session TS-1861
SM
java.sun.com/javaone/sf