Copyright Callista Enterprise AB, 2005 Page:1 EJB 3.0 Johannes Carlén - Jan Västernäs Callista Enterprise AB.

Slides:



Advertisements
Similar presentations
Introduction to NHibernate By Andrew Smith. The Basics Object Relation Mapper Maps POCOs to database tables Based on Java Hibernate. V stable Generates.
Advertisements

11 Copyright © 2005, Oracle. All rights reserved. Creating the Business Tier: Enterprise JavaBeans.
Spring, Hibernate and Web Services 13 th September 2014.
An architecture for webb applications, J2EE
JBoss Seam: Contextual Components Jason Bechtel
Enterprise JavaBeans 2.0 Wu Lu (Cont’d). EJB2.0 Query Language EJB QL is a declarative language similar in many respects to SQL Is intended to be portable.
Introduction to Enterprise JavaBeans. Integrating Software Development Server-side Component Model Distributed Object Architecture –CORBA –DCOM –Java.
Emmanuel Cecchet et al.  Performance Scalability of J2EE application servers.  Test effect of: ◦ Application Implementation Methods ◦ Container Design.
An Introduction to Hibernate Matt Secoske
Data Persistence and Object-Relational Mapping Slides by James Brucker, used with his permission 1.
CIS 764 Kansas State University
Hibernatification! Roadmap for Migrating from Plain Old SQL on JDBC to JPA on Hibernate Duke Banerjee Senior Developer, DrillingInfo.com.
Java Persistence API Maciej Adamiak. Agenda -Entity, -Entity Operations, -Query Language.
CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren.
Agenda What is Hibernate Spring Integration Questions Overview
Maven for building Java applications By Nalin De Zoysa
1 The JNDI ENC and Injection Every EJB container that is deployed in an application server has its own personal internal registry called the Enterprise.
EJB. Component Characteristics An enterprise Bean typically contains business logic that operates on the enterprise’s data. An enterprise Bean’s instances.
JPA Java Persistence API. Introduction The Java Persistence API provides an object/relational mapping facility for managing relational data in Java applications.
1 Session Bean Chuyên đề Lập trình Java & J2EE Chương 14 Biên soạn: Th.S Nguyễn văn Lành.
Ing. Ignacio Roqueta ARTech GeneXus and J2EE.
Enterprise JavaBeans EJB Container Services. EJB container Enterprise JavaBeans are deployed in an EJB container within the application server EJB container.
Chemical Toxicity and Safety Information System Shuanghui Luo Ying Li Jin Xu.
Container-Managed Persistence (CMP) Entity Beans Lesson 3A / Slide 1 of 42J2EE Server Components Objectives In this lesson, you will learn to: Identify.
Enterprise Java Bean Matt. 2 J2EE 3 J2EE Overview.
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.
Message-Driven Beans and EJB Security Lesson 4B / Slide 1 of 37 J2EE Server Components Objectives In this lesson, you will learn about: Identify features.
Dependency Injection in Action Jan Västernäs. CADEC2006, DI, Slide 2 Copyright 2006, Callista Enterprise AB Agenda (DI=Dependency Injection) Background.
JBoss at Work JAW Motors Application Chapter 1-3 Jeff Schmitt October 9, 2006.
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.
JavaEE Seams Easy JBoss Seam: A Web Application Component Framework for EJB3, JPA, JSF and AJAX.
Enterprise JavaBeans Understanding EJB Components Version 0.1 Kamal Wickramanayake
EJB 3.0 Persistence Based on: Patel, Brose, Silverman, Mastering Enterprise JavaBeans 3.0.
1 Architectural Overview For application developers, assembling enterprise beans requires little or no expertise in the complex system-level issues that.
Creating competitive advantage Copyright © 2003 Enterprise Java Beans Presenter: Wickramanayake HMKSK Version:0.1 Last Updated:
MCS 270 Spring 2014 Object-Oriented Software Development.
Middleware Technology (J2EE/EJB) Entity Bean (JBoss EJB 3.0 tutorial)
Java Persistence API v1.0 a standard for ORM frameworks and POJO based Persistence Magnus Larsson
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool The problem fixed by ORM Advantage Hibernate Hibernate Basic –Hibernate sessionFactory –Hibernate Session.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
v110912Java Persistence: EntityManager2 Overview Earlier versions of EJB Specification defined the persistence layer –javax.ejb.EntityBean Java EE 5 moved.
By Srinivas Mahakud Java Persistence API JPA. Review Topics: Introduction what is the JPA? What is the JPA contains of? Why developers should Create the.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
Enterprise Java Beans N.V.RAJASEKHAR REDDY. Definition of EJB EJBs are the components that are the set of classes and interfaces deployed within a container.
13 Copyright © 2004, Oracle. All rights reserved. Managing Persistent Data in the Business Tier Entity EJBs.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool Used in data layer of applications Implements JPA.
©NIIT Introducing Enterprise JavaBeans (EJB) Lesson 1A / Slide 1 of 43J2EE Server Components Objectives In this lesson, you will learn about: The features.
Enterprise JavaBeans: Fundamentals. EJB Fundamentals(c)CDAC(Formerly NCST)2 Contents Introduction Technology Overview EJB Architecture EJB Specification.
Middleware Technology (J2EE/EJB) EJB Fundamentals.
Hibernate Thuy, Le Huu. Pentalog VN. Agenda Hibernate Annotations Improving performance – Lazy loading – Fetching Strategies – Dynamic insert, dynamic.
Singleton Academy, Pune. Course syllabus Singleton Academy Pune – Course Syllabus1.
EJB Enterprise Java Beans JAVA Enterprise Edition
1 Entity Callbacks and Listeners When you execute EntityManager methods like persist( ), merge( ), remove( ), and find( ), or when you execute EJB QL queries,
1 EJB 3.0: There’s Something Different About You Martin Jäkle, TSBU Middleware.
©NIIT Session Beans Lesson 1B/ Slide 1 of 37J2EE Server Components Objectives In this lesson, you will learn to: Describe the characteristics of session.
Enterprise Java Beans. Contents  Understanding EJBs  Practice Section.
CS6320 – Java Persistence API
Entity Bean Chuyên đề Lập trình Java & J2EE Chương 15
Hibernate (JPA) Code First Entity Relations
Spring Data Advanced Querying
Database Applications (15-415) ORM - Part I Lecture 11, February 11, 2018 Mohammad Hammoud.
Understanding and Designing with EJB
Understanding and Designing with EJB
Knowledge Byte In this section, you will learn about:
Lab 6 – EJB User Managment
Understanding and Designing with EJB
Developing and testing enterprise Java applications
Enterprise Java Beans.
Knowledge Byte In this section, you will learn about:
Presentation transcript:

