session beans informatics engineering – university of brawijaya eriq muhammad adams j...
TRANSCRIPT
![Page 1: Session Beans INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J eriq.adams@ub.ac.id](https://reader030.vdocuments.site/reader030/viewer/2022032605/56649e805503460f94b8440b/html5/thumbnails/1.jpg)
JEE PROGRAMMINGSession Beans
INFO
RM
ATIC
S E
NG
INEER
ING
– U
NIV
ER
SIT
Y O
F B
RA
WIJ
AYA
Eriq Muhammad Adams [email protected]
![Page 2: Session Beans INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J eriq.adams@ub.ac.id](https://reader030.vdocuments.site/reader030/viewer/2022032605/56649e805503460f94b8440b/html5/thumbnails/2.jpg)
Agenda
What is Session Beans ? When do you use Session Beans ? Rich Client Applications Web Based Applications Local vs Remote Interface Stateless vs Stateful Bean Stateless Bean Lifecycle Stateful Bean Lifecycle Session Beans Practice Demo
![Page 3: Session Beans INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J eriq.adams@ub.ac.id](https://reader030.vdocuments.site/reader030/viewer/2022032605/56649e805503460f94b8440b/html5/thumbnails/3.jpg)
What is EJB Session Beans ? Java components that run in EJB Containers / JEE
Application Servers Java components typically used to model use
cases Hold business logic There are two types :
Stateless : This type of bean does not maintain any conversational state on behalf of a client application.
Stateful: This type of bean maintains state, and a particular instance of the bean is associated with a specific client request. Stateful beans can be seen as extensions to client programs that are running on the server.
![Page 4: Session Beans INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J eriq.adams@ub.ac.id](https://reader030.vdocuments.site/reader030/viewer/2022032605/56649e805503460f94b8440b/html5/thumbnails/4.jpg)
When do you use Session Beans ? If you want to :
write business logic maintain a client ‘s conversation state model back-end processes
You can use it in : 2-tier Applications 3-tier Applications
Rich Client Applications Web-based Applications
![Page 5: Session Beans INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J eriq.adams@ub.ac.id](https://reader030.vdocuments.site/reader030/viewer/2022032605/56649e805503460f94b8440b/html5/thumbnails/5.jpg)
Rich Client Applications
![Page 6: Session Beans INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J eriq.adams@ub.ac.id](https://reader030.vdocuments.site/reader030/viewer/2022032605/56649e805503460f94b8440b/html5/thumbnails/6.jpg)
Web-based Applications
![Page 7: Session Beans INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J eriq.adams@ub.ac.id](https://reader030.vdocuments.site/reader030/viewer/2022032605/56649e805503460f94b8440b/html5/thumbnails/7.jpg)
Local vs Remote Interface
A web client using local interfaces of session beans
![Page 8: Session Beans INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J eriq.adams@ub.ac.id](https://reader030.vdocuments.site/reader030/viewer/2022032605/56649e805503460f94b8440b/html5/thumbnails/8.jpg)
Local vs Remote Interface (cont.)
A rich client using remote interfaces of session beans
![Page 9: Session Beans INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J eriq.adams@ub.ac.id](https://reader030.vdocuments.site/reader030/viewer/2022032605/56649e805503460f94b8440b/html5/thumbnails/9.jpg)
Stateless vs Stateful Bean
Stateless Session Beans Stateful Session Beans
![Page 10: Session Beans INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J eriq.adams@ub.ac.id](https://reader030.vdocuments.site/reader030/viewer/2022032605/56649e805503460f94b8440b/html5/thumbnails/10.jpg)
Stateless vs Stateful Bean (cont.)
![Page 11: Session Beans INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J eriq.adams@ub.ac.id](https://reader030.vdocuments.site/reader030/viewer/2022032605/56649e805503460f94b8440b/html5/thumbnails/11.jpg)
Stateless Lifecycle
![Page 12: Session Beans INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J eriq.adams@ub.ac.id](https://reader030.vdocuments.site/reader030/viewer/2022032605/56649e805503460f94b8440b/html5/thumbnails/12.jpg)
Stateful Bean Lifecycle
![Page 13: Session Beans INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J eriq.adams@ub.ac.id](https://reader030.vdocuments.site/reader030/viewer/2022032605/56649e805503460f94b8440b/html5/thumbnails/13.jpg)
Session Beans Best Practices Choose your bean type carefully . Mostly use Stateless, if you
have web-tier client use HttpSession instead. Carefully examine interface types for session beans. If the
client will always be used within the same JVM as the bean, then use a local interface.
Inject carefully. Make sure you don’t inject a stateful session bean into a stateless session bean or servlet.
Separate crosscutting concerns such as logging and auditing using business interceptors.
Closely examine what kind of data you are storing in the conversation state.
Try to use small, primitive instance variables in a stateful bean whenever possible as opposed to large nested composite objects.
Don’t forget to define remove methods in a stateful session bean. Tune passivation and timeout configurations to find the optimal
values for your application.
![Page 14: Session Beans INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J eriq.adams@ub.ac.id](https://reader030.vdocuments.site/reader030/viewer/2022032605/56649e805503460f94b8440b/html5/thumbnails/14.jpg)
Demo
Demo in SessionBeansDemo.zip http://eriq.lecture.ub.ac.id/files/2011/03/SessionBeansD
emo.zip
![Page 15: Session Beans INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J eriq.adams@ub.ac.id](https://reader030.vdocuments.site/reader030/viewer/2022032605/56649e805503460f94b8440b/html5/thumbnails/15.jpg)
References
EJB In Action, Manning Beginning EJB 3 Application
Development, Apress