Introduction to Seam. Pete Muir. JBoss, a division of Red Hat

Similar documents
Seam. Pete Muir JBoss, a Division of Red Hat.

Seam & Web Beans. Pete Muir JBoss, a division of Red Hat.

Seam. Pete Muir JBoss, a Division of Red Hat.

Introduction to JBoss Seam

Improve and Expand JavaServer Faces Technology with JBoss Seam

Seam 3. Pete Muir JBoss, a Division of Red Hat

object/relational persistence What is persistence? 5

JBoss Seam. Israel JBoss User Group Session 05 / By : Yanai Franchi, Chief Architect Tikal

Refactoring to Seam. NetBeans. Brian Leonard Sun Microsystems, Inc. 14o

JBoss Seam Integration with intent to use. Dan Allen Software Consultant Author, Seam in Action

Shale and the Java Persistence Architecture. Craig McClanahan Gary Van Matre. ApacheCon US 2006 Austin, TX

Oracle - Developing Applications for the Java EE 7 Platform Ed 1 (Training On Demand)

Fast Track to EJB 3.0 and the JPA Using JBoss

Developing Applications with Java EE 6 on WebLogic Server 12c

CO Java EE 6: Develop Database Applications with JPA

foreword to the first edition preface xxi acknowledgments xxiii about this book xxv about the cover illustration

CMP 436/774. Introduction to Java Enterprise Edition. Java Enterprise Edition

Spring Framework 2.0 New Persistence Features. Thomas Risberg

JBoss Seam. Michael Yuan, PhD Ezee Inc.

More reading: A series about real world projects that use JavaServer Faces:

Pro JPA 2. Mastering the Java Persistence API. Apress* Mike Keith and Merrick Schnicariol

Enterprise JavaBeans, Version 3 (EJB3) Programming

Object-relational mapping EJB and Hibernate

Enterprise Java Development using JPA, Hibernate and Spring. Srini Penchikala Detroit JUG Developer Day Conference November 14, 2009

Migrating traditional Java EE applications to mobile

Java- EE Web Application Development with Enterprise JavaBeans and Web Services

Java Enterprise Edition

Web Application Development Using Spring, Hibernate and JPA

Not just an App. Server

Java EE 6: Develop Web Applications with JSF

Devoxx 2008 in a breeze

Web Application Development Using Spring, Hibernate and JPA

Web Application Development Using Spring, Hibernate and JPA

Java EE 7: Back-End Server Application Development

Java EE 6 New features in practice Part 2

"Web Age Speaks!" Webinar Series

What is it? What does it do?

The Good, the Bad and the Ugly

Maturing your application s security with Seam Security. Dan Allen Senior Software Engineer JBoss, by Red Hat

JavaServer Faces Technology, AJAX, and Portlets: It s Easy if You Know How!

Rational Application Developer 7 Bootcamp

J2EE - Version: 25. Developing Enterprise Applications with J2EE Enterprise Technologies

Oracle Developer Day

Contents at a Glance

Oracle Fusion Middleware 11g: Build Applications with ADF I

EJB ENTERPRISE JAVA BEANS INTRODUCTION TO ENTERPRISE JAVA BEANS, JAVA'S SERVER SIDE COMPONENT TECHNOLOGY. EJB Enterprise Java

CO Java EE 7: Back-End Server Application Development

What s new in Spring Web Flow 2.0

Web Application Development Using JEE, Enterprise JavaBeans and JPA

Java EE Application Assembly & Deployment Packaging Applications, Java EE modules. Model View Controller (MVC)2 Architecture & Packaging EJB Module

Type of Classes Nested Classes Inner Classes Local and Anonymous Inner Classes

Web Application Development Using JEE, Enterprise JavaBeans and JPA

PATTERNS & BEST PRACTICES FOR CDI

JBoss Seam and beyond

Building modern enterprise applications from scratch: lessons learned DOAG 2014 Dr. Clemens Wrzodek

Enterprise JavaBeans 3.1

Implementing a Numerical Data Access Service

Example jsf-cdi-and-ejb can be browsed at

Introduction to JPA. Fabio Falcinelli

POJOs to the rescue. Easier and faster development with POJOs and lightweight frameworks

Chapter 1 Introducing EJB 1. What is Java EE Introduction to EJB...5 Need of EJB...6 Types of Enterprise Beans...7

Java EE 6 - Update Harpreet Singh GlassFish Portfolio Product Manager

JSF Tags. This tutorial will cover a number of useful JSF tags. For a complete listing of available JSF tags consult the Oracle documentation at:

ADVANCED JAVA TRAINING IN BANGALORE

Oracle Application Development Framework Overview

"Charting the Course... Mastering EJB 3.0 Applications. Course Summary

Session 24. Introduction to Java Server Faces (JSF) Robert Kelly, Reading.

5/2/2017. The entity manager. The entity manager. Entities lifecycle and manipulation

E Eclipse debugging a JSF application, 25 downloading, 2 installing, 2 launching JBoss in, 3