Copyright Callista Enterprise AB, 2005 Page:1 EJB 3.0 Johannes Carlén - Jan Västernäs Callista Enterprise AB

Copyright Callista Enterprise AB, 2005 Page:2 Vad tycker vi ?  Min ödmjukhet är byggd på 35 års framgångar  Bert Karlsson  Det är min uppfattning. Och jag delar den.  Alf Svensson  Kronan har flera mynt  Gunnar Persson, Brynäscoach

Copyright Callista Enterprise AB, 2005 Page:3 Outline  Current Situation ( pre EJB 3.0 )  Java 5.0 Annotations  EJB 3.0 ( based on early draft – not complete )  Demo  Conclusion

Copyright Callista Enterprise AB, 2005 Page:4 Current situation

Copyright Callista Enterprise AB, 2005 Page:5 Current situation  EJB used to be the ”silver bullet”  Many people disagree  Need Application Server  Deployment Descriptors  Callbacks  Too much overhead  Testing is difficult  Persistence model (Entity Beans) sucks

Copyright Callista Enterprise AB, 2005 Page:6 Current situation  EJB also bring values  Declarative Transactions & Security, Threading, Resource Pooling etc  May not be needed by all applications  Component Programming model  Strong Open Source alternate products has emerged  Spring – IoC and much more  Hibernate - persistence  xDoclet – javadoc-driven source/configuration files generation

Copyright Callista Enterprise AB, 2005 Page:7 Java 5.0

