Enterprise JavaBeans Session Beans. Session beans are a type of Enterprise JavaBean component designed to implement business logic responsible for managing.

Slides:



Advertisements
Similar presentations
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
Advertisements

12 Copyright © 2005, Oracle. All rights reserved. Implementing Business Tasks with Session EJBs.
11 Copyright © 2005, Oracle. All rights reserved. Creating the Business Tier: Enterprise JavaBeans.
ISE 390 Dynamic Web Development Java EE Web Applications.
Sapana Mehta (CS-6V81) Overview Of J2EE & JBoss Sapana Mehta.
Enterprise Java Beans Welcome to the world of “Distributed System” Presented By: Sameer Nanda Date: 12/17/03.
Copyright W. Howden1 Lecture 19: Intro to O/O Components.
Point Of Sale(POS) J2EE Application Department : Computer Science Degree : Master Student : Woojin Choi ID : (POS J2EE Application with JRun)
1 CS 483 Enterprise and Web Application Programming Week 6 Session Beans JSP Tutorial.
Enterprise Java Beans (EJB)
J2EE Kenneth M. Anderson CSCI Web Technologies October 3, 2001.
Structure of a web application1 Dr Jim Briggs. MVC Structure of a web application2.
Object Oriented Analysis and Design 1 Chapter 8 - Web Application System Design  Modeling Web Application using UML  Application Server  Web Application.
Emmanuel Cecchet et al.  Performance Scalability of J2EE application servers.  Test effect of: ◦ Application Implementation Methods ◦ Container Design.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
EJB. Component Characteristics An enterprise Bean typically contains business logic that operates on the enterprise’s data. An enterprise Bean’s instances.
1 J2EE Components. 2 Application Servers relieve the programming burden for business distributed components. They provide support for system level services.
1 l Enterprise Computing -- 3-tier and multi-tier applications l Enterprise JavaBeans n EJB Features n Types of EJBs l Example – A Currency Converter n.
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.
J2EE Part 2: Enterprise JavaBeans CSCI 4300 Images and code samples from jGuru EJB tutorial,
Enterprise Java Beans - (EJB)
Developing and Deploying Business Components using PowerJ.
Enterprise JavaBeans EJB Container Services. EJB container Enterprise JavaBeans are deployed in an EJB container within the application server EJB container.
Session Beans Overview EJB container Remote Invocation Represent client's access to app Local / Remote speed / flexibility trade-off when to choose local.
Advanced Java Session 7 New York University School of Continuing and Professional Studies.
Enterprise JavaBeans Umer Farooq CS6704: Design Patterns & Component FrameworksFebruary 25, 2002.
September 16, 2010COMS W41561 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser
1 Stateful Session Beans Stateless Session Beans Michael Brockway Sajjad Shami Northumbria University School of Computing, Engineering & Information Sciences.
Enterprise Java Bean Matt. 2 J2EE 3 J2EE Overview.
The Triad of Beans I Oleh: Dini Addiati ( ) Fahrurrozi Rahman ( Y) Irfan Hilmy ( ) Salman Azis A ( ) Aziiz Surahman.
Presented By Pradeep K Sahu. What will be the Contents of the Seminar ? What is EJB ? EJB Architecture Types of EJB Session Entity Why EJB ? Writing a.
Enterprise JavaBeans. Lesson 1: Introduction to Server-Side Component Software.
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.
Middleware Technology (J2EE/EJB) Stateful Session Bean.
Introduction to J2EE Architecture Portions by Kunal Mehta.
EJB Framework.  As we know, EJB is the center of the J2EE architecture that provides a sturdy framework for building enterprise applications. The major.
Java Server Pages A JSP page is a text-based document that contains two types of text: static template data, which can be expressed in any text-based format,
J2EE Structure & Definitions Catie Welsh CSE 432
Session Beans Objectives Introduction to Session Beans Local and Remote Session Beans Stateless and Stateful Session Beans Session Bean Lifecycle Accessing.
Session Beans -) stateless -) stateful. Session Beans A session bean represents a single client inside the J2EE server. To access an application that.
Fall CIS 764 Database Systems Engineering L7. EJB’s.
1 Architectural Overview For application developers, assembling enterprise beans requires little or no expertise in the complex system-level issues that.
Fall CIS 764 Database Systems Engineering L7. ADF + EJB Context: Oracle Application Development Framework …but … only EJB.
Introduction to Enterprise JavaBeans Topics In Systems Architecture Barry Herbold
Session Beans Based on: Patel, Brose, Silverman, Mastering Enterprise JavaBeans 3.0.
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.
Session Beans Objectives Introduction to Session Beans Local and Remote Session Beans Stateless and Stateful Session Beans Session Bean Lifecycle Accessing.
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.
Library Example February 2010 – August 2010
Copyright © 2002 ProsoftTraining. All rights reserved. Enterprise JavaBeans.
13 Copyright © 2004, Oracle. All rights reserved. Managing Persistent Data in the Business Tier Entity EJBs.
Enterprise JavaBeans: Fundamentals. EJB Fundamentals(c)CDAC(Formerly NCST)2 Contents Introduction Technology Overview EJB Architecture EJB Specification.
Enterprise JavaBeans. Lesson 1: Introduction to Server-Side Component Software.
Advanced Java Session 7 New York University School of Continuing and Professional Studies.
EJB Enterprise Java Beans JAVA Enterprise Edition
EJB. Introduction Enterprise Java Beans is a specification for creating server- side scalable, transactional, multi-user secure enterprise-level applications.
©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.
Callbacks and Interceptors. Contents  Session Beans Life Cycle  Interceptors.
Structure of a web application
EJB (Enterprise Java Beans)
ISE 390 Dynamic Web Development
Understanding and Designing with EJB
Understanding and Designing with EJB
Remote method invocation (RMI)
Component-based Applications
Understanding and Designing with EJB
Enterprise Java Beans.
Introduction to Session beans
Knowledge Byte In this section, you will learn about:
Presentation transcript:

