Thông tin tài liệu:
Learning objectives of this chapter include: Define a Stateful Session Bean, list the characteristics of a Stateful Session Bean, write Stateful session bean programs, differentiate between Stateless and Stateful Session beans.
Nội dung trích xuất từ tài liệu:
Bài giảng Lập trình mạng nâng cao: EJB: Stateful Session Bean - Nguyễn Xuân Vinh TRƯỜNGĐẠIHỌCNÔNGLÂMTP.HCMGV:NGUYỄNXUÂNVINHMÔN:LẬPTRÌNHMẠNG2 KHOACÔNGNGHỆTHÔNGTIN EJB: Stateful Session Bean15/01/16 Presenter:NguyễnXuânVinh InformationTechnologyFaculty/XX NongLamUniversity1 TRƯỜNGĐẠIHỌCNÔNGLÂMTP.HCM KHOACÔNGNGHỆTHÔNGTIN SessionObjectivesGV:NGUYỄNXUÂNVINH DefineaStatefulSessionBean ListthecharacteristicsofaStatefulSessionBean. WriteStatefulsessionbeanprograms. DifferentiatebetweenStatelessandStatefulSessionbeans.MÔN:LẬPTRÌNHMẠNG215/01/16/XX2 TRƯỜNGĐẠIHỌCNÔNGLÂMTP.HCM KHOACÔNGNGHỆTHÔNGTIN ReviewofSession3(1of3)GV:NGUYỄNXUÂNVINH Thebeanclass,theEJBobject,theremoteinterface,thehomeinterface,the homeobject,thedeploymentdescriptors,andthejarfilesconstitutethe enterprisebean. Beanclasscontainstheimplementationofthebusinesslogicmethods. EJBcontainerperformsimportantmanagementfunctionswhenitintercepts clientrequestssuchas: *TransactionlogicMÔN:LẬPTRÌNHMẠNG2 *Securitylogic *Beaninstancelogic TheRemoteinterfaceduplicatesthemethodsexposedbythebeanclass. ResponsibilitiesoftheEJBhomeobject: *CreatingEJBobjects *SearchingforexistingEJBObjects *RemovingEJBObjects15/01/16/XX3 TRƯỜNGĐẠIHỌCNÔNGLÂMTP.HCM KHOACÔNGNGHỆTHÔNGTIN ReviewofSession3(2of3)GV:NGUYỄNXUÂNVINH Thedeploymentdescriptor:AfilethattellstheEJBserverabout theclasses,thehomeinterface,andtheremoteinterfacethatMÔN:LẬPTRÌNHMẠNG2 formthebean. Thelifetimeofasessionbeanmaylasttillsuchtimeasthatofa clientsession.Itcouldbeaslongasawindowisopenoras longasanapplicationisopen.Sessionbeansdonot,therefore, surviveapplicationservercrashesormachinecrashes. Threeclassesareessentialfordeployment: HomeInterface15/01/16 RemoteInterface Beanclass/XX4 TRƯỜNGĐẠIHỌCNÔNGLÂMTP.HCM KHOACÔNGNGHỆTHÔNGTIN ReviewofSession3(3of3)GV:NGUYỄNXUÂNVINH Theejbjar.xmlfileisacompressedfilethatcontains thedeclarationsoftheenterprisebeanclass,theMÔN:LẬPTRÌNHMẠNG2 remoteinterfaceandthehomeinterface. AnEJBclientcanbe: *AnordinaryJavaBean *AnotherEJB *AJSPPage *Aservlet *Anapplet15/01/16 *Astandaloneapplication/XX5 CharacteristicsofStatefulSession TRƯỜNGĐẠIHỌCNÔNGLÂMTP.HCM KHOACÔNGNGHỆTHÔNGTIN BeansGV:NGUYỄNXUÂNVINH Conversionalstateoccurswhenaclientcallsamethodonabean. Poolinghastobedonetoconserveresourcesandenhancesscalability. Thecontainerswapsoutabeanandsavestheconversationalstateto theharddiskorotherstoragedevices.Thisprocessiscalled passivation.MÔN:LẬPTRÌNHMẠNG2 Whentheclientrequestsforamethod,thepassivatedconversational stateisreturnedtothebean.Thebeanisagainreadytomeetthe request.Thisprocessiscal ...