Introduction to Java Server Faces(JSF)

Spring Web Flow: Enabling High Level, Low Effort Web Conversations

Oracle Fusion Middleware 11g: Build Applications with ADF Accel

Introduction to CDI Contexts and Dependency Injection

Oracle Fusion Middleware 11g: Build Applications with ADF I

Introduction to Web Application Development Using JEE, Frameworks, Web Services and AJAX

<Insert Picture Here> Productive JavaEE 5.0 Development

SOFTWARE DEVELOPMENT SERVICES WEB APPLICATION PORTAL (WAP) TRAINING. Intuit 2007

Fast Track to Spring 3 and Spring MVC / Web Flow

Java Training Center, Noida - Java Expert Program

Nuxeo Roadmap. From Memphis to Chicago Nuxeo Team

TheServerSide.com. Dependency Injection in Java EE 6 - Part 5

Spring & Hibernate. Knowledge of database. And basic Knowledge of web application development. Module 1: Spring Basics

The Next Generation. Prabhat Jha Principal Engineer

<Insert Picture Here> Accelerated Java EE Development: The Oracle Way

Call: JSP Spring Hibernate Webservice Course Content:35-40hours Course Outline

Java EE 6: Develop Business Components with JMS & EJBs

Metawidget UI Generation done right

Hibernate Search Googling your persistence domain model. Emmanuel Bernard Doer JBoss, a division of Red Hat


Table of Contents. I. Pre-Requisites A. Audience B. Pre-Requisites. II. Introduction A. The Problem B. Overview C. History

Migrating SAP Portal Application to JBoss Portal Sushil Ajgaonkar

Performance evaluation of J2EE

JVA-163. Enterprise JavaBeans

JBoss DNA. Randall Hauch Principal Software Engineer JBoss Data Services

SPRING MOCK TEST SPRING MOCK TEST I

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved.

Struts: Struts 1.x. Introduction. Enterprise Application

Sitesbay.com. A Perfect Place for All Tutorials Resources. Java Projects C C++ DS Interview Questions JavaScript

JBoss World 2009 Marius Bogoevici

Spring Interview Questions

Transcription:

Introduction to Seam Pete Muir JBoss, a division of Red Hat

Road Map Background Seam concepts Seam with Wicket (at the BOF) Seam Extras 2

Advantages of JSF/JPA over Struts/EJB 2 Fewer, finer grained artifacts No DTOs required Clean MVC Less noise No Struts/EJB 2.x boilerplate code No direct calls to HttpSession or HttpRequest Simple ORM Even simpler than the Hibernate API! 3

Advantages of JSF/JPA over Struts/EJB 2 JSF is flexible and extensible Custom UI widget suites (open source) Good AJAX support JPA Powerful object/relational mapping, far beyond EJB 2.x CMP entity beans All components are POJO so easily testable with TestNG or JUnit 4

But, still some problems JSF Backing bean couples layers and is just noise Hard to refactor all the XML and String outcomes No support for the business layer Validation breaks DRY XML is too verbose How do we write our business layer EJB3? - can t be used directly by JSF EJB3? - no concept of scopes 5

And, some other stuff to solve! Workflow Ad-hoc back buttoning not suppored No stateful navigation Long running business processes? Multi-tab/window support is not built in All operations happen in the session - leakage No support for a conversation context Memory leak - objects don t get cleaned up quickly 6

Simple JSF with Seam Reference the entities directly! <h:form> Item: <h:outputtext value="#{itemeditor.id} /> Name: <h:inputtext value="#{itemeditor.item.name}"> <f:validatelength maximum="255" /> </h:inputtext> Price (EUR): <h:inputtext value="#{itemeditor.item.price}"/> <f:convertnumber type="currency" pattern="$###.##" /> </h:inputtext> <h:messages /> <h:commandbutton value="save" action="#{itemeditor.save}" /> </h:form> 7

Adding Seam A conversation scoped Seam component @Name("itemEditor") @Scope(CONVERSATION) public class EditItemBean implements EditItem { @In EntityManager entitymanager; Long id; Item item; // getter and setter pairs @Begin public String find(long id) { item = entitymanager.find(item.class, id); } return item == null? "notfound" : "success"; Begin and End a conversation - state is maintained over multiple requests between these methods @End public String save(item item) { } item = entitymanager.merge(item); return "success"; 8

Road Map Background Seam concepts Seam with Wicket Seam Extras 9

Contextual variables Contexts available in Seam Event Page Conversation Session Business Process Application 10

JSF lifecycle - quick review RESTORE VIEW: Restore the tree of UI components APPLY REQUEST VALUES: Synchronize request parameters with UI components PROCESS VALIDATIONS: Validate state of UI components UPDATE MODEL: Synchronize UI components with bound backing bean properties INVOKE APPLICATION: Notify action listeners, call action methods RENDER RESPONSE: Render a new tree of UI components 11

Application lifecycle Seam provides hierarchical, stateful contexts BUSINESS PROCESS APPLICATION SESSION SESSION CONVERSATION CONVERSATION EVENT EVENT EVENT PAGE INVOKE APPLICATION RENDER RESPONSE INVOKE APPLICATION 12

How is state stored? Depends on the context: Conversation context Segmented HttpSession - times out if not used Page context Stored in the component tree of the JSF view (page) Can be stored in HttpSession or serialized to client Business Process context 13

Bijection Seam provides hierarchical, stateful contexts (Dependency) Injection fine for stateless applications BUT stateful applications need bidirectional wiring. Think about aliasing a stateful object into a context @Name("passwordChanger") public class PasswordChanger { @In EntityManager entitymanager; @In @Out User currentuser; } public void changepassword() { } entitymanager.merge(currentuser); Bijection: before the method call, inject the current user; after the method call, save it back into the context. 14

JPA Persistence Context What is the Persistence Context? a HashMap of all the objects I ve loaded and stored holds (at most) one in-memory object for each database row while the PC is active a natural first-level cache can do dirty checking of objects and write SQL as late as possible (automatic or manual flushing) The Persistence Context has a flexible scope default: same scope as the system transaction (JTA) extended: the PC is bound to a stateful session bean 15

Which PC scope to use? Transaction scoped & detached objects LazyInitializationException NonUniqueObjectException Less opportunity for caching An extended persistence context of a SFSB is not available during view rendering (LIE again) very complicated propagation rules No concept of a conversation 16

Seam managed persistence and transactions Seam managed PC is conversation scoped Remains active through conversation, Inject using @In Allows use of manual flush mode CONVERSATION EVENT EVENT RESTORE VIEW APPLY REQUEST VALUES PROCESS VALIDATIONS UPDATE MODEL INVOKE APPLICATION RENDER RESPONSE PERSISTENCE CONTEXT FLUSH SYSTEM TRANSACTION 17

Navigation Stateful Pageflow powered by jbpm engine (graphical editor) Back button normally disabled Stateless Through JSF or pages.xml pages.xml is very powerful compared to JSF navigation rules (outcomes, application state, raise events on navigation) 18

Workflow - Business Process Management What is it? Very long running (multiple days) Lots of users (tasks can be assigned) Can contain many tasks A task is completed by one user Often a conversation 19

Model based validation Validate in the user interface? Yes, need to report validation errors back to the user on the correct field BUT normally need to enforce same constraints at the persistence layer and the database public @Entity class Item { @Id @GeneratedValue Long id; String name; @Length(min=3, max=1000, message="must be between 3 and 1000 characters") String description; 20

Hibernate Validator Many built-in validators: Max, Min, Length, Range, Size, Email, Future, Past, Pattern, Email, CreditCard,... Easy (very) to write custom validators Validation and message/error display with Seam UI components for JSF Works with every JPA provider, if used with Hibernate it generates SQL DDL constraints you can use in your database schema Standardization effort under way - JSR 303 21

Road Map Background Seam concepts Seam with Wicket Seam Extras 22

Seam Application Framework <components> <fwk:entity-home name="userhome" entity-class="user" /> </components> <h:form> <h:inputtext value="#{userhome.instance.name}" /> <h:inputsecret value="#{userhome.instance.password}" /> <h:commandbutton action="#{userhome.update}" /> <h:messages /> </h:form> 23

Contextual Events @Name("hotelBooking") public class HotelBooking { } @End public void confirmroomchoice() { booking.setroom(chosenroom); } Events.instance().raiseEvent("roomChosen"); public @Name("RoomList") class RoomList { @Out List<Room> availablerooms; } @Observer("roomChosen") public void refresh() { } availablerooms = entitymanager.createquery("select..."); 24

And more Security Email PDF Remoting Asynchronicity (Java SE, EJB3 or Quartz) Google your app using Hibernate Search Integration and Unit Testing JSF components (deep integration into JPA) Components in groovy Webservices > 25 examples Portal support 25

Want to learn more? Security SSO Identity Management GWT Wicket? Flex? Web Beans! http://www.seamframework.org 26

Go get it! Security SSO Seam Identity in Management JBoss Enterprise Application Platform 4.2 - GWTsupported product with Seam 1.2 Wicket? Seam 2.0.1.GA - community release of Seam2 Flex? Web Seam Beans! 2.1.0.A1 - preview release of Seam 2.1 with Wicket and Portal support 27

The future of Seam? Security SSO Identity Web Beans!! Management GWT Wicket? First class support for other other containers (e.g. Flex? Websphere) Web Beans! Friendly URLs Identity Management SSO for security Flex support (talk at JBoss World!) Deeper integration with JBoss Portal (inter-portlet communication) 28

Q&A 29

More Seam at JBoss World Gavin is talking about Web Beans at 1:40pm on Friday Seam, Tools and Web Beans BOF tonight at 8pm 2 (!) Seam Case Studies on Friday at 9am Agile development on Friday at 1:40pm on Friday 30