An Introduction to Seam 3 Reza Rahman Expert Group Member, Java EE 6 and EJB 3.1 Resin EJB 3.1 Lite Container Lead Author, EJB 3 in Action

Slides:



Advertisements
Similar presentations
Java EE - Introduction -
Advertisements

J2EE Architecture Overview
@mnriem#DV14 #MVC MVC 1.0 in JavaEE 8 A long time coming, or like some would say “finally!” Why are we doing it now? Survey input Customer input JavaEE.
ISE 390 Dynamic Web Development Java EE Web Applications.
Introduction to Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
10/8/12http://free.smartbiz.vn1 JSR-299 CDI Java Contexts & Dependency Injection JBoss Weld Implementation.
An architecture for webb applications, J2EE
JBoss Seam: Contextual Components Jason Bechtel
An introduction to Java Servlet Programming
© 2005, Cornell University. Rapid Application Development using the Kuali Architecture (Struts, Spring and OJB) A Case Study Bryan Hutchinson
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.Public 1 Testing Java EE Applications using Arquillian Reza Rahman Java EE/GlassFish.
Session-01. What is a Servlet? Servlet can be described in many ways, depending on the context: 1.Servlet is a technology i.e. used to create web application.
Web Applications Basics. Introduction to Web Web features Clent/Server HTTP HyperText Markup Language URL addresses Web server - a computer program that.
Introduction to Java web programming Dr Jim Briggs JWP intro1.
© Internna Technologies 1 IWebMvc Features, Possibilities & Goals.
UNIT-V The MVC architecture and Struts Framework.
Lecture 2 - Struts ENTERPRISE JAVA. 2 Contents  Servlet Deployment  Servlet Filters  Model View Controllers  Struts  Dependency Injection.
JavaServer Faces: The Fundamentals Compiled from Sun TechDays workshops (JSF Basics, Web-Tier Codecamp: JavaServer Faces, Java Studio Creator; IBM RAD)
Intermediate Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
AJAX Without the “J” George Lawniczak. What is Ajax?
Objectives Java Servlet Web Components
JavaServer Faces Jeff Schmitt October 5, Introduction to JSF Presents a standard framework for building presentation tiers for web applications.
CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren.
Enterprise Java Bean Matt. 2 J2EE 3 J2EE Overview.
Web Applications - Basics. Introduction to Web Web features Clent/Server HyperText Transfer Protocol HyperText Markup Language URL addresses Web server.
Web applications using JavaServer Faces (JSF) A brief introduction 1JavaServer Faces (JSF)
Enterprise Java v120131Intro to JavaEE1 Java EE 5 TM Introduction.
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
Spring Framework. Spring Overview Spring is an open source layered Java/J2EE application framework Created by Rod Johnson Based on book “Expert one-on-one.
Introduction to Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
J2EE Overview ver 1.0Page 1 © Wipro Technologies Talent Transformation J2EE Overview.
JavaEE Seams Easy JBoss Seam: A Web Application Component Framework for EJB3, JPA, JSF and AJAX.
Ch 2 – Application Assembly and Deployment COSC 617 Jeff Schmitt September 14, 2006.
A Presentation By V AIBHAV S AHARAN Web-enHanced Information Management COMS E6125.
BOF # The Struts Framework Community The Struts Framework Community Craig McClanahan.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Spring Remoting Simplifying.
JSF Framework Java Server Faces Presented by Songkran Totiya (6/10/2014)
CSCI 6962: Server-side Design and Programming Java Server Faces Scoping and Session Handling.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Views Rendering custom views.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
Chính phủ điện tử TS. Phạm Văn Tính Khoa CNTT, ĐH Nông Lâm TP.HCM
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.
Assignment of JAVA id : BSSE-F10-M-10-JAVA1 Overview of J2EE/Session 2/Slide 1 of 38.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Essentials Getting started.
Professional Java EE Design Patterns Alex alextheedom.com.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
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.
1 Spring Framework April, 2012 Lam Ho Lam To. © 2010 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 2 1.Spring Overview 2.Framework.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
JAVA EE 6 Best Practices for Migrating Spring to WTF ?!?
Text 16 de mayo de 2009 Spring Framework Part III. Portable Service Abstractions Buenos Aires, June 2009.
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.
Enterprise Java v JNDI Enterprise Naming Conext (ENC) and Injection JNDI ENC.
EJB Enterprise Java Beans JAVA Enterprise Edition
Test Java EE applications with Arquillian Ivan St. Ivanov.
1.Education Overview JAVA EE 6 Technologies
Enterprise Java Beans. Contents  Understanding EJBs  Practice Section.
J2EE Lecture 6: Spring – IoC and Dependency Injection
Java Servlets By: Tejashri Udavant..
Magento Technical Guidelines Eugene Shakhsuvarov, Software Magento
ISE 390 Dynamic Web Development
Understanding and Designing with EJB
JavaServer Faces: The Fundamentals
J2EE Lecture 13: JMS and WebSocket
Testing your DAO’s with Java
Presentation transcript:

An Introduction to Seam 3 Reza Rahman Expert Group Member, Java EE 6 and EJB 3.1 Resin EJB 3.1 Lite Container Lead Author, EJB 3 in Action

CDI, Weld and Seam 3 CDI is the dependency injection standard for Java EE Weld is the reference implementation of CDI Seam 3 is a set of CDI portable extension modules

Contexts and Dependency Injection for Java EE (CDI)

CDI Overview Next-generation dependency injection for Java EE Also known as JSR-299, formerly known as WebBeans Synthesizes best ideas from Seam 2, Guice and Spring Many innovative features on its own right Focus on loose-coupling, Java-centric type-safety, annotations, expressiveness and ease-of-use Makes Java EE much more flexible, testable, pluggable and extensible

CDI Features Basic Instance, Component

CDI Features Custom InjectionPoint Lightweight Events @Delegate Portable extensions SPI*

JBoss Weld

Weld Overview CDI reference implementation and compatibility test kit from JBoss Included in GlassFish and JBoss AS Can be used with Tomcat, Jetty Can be used in Java SE

Weld Runtime Environments

Weld Event Based Java SE public class AlertListener {... public void ContainerInitialized List parameters) { showSplash(); setupUi(); showUi(parameters); }... }

Weld Java SE Programmatic Bootstrap public static void main(String[] arguments) { WeldContainer weld = new Weld().initialize(); weld.instance().select( AlertListenerBean.class).startListening(); weld.shutdown(); }

JBoss Seam 3

Seam 3 Set of CDI portable extensions independent of Weld Each module developed separately There are Seam “umbrella” releases

ModuleDescription SolderGeneral enhancements to CDI XML ConfigurationXML configuration for managed beans Persistence Transactions and persistence for non-EJB managed beans FacesJSF enhancements ServletServlet enhancements JMSJMS integration RESTREST enhancements RemotingJavaScript remoting of managed beans Seam Modules

ModuleDescription CatchException handling framework InternationalInternationalized/localized locale, time, messages SecurityHigher level security API for Java EE MailJavaMail integration CronCDI based scheduling DocumentDocument generation (PDF, Excel) Seam 2Seam 2 backwards compatibility SpringSpring interoperability Seam Modules

ModuleDescription WicketWicket Integration GWTGWT integration DroolsDrools integration jBPMjBPM integration JBoss ESBJBoss ESB integration CloudsCloud frameworks integration (JClouds, Infinispan) ForgeRapid application development for Java EE Seam Modules

Solder Used to be part of Weld, good laboratory for CDI.next Generally useful CDI extensions for application, plug-in and framework developers Logging Injecting EL expression evaluator Extended resource loading Extended APIs for injection, naming, management Annotation processing and reflection utilities

public interface %s was overdrawn by %10.2f") public void overdrawn(String accountNumber, double @Locale("en_GB") AccountLog log; log.overdrawn(account.getNumber(), amount);

Programmatic EL private Expressions expressions;... Customer customer = expressions.evaluateValueExpression( "#{account.customer}");... Double interest = expressions.evaluateMethodExpression( "#{account.calculateMonthlyInterest}");

Enhanced private private private Properties awsProperties;

XML Configuration CDI Focuses mainly on annotations, not XML XML configuration is sometimes needed or preferred Seam XML configuration allows portable CDI XML configuration across implementations More compact, schema-driven and type-safe than traditional XML configuration Likely candidate for CDI.next

Seam XML Configuration public class MailSender {... public void set (String ) {... @Target({ ElementType.FIELD, ElementType.METHOD }) @Target({ ElementType.FIELD, ElementType.METHOD }) Support {}

XML Object (Re)-Wiring <beans xmlns=" xmlns:xsi=" xmlns:seam="urn:java:seam:core" xmlns:acme="urn:java:com.acmebank">...

Injecting XML-Wired Objects public class private MailSender mail;... mail.send();... }

Refining Beans with public class CurrencyConverter {... private String currency = “us-dollar”; private int precision = 2;... } --> 4

Seam Persistence EJB transactions in CDI managed beans instead of EJB beans JPA bootstrap to work with Seam Persistence Likely standardized in Java EE 7

Persistence and Transactions public class DefaultAccountService implements AccountService private EntityManager entityManager; public void addAccount(Account account) {... }... }

Seam Faces CDI Enhancements for JSF 2 More CDI scopes to match @FlashScoped Cross-field validation, page pre-load in Validators and Converters Injecting Faces objects Bridging CDI Events with the JSF life-cycle Likely standardized in Java EE 7

Cross-Field Validation Form <h:commandButton id="submit" value="Submit“ action="#{bean.submit}"/> <seam:validateForm validatorId="locationValidator"/>

public class LocationValidator implements Validator {... Directory String String String zip;... public void validate(FacesContext context, UIComponent component, Object values) throws ValidatorException { if (!directory.exists(city, state, zip)) throw new ValidatorException( new FacesMessage(“Invalid location, try again")); }

JSF Pre-Load <f:viewParam name="id" value="#{accountManager.accountId}"/> <s:viewAction action="#{accountManager.loadAccount}"/>

JSF Object FacesContext ExternalContext NavigationHandler Flash flash;

Seam JMS Injecting connections, sessions, queues, topics, message producers, message receivers CDI Event Observers as JMS message listeners CDI Events sent to JMS destinations Some features could be standardized in Java EE 7

Seam JMS Resource Injection public class transacted=true, acknowledgementType=Session.AUTO_ACKNOWLEDGE) private private MessageProducer producer;... public void sendTransfer(Transfer transfer) {... producer.send(session.createObjectMessage(transfer));... }... }

Event-based exception handling framework Automatic exception chain handling Type-based handler callback hierarchy Catch

Exception public class IOExceptionHandler {... public void CaughtException event) { System.out.println(“I/O Problem: " + event.getException().getMessage()); }... }

Seam REST Configure exception handling rules Integrate with Seam Catch Integrate Bean Validation with JAX-RS Templates for JAX-RS output RESTEasy client integration Some features could be standardized in Java EE 7

Seam REST Exception Mapping <exceptions:Mapping exceptionType="javax.persistence.NoResultException" statusCode="404"> Resource does not exist. <exceptions:Mapping exceptionType="java.lang.IllegalArgumentException" statusCode="400"> Illegal value.

Seam REST public class DefaultBidService implements @ValidateRequest public void addBid(Bid bid) {... }... }

Seam REST "application/json", "application/categories+xml", value="/freemarker/categories.ftl", produces = value="/freemarker/categories-short.ftl", produces = "application/categories-short+xml")}) public List getCategories() {

Seam private BidService bidService;... bidService.addBid(bid);

Seam Remoting Export CDI beans to AJAX via remoting RPC and domain object models of remoting Remote context Client-side bean validation

Seam Remoting on public class DefaultBidService implements BidService public void addBid(String bidder, String item, Double amount) {... }... }

Seam Remoting on the Client function addBid() {... Seam.createBean(“bidService").addBid(bidder, item, amount);... } Bid!

Bridging CDI Events with the Servlet life-cycle Injecting Servlet objects Integration with Seam Catch Some features could be standardized in Java EE 7 Seam Servlet

Servlet Life-Cycle as CDI Events public ServletContext context) {... } public HttpSession session) {... } public @Path(“/bid") HttpServletRequest request) {... }

Servlet Object ServletConfig ServletContext HttpSession String HttpServletResponse List cookies;

Managing locale/time-zone for the application or session Internationalized, localized messages International

Getting and Setting Default Locale DateTimeZone defaultTimeZone; en_US America/New_York

Getting and Setting Event timeZoneEvent; public void setUserLocale() { localeEvent.fire(Locale.CANADA); } public void setUserTimeZone() { timeZoneEvent.fire( DateTimeZone.forID("America/Vancouver")); }

CDI next generation dependency injection for Java EE Weld reference implementation from JBoss included in GlassFish and JBoss AS Seam a large set of CDI portable extensions Logging, XML, RAD, persistence/tx, JSF, JMS, JAX-RS, JavaScript remoting, security, i18n & l10n, JavaMail, scheduling, documents, Servlet, Spring, Wicket, GWT, Drools, jBPM, JBoss ESB, exceptions, cloud More on the way! Summary

References JSR 299: Contexts and Dependency Injection for Java EE, Weld, the JBoss reference implementation for JSR 299, Seam 3,