Session Beans: Use, Types, and Implementation in Enterprise Applications - Prof. Ye Wu, Study notes of Engineering

This document, authored by dr. Ye wu for swe 645: component-based software development at george mason university, discusses session beans in enterprise applications. It covers when to use session beans, their benefits, concerns, and differences between stateless and stateful session beans. The document also includes instructions for implementing stateless and stateful session beans using eclipse ide.

Typology: Study notes

Pre 2010

Uploaded on 02/12/2009

koofers-user-5z2
koofers-user-5z2 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Session Beans
Ye Wu
http://www.ise.gmu.edu/~wuye
SWE 645
Component-based Software Development
2008-2-18 © Dr. Ye Wu 2
When to Use Session Beans
Implement non-trivial enterprise’s workflow or
processes
Usually are used in multi-tiered applications
2008-2-18 © Dr. Ye Wu 3
Example
DB1
Manager DB1 DB2
Manager DB2
2008-2-18 © Dr. Ye Wu 4
Example
DB1
Manager DB1 DB2
Manager DB2
Session
Bean
2008-2-18 © Dr. Ye Wu 5
Why Using Session Beans
Simplify Enterprise Application
Decouple dependences between client and server
Reduce network traffic
Enhanced security, transaction support
Increase maintainability
2008-2-18 © Dr. Ye Wu 6
Concerns for Session Beans
How to determine the scope for a Session Beans
Use cases
Classes
pf3

Partial preview of the text

Download Session Beans: Use, Types, and Implementation in Enterprise Applications - Prof. Ye Wu and more Study notes Engineering in PDF only on Docsity!

Session Beans

Ye Wu http://www.ise.gmu.edu/~wuye SWE 645 Component-based Software Development

2008-2-18 © Dr. Ye Wu 2

When to Use Session Beans

  • Implement non-trivial enterprise’s workflow or processes
  • Usually are used in multi-tiered applications

2008-2-18 © Dr. Ye Wu 3

Example

DB Manager DB^

DB Manager DB

2008-2-18 © Dr. Ye Wu 4

Example

DB Manager DB^

DB Manager DB

Session Bean

2008-2-18 © Dr. Ye Wu 5

Why Using Session Beans

  • Simplify Enterprise Application
  • Decouple dependences between client and server
  • Reduce network traffic
  • Enhanced security, transaction support
  • Increase maintainability

2008-2-18 © Dr. Ye Wu 6

Concerns for Session Beans

  • How to determine the scope for a Session Beans
    • Use cases
    • Classes

2008-2-18 © Dr. Ye Wu 7

Stateless vs Stateful Session Beans

  • A stateful session bean can keep data between client accesses. A stateless session bean must not.
  • Both represent a private resource for the client that created them
  • Both are intend to model a process or task
  • Both can update shared data, but do not represent that shared data in the way that an entity bean does. 2008-2-18 © Dr. Ye Wu 8

Stateless Session Bean LifeCycle

Not Exist

Method Ready

  1. Class.newInstance()
  2. injection @Predestroy 3. PostConstruct

Business methods

2008-2-18 © Dr. Ye Wu 9

Stateless Beans

  • Subsequent calls from clients may go to different stateless beans.
  • Stateless beans do not store client specific information
  • Stateless session beans not subject to activation/passivation

2008-2-18 © Dr. Ye Wu 10

Stateful Session Bean LifeCycle

Not Exist

Method Ready Passive

@Predestroy timeout

  1. Class.newInstance()
  2. injection
  3. PostConstruct

@PrePassive @PostActive

Business methods

timeout

2008-2-18 © Dr. Ye Wu 11

Stateful Session Bean Transitions

  • Not Exist → Method Ready
    • Request from clients receive by EJB container
  • Method Ready → Passive
    • Caused by limited resources of EJB container
  • Passive → Method Ready
    • Client invoking method while bean in passive state
  • Method Ready → Not Exist
    • Timeout, client application remove the bean 2008-2-18 © Dr. Ye Wu 12

Implementing Stateless Session Beans

  • Write remote/local interfaces for a stateless session bean
  • Write a bean implementation class for a stateless session bean
  • Package the application
  • Deploy the stateless session bean
  • Test the stateless session bean with a client program