Enterprise JavaBeans Session Beans

Session beans are a type of Enterprise JavaBean component designed to implement business logic responsible for managing processes, tasks, workflows To access an application that is deployed on the server, the client invokes the session bean’s methods Is similar to an interactive session Is not shared between clients and is not persistent

State management modes There are two types of session beans Stateless and Stateful

Stateless session beans Does NOT maintain a conversational state with the client Instance variables may contain a state specific to client, but ONLY for the duration of the invocation Offer BETTER scalability for applications that require large numbers of clients CAN implement a web service, but other types of EJBs cannot

Stateful session beans Instance variables represent the state of a unique client-bean session The state is retained for the duration of the client-bean session If the client removes the bean or terminates, the session ends and the state disappears Storing the state is a very resource-intensive process, so an application that uses stateful beans may not be easily scalable

Stateless vs. Stateful

Elements of a session bean Every session bean requires the presence of a bean interface and a bean class

Bean interface and class A bean interface is the mechanism by which client code will interact with the bean internals The implementation of the business logic of a session bean is located in its bean class The bean class must either implement the javax.ejb.SessionBean interface or be annotated The bean interface may be implemented by the developer, or it can be generated automatically

Example: Stateless session bean Bean interfaces: public interface Calculator { public int add(int x, int y); public int subtract(int x, int y); public interface CalculatorRemote extends Calculator{ public interface CalculatorLocal extends Calculator{ }

Example: Stateless session bean Bean public class CalculatorBean implements CalculatorRemote, CalculatorLocal { public int add(int x, int y){ return x + y; } public int subtract(int x, int y){ return x - y; }

Example: Stateless session bean Session bean client: public class Client{ public static void main(String[] args) throws Exception { Context ctx = new InitialContext(); Calculator calculatorRemote = (Calculator) ctx.lookup("CalculatorBean/remote"); System.out.println("1 + 1 = " + calculatorRemote.add(1, 1)); } -Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory -Djava.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces -Djava.naming.provider.url=localhost VM arguments:

Reusability of Stateless instances Container transparently reuses bean instances to serve different clients Pool of bean instances are created by container at appropriate time (ex: at the time of system boot or when the size of pool becomes too small) Bean instances are then recycled Smaller number of bean instances (pool of bean instances) can serve larger number of clients at a single time – improves scalability of the system clients can be idle between calls

When to use stateful beans? Typical example – shopping cart Use it when bean needs to hold information about the client across method invocations Advantages Transient information can be stored in the instance variables, not it the database Save bandwidth on method invocations Disadvantages Bad performance and poor scalability Can be swapped in and out of memory (activated and deactivated), state gets stored

Example: Stateful session bean public interface ShoppingCart { void buy(String product, int quantity); HashMap void checkout(); } Bean interfaces:

Example: Stateful public class ShoppingCartBean implements ShoppingCart, Serializable{ private HashMap cart = new HashMap (); public void buy(String product, int quantity){ if (cart.containsKey(product)){ int currq = cart.get(product); currq += quantity; cart.put(product, currq); } else { cart.put(product, quantity); } public HashMap getCartContents(){ return public void checkout(){ System.out.println("To be implemented"); } }

References EJB fundamentals and session beans ejb.html SessionBean Presentation A quick look at EJB 3.0 Stateless Session Beans stateless_session_ejb_tutorial.html