JavaEE Spring Seam

download JavaEE Spring Seam

If you can't read please download the document

description

comparing and application build using JavaEE, Java EE with Spring, or JavaEE with SEAM

Transcript of JavaEE Spring Seam

  • 1. JavaEE with Spring or Seam Carol McDonald, Java Architect

2. About the Speaker

  • CarolcDonald:
    • Java Architect at Sun Microsystems
    • Before Sun, worked on software development of:
      • Application tomanage car LoansforToyota(>10 million loans)
      • PharmaceuticalIntranet apps( RocheSwitzerland)
      • TelecomNetwork Mgmtapp ( DigitalFrance)
      • X.400Email Server( IBMGermany)

3. Agenda

  • Look at a sample application built 3 ways:
  • using Java EE,
  • Java EE and Spring,
  • Java EE and Seam
  • all running on Glassfish

4. Sample Application 5. Catalog Java EEApplication

      • Persistence JPA Entities

DB Registration Application Managed Bean JSF Components Session Bean Entity Class Catalog Item ManagedBean 6. JPA Unifying/Standardizing Persistence

  • Based on existing successful technologies:
    • TopLink, Hibernate, Kodo, Java Data Object s, etc.
    • Onecommon APIfor all majorORMframeworks
    • Standardizedannotations @andXML
      • xml for mapping is optional
    • Support forpluggable3 rdpartyPersistence provider s

7. JPA: Simplifying/Unifying/Standardizing Persistence

  • POJObased programming/persistence model
    • Simple Java classes notEJB components
      • Can be used inJava SE ,weborEJB -based applications
      • No need forD ataT ransferO bjects
      • Facilitatestestability
  • Simpler and easier:
    • Mostconfigurationisdefaulted configure by exception only (configure only to override default)

8. Entity Annotated as Entity @Id denotes primary key Getters/setters to access state @Entity public class Item implements Serializable { @Idprotected Long id; private String name; private BigDecimal price; public Item() {} public Long getId() {return id;} public String getName() {return name;} public void setName(String name) {this.name = name;} public String getPrice() {return price;} public void setPrice( BigDecimalname){this.price=price;} } 9. Simple Mapping Mapping defaultsto matchingcolumn name . Onlyconfigure ifentity field and table column names aredifferent public class Item {int id; String name;String description; String url ; } @Entity @Column(name=DESC) @Id Item ID NAME DESC URL 10. Relationships JPA Standardized O/R Mapping

  • Standardized o bject/ r elationalm apping
    • annotations to specify how tomapattributes toDB
      • xml for mapping is optional
    • Mostconfigurationisdefaulted

Relationships 11. Relationship Mappings OneToMany Bidirectional public classProduct{ int id; ... Collection items; } public classItem{ int id; ... Product product; } @Entity @Entity @OneToMany( mappedBy = product ) @ManyToOne @Id @Id 1 n has to saywhere the foreign key isusingmappedBy Item ID PROD_ID PRODUCT ID . . . 12. PersistenceContext EntityManager persist() remove() refresh() merge() find() createQuery() createNamedQuery() contains() flush() EntityManagerAPI to manipulate entities Set of managed entities Interface thru which applications interact with the entities and the persistence engine Servlets EJBs Java app 13. How Does it Work? Entity Manager

  • EntityManagerAPI to manipulate entities
  • stores/retrievesentities in DB:
    • UseEntityManager methodstopersist, update, deletedata
      • em. persist (p);em. merge (p);em. find (p.class, id); ; em. remove (p);
    • Queryusing EJB QL or SQL
      • List listP =em. createQuery (select p from Passenger p) .getResultList ();

14. Persistence Context

  • ~HashMap ofManaged Entityobjects
    • first-levelcache
    • holds (at most)onein-memoryEntity for eachdatabase row
    • can dodirty checkingof objects andwrite SQL as lateas possible (automatic or manual flushing)
  • The Persistence Context has ascope, for EJBs:
    • default : same scope as the systemtransaction(JTA)
    • extended : the PC is bound to a stateful session bean