Copyright Callista Enterprise AB, 2005 Page:8 Java 5.0  Annotations  Generics  Map points = new HashMap  Autoboxing  points.put(jan,5);  Enums  enum Season { WINTER, SPRING, SUMMER, FALL }  Enhanced for-loop List =.... for ( String s : list ) { System.out.println(s); }

Copyright Callista Enterprise AB, 2005 Page:9 Java 5.0 Annotations definitions  to public OrderImplTest public public shipOrder()  Can be used on class, interface, method, method parameter, field.  Annotation must be defined in an interface Unittest {  Can have arguments Enterprise AB”)  java.lang.annotation package

Copyright Callista Enterprise AB, 2005 Page:10 Java 5.0 Annotations usage  Parse source code  Runtime via new Class, Method and Field class methods Class myclass = OrderImplTes.class; for (Annotation a : myclass.getAnnotations()) { System.out.println("annotation: " + a.annotationType()); } annotation: interface se.callista.annotate.Unittest

Copyright Callista Enterprise AB, 2005 Page:11 EJB 3.0 Extreme makeover

Copyright Callista Enterprise AB, 2005 Page:12 Overall goals with EJB 3.0  Decrease the number of required artifacts ( some are optional )  Home, LocalHome, Local Interface  Deployment Descriptors  Vendor Deployment Descriptors  Use of annotations  POJO’s and POJI’s  Transparent persistence (POJO-based a la Hibernate )

Copyright Callista Enterprise AB, 2005 Page:13 Overall goals with EJB 3.0 (cont’d)  Enhancements of entity beans  Inheritance and polymorphism  Metadata annotations for ORM  Enhancements of EJB QL – explicit inner and outer joins, subqueries, group-by, dynamic queries…  No callbacks  Dependency Injection  Decrease the requirements of checked exceptions  Out of container testing

Copyright Callista Enterprise AB, 2005 Page:14 Interface  DD…. Declare Directly Declare your interface to be remote or local directly in your class public interface OrderService { public OrderDTO findByOrderNo(Long orderNo); } Local interface declaration

Copyright Callista Enterprise AB, 2005 Page:15 Implementation  Set the the type of your EJB the same public class OrderServiceBean implements OrderService { … } Big difference compared with todays decoupled impl/interface

Copyright Callista Enterprise AB, 2005 Page:16 Transaction Handling  Set the the transaction attribute of the public void updateOrder (OrderDTO order) { … }

Copyright Callista Enterprise AB, 2005 Page:17 Message = javax.jms.Queue.class, destinationJndiName = “jms/orderconfirmation", durable = true, subscriptionId = "queueExample") public class ConfirmationMDB implements MessageListener { public void onMessage(Message recvMsg) {...

Copyright Callista Enterprise AB, 2005 Page:18 Dependency  anything from JNDI  Access objects like SessionContext, TimerService, UserTransaction, EntityManager, EJB’s, data sources, environment variables, JMS Queues private DataSource ds;

Copyright Callista Enterprise AB, 2005 Page:19 Dependency Injection  inject EJB references private OrderBean = "se.callista.Orderbean") public void setOrderBean(OrderBean orderBean) { this.orderBean = orderBean; }  access data sources  other

Copyright Callista Enterprise AB, 2005 Page:20 Entity Beans  Plain Old Java Objects  Inheritance and polymorphism  O/R mapping with annotations  Allocate with new.  Accessed through the EntityManager

Copyright Callista Enterprise AB, 2005 Page:21 Entity = ”CALLISTA_PRODUCT") public class CallistaProduct implements java.io.Serializable { private Long id; private String name;... }

Copyright Callista Enterprise AB, 2005 Page:22 EntityManager  javax.ejb.EntityManager  Possible to attach, detach, reattach to/from EntityManager public void create(Object entity); // attach public T find(Class entityClass, Object primaryKey); public T merge(T entity); // reattach public void remove(Object entity); public Query createQuery(String ejbqlString); public void flush(); public void evict(Object entity); // detach...

Copyright Callista Enterprise AB, 2005 Page:23 Making objects private EntityManager entityManager; public void create(CallistaProduct product) { entityManager.create(product); // entityManager.flush(); }

Copyright Callista Enterprise AB, 2005 Page:24 Deleting private EntityManager entityManager; public void delete(CallistaProduct product) { entityManager.remove(product); // entityManager.flush(); }

Copyright Callista Enterprise AB, 2005 Page:25 Updating private EntityManager entityManager; public void update(CallistaProduct product) { entityManager.merge(product); // entityManager.flush(); }

Copyright Callista Enterprise AB, 2005 Page:26 Entity Beans – mapping tables = "PURCHASE_ORDER") public class Order implements java.io.Serializable { private int id; private String customerName private Date = GeneratorType.AUTO) public int getId(){return length=80) public String getCustomerName(){ return customerName; } public Date getOrderDate(){ return orderDate; }

Copyright Callista Enterprise AB, 2005 Page:27 Entity Beans – one-to-many (1) = CascadeType.ALL, fetch = = "order_id") public Collection getItems() { return items; }

Copyright Callista Enterprise AB, 2005 Page:28 Entity Beans – one-to-many (2) public class OrderItem implements java.io.Serializable { private = "order_id") public Order getOrder(){ return order;} }

Copyright Callista Enterprise AB, 2005 Page:29 private EntityManager manager; public List findByLastName(String lastName){ Query query = manager.createQuery( "from Customer c where c.lastname = :lastname"); query.setParameter(”lastname", lastName); return (List ) query.listResults(); }

Copyright Callista Enterprise AB, 2005 Page:30 Calling the service List customerList = service.findByLastName("Svensson"); for (Customer c : customerList) { System.out.println(c.getName()); }

Copyright Callista Enterprise AB, 2005 Page:31 Object Relational Mapping  Object model is NOT equal to Database schema  Fine-grained Objects, aka Complex attributes  Company having a Billing Address and Home Address, all attributes in one Table – three Objects  Inheritance  See coming slides  Derived properties  Exists in the Object but not in the Database

Copyright Callista Enterprise AB, 2005 Page:32 Entity Beans - inheritance  Three ways to implement inheritance. First up…  Single table strategy

Copyright Callista Enterprise AB, 2005 Page:33 Entity Beans - inheritance  One table per subclass

Copyright Callista Enterprise AB, 2005 Page:34 Entity Beans - inheritance  Join table strategy

Copyright Callista Enterprise AB, 2005 Page:35 Join = InheritanceType.JOINED, discriminatorType = = ”CUSTOMER_TYPE") public class Customer implements = InheritanceType.JOINED, discriminatorType = DiscriminatorType.STRING, discriminatorValue = ”B_CUST") public class BusinessCustomer extends Customer {

Copyright Callista Enterprise AB, 2005 Page:36 Demo - Callista Store EJB3.0  Eclipse 3.1 M4, compile-checking favorite Notepad  JBoss with EJB3 Preview 2  Ant build  Changes – less code  No DAO:s  No SQL  No Deployment Descriptors  No Home Interfaces  No callbacks  Changes – more code  Annotations

Copyright Callista Enterprise AB, 2005 Page:37 Demo content  Polymorfistic Query on Customer  Find all customers  call description() abstract method for each hit

Copyright Callista Enterprise AB, 2005 Page:38 Conclusion

Copyright Callista Enterprise AB, 2005 Page:39 Good news  Easier development – less artifacts  POJO + POJI + Annotations  Entity beans – completely new  Transparent, POJO-based  Dependency Injection  Better for testing  Is a specification – not some proprietary open source  Vendor competition  Portability

Copyright Callista Enterprise AB, 2005 Page:40 Concerns  Timing – when will it be ready ?  Spring+Hibernate is gaining momentum  Out of container testing. Not in the spec yet.  Maybe ”next release”  Dependency Injection – not a full implementation  Inject non-JNDI POJO:s ?

Copyright Callista Enterprise AB, 2005 Page:41 Questions ?

Copyright Callista Enterprise AB, 2005 Page:42 EJB 3.0  Coming to an Application Server near you soon  Considerably easier to use

Copyright Callista Enterprise AB, 2005 Page:43 Rod Johnson 14 april  Färgstark kille !  Självkostnad c:a 1000:-  Börja bearbeta din chef nu.  Preliminärt intresse till Maria  Välkommna!