Seam - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

Seam

Description:

Allows easy creation of JEE applications. Eliminates complexity ... Wicket. PDF. Web Services. Even Spring. Can even run in just Tomcat. The End ... – PowerPoint PPT presentation

Number of Views:61
Avg rating:3.0/5.0
Slides: 23
Provided by: cameron66
Category:
Tags: seam | wicket

less

Transcript and Presenter's Notes

Title: Seam


1
Seam
2
What is Seam?
  • Application Framework for JEE
  • One kind of stuff
  • Integrate JSF and EJB 3.0
  • Declarative State management
  • Bijection
  • Prefer annotations to XML
  • Integration Testing
  • There's more to a web application than serving
    HTML pages
  • Versatility

3
What is Seam
  • Designed for Stateful web applications
  • Allows easy creation of JEE applications
  • Eliminates complexity
  • Easiest way to get started with EJB 3.0
  • Light weight framework

4
Conversation
  • Why?
  • Fine grained control over HTTPSession
  • _at_Begin, _at_End
  • Long Running vs. Temporary
  • Database Transactions are tied to Conversations
  • Nesting( _at_Begin(nestedtrue) )
  • Foreground vs. Background
  • http//solutionsfit.com/blog/2007/12/13/explaining
    -the-conversation-timeout-setting-through-example/
  • See conversations in action

5
(No Transcript)
6
Bijection
  • Its not injection its bijection
  • Seam emphasizes stateful components
  • _at_In _at_Out
  • Will use the name of var as default
  • _at_In _at_Out private Customer customer
  • _at_In(namecust) _at_Out(namecust) private
    Customer customer
  • Seam manages the life cycle
  • Bijection can occur with any Seam component,
    takes place every time a component is invoked
  • Outject to any scope
  • If not available Seam will create the component
  • Careful of excessive bijection

7
Entities, Entities and Entities
  • Home Objects can be JPA or Hibernate
  • Home objects can be defined in components.xml
  • Easier but more restrictive
  • ltframeworkentity-home name"personHome" entity-cl
    ass"eg.Person/gt
  • Declared Home objects
  • _at_Name("personHome") public class PersonHome exten
    ds EntityHomeltPersongt 
  • Can override functionality or add extra
    functionality
  • Can be a stateful or stateless component
  • Provide default behavior persist(), remove(),
    update() and getInstance().
  • First call setId() before you call the
    method

8
Entities, Entities and Entities cont.
  • Query Objects
  • ltframeworkentity-query name"people"            
                 ejbql"select p from Person p"/gt
  • Can be called like any seam component
  • i.e. people.resultList()
  • Can support pagination
  • Add to entity query max-results"20"
  • Call people.firstResults, people.nextFirstResult
    or people.lastFirstResult
  • Supports search criteria
  •  ltframeworkrestrictionsgt     ltvaluegtlower(firstN
    ame) like lower( concat(examplePerson.firstName
    ,'') )
  • lt/valuegt      ltvaluegtlower(la
    stName) like lower( concat(examplePerson.lastNam
    e,'') )
  • lt/valuegt    lt/frameworkrestri
    ctionsgt

9
Entities, Entities and Entities cont.
  • Controller objects
  • Optional
  • Add convenience methods like
  • createQuery, persist or addFacesMessage
  • _at_Stateless
  • _at_Name("register")
  • public class RegisterAction extends EntityControll
    er 
  • implements Register

10
Observers and Events
  • One of the more powerful components of Seam
  • You can observe any seam event
  • Raising an event is extremely easy
  • _at_RaiseEvent(hello)
  • Events.instance().raiseEvent("hello")
  • Observe an event
  • _at_Observer("hello")
  • _at_Observer(org.jboss.seam.validationFailed)

11
Observation and Events
  • State can be passed from producer to consumer
  • Events.instance().raiseEvent("hello", name)
  • _at_Observer("hello")
  • public void sayHelloBack(String name) 
  • FacesMessages.instance().add("Hello 0!", name)
  • However this is not necessary since state is held
    in the seam context

12
POJO
  • Seam Components are POJO
  • Entity Manager needs to be Seam Managed
  • Add lttransactionentity-transaction
    entity-manager""/gt To the components.xml
  • Seam pojos can be used interchangeably instead
    of ejbs
  • POJOs dont support clustering

13
Pages.xml
  • A very powerful way to navigate through your
    application
  • Integrates with Security, JBoss Rules
  • Can begin and stop a conversation
  • Navigation can be evaluated from a el expression
  • Navigation can occur based on an exception type
  • ltexception class"org.jboss.seam.security.NotL
    oggedInException"gt
  • ltredirect view-id"/login.xhtml"gt
  • ltmessagegtPlease log in
    firstlt/messagegt
  • lt/redirectgt
  • lt/exceptiongt
  • Can be driven from a return of a Seam component
    similar to a struts forward

14
Seam Managed Transactions
  • Transactions in Seam may not happen in a single
    method call
  • Seam is a stateful framework so use of
    LazyFetching is encouraged
  • Makes use of a Persisted Context at the
    Conversation level

15
Seam Managed Transactions
  • Seam uses JTA by default
  • If you are running Seam in a non EE5 container,
    Seam will try to figure out what you are using
  • Seam managed transactions can be disabled
  • ltcoreinit transaction-management-enabled"false"/
    gt        lttransactionno-transaction /gt
  • With EJBs you should add
  • lttransactionejb-transaction /gt

16
Seam Security
  • Custom Authentication Method
  • Roles can be any thing
  • Integrates Seamlessly with JAAS
  • Integrates with JBoss Rules for security checking

17
Seam Security Cont
  • Simple authentication
  • Default
  • Uses one of your seam components
  • You can use your entity classes to authenticate
    with
  • ltsecurityidentity authenticate-method"authenti
    cator.authenticate"/gt
  • In your authenticate method add roles to the
    identity class
  •  Identity.instance().addRole(ltYour Rolegt)
  • If your session isnt authenticated then call add
    role before you authenticate
  • Add _at_Restrict(ltRoleNamegt) to either your class or
    your method
  • _at_Restrict("shasRole(ltRoleNamegt)"
  • To use the default system JAAS add to
    components.xml
  • ltsecurityidentity jaas-config-name"other"/gt

18
Validation(DRY)
  • Integrates With Hibernate Validator
  • Annotate your messages or use properties file
  • Use ltsvalidategt or ltsvalidateAll/gt
  • lthinputText id"userName" required"true"       
           value"customer.userName"gt  ltsvalidate
     /gt
  • lt/hinputTextgt
  • lthmessage for"userName" styleClass"error" /gt

19
Interceptors
  • No Dependency on the Web.xml
  • Very Easy to Use!
  • Just annotate your class
  • _at_Scope(ScopeType.APPLICATION)
  • _at_Name("org.granite.seam.SeamMessagesFilter")
  • _at_BypassInterceptors
  • _at_Filter(within"org.jboss.seam.web.contextFilter")
  • _at_Install(precedenceInstall.BUILT_IN)
  • _at_Dependency()

20
Seam Gen
  • Creates a fully configured project including jsf
    pages
  • Just type seam setup in seam root dir and then
    answer the questions

21
Flexability
  • Flex via Tide/GraniteDS(and BlazeDS, Flamingo)
  • GWT
  • Wicket
  • PDF
  • Web Services
  • Even Spring
  • Can even run in just Tomcat

22
The End
  • We just touched the surface
  • Seam is a powerful, flexible and easy to use and
    build with framework
  • For more information on seam check out
  • http//www.seamframework.org
  • Flex and Seam
  • http//www.graniteds.org
  • Email
  • cameron.ingram_at_graniteds.org
  • My blog
  • http//www.rationaldeveloper.com
  • Questions!
Write a Comment
User Comments (0)
About PowerShow.com