15. Declarative Transaction Management Example TX_REQUIRED TX_REQUIRED TX_REQUIRED PC PC PC Session Facade Inventory Service Order Service Check Out 1. Update Inventory New Persistence Context Persistence ContextPropagated Transaction Attributes 2. Create Order 16. Persistence Context- Transactional vs. Extended @Stateless public class OrderSessionStateless implements OrderService { @PersistenceContext(unitName=java_one) EntityManager em;public voidaddLineItem (OrderLineItem li){// First, look up the order. Order order = em.find(Order.class, orderID); order.lineItems.add(li); } @Stateful public class OrderSessionStateful implements OrderService { @PersistenceContext(type = PersistenceContextType. EXTENDED )) EntityManager em; // Order is a member variable Loaded from the db in lookupOrder Order order public voidaddLineItem (OrderLineItem li){ // No em.find invoked for the order objectorder.lineItems.add(li); } 17. Catalog Java EEApplication

      • Stateless Session EJB

DB Registration Application Managed Bean JSF Components Session Bean Entity Class Catalog Item ManagedBean 18. Business Interface

  • public interfaceCatalogService{
  • public Item getItem(String itemID);
  • public int getItemCount();
  • public ListgetItems (int firstItem,
        • int batchSize );
  • }

CatalogServiceBusiness Interface 19. Catalog Stateless Session EJB, JPA Query@Stateless public classCatalogimplementsCatalogService{ @PersistenceContext(unitName=PetCatalogPu) EntityManager em; @TransactionAttribute(NOT_SUPPORTED) public ListgetItems (intfirstItem , intbatchSize ) {Queryq =em . createQuery (" select i from Item as i ");q. setMaxResults ( batchSize ); q. setFirstResult ( firstItem ); List items= q.getResultList(); return items;} } 20. Java EE: Dependency Injection

  • DependencyInjection =Inversion of Control
  • Don't call us, we'll call you(Hollywood Principle)
    • Beanspecifies what itneedsthrough@
  • References to resourcesareinjectedwhen instance is constructed:
    • @Resource :for connection factories, EJBContext,UserTransaction , etc.
    • @EJB:For EJB References
    • @PersistenceContext:For container-managedEntityManager
    • @PersistenceUnit :For EntityManagerFactory

21. Agenda

  • Catalog Java EE Application
    • JSF

22. JSFComponent, EventDrivenWeb Framework

  • Pages composed ofserver side components

View Root Form id=guess Managed Bean getUserNumber() setUserNumber(..) guess() Business Service guess()

    • Eventscall ManagedBean methods

UIIputid=guessNum UICommandid=submit 23. What is a JSF UI Component? Some Standard Components 24. Some Open Source UI Components 25. UI Components

    • So... what is a UI component?
      • To a page author XML tag (JSP or Facelets)
      • To a component author component class and renderer

maintains component state, processes input renders a user interface Component Class XML Tag Renderer 26. JSF Web FrameworkView Controller Model Request ServiceInterface Events 27. Catalog Java EEApplication

      • JSF components and Managed Bean

DB Registration Application Managed Bean JSF Components Session Bean Entity Class Catalog Item ManagedBean 28. List ItemspageData Table 29. list.jsp

  • h: outputTextvalue="Name"/>
  • h: outputText value =" Photo "/>
  • < h: graphicImage url ="#{ dataTableItem.imagethumburl }"/>
  • h: outputText value =" Price "/>

30. Binding UI to Managed Bean

  • list.jsp
    • value ="#{ itemController .items }"
  • faces-config.xml
  • < managed-bean-name >
  • itemController
  • < managed-bean-class >
  • package. ItemController
    • session

ItemController.java public classItemController ... public longgetItems(){

    • JSP, JSF
    • Expression
    • Language

Managed Bean property 31. Managed Bean Value Binding

  • UI Outputcomponentvalue attribute:
    • The propertygetteris invoked when the component isrendered
    • The propertysetteris invoked when the componentinputis processed

GET SET 32. list.jspPage < h:dataTablevalue='#{ itemController.items }'var=' dataTableItem '> value='Name'/> < h:commandLinkaction='#{item.detailSetup}' value='#{ dataTableItem .name}'/> ... < h:graphicImageurl='#{ dataTableItem .imagethumburl}'/> ... < h:outputTextvalue='#{ dataTableItem .price}'/> ... 33. UIComponents Bindingto a Managed Bean

  • public classItemController {
  • private DataModel model ;
  • DataModelgetItems(){
  • . . .
  • return model;
  • }
  • . . .
  • }

Managed Bean property Managed Bean

    • dataTable
  • useful to show aCollectionin atable
  • binding toDataModelwhich wraps
  • a collectionof data objects

Client Server A B C Backing Bean Form c1 A c2 B c3 C c1 c2 c3 A B C Page 34. Managed Bean: ItemController

  • importjavax.faces.model.DataModel ;
  • import javax.faces.model.ListDataModel;
  • public class ItemController {
  • privateDataModelmodel;
  • private intbatchSize= 10;
  • private intfirstItem= 0;
  • @EJBprivateCatalogService catalog ;
  • publicDataModel getItems(){
  • model = newListDataModel (
      • catalog.getItems( firstItem,batchSize) ;
  • return model;
  • }
  • . . .
    • dataTable binds to aDataModel
  • which wraps Collection of data objects

35. Catalog Stateless Session EJB@Stateless public class Catalog implements CatalogService { @PersistenceContext(unitName=PetCatalogPu) EntityManager entityManager; @TransactionAttribute(NOT_SUPPORTED) public ListgetItems (int firstItem, int batchSize) {Queryq = em. createQuery (" select i from Item as i ");q. setMaxResults (batchSize); q. setFirstResult (firstItem); List items= q.getResultList(); return items;} } 36. Relationship Between Objects getItems() viaEntityBean 1 m #{itemController.items} Item Entity Product Entity Catalog StatelessSB Item Controller list.jsp 37. List ItemspageLink to see Item Details JSF is event-driven,listens for actions 38. list.jsp

  • h: outputText value=" Name "/>
  • value ="#{ dataTableItem.name }"/>
  • h: outputText value =" Photo "/>
  • < h: graphicImage url ="#{ dataTableItem.imagethumburl }"/>
  • h: outputText value =" Price "/>

Click causes Action Event JSF is event-driven,listens for actions 39.

    • JSF controller handles action events, such as submitting a form or linking to another page.

JSF Standard request processing lifecycle Request Restore View Response Render Response Apply Request Values Invoke Application Update Model Values Process Validations

    • action events

JSF is event-driven,listens for actions 40. JSF Actions

    • CommandAction: Refers to a backingbean methodthat performsnavigation processingand returns a logicaloutcomeString
  • public class ItemController {
  • privateItem item ;
  • private DataModelmodel ;
  • public ItemgetItem(){
  • return item;
  • }
  • public StringdetailSetup(){
  • item = (Item) model.getRowData();
  • return " item_detail ";
  • }

41. Navigation Example from-view to-view from-outcome list.jsp new_usr.jsp error.jsp error.jsp detail.jsp item_detail new user error 42. Navigation

    • < from-view -id> /list.jsp
    • < from-outcome > item_detail
    • < to-view -id> /detail.jsp
    • . . .

< h: commandLink action ="#{ itemController.detailSetup } /> 43. Standard request processing lifecycle JavaServer Faces Lifecycle Request Restore View Response Render Response Apply Request Values Invoke Application Update Model Values Process Validations 44. Item Detail Page 45. detail.jsp

  • . . .

Calls itemController.getItem().getName() 46. UIOutput component value attribute

  • public class ItemController {
  • privateItem item ;
  • private DataModelmodel ;
  • public ItemgetItem(){
  • return item;
  • }
  • public StringdetailSetup(){
  • item = (Item) model.getRowData();
  • return " item_detail ";
  • }

Calls itemController.getItem().getName() 47. Get Next List of Itemspage 48. Invoke Application Phase

    • UICommandAction: Refers to a backingbean methodthat performsnavigation processingand returns a logicaloutcomeString
  • public class ItemController {
  • public Stringnext(){
  • if (firstItem + batchSize < itemCount) {
  • firstItem += batchSize;
  • }
  • return " item_list ";
  • }

49. Navigation

    • < from-outcome > item_list
    • < to-view -id> /list.jsp
    • . . .

< h: commandLink action ="#{ itemController.next } /> 50. Standard request processing lifecycle JavaServer Faces Lifecycle Request Restore View Response Render Response Apply Request Values Invoke Application Update Model Values Process Validations 51.

  • h: outputText value=" Name "/>
  • h: outputText value =" Photo "/>
  • < h: graphicImage url ="#{ dataTableItem .imagethumburl }"/>
  • h: outputText value =" Price "/>

Render Will call getItems() which will display next items 52. GlassFish Application Server

  • Java EE 5, Toplink JPA
  • Enterprise Quality
    • GlassFish Enterprise
  • Open Source
    • Dual-licensed with GPLv2/CPE
  • Community at Java.Net
    • Sources, bug DBs, discussions at Java.Net
    • Roadmaps, Architecture Documents
  • Sample application on Carol's blog :
  • http://weblogs.java.net/blog/caroljmcdonald/

53. Timeline of Project GlassFish Tomcat Jasper Catalina JSTL Struts Crimson XSLTC Xalan Xerces JAXB JAX-RPC JSF June 2005 May 2006 GlassFish Launch v2 v1 v3 Mid-2009 UR1 v2.1 UR2 v3 Prelude Oct 2008 Dec 2008 Sept. 2007 54. Demo Demo Netbeans 6.5 JPA entity JSF pages generation from DB tables 55. Agenda

  • Catalog Java EE Application
  • Catalog Spring 2.5 JSF and JPA Application
  • Catalog Java EE Seam Application
  • Summary

56. Spring Framework Goals

  • Inversion of controlcontainer for application components and lifecycle
      • Wiring components throughDependency Injection
      • Promotes de-couplingamong the parts that make up an application
  • Provide JavaAOP implementation
    • allowing the separation of cross-cutting concerns
      • Logging ...
  • Facilitate unit testing
    • Allow effective TDD
    • Allow POJO classes to be unit tested outside the container

57. Spring Framework 58. What Is Spring Not?

  • Not Java EEPlatform Container
    • Spring typically runs withinaJava EEplatform orWebcontainer
    • Spring can run in Java SEorJava EE
    • Springleveragesand prefers to useexisting standards
    • relies upon the services of the serverin which it is deployed

59. Catalog JSF, JPA, Spring Application DB Registration Application Managed Bean JSF Components SpringBean Entity Class Catalog Item ItemController Spring Framework 60. Bean Factory and Dependency Injection Spring Bean Factoryinjects dependencies Application's POJOs Configuration file Dependencies inapplicationContext.xml Fully configured and ready to use objects 61. Spring Dependency Injection

  • public class ItemController {
  • private CatalogService catalogService ;
  • public voidsetCatalogService (CatalogService catalogService) {
  • this.catalogService = catalogService;
  • }

Inject Spring Bean

  • < property name =" catalogService ">ref =" catalogService "/>

applicationContext.xml 62. Spring 2.5 Dependency Injection

  • public class ItemController {
  • @Autowired
  • public voidsetCatalogService (CatalogService catalogService) {
  • this.catalogService = catalogService;
  • }
  • }
  • @Repository ("catalogService")
  • public class CatalogDAO implements CatalogService{
  • }

Inject Spring Bean

    • CatalogService injected by type

applicationContext.xml 63. Spring 2.5 Stereotypes and Autowiring

  • @Autowiredtakes care of wiring , enables DI without XML
    • Default is match by type,@Qualifiermatch by bean name
  • A component scan can discover beans
  • @ComponentdesignatesSpring component
  • @Controller @Service @Repositoryextend @Component , designate a web controller, service, or DAO component

applicationContext.xml 64. Catalog JSF, JPA, Spring Application DB Registration Application Managed Bean JSF Components SpringBean Entity Class Catalog Item ItemController Spring Framework 65. ItemController Bean and Spring Dependency Injection

  • import service.CatalogService;
  • @Component
  • @Scope("session")
  • public class ItemController {
  • private CatalogService catalogService ;
  • @Autowired
  • public voidsetCatalogService (CatalogService catalogService) {
  • this.catalogService = catalogService;
  • }
  • public int getItemCount() {
  • return = catalogService ().getItemCount();
  • }
  • . . .

Inject Spring Bean

    • Creates ItemController
    • Spring beanno need to put in
    • faces_config.xml
    • CatalogService injected by type

66. Spring JSF Configuration infaces-config.xml

    • Spring's Expression Language resolver
    • JSP
    • Expression
    • Language

applicationContext.xml Will scan for components, don't have toconfiguremanaged beans infaces-config.xml org.springframework.web.jsf.el.SpringBeanFacesELResolver 67. Spring JSF Configuration inweb.xml

      • for intercepting request to JSF
      • bootstrapping Spring's web application context

contextConfigLocation/WEB-INF/ applicationContext.xml org.springframework.web.context.ContextLoaderListener org.springframework.web.context.request.RequestContextListener 68. Rest of JSF stays the same

  • Spring Web Flow can also be used with JSF, but not was used in this example

69. Catalog JSF, JPA, Spring Application DB Registration Application Managed Bean JSF Components SpringBean Entity Class Catalog Item ItemController Spring Framework 70. Catalog Spring Bean Using JPA @Repository @Transactional public class CatalogDAO implementsCatalogService{ @PersistenceContext (unitName="PetCatalogPu") privateEntityManager em; @Transactional(readOnly=true) public ListgetItems (int firstItem,int batchSize) {Query q =em. createQuery("select object(o) from Item as o"); q.setMaxResults(batchSize); q.setFirstResult(firstItem); List items= q.getResultList(); return items;} Component Stereotype Spring transactions use aop 71. Configuration of catalogService Spring Bean in aplicationContext.xml

  • . . .
  • Spring will scan for components in the service package
    • Configurationis done withmatching type

Scan for components 72. Catalog JSF, JPA, Spring Application DB Registration Application Managed Bean JSF Components SpringBean Entity Class Catalog Item ItemController Spring Framework 73. JPA Entity stays the same @Entity public class Item implements Serializable { @Idprotected Long id; private String name; private BigDecimal price; public Item() {} public Long getId() {return id;} public String getName() {return name;} public void setName(String name) {this.name = name;} public String getPrice() {return price;} public void setPrice( BigDecimalname){this.price=price;} } 74. Configuring Persistence Provider Container managed JPA Defined data source TopLink Classfile enhancer, for lazy loading 75. Spring JPA Configuration forDerby JDBC driver 76. Spring & GlassFish Application Server

  • To Run Spring on Glassfish:
    • Add Spring 2.5 jar files to application War
    • Configure .xml files
  • Sample on Carol's blog :
  • http://weblogs.java.net/blog/caroljmcdonald/

77. Get Spring (and this sample) from theGlassFish Update Center 78. Or Get Spring from from Netbeans Plugins catalog 79. Summary

  • Spring
    • HeavilyAOPand POJO based
    • Annotation andconfigurationcentric, but easy to test
    • Provides its own way for transaction management, data sources, etc
  • Java EE Glassfish future:
    • OSGI ,faster startup , only load needed modules going into Glassfish V3

80. Agenda

  • Catalog Java EE Application
  • Catalog Java EE Spring Application
  • Catalog Java EE Seam Application
  • Summary

81. What is Seam?

  • Framework on top JavaEE 5
  • Seamunifiesthe web tier with the enterprise tier
  • Glue forJSFandEJB3components
    • EnableEJB3.0 components to used as JSFmanaged beans
    • Prototypefor JSR 299WebBeans , will be in Java EE 6
    • Can also work with POJOs instead of EJBs

82. WebBeansJSR 299

  • @Component
  • @SessionScoped
  • public classCredentials{
  • private String username;
  • private String password;
  • ...
  • }
  • public class Login {
  • @InCredentialscredentials;
  • ...
  • }

Component: Managed class can be injectedGavin KingJSR 299 lead, Sun,Google , Oracle... members Component: Definition of Managed class when name is requested, instantiated Scope: Context Buckets where the component instances are stored 83. Bean Validation FrameworkJSR 303

  • Bean Validation FrameworkJSR 303 going into Java EE 6
  • @Entity
  • public class Address {
  • @Max(9) @NotNull
  • private String zipcode;
  • }

Emmanuel Bernard (Red Hat) JSR 303 lead, Sun, Google, Oracle... members 84. Seam Catalog ApplicationDB Session EJB EntitySeam Framework JSF Components CatalogBean Item 85. Seam Key Concepts

  • Eliminate the ManagedBean bind directly to any component: Entity, EJB....
  • Componentsare associated withcontext variablesusing@Name
    • The @Name annotation binds the component to a contextualvariable its just like < managed-bean-name > in the JSF XML

@Name = gives a name to reference a component Context ~=bucket 86. Seam Key Concepts

  • Componentsare assigned ascopeusing the@Scopeannotation
    • EVENT scope --Spans aserver request , from restore view to render response
    • SESSIONscope httpsession
    • CONVERSATIONscope --Spans multiple requestsfrom the same browser window, demarcated by @Beginand @End methods.
    • Others:PAGE, APPLICATION, BUSINESS_PROCESS

Context=bucket Scope=how long stored in context bucket @Name = gives a name to reference a component 87. Seam Key Concepts

  • less xml use annotations instead
  • dependencies are injected and updated every time a component is accessed
  • Bijection of components
  • @Inprivate MyServiceOne service1;
    • injectionis applied before the method is invoked
  • @Outprivate Item item;
    • outjectionis appliedafterthe method is invoked

88. Seam Catalog ApplicationDB Session EJB EntitySeam Framework JSF Components CatalogBean Item 89. JPA Entity & Seam @Entity @Name(" item ") @Scope(ScopeType.EVENT) public classItemimplements Serializable { @Idprotected Long id; private String name; private BigDecimal price; public Item() {} public Long getId() {return id;} public String getName() {return name;} public void setName(String name) {this.name = name;} public String getPrice() {return price;} public void setPrice( BigDecimalname){this.price=price;} } The@Nameannotation binds the component to a contextual variable its just likein the JSF XML 90. Seam Catalog ApplicationDB Session EJB EntitySeam Framework JSF Components CatalogBean Item 91. Seam JSF Configuration infaces-config.xml org.jboss.seam.jsf.SeamELResolver org.jboss.seam.jsf.SeamPhaseListener 92. Component Bindings List.jsp ... ... A snippet fromList.jsp 93. UIComponents Bindingto a Session EJB

  • public classCatalogBean {
  • @DataModel
  • List items
  • @Factory ("items")
  • public voidgetItems () {
  • ...
  • }
  • . . .
  • }
    • var='dataTableItem'

Session Bean @DataModel for exposing to page @Factory for initializing Client Server A B C Backing Bean Form c1 A c2 B c3 C c1 c2 c3 A B C Page 94. Catalog Session EJB @Stateful @Scope(SESSION) @Name(" catalog ") @Interceptors ({org.jboss.seam.ejb. SeamInterceptor .class}) public classCatalogBeanimplements Serializable,Catalog{@PersistenceContext(unitName=PetCatalogPu)EntityManager entityManager; @DataModel private List items=null; @Factory(" items ") public voidgetItems(){ Query q = em.createQuery( "select object(o) from Item as o"); q.setMaxResults( batchSize ); q.setFirstResult( firstItem ); items= q.getResultList(); } Seam JSFDataModelcomponent SeamFactoryMethod, called on initialization 95. EJB 3.0Interceptors

  • Interceptorsintercept calls
    • sitbetween callerand abean
  • basicAOP
  • Invocation model: around methods
    • Wrapped around invocationof business method
  • Uses:
    • Auditing, logging , exception handling,security

interceptor

    • dataTable value ="#{ items }"

@Stateless public class CatalogBean { public void book() {} } 96. Component Bindings List.jsp ... ... A snippet fromList.jsp Action link@DataModelSelectionholds the selected value 97. UIComponents Bindingto a Session Bean

Session Bean JSF positions DataModel.getRowData() torow of actionbefore calling action listener

  • public classCatalogBean {
  • @DataModelSelection
  • @Out
  • private Item item;
  • public Stringselect(){
  • return "item_detail";
  • }
  • . . .
  • }

Client Server A B C Backing Bean Form c1 A c2 B c3 C c1 c2 c3 A B C Page 98. Invoke Application Phase

@Stateful @Scope(SESSION) @Name(" catalog ") @Interceptors ({... SeamInterceptor .class}) public classCatalogBeanimplements Serializable,Catalog @DataModel private List< Item > items =null; @DataModelSelection @Out(required=false) private Item item; public Stringselect(){ return"item_detail"; } Action methodNavigation response outject to theitemcontextvariable inject the DataModel rowitemcorresponding to clicked Link Action method 99. Navigation (same as before)from-view to-view from-outcome Navigation rulesin faces-config.xml,Or in Seam'spages.xml .list.jsp new_usr.jsp error.jsp error.jsp detail.jsp item_detail new user error 100. Seam Catalog ApplicationDB Session EJB EntitySeam Framework JSF Components CatalogBean Item 101. Standard request processing lifecycle Render Response Request Restore View Response Render Response Apply Request Values Invoke Application Update Model Values Process Validations outjected itemevent context variable, available to JSP 102. Component Bindings Detail.jsp ... ... A snippet fromDetail.jsp @Out exposesvalue to page outjected itemevent context variable, available to JSP 103. Seam & GlassFish Application Server

  • To Run Seam on Glassfish:
    • Add Seam jar files to application: some in War some in EJB jar
    • Configure .xml files
  • Seam 2.0 example on Carol's blog :
  • http://weblogs.java.net/blog/caroljmcdonald/
  • Seam 2.1 glassfish configuration:
  • http://docs.jboss.com/seam/2.1.0.SP1/reference/en-US/html/glassfish.html

104. Agenda

  • Catalog Java EE Application
  • Catalog Java EE Spring Application
  • Catalog Java EE Seam Application
  • Summary

105. Summary

  • Each open source project provides a different approach to how an application is built
  • Spring
    • HeavilyAOPand POJO based
    • Annotation andconfigurationcentric, but easy to test
    • Provides its own way for transaction management, data sources, etc
  • Seam builds on JavaEE
    • Simplification ofEJB3 and JSF development
  • Java EE Glassfish future:
    • Web BeansandBean Validationgoing into Java EE 6
    • OSGI ,faster startup , only load needed modules going into Glassfish V3

106. Which one,don't ask me

  • Best Tool for the Job?
  • Better Framework depends on your application requirements
  • Pick 2-3 frameworks for your type of application...
  • ... and prototype!
  • If prototype doesn't meet requirements, switch

107. For More Information

  • Glassfish
    • https://glassfish.dev.java.net/
    • http://blogs.sun.com/theaquarium/
  • JavaEE
    • http://java.sun.com/javaee/
  • Spring
    • http://www.springframework.org/
  • Seam
    • http://www.seamframework.org/
    • Seam in Action Book, by Dan Allen
  • Carol's blog
    • http://weblogs.java.net/blog/caroljmcdonald/

108.

  • Presenters Name
    • [email_address]

Carol McDonald Java Architect Tech Days 2009