Introduction to JBoss Seam - XeNoNSoFT.com to JBoss Seam ... • Java EE 5 Programming Model •...

Post on 29-May-2018

223 views 0 download

Transcript of Introduction to JBoss Seam - XeNoNSoFT.com to JBoss Seam ... • Java EE 5 Programming Model •...

Introduction to JBoss Seam

Sebastien Degardinsebastien.degardin@gmail.com

http://www.seamframework.org

Agenda

• What is Seam ?, The goal of this talk• Java EE 5 Programming Model

• Java Server Faces (JSF)

• Enterprise Java Bean 3.0 (EJB)

• Example Application

• What can be improved

• Seam• Key features

• Demo With JBoss Developer Studio

• The Contextual Component Model

• Bijection

• Demo

• Conversations and Workspace management

• Demo

• Seam and Object/Relational Mapping

• Demo

Agenda

• Seam• JSF Validation in Seam

• Demo

• Security

• Demo

• Pageflows and Business Processes

• Event, Interceptors and Exceptions

• Demo

• Email

• Demo

• Testing Seam applications

• Demo

• Seam and others frameworks

• What’s coming

• Questions

• References

What is Seam

• Seam is an application framework for Java EE 5 that simplify the development of web application”• Unify the 2 main Component models in Java EE 5, EJB 3.0 &

JSF

• Designed for Stateful Application

• Design with ORM in mind

Java EE 5

• Java EE 5 is a major step forward from J2EE

• Java Server Faces

• EJB 3.0

Java Server Faces

• Component Based MVC

• Component model for widget

• Embedded in Template language

• No more JSP, Facelets

• Component model for application logic, Managed Bean

• JavaBean component with xml deployment descriptor

• Stateful component attached to a context (request/session/application)

• EL for mapping between the 2 component models

• Other stuff like Validators and Converters

EJB 3.0

• Transaction• Declarative Transaction Management

• Transaction Propagation

• Persistence• JPA, Java Persistence 1.0

• Persistence Context, Extended Persistence Context (for Optimistic Transaction)

• Interceptor for AOP

• Others Services• Concurrency, Security, Distributed Object, Asynchronous

Messaging, Naming, Timer Services

EJB 3.0

• Stateful Session Bean

• Stateful Component that can be clustered

Example ApplicationA Java EE 5 Application

Entity BeanMark the Class

as an Entity

All entity must have an Id

Define the DatabaseConstraints using

Hibernate Validators

Stateless Session Bean

The PC is injected

Mark the Classas Stateless

Session Bean

JSF Search Page

The JSF Life Cycle

JSF Edit Page

JSF Managed Bean

Managed Bean Deployment Descriptor

Navigation Rules

What can be improved

• The concern of the Managed Bean is “Glue”• Layering is useful but does not have to be the first priority and

should not be imposed by the spec

• The Backing Bean isolate the Presentation from the Business Tier in a Wrong Way

• Calling the Session Bean directly make sense,

• Validation in JSF, Backing Bean and Entity Bean

• XML in JSF is very verbose

What can be improved

• HttpSession is not the right place to store application state

JBoss Seam

Key Features of Seam

• Unify the 2 components Models• Remove the JSF Backing Bean

• Connect the Session Bean to the View

• No more verbose XML

Key Features of Seam

• Natural Period of user Action

• Multi-tab with the conversation context

• WorkFlow, Wizard (stateful navigation)

• Business Process Management ( ex: Amazon order)

DEMO

• Create a Seam application with JBoss Developer Studio

• First Application tour

• JBoss Developer Studio

• The project skeleton

• The Facelets template

• Login/logout functionality

The Contextual Component Model

• The 3 built-in contexts are not especially meaningful from the point of view of the business logic

• Most components are scoped to the conversation or the Business Process context

• Contexts are created and destroyed by the framework or in some case via annotation

The Contextual Component Model

• Seam Contexts• Stateless context

• Event context (request)

• Page context• attached to the page, useful for clickable list, ...

• Conversation context• one of the most powerful concept provided by Seam

• Session Context

• Business process context• longer than session, (eBay auction)

• Application Context

The Contextual Component Model

• Seam component• Stateless Session Bean (SLSB)

• Stateful Session Bean (SFSB)

• Entity Bean

• Java Bean

• Message Driven Bean (MDB)

• Interception

Bijection

• Seam emphasizes the concept of Stateful component, traditional DI is no longer very useful

• Bijection is : • Contextual, assembles various component from different context.

(even from narrower context)

• Bidirectional, values are injected from the context variables when the component is invoked and outjected back into the context variables.

• Dynamic, since values of contextual variable changes over time and since component are stateful, bijection takes place every time a component is invoked

DEMO

• Seam Contextual Component Model

• Bijection

Seam and Persistence

• Introduction• The optimistic transaction problem

• The EJB 3.0 improvement

• Seam’s solution

• Seam managed transactions• Seam managed persistence context

JSF Validation in Seam

• The DRY Concept• JSF Tags

DEMO

• Seam Validation

• Seam’s JSF Validation Tags

Security in Seam

• Simple security• Advanced Security using JBoss Rules (Drools)

Other Stuff

• Email Using Facelets Template• PDF Using Facelets Template

Other Stuff

• Remoting• Web Services• Portal• Integration with different App Servers

Seam and Other Frameworks

• Seam and GWT

• Seam and Spring

• Sean and Wicket

• Seam and Adobe Flex

• Groovy Integration

What’s coming

• JAVA EE 6.0 (JSR 316)

• EJB 3.1 (JSR 220)

• JPA 2.0 (JSR 317)

• JSF 2.0 (JSR 314)

• Web Beans (JSR 299)

EJB 3.1 New Features

• EJB Interfaces are Optional• Singleton Bean (@Singleton)• Concurrency• Direct use in the Servlet container (War file)• Stateful Web Services using SFSB

JPA 2.0

• More flexible Model• Support for Collection of basic type (String, ...)• @OrderedList• Bean Validation (JSR 303)

Questions ?

References

• JBoss Seam http://www.seamframework.org

• JBoss Community http://www.jboss.org

• Java EE 5 http://java.sun.com/javaee

• EJB 3.0 http://java.sun.com/products/ejb

• JSF http://java.sun.com/javaee/javaserverfaces

• Facelets http://facelets.dev.java.net

• Web Beans http://jcp.org/en/jsr/detail?id=299

Books

Thank you !