JavaEE Seams Easy JBoss Seam: A Web Application Component Framework for EJB3, JPA, JSF and AJAX.

Slides:



Advertisements
Similar presentations
11 Copyright © 2005, Oracle. All rights reserved. Creating the Business Tier: Enterprise JavaBeans.
Advertisements

Apache Struts Technology
 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
ISE 390 Dynamic Web Development Java EE Web Applications.
Spring, Hibernate and Web Services 13 th September 2014.
JBoss Seam: Contextual Components Jason Bechtel
Sapana Mehta (CS-6V81) Overview Of J2EE & JBoss Sapana Mehta.
Java Server Faces Model/View/Controller Design Pattern for Web Development Slides adapted from “Core JavaServer Faces” by Geary and Horstmann and the J2EE.
Application Architectures Vijayan Sugumaran Department of DIS Oakland University.
Introduction to EJB INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J
Emmanuel Cecchet et al.  Performance Scalability of J2EE application servers.  Test effect of: ◦ Application Implementation Methods ◦ Container Design.
Stateful Web Application Development with Spring Web Flow John Case Senior Consultant Centare Group, Ltd.
Struts 2.0 an Overview ( )
UNIT-V The MVC architecture and Struts Framework.
CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren.
WebWork in Action An introduction to WebWork Patrick A. Lightbody.
JavaServer Faces: The Fundamentals Compiled from Sun TechDays workshops (JSF Basics, Web-Tier Codecamp: JavaServer Faces, Java Studio Creator; IBM RAD)
Pittsburgh Java User Group– Dec Java PureFaces: A JSF Framework Extension.
Enterprise JavaBeans EJB Container Services. EJB container Enterprise JavaBeans are deployed in an EJB container within the application server EJB container.
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
95-843: Service Oriented Architecture 1 Master of Information System Management Service Oriented Architecture Lecture 10: Service Component Architecture.
JDeveloper 10g and JavaServer Faces: High-Performance UIs on the Web Avrom Roy-Faderman Senior Programmer May, 2006.
1 Stateful Session Beans Stateless Session Beans Michael Brockway Sajjad Shami Northumbria University School of Computing, Engineering & Information Sciences.
Enterprise JavaBeans. What is EJB? l An EJB is a specialized, non-visual JavaBean that runs on a server. l EJB technology supports application development.
EJB Framework.  As we know, EJB is the center of the J2EE architecture that provides a sturdy framework for building enterprise applications. The major.
Dependency Injection in Action Jan Västernäs. CADEC2006, DI, Slide 2 Copyright 2006, Callista Enterprise AB Agenda (DI=Dependency Injection) Background.
© 2006 IBM Corporation IBM WebSphere Portlet Factory Architecture.
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
JBoss Seam Presented by Andy Nguyen Truc Pham. What is JBoss Seam? Created by Gavin King Created by Gavin King A lightweight framework for Java EE 5.0.
Chapter 8 Script-free pages. Problem with scripting in JSP When you use scripting (declaration, scriplet, expressions) in your JSP, you actually put Java.
J2EE Structure & Definitions Catie Welsh CSE 432
JSF Introduction Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
Stanisław Osiński, 2002JSP – A technology for serving dynamic web content Java Server Pages™ A technology for serving dynamic web content Stanisław Osiński,
Case Study + MVC Lec Error Pages By means of the page directive, a JSP can be given the responsibility of an Error page An Error JSP will be called.
Fall CIS 764 Database Systems Design L8. Web ….
Introduction to Web Dimitar Nenchev Ivan Nakov
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
Drools Sofia Jonsson CADEC2006, Drools, Slide 2 Copyright 2006, Callista Enterprise AB Agenda Rule Engines - History/Background.
Fall CIS 764 Database Systems Engineering L7. ADF + EJB Context: Oracle Application Development Framework …but … only EJB.
JSF Framework Java Server Faces Presented by Songkran Totiya (6/10/2014)
Introduction to Spring Web Flow Andrew Petro Software Developer Unicon, Inc. Jasig 2011 Westminster, CO 23 May 2011 © Copyright Unicon, Inc., Some.
AJAX The new hot technology for building Rich Internet Applications? Mikael Hammarlund.
Java Persistence API v1.0 a standard for ORM frameworks and POJO based Persistence Magnus Larsson
INTEGRATION OF BACKBONE.JS WITH SPRING 3.1. Agenda New Features and Enhancements in Spring 3.1 What is Backbone.js and why I should use it Spring 3.1.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Essentials Getting started.
Spring and DWR Frameworks for Rich Web Enterprise Application Thomas Wiradikusuma Presentation to the 20 th.
Jonathan Gallimore | Tomitribe Cluster your application with JCache and CDI.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
3246 JSF Support in JBuilder 2005 Karl Ewald R&D Engineer Borland Software Corporation.
J2EE Chris Hundersmarck Maria Baron Jeff Webb.  Java 2 Platform, Micro Edition (J2ME)  Java 2 Platform, Standard Edition (J2SE)  Java 2 Platform, Enterprise.
1 Copyright © 2004, Oracle. All rights reserved. Oracle Application Development Framework.
JAVA EE 6 Best Practices for Migrating Spring to WTF ?!?
Session Beans Based on: Patel, Brose, Silverman, Mastering Enterprise JavaBeans 3.0.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Data Access with Spring.
Introduction to EJB. What is an EJB ?  An enterprise java bean is a server-side component that encapsulates the business logic of an application. By.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Overview of the Spring Framework Introducing.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
EJB Enterprise Java Beans JAVA Enterprise Edition
Apache Struts Technology A MVC Framework for Java Web Applications.
Test Java EE applications with Arquillian Ivan St. Ivanov.
Enterprise Java Beans. Contents  Understanding EJBs  Practice Section.
J2EE Lecture 6: Spring – IoC and Dependency Injection
EJB (Enterprise Java Beans)
Enterprise Java Bean. Overview of EJB View of EJB Conversation Roles in EJB, Types of Enterprise Beans Lifecycle of Beans Developing Applications using.
ISE 390 Dynamic Web Development
JavaServer Faces: The Fundamentals
Developing and testing enterprise Java applications
Intro to J2EE Concepts.
Presentation transcript:

JavaEE Seams Easy JBoss Seam: A Web Application Component Framework for EJB3, JPA, JSF and AJAX

Cadec 2007, JBoss Seam, Slide 2 Copyright , Callista Enterprise AB Agenda The JavaEE 5 programming model: Remaining issues Introducing Seam –Contextual Components –Seam Conversations –Bijection –Remoting –Testability Short demo Summary Q&A

Cadec 2007, JBoss Seam, Slide 3 Copyright , Callista Enterprise AB Java EE 5 programming model JSF 1.2 –Template language extensible component model for widgets –“Managed bean” component model JavaBeans with dependency injection XML-based declaration –Defines interactions between the page and managed beans Expression Language (EL) for binding controls to managed beans

Cadec 2007, JBoss Seam, Slide 4 Copyright , Callista Enterprise AB Java EE 5 programming model (contd.) EJB 3.0 –Component model for transactional components dependency injection declarative transaction and persistence context demarcation sophisticated state management –JPA ORM for persistence –Annotation-based programming model

Cadec 2007, JBoss Seam, Slide 5 Copyright , Callista Enterprise AB Java EE 5 Compared to J2EE Simpler programming model –Fewer artifacts (look Mum, no DTOs!) –Less noise (EJB boilerplate, Struts boilerplate) –Much simpler ORM –Finer grained components More powerful for complex problems –Powerful ORM engine –EJB interceptors support lightweight AOP –JSF is amazingly flexible and extensible Much better testability –All components (except JSP pages) can be unit tested in isolation

Cadec 2007, JBoss Seam, Slide 6 Copyright , Callista Enterprise AB So what is the problem? Incoherent programming models Remaining JSF complexity –Managed beans are just unnecessary plumbing –XML configuration Lack of power –Enemy of the State: No Flows –Dependency Injection is not enough What about Ajax?

Cadec 2007, JBoss Seam, Slide 7 Copyright , Callista Enterprise AB Seam Goals Unify the two component models –Simplify Java EE 5, filling a gap –Improve usability of JSF Deprecate stateless architectures Decouple technology from execution environment Enable richer user experience

Cadec 2007, JBoss Seam, Slide 8 Copyright , Callista Enterprise AB Fix the mismatch between JSF and EJB 3.0 component programming models No more excessive XML configuration everywhere! –#{EL} expressions everywhere! No more awkward “Managed Beans”. (Want to know what gets between my JSFs and my EJBs? –Nothing … )

Cadec 2007, JBoss Seam, Slide 9 Copyright , Callista Enterprise AB Seam Components public EditDocumentBean implements EditDocument private EntityManager em; private Long id; public void setId(Long id) { this.id = id; } private Document document; public Document getDocument() { return document; } public void save() {... } Title Password annotation binds a component to a contextual variable Context variables are accessible from EL Seam components can be Session Beans, Entity Beans or simply POJOs

Cadec 2007, JBoss Seam, Slide 10 Copyright , Callista Enterprise AB Contextual Components Most of the problems in Web Application development relate directly or indirectly to state management –Servlet Spec contexts (Page, Request, Session, Application) are not meaningful in terms of the application We want a richer context model providing meaningful, “logical” contexts What’s missing: Conversations

Cadec 2007, JBoss Seam, Slide 11 Copyright , Callista Enterprise AB Conversations @Scope(ScopeType.CONVERSATION) public EditDocumentBean implements EditDocument private EntityManager public String get() { document = em.find(Document.class, id); return document==null ? “notFound” : “success”; public String save(Document doc) { document = em.merge(doc); return “success”; } Conversations are demarcated annotations Components are assigned to a scope using annotation

Cadec 2007, JBoss Seam, Slide 12 Copyright , Callista Enterprise AB Conversations helps solve real, inherent problems in Web Applications Multi-Window operations Back Button support “Workspace Management” Nested conversations –multiple concurrent inner conversations within an outer conversation - a stack of continuable states Time for a demo!

Cadec 2007, JBoss Seam, Slide 13 Copyright , Callista Enterprise AB Conversations and Persistence Transaction-scoped persistence contexts have problems if you (re)use objects across transactions –not held open for entire request (while rendering view), hence can result in LazyInitializationException while navigating lazy associations –NonUniqueObjectException reassociating detached instances –Less opportunity for caching Conversation-scoped persistence contexts solves these problems –Much cleaner than well-known (and highly questionable) “open session in view” idiom!

Cadec 2007, JBoss Seam, Slide 14 Copyright , Callista Enterprise AB Dependency Injection Sucks! Here’s Bijection! Dependency injection is broken for stateful components –Rigid and static –Does not support the notion of contexts What we really need is Bijection, which is –Dynamic –Bidirectional Injection “Outjection” –Contextual

Cadec 2007, JBoss Seam, Slide 15 Copyright , Callista Enterprise AB Bijection public class ChangePasswordBean implements Login private private User currentUser; public String changePassword() { currentUser = em.merge(currentUser); annotations are used to inject and “outject“ variables into the context

Cadec 2007, JBoss Seam, Slide 16 Copyright , Callista Enterprise AB Bijection public class HotelSearchingAction implements HotelSearching private EntityManager em; private String searchString; private int pageSize = private List private Hotel selectedHotel; public String find() annotation outjects search result into the context

Cadec 2007, JBoss Seam, Slide 17 Copyright , Callista Enterprise AB Bijection in Action – Referring to context variable 0}"> Name #{hot.name} Address #{hot.address} City, State #{hot.city}, #{hot.state}

Cadec 2007, JBoss Seam, Slide 18 Copyright , Callista Enterprise AB What about Ajax? Ajax seems to be here to stay, whether we like it or not. And the JavaScript programming model comes straight from Hell … JSF components in themselves can encapsulate JavaScript code, but that is a closed model –What about those fancy JS libraries that you might have to use (Rico, Prototype, script.acolo.us, …)? –What about access to the server-side, contextual components? Seam Remoting gives DWR-like Javascript access to any Seam component

Cadec 2007, JBoss Seam, Slide 19 Copyright , Callista Enterprise AB Seam Remoting in public interface Manager public boolean checkName (String name);String public class ManagerAction implements Manager { public boolean checkName (String name) {String … } // Get the "manager" Seam component var manager = Seam.Component.getInstance("manager"); // Make the async call with a callback handler function checkName () { var e = document.getElementById("form:name"); var inputName = e.value; manager.checkName(inputName, checkNameCallback); } function checkNameCallback (result) { if (result) { hideCheckNameError (); } else { showCheckNameError (); }

Cadec 2007, JBoss Seam, Slide 20 Copyright , Callista Enterprise AB Runtime Requirements Java SE 5 JSF 1.x Servlet 2.4+ container (i.e. Tomcat 5.x) JPA implementation only required if persistent contextual objects are used EJB 3 container only required if the Contextual objects are EJBs –Also works with JBoss Embeddable EJB3 container

Cadec 2007, JBoss Seam, Slide 21 Copyright , Callista Enterprise AB Conclusions Seam provides a unified programming model that brings together JSF, JPA, EJB 3 and AJAX Relies on two powerful tools: –Annotations –Expression Language Greatly simplifies development of stateful Web Applications with complex flows … but is not yet a standard, which might lead to single vendor lock-in. You might want to wait for WebBeans (JSR 299).

Cadec 2007, JBoss Seam, Slide 22 Copyright , Callista Enterprise AB Time for Questions!

Cadec 2007, JBoss Seam, Slide 23 Copyright , Callista Enterprise AB Seam Contexts EVENT PAGE CONVERSATION SESSION PROCESS APPLICATION Components are assigned to a scope using annotation

Cadec 2007, JBoss Seam, Slide 24 Copyright , Callista Enterprise AB Support for Test Driven Development public class BookingTest extends SeamTest public void testBookHotel() throws Exception { new FacesRequest() protected void invokeApplication() throws Exception { Contexts.getSessionContext().set("loggedIn", true); Contexts.getSessionContext().set("user", new User("Gavin King", "foobar")); } }.run(); new FacesRequest("/main.xhtml") protected void updateModelValues() throws Exception { setValue("#{hotelSearch.searchString}", "Union Square"); protected void renderResponse() { DataModel hotels = (DataModel) Contexts.getSessionContext().get("hotels"); assert hotels.getRowCount()==1; assert ( (Hotel) hotels.getRowData() ).getCity().equals("NY"); assert getValue("#{hotelSearch.searchString}").equals("Union Square"); assert !Manager.instance().isLongRunningConversation(); } }.run();