JBoss Seam and beyond

Similar documents
Improve and Expand JavaServer Faces Technology with JBoss Seam

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

Fast Track to EJB 3.0 and the JPA Using JBoss

JVA-163. Enterprise JavaBeans

Not just an App. Server

Developing Applications with Java EE 6 on WebLogic Server 12c

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

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

Java EE 7: Back-End Server Application Development

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

Eclipse Java Ejb 3.0 Tutorial For Beginners With Examples Pdf

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

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

Enterprise JavaBeans, Version 3 (EJB3) Programming

Migrating traditional Java EE applications to mobile

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

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

THIS IS ONLY SAMPLE RESUME - DO NOT COPY AND PASTE INTO YOUR RESUME. WE ARE NOT RESPONSIBLE Name: xxxxxx

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

Contents at a Glance

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

Java EE 6: Develop Business Components with JMS & EJBs

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

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

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

ADVANCED JAVA COURSE CURRICULUM

CO Java EE 7: Back-End Server Application Development

Course Content for Java J2EE

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

Introduction to JBoss Seam

JBPM Course Content. Module-1 JBPM overview, Drools overview

Web Application Development Using JEE, Enterprise JavaBeans and JPA

Web Application Development Using JEE, Enterprise JavaBeans and JPA

Courses For Event Java Advanced Summer Training 2018

Integrating Seam and GWT

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

Chapter 6 Enterprise Java Beans

NetBeans IDE Field Guide

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

JBoss World 2009 Marius Bogoevici

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

Java EE 6: Develop Web Applications with JSF

object/relational persistence What is persistence? 5

@jbossdeveloper. explained

1 Markus Eisele, Insurance - Strategic IT-Architecture

Spring Framework 2.0 New Persistence Features. Thomas Risberg

TOOLING SUPPORT FOR ENTERPRISE DEVELOPMENT RYAN CUPRAK & REZA RAHMAN

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

V3 EJB Test One Pager

CA1033A - Work-In-Progress Presentation

APPLICATION SECURITY ENHANCEMENTS IN JAVA EE 6

Overview p. 1 Server-side Component Architectures p. 3 The Need for a Server-Side Component Architecture p. 4 Server-Side Component Architecture

Introduction to Spring 5, Spring MVC and Spring REST

DVS WEB INFOTECH DEVELOPMENT TRAINING RESEARCH CENTER

Outline. Project Goal. Overview of J2EE. J2EE Architecture. J2EE Container. San H. Aung 26 September, 2003

Spring ROO. Internals and add-ons. Massimiliano Dessì - SpringFramework Italian User Group Javaday IV Roma 30 gennaio 2010

"Web Age Speaks!" Webinar Series

Hands-on Development of Web Applications with Java EE 6

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

IBM Rational Application Developer for WebSphere Software, Version 7.0

Building the Enterprise

Software Systems Architecture

Java Enterprise Edition

Leverage Rational Application Developer v8 to develop Java EE6 application and test with WebSphere Application Server v8

PATTERNS & BEST PRACTICES FOR CDI

(800) Toll Free (804) Fax Introduction to Java and Enterprise Java using Eclipse IDE Duration: 5 days

Desarrollo de Aplicaciones Web Empresariales con Spring 4

Rational Application Developer 7 Bootcamp

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

Soap Based Web Services In Java Tutorial Eclipse Jboss

Devoxx 2008 in a breeze

JAVA COURSES. Empowering Innovation. DN InfoTech Pvt. Ltd. H-151, Sector 63, Noida, UP

}w!"#$%&'()+,-./012345<ya

JBoss Seam. Michael Yuan, PhD Ezee Inc.

Deccansoft Software Services. J2EE Syllabus

Apache TomEE Tomcat with a kick

WHAT IS EJB. Security. life cycle management.

The Next Generation. Prabhat Jha Principal Engineer

LTBP INDUSTRIAL TRAINING INSTITUTE

Webservices In Java Tutorial For Beginners Using Netbeans Pdf

Environment: Java, J2EE, JSP, Servlet, Struts, Spring IoC, Hibernate, XML, Maven, JUnit, Eclipse, Oracle, tomcat, perforce.

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

Java Training Center, Noida - Java Expert Program

com Spring + Spring-MVC + Spring-Boot + Design Pattern + XML + JMS Hibernate + Struts + Web Services = 8000/-

Maturing your security with Seam. Dan Allen Senior Software Engineer JBoss, a division of Red Hat

Metadata driven component development. using Beanlet

Fast Track to Spring 3 and Spring MVC / Web Flow

CONFIGURING A SPRING DEVELOPMENT ENVIRONMENT

Java Persistence API (JPA) Entities

OSGi on the Server. Martin Lippert (it-agile GmbH)

LTBP INDUSTRIAL TRAINING INSTITUTE

Java SE 8 Fundamentals

Java J Course Outline

Java EE 6 - Update Harpreet Singh GlassFish Portfolio Product Manager

Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat

Fast Track to Java EE 5 with Servlets, JSP & JDBC

Oracle Application Development Framework Overview

CORE JAVA 1. INTRODUCATION

Oracle Corporation

Vision of J2EE. Why J2EE? Need for. J2EE Suite. J2EE Based Distributed Application Architecture Overview. Umair Javed 1

Transcription:

JBoss Seam and beyond Jeroen Verhulst Joris De Winne Karel Maes

Overall Presentation Goal basic concepts of Seam with practical demo (Jeroen) testing Seam applications (Joris) real-life project with Seam (Karel)

RealDolmen Java Competence Center

RealDolmen Java Competence Center Rock solid passion for JAVA 200 Java Super Powers 10 years of experience in Java projects

RealDolmen Java Competence Center Rock solid passion for JAVA 200 Java Super Powers 10 years of experience in Java projects Proven approach: Java Project Platform

RealDolmen Java Expertise

RealDolmen Java Expertise Tailor-made software Rich Internet Applications Mobile Solutions Service Oriented Architecture Enterprise Architecture Web Content Management Business Process Management Eclipse IntelliJ RAD NetBeans FLEX JavaFX Java EE EJB 3 Spring Hibernate Agile SCRUM Test Driven Development Websphere JBoss Ant Maven JIRA Bamboo Tomcat Swing JSF Struts Polopoly Alfresco ESB Mule / AquaLogic

Ask your free poster here!

Ask your free poster here!

JBoss Seam Drools AJAX jbpm Spring

JBoss Seam JSF Drools AJAX jbpm Spring EJB

JBoss Seam J S F Drools AJAX jbpm Spring EJ B

JBoss Seam AJAX Drools J S F EJ B jbpm Spring

Components seam container lightweight control lifecycle factory for component instances application seam container stateful stateful contexts getinstance(name) instance opt lookup(name) instance newinstance() [not found]

Components component instance proxy object caller proxy security tx target component instance contextual

Context model event 1 event 2 event 3 event 4 event 5 page IA RR conversation 1 conversation 2 conversation 3 conversation 4 session 1 session 2 session 3 application 1 application 2 business process

Defining components @Name declares a class as a seam component @Scope scope in which the context variable will be stored defaults SFSB, JPA entity: conversation SLSB, MDB: stateless JavaBean: event

Accessing components seam API Component.getInstance( componentname ); Component.getInstance(ComponentClass.class) expression language (EL) can be used almost everywhere in Seam seam enhancements #{seamcomponentname.methodname(parameter1, parameter2)} #{componentname.getproperty(parameter1)} #{somelist.size} #{somelist.{ listitem listitem.property}} List result = new ArrayList(); for(object listitem : somelist) { result.add(listitem.getproperty()); } return result;

Defining components in XML components.xml define components static injection <components xmlns="http://jboss.com/products/seam/components" si="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation=" http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd"> <component name= matchbean" class= com.realdolmen.soccer.business.matchbeanimpl" scope= conversation"> <property name= match >#{nextmatch}</property> <property name= matchdurationinminutes >15</property> </components> </components>

Bijection @In inject value from seam container into property @In(create=true) private FacesMessages facesmessages; @In(required=true, scope=scopetype.application) private MatchControllerBean matchcontrollerbean; @In(value= nextmatch ) public void setmatch(match match) { this.match = match; }

Bijection @Out outject value from property towards context @Out(scope=ScopeType.SESSION, value= loggedinuser") private User user; @Out(value= nextmatch, required= false ) public Match getmatch() { return this.match; } null value removes the context variable

Bijection dynamic vs. static seam component instance @In( loggedinuser ) @Out( loggedinuser ) private User user = null; @In @Out private Account account = null; seam container loggedinuser private String name = Verhulst private String firstname = Jeroen account private String number = 123-1234567-12 public void updateaccount() { account.setnumber( 321-7654321-21 ); } user = null;

Bijection injection @In( loggedinuser ) @Out( loggedinuser ) private User user; seam component instance @In @Out private Account account; seam container loggedinuser private String name = Verhulst private String firstname = Jeroen account private String number = 123-1234567-12 public void updateaccount() { account.setnumber( 321-7654321-21 ); } user = null;

Bijection outjection @In( loggedinuser ) @Out( loggedinuser ) private User user; seam component instance @In @Out private Account account; seam container loggedinuser private String name = Verhulst private String firstname = Jeroen account private String number = 321-7654321-21 public void updateaccount() { account.setnumber( 321-7654321-21 ); } user = null;

Bijection disinjection seam component instance @In( loggedinuser ) @Out( loggedinuser ) private User user = null; @In @Out private Account account = null; seam container loggedinuser private String name = Verhulst private String firstname = Jeroen account private String number = 321-7654321-21 public void updateaccount() { account.setnumber( 321-7654321-21 ); } user = null;

Events raise @In private Events events; events.raiseevent( matchstarted ); // immediate events.raisetransactionsuccessevent( matchstarted, match); // tx completed observe @Observer( matchstarted ) public void watchmatch(match match) { // same parameters } built-in events org.jboss.seam.presetvariable.newplayer org.jboss.seam.postcreate.matchbean // matchbean passed as arg org.jboss.seam.predestroycontext.application org.jboss.seam.aftertransactionsuccess org.jboss.seam.notloggedin

DEMO soccer application

Testing Seam: Overview Unit Testing Integration Testing Mocks ( DBUnit ) Mock Data Integration Testing User Interactions Testing Seam Mail Supported by Seam 23

Too difficult to write? 24

Testing Seam: Component Unit Testing: Seam Components PoJo's Integration Testing 25

Testing Seam: Component Unit Testing: Seam Components PoJo's Integration Testing @Test public void testversion() throws Exception { new ComponentTest() { } protected void testcomponents() throws Exception { EntityManager em = (EntityManager) getvalue("#{entitymanager}"); Assert.assertNotNull(em); Commentator commentator = new CommentatorImpl(); commentator.setname("annoying person"); commentator.setusername("username"); commentator.setpassword("password"); em.persist(commentator); Assert.assertEquals(0, commentator.getversion().intvalue()); commentator.setversion(1); Assert.assertEquals(1, commentator.getversion().intvalue()); } }.run(); 25

EntityManager Integration Testing: EntityManager injection 26

EntityManager Integration Testing: EntityManager injection <persistence:entity-manager-factory name="soccer" persistence-unit-name="soccer"/> <persistence:managed-persistence-context name="entitymanager" entity-manager- factory="#{soccer}" auto-create="true" persistence-unit-jndi-name="java:/soccerds" /> 26

EntityManager Integration Testing: EntityManager injection <persistence:entity-manager-factory name="soccer" persistence-unit-name="soccer"/> <persistence:managed-persistence-context name="entitymanager" entity-manager- factory="#{soccer}" auto-create="true" persistence-unit-jndi-name="java:/soccerds" /> protected void testcomponents() throws Exception { EntityManager em = (EntityManager) getvalue("#{entitymanager}"); Assert.assertNotNull(em); 26

Who's going to pay for the extra test server? 27

JBoss Embedded 28

JBoss Embedded Bootstrap on classpath http://www.jboss.org/community/docs/doc-9690 28

JBoss Embedded Bootstrap on classpath http://www.jboss.org/community/docs/doc-9690 <core:init debug="true" jndi-pattern="${jndi.pattern}"/> 28

JBoss Embedded <profiles> Bootstrap <profile> on classpath <!-- "Profile package" is used for production --> http://www.jboss.org/community/docs/doc-9690 <id>package</id> <activation> <activebydefault>false</activebydefault> <property> <name>embedded</name> <value>false</value> </property> </activation> <properties> <jndi.pattern>soccer-ear-${version}/#{ejbname}/local</jndi.pattern> </properties> <core:init debug="true" jndi-pattern="${jndi.pattern}"/> </profile> <profile> <!-- "Profile test" is used for embedded jboss --> <id>test</id> <activation> <activebydefault>true</activebydefault> <property> <name>embedded</name> <value>true</value> </property> </activation> <properties> <jndi.pattern>#{ejbname}/local</jndi.pattern> </properties> </profile> </profiles> 28

JBoss Embedded <profiles> Bootstrap <profile> on classpath <!-- "Profile package" is used for production --> http://www.jboss.org/community/docs/doc-9690 <id>package</id> <activation> <activebydefault>false</activebydefault> <property> Maven version: >= 2.0.8 <name>embedded</name> <value>false</value> </property> JNDI </activation> Pattern issue <properties> <jndi.pattern>soccer-ear-${version}/#{ejbname}/local</jndi.pattern> <core:init debug="true" jndi-pattern="${jndi.pattern}"/> </profile> <profile> Change </properties> ports mbeans <!-- "Profile test" is used for embedded --> jboss.messaging:service=connector,transport=bisocket <id>test</id> <activation> <activebydefault>true</activebydefault> jboss.remoting:type=connector,name=defaultejb3conne <property> <name>embedded</name> <value>true</value> ctor,handler=ejb3 </property> </activation> <properties> <jndi.pattern>#{ejbname}/local</jndi.pattern> </properties> </profile> </profiles> 28

Why should I write mockups? 29

Testing Mocks 3rd party systems. /** * @author Joris De Winne - RealDolmen */ (" Name("homeBean @ ( Install.MOCK @Install(precedence = ( Scope(ScopeType.CONVERSATION @ public class HomeBeanMockImpl implements HomeBean { /** () com.realdolmen.soccer.business.home.homebean#getnextmatch @see * */ (" Factory("nextMatch @ public Match getnextmatch() { 30

Testing Mocks 3rd party systems. Put src/test/java on classpath /** * @author Joris De Winne - RealDolmen */ (" Name("homeBean @ ( Install.MOCK @Install(precedence = ( Scope(ScopeType.CONVERSATION @ public class HomeBeanMockImpl implements HomeBean { /** () com.realdolmen.soccer.business.home.homebean#getnextmatch @see * */ (" Factory("nextMatch @ public Match getnextmatch() { 30

Mocks: continued (" Factory("nextMatch @ public Match getnextmatch() { Match matchmock = new MatchImpl(); matchmock.setaway(null); matchmock.setawayscore(10); matchmock.setcommentator(null); matchmock.setevents(null); matchmock.sethome(null); matchmock.sethomescore(1); matchmock.setid(666l); matchmock.setmatchdate(calendar.getinstance().gettime()); matchmock.setstartdate(calendar.getinstance().gettime()); matchmock.setversion(999); return matchmock; } 31

Mocks: continued And how do we test it? 32

Mocks: continued And how do we test it? @Test public void testgetnextmatch() throws Exception { new ComponentTest() { protected void testcomponents() throws Exception { Match match = (Match) invokemethod("#{homebean.getnextmatch()}"); Assert.assertNotNull(match); } Assert.assertEquals(666, match.getid().intvalue()); } }.run(); 32

DBUnit 33

DBUnit We want some dummy data inserted! 33

DBUnit We want some dummy data inserted! (" business " @Test(testName = "authentication", suitename = "all", groups = public class AuthenticationManagerTest extends DBUnitSeamTest { 33

DBUnit We want some dummy data inserted! (" business " @Test(testName = "authentication", suitename = "all", groups = public class AuthenticationManagerTest extends DBUnitSeamTest { @Override protected void preparedbunitoperations() { beforetestoperations.add(new DataSetOperation( "soccer/datasets/authenticationtestdata.xml")); } 33

Test everything! Also JSF pages! 34

User Interactions Test web application Functional Testing 35

User Interactions Test web application Functional Testing /** * Test correct signon services contact login. * * @throws Exception * the exception */ @Test public void testcorrectsignon() throws Exception { final FacesRequest fr = new FacesRequest("/login.xhtml") { 35

User Interactions: cont. final FacesRequest fr = new FacesRequest("/login.xhtml") { @Override protected void beforerequest() { super.beforerequest(); } @Override protected void processvalidations() throws Exception { validatevalue("#{identity.username}", "pemae"); validatevalue("#{identity.password}", "pemae"); assert!isvalidationfailure(); } @Override protected void updatemodelvalues() throws Exception { setvalue("#{identity.username}", "pemae"); setvalue("#{identity.password}", "pemae"); } @Override protected void invokeapplication() { invokemethod("#{identity.login}"); } @Override public String tostring() { return result; } }; fr.run(); 36

They take too long to execute! 37

Run faster 38

Run faster JBoss Embedded: Kick out jms 38

Run faster JBoss Embedded: Kick out jms Use Seam 2.1.1.CR1 CR2 38

Run faster JBoss Embedded: Kick out jms Use Seam 2.1.1.CR1 CR2 Example: compilation, packaging and testing (54 integration tests) 1 minute 18 seconds 38

DEMO Time to run the tests!

Seam References Corelio Newspapers: 0.5 million / day Freesheets: 4million copies / week Magazines: CÃTCHY, PC Magazine ( annum Printing (e.g.: 50,000 tons of newspaper per ( day E-media: Online sites (> 300.000 visitors / 40

Seam References Corelio Newspapers: 0.5 million / day Freesheets: 4million copies / week Magazines: CÃTCHY, PC Magazine ( annum Printing (e.g.: 50,000 tons of newspaper per ( day E-media: Online sites (> 300.000 visitors / 40

Seam References Corelio Newspapers: 0.5 million / day Freesheets: 4million copies / week Magazines: CÃTCHY, PC Magazine ( annum Printing (e.g.: 50,000 tons of newspaper per ( day E-media: Online sites (> 300.000 visitors / 40

Reference Case External Service For Prevention and Protection at Work Well-being at work Company visits 41

BRIE Project Goal Improve existing service of company visits Give the company visitor (400 users) a tool that helps him in his daily activities Registration of observations in central DB Easy creation of summary report for the customer 42

BRIE Global Design Phase Focus on JEE, Open Source, SOA Users are not familiar with web applications 43 Changing business processes of company visits

BRIE Architecture Scalable infrastructure Rich look and feel JEE6 in mind (Web Beans) 44 Learning Curve developers

BRIE Scrum Sprint review Ondersteun mijn business Sprint retrospective Ease of development Automatic testing not straightforward ı 45

BRIE Testing Unit & Automated Functional Tests Selenium SeamTest JSF, Ajax Maven Performance & Stress Tests JMeter cid Maven Site & Bamboo Maven Archetype JSF, Seam project dashboard jumpstart future 46 projects

Summary 47

Summary Web applications == Seam 47

Summary Web applications == Seam Perfect integration: JSF, Facelets, Richfaces, EJB3,... 47

Summary Web applications == Seam Perfect integration: JSF, Facelets, Richfaces, EJB3,... Fast development 47

Summary Web applications == Seam Perfect integration: JSF, Facelets, Richfaces, EJB3,... Fast development Issues: 47

Summary Web applications == Seam Perfect integration: JSF, Facelets, Richfaces, EJB3,... Fast development Issues: Mavenizing the project 47

Summary Web applications == Seam Perfect integration: JSF, Facelets, Richfaces, EJB3,... Fast development Issues: Mavenizing the project JBoss Embedded configuration 47

Summary Web applications == Seam Perfect integration: JSF, Facelets, Richfaces, EJB3,... Fast development Issues: Mavenizing the project JBoss Embedded configuration Stress / Performance testing 47

Q&A

Thanks for your attention!