From J2EE to Java EE
       Filippo Diotalevi
     http://www.diotalevi.com
   filippo.diotalevi@jugmilano.it




        ...
Summary
       “... from J2ee to S+H, and back to Java EE..”


2001     2002    2003 2004      2005      2006 2007 ..........
Core J2ee Patterns - 2001-2003

The 'reference architecture'
for J2EE applications


Collection of patterns for
the develo...
Did you say...



Patterns?
       From J2EE to Java EE Tour – Jug Prague
Did you say... patterns?




          From J2EE to Java EE Tour – Jug Prague
Core J2ee Patterns – Web Tier
                                     Client


                                 Intercepting ...
Core J2ee Patterns – Business & Int. Tier


  Action
                       Delegate
 Controller
                         ...
Core J2ee Patterns – Technology mappings
 Service delegates   POJO

 Session Facades     Session Stateless Bean

 Services...
Core J2ee Patterns – Why?

• Business Delegate: reduce coupling between presentation-tier
and business services

• Session...
Core J2ee Patterns – Pros & Cons




              From J2EE to Java EE Tour – Jug Prague
Core J2ee Patterns – Pros & Cons

Pros:
• Standard based
• Decoupled architecture
• Easy to split work between team member...
Core J2ee Patterns – Pros & Cons




              From J2EE to Java EE Tour – Jug Prague
Core J2ee Patterns – Pros & Cons

Cons:
• Complex
• Verbouse
• Can be inefficient
• Complex
• Did I say,, complex?

      ...
2004-2006: “J2EE development without EJB”?!?!




                    From J2EE to Java EE Tour – Jug Prague
2004-2006: “J2EE development without EJB”?!?!




                    From J2EE to Java EE Tour – Jug Prague
2004-2006: The “Spring+Hibernate revolution”




     Powerful JavaBeans-based configuration
     management, applying Inv...
2004-2006: The “Spring+Hibernate revolution”




.. an object-relational mapping (ORM) solution
for the Java language...

...
2004-2006: The “Spring+Hibernate revolution”




    Mix together
                    From J2EE to Java EE Tour – Jug Prague
2004-2006: The “Spring+Hibernate revolution”


1/3 – Your favourite web framework
1/3 – Spring Framework
1/3 – Hibernate
S...
Spring+Hibernate based architectures
Your favourite          Service Layer          Integration Layer
Web Framework
here (...
Pojo in action
public class PersonHibernateDAO extends HibernateDaoSupport implements PersonDAO {

    public List listDoc...
Dependy injection in action
<bean id=quot;personDAOquot; class=quot;com.pnetx.pulse.dao.hibernate.PersonHibernateDAOquot;>...
S+H Architecture – Pros & Cons




             From J2EE to Java EE Tour – Jug Prague
S+H Architecture – Pros & Cons

Pros:
• Really decoupled architecture
• Lightweight (less patterns, less infrastructure)
•...
S+H Architecture – Pros & Cons




             From J2EE to Java EE Tour – Jug Prague
S+H Architecture – Pros & Cons

Cons:
• Non-standard
• Less documented




              From J2EE to Java EE Tour – Jug P...
Java EE 5
Crash Course
     From J2EE to Java EE Tour – Jug Prague
JavaEE5 Crash Course – 0' 00''


Java EE 5 released on May 2006
  Mantra: “EOD – Easy of Development”



                 ...
JavaEE5 Crash Course – 0' 29''




    POJO
             From J2EE to Java EE Tour – Jug Prague
JavaEE5 Crash Course – 1' 12''



Annotations
              From J2EE to Java EE Tour – Jug Prague
JavaEE5 Crash Course – 2' 07''


 Resource
 injection
             From J2EE to Java EE Tour – Jug Prague
JavaEE5 Crash Course – 2' 59''
EJB 3:

• POJO Implementation
• POJI Business Interface
• Annotations
• “Configuration by e...
JavaEE5 Crash Course – 4'59''
EJB 3:

@Stateless
@Stateful
@Entity
@MessageDriven
                 From J2EE to Java EE To...
JavaEE5 Crash Course – 5'34''

Java Persistence API:
• EntityManager API
• EJB QL
• Query API


             From J2EE to ...
JavaEE5 Crash Course – 6'31''
• Java Persistence API (JSR-220)
• EJB 3.0 (JSR-220)
• JavaServer Faces 1.2 (JSR-252)
• JSP ...
Java EE 5 Architecture


• Inspired by S+H Architecture
• Uses EJB 3.0 and dependency injection
• All standard based



  ...
A reference architecture for Java EE 5

                                   Dependency injection


                        ...
Services
@Stateless
public class PageManagerImplementation implements PageManager {
       @EJB public PageDao dao;
      ...
Entities
@Entity
public class Page implements Serializable{
    private String title, content;
    private Date lastModifi...
DAOs
@Stateless
public class PageDaoImplementation implements PageDao {
    @PersistenceContext EntityManager entityManage...
Delegates?
Java EE 5 dependency injection is less
powerful and flexible than Spring d.i.
    Dependency injection can only...
@Questions?




 Thank you!
    From J2EE to Java EE Tour – Jug Prague
References
• JSR 220: Enterprise JavaBeansTM 3.0
http://www.jcp.org/en/jsr/detail?id=220
• Glassfish website and documenta...
Filippo Diotalevi
  http://www.diotalevi.com
filippo.diotalevi@jugmilano.it




              From J2EE to Java EE Tour – ...
From J2EE To Java EE (Jug Praga. Nov. 2006)
Upcoming SlideShare
Loading in …5
×

From J2EE To Java EE (Jug Praga. Nov. 2006)

7,659 views

Published on

new features of JavaEE 5, how to migrate from J2EE 1.4 to Java EE 5

Published in: Business, Technology
1 Comment
14 Likes
Statistics
Notes
No Downloads
Views
Total views
7,659
On SlideShare
0
From Embeds
0
Number of Embeds
120
Actions
Shares
0
Downloads
770
Comments
1
Likes
14
Embeds 0
No embeds

No notes for slide

From J2EE To Java EE (Jug Praga. Nov. 2006)

  1. 1. From J2EE to Java EE Filippo Diotalevi http://www.diotalevi.com filippo.diotalevi@jugmilano.it Novermber 23rd, 2006
  2. 2. Summary “... from J2ee to S+H, and back to Java EE..” 2001 2002 2003 2004 2005 2006 2007 ....... Java EE reference architecture? From J2EE to Java EE Tour – Jug Prague
  3. 3. Core J2ee Patterns - 2001-2003 The 'reference architecture' for J2EE applications Collection of patterns for the development of enterprise applications From J2EE to Java EE Tour – Jug Prague
  4. 4. Did you say... Patterns? From J2EE to Java EE Tour – Jug Prague
  5. 5. Did you say... patterns? From J2EE to Java EE Tour – Jug Prague
  6. 6. Core J2ee Patterns – Web Tier Client Intercepting Filters Front uses uses View Action Controller Controller Controller creates uses uses Context Object Taken from “Pattern per lo sviluppo di applicazioni J2ee”, Filippo Diotalevi, Webbit 2004 From J2EE to Java EE Tour – Jug Prague
  7. 7. Core J2ee Patterns – Business & Int. Tier Action Delegate Controller BO Service BO Service Facade DAO Context Object Locator BO DAO Facade BO DAO Service Delegate Action Dati ontroller Taken from “Pattern per lo sviluppo di applicazioni J2ee”, Filippo Diotalevi, Webbit 2004 From J2EE to Java EE Tour – Jug Prague
  8. 8. Core J2ee Patterns – Technology mappings Service delegates POJO Session Facades Session Stateless Bean Services Session Stateless Bean Persistence Entity Beans Service Locators JNDI From J2EE to Java EE Tour – Jug Prague
  9. 9. Core J2ee Patterns – Why? • Business Delegate: reduce coupling between presentation-tier and business services • Session Facade: encapsulate the complexity of interactions between the business objects participating in a workflow. The S.F. provides a uniform coarse-grained service access layer to clients • ServiceLocator: abstract all JNDI usage and to hide the complexities of initial context creation, EJB home object lookup, and EJB object re-creation From J2EE to Java EE Tour – Jug Prague
  10. 10. Core J2ee Patterns – Pros & Cons From J2EE to Java EE Tour – Jug Prague
  11. 11. Core J2ee Patterns – Pros & Cons Pros: • Standard based • Decoupled architecture • Easy to split work between team members • Highly documented From J2EE to Java EE Tour – Jug Prague
  12. 12. Core J2ee Patterns – Pros & Cons From J2EE to Java EE Tour – Jug Prague
  13. 13. Core J2ee Patterns – Pros & Cons Cons: • Complex • Verbouse • Can be inefficient • Complex • Did I say,, complex? From J2EE to Java EE Tour – Jug Prague
  14. 14. 2004-2006: “J2EE development without EJB”?!?! From J2EE to Java EE Tour – Jug Prague
  15. 15. 2004-2006: “J2EE development without EJB”?!?! From J2EE to Java EE Tour – Jug Prague
  16. 16. 2004-2006: The “Spring+Hibernate revolution” Powerful JavaBeans-based configuration management, applying Inversion-of- Control (IoC) principles From J2EE to Java EE Tour – Jug Prague
  17. 17. 2004-2006: The “Spring+Hibernate revolution” .. an object-relational mapping (ORM) solution for the Java language... From J2EE to Java EE Tour – Jug Prague
  18. 18. 2004-2006: The “Spring+Hibernate revolution” Mix together From J2EE to Java EE Tour – Jug Prague
  19. 19. 2004-2006: The “Spring+Hibernate revolution” 1/3 – Your favourite web framework 1/3 – Spring Framework 1/3 – Hibernate Simple, efficient and flexible architecture From J2EE to Java EE Tour – Jug Prague
  20. 20. Spring+Hibernate based architectures Your favourite Service Layer Integration Layer Web Framework here (es. Struts) Dependency injection Dependency injection Action Service DAO Dependency injection Dependency injection Action Service DAO From J2EE to Java EE Tour – Jug Prague
  21. 21. Pojo in action public class PersonHibernateDAO extends HibernateDaoSupport implements PersonDAO { public List listDocuments() { return this.getHibernateTemplate() .find(quot;from com.myapp.domain.Document order by codequot;); } public void deletePerson(Person person) { this.getHibernateTemplate().delete(person); } .... } public class TaxServiceImpl implements TaxService { private PersonDAO personDAO; public PersonDAO getPersonDAO() { return personDAO; } public void setPersonDAO(PersonDAO personDAO) { this.personDAO = personDAO; } public List findStudents(TaxStudentQueryParams params) { ...... From J2EE to Java EE Tour – Jug Prague
  22. 22. Dependy injection in action <bean id=quot;personDAOquot; class=quot;com.pnetx.pulse.dao.hibernate.PersonHibernateDAOquot;> <property name=quot;sessionFactoryquot;> <ref bean=quot;sessionFactoryquot;/> </property> </bean> <bean id=quot;taxServiceTargetquot; class=quot;com.pnetx.pulse.spring.services.TaxServiceImplquot;> <property name=quot;taxDAOquot;> <ref bean=quot;taxDAOquot;/> </property> <property name=quot;personDAOquot;> <ref bean=quot;personDAOquot;/> </property> <property name=quot;academicSemesterDAOquot;> <ref bean=quot;academicSemesterDAOquot;/> </property> <property name=quot;userManagerquot;> <ref bean=quot;userManagerquot;/> </property> </bean> From J2EE to Java EE Tour – Jug Prague
  23. 23. S+H Architecture – Pros & Cons From J2EE to Java EE Tour – Jug Prague
  24. 24. S+H Architecture – Pros & Cons Pros: • Really decoupled architecture • Lightweight (less patterns, less infrastructure) • Really powerful • Simple (see projects Appfuse or Equinox) From J2EE to Java EE Tour – Jug Prague
  25. 25. S+H Architecture – Pros & Cons From J2EE to Java EE Tour – Jug Prague
  26. 26. S+H Architecture – Pros & Cons Cons: • Non-standard • Less documented From J2EE to Java EE Tour – Jug Prague
  27. 27. Java EE 5 Crash Course From J2EE to Java EE Tour – Jug Prague
  28. 28. JavaEE5 Crash Course – 0' 00'' Java EE 5 released on May 2006 Mantra: “EOD – Easy of Development” From J2EE to Java EE Tour – Jug Prague
  29. 29. JavaEE5 Crash Course – 0' 29'' POJO From J2EE to Java EE Tour – Jug Prague
  30. 30. JavaEE5 Crash Course – 1' 12'' Annotations From J2EE to Java EE Tour – Jug Prague
  31. 31. JavaEE5 Crash Course – 2' 07'' Resource injection From J2EE to Java EE Tour – Jug Prague
  32. 32. JavaEE5 Crash Course – 2' 59'' EJB 3: • POJO Implementation • POJI Business Interface • Annotations • “Configuration by exception” • Java Persistence API • No more Home interfaces! From J2EE to Java EE Tour – Jug Prague
  33. 33. JavaEE5 Crash Course – 4'59'' EJB 3: @Stateless @Stateful @Entity @MessageDriven From J2EE to Java EE Tour – Jug Prague
  34. 34. JavaEE5 Crash Course – 5'34'' Java Persistence API: • EntityManager API • EJB QL • Query API From J2EE to Java EE Tour – Jug Prague
  35. 35. JavaEE5 Crash Course – 6'31'' • Java Persistence API (JSR-220) • EJB 3.0 (JSR-220) • JavaServer Faces 1.2 (JSR-252) • JSP 2.1 (JSR-245) • JAX-WS 2.0 (JSR-224) • JAXB 2.0(JSR-222) • Common Annotations (JSR-250) • StAX (JSR-173) From J2EE to Java EE Tour – Jug Prague
  36. 36. Java EE 5 Architecture • Inspired by S+H Architecture • Uses EJB 3.0 and dependency injection • All standard based From J2EE to Java EE Tour – Jug Prague
  37. 37. A reference architecture for Java EE 5 Dependency injection Service Delegate BO Data Access Object Put your DBA Service Delegate favourite web Data Access BO Object framework here Delegate Service Stateless NE W! Session Bean Stateless Entity JPA Session Bean From J2EE to Java EE Tour – Jug Prague
  38. 38. Services @Stateless public class PageManagerImplementation implements PageManager { @EJB public PageDao dao; public void save(Page pagina) { pagina.setLastModified(new Date()); dao.save(pagina); @Local } public interface PageManager //.. { } public void save(Page pagina); //.. } From J2EE to Java EE Tour – Jug Prague
  39. 39. Entities @Entity public class Page implements Serializable{ private String title, content; private Date lastModified; @Id public String getTitle() { return title; } @Temporal(TemporalType.DATE) public Date getLastModified() { return lastModified; } public String getContent() { return content; } //... setters and other methods follow... } From J2EE to Java EE Tour – Jug Prague
  40. 40. DAOs @Stateless public class PageDaoImplementation implements PageDao { @PersistenceContext EntityManager entityManager; public void save(Page pagina) { entityManager.merge(pagina); } //... public interface PaginaDao { } public void salva(Pagina pagina); //... } From J2EE to Java EE Tour – Jug Prague
  41. 41. Delegates? Java EE 5 dependency injection is less powerful and flexible than Spring d.i. Dependency injection can only be used by managed classes Use Spring to manage EJB services and inject them in the front end Ref. http://forum.springframework.org/archive/index.php/t-19669.html From J2EE to Java EE Tour – Jug Prague
  42. 42. @Questions? Thank you! From J2EE to Java EE Tour – Jug Prague
  43. 43. References • JSR 220: Enterprise JavaBeansTM 3.0 http://www.jcp.org/en/jsr/detail?id=220 • Glassfish website and documentation https://glassfish.dev.java.net • JBoss website and documentation http://www.jboss.org • Gavin King's “Entity Beans in EJB 3” http://hibernate.org/gavin/ebejb3.pdf • Kenneth Saks “Enterprise Java Bean 3.0” http://www.javasig.com/Archive/lectures/JavaSIG-EJB30.pdf • Filippo Diotalevi's “Java EE 5 – Step by Step” http://www.diotalevi.com/weblog/?page_id=125 From J2EE to Java EE Tour – Jug Prague
  44. 44. Filippo Diotalevi http://www.diotalevi.com filippo.diotalevi@jugmilano.it From J2EE to Java EE Tour – Jug Prague

×