•
•
TableofContents
Index
ApplyingEnterpriseJavaBeans™:ComponentBasedDevelopmentfortheJ2EE™Platform,
SecondEdition
ByVladaMatena,SanjeevKrishnan,Linda
DeMichiel,BethStearns
Publisher :AddisonWesley
PubDate :May30,2003
ISBN :0-201-91466-2
Pages :496
WrittenbythearchitectsoftheEnterpriseJavaBean
(EJB)specification,ApplyingEnterprise
JavaBeans(TM),SecondEditionisanadvanced
programmingguideandreferencesourcewhichhas
beenupdatedandexpandedtoreflectupdatesin
theEJB2.1specification.Thisbookisaninvaluable
resourceforITpersonnelbuildingin-house
applicationsandfortheindependentsoftware
vendors(ISVs)buildingapplicationsforsaleto
enterprise.
Theauthorsuseexampleapplicationstoclearly
illustratemanyofthetypicalproblemsencountered
inenterpriseapplicationdevelopment,andtohelp
developerslearntousethenewestfeaturesofthe
EJB.ApplyingEnterpriseJavaBeans(TM),Second
EditionalsoexplorestheuseofEJBarchitecturein
theconstructionandaccessingofWebservices,
thusintegratingapplicationsacrossenterpriseswith
interoperable,standards-basedprotocolsand
servicedescriptionformats.
In-depthcoverageincludessuchEJBtopicsas:
SupportforWebservicesandsecurity
management
Message-drivenbeansandintegrationwithJava
MessagingService(JMS)
Sessionbeans-includingadiscussionofthe
differencesbetweenstatefulandstateless
sessionbeans
Entitybeans-includinglifecycle,persistence
management,andcontainermanagement
Transactionmanagement
EJBQueryLanguage
ApplyingEnterpriseJavaBeans(TM),Second
EditiondiscusseswhenandhoweachEJBfeature
shouldbeusedinapplicationsandconcludeswitha
comprehensiveAPIreferencefordevelopers.This
bookisanessentialadditiontoeveryJava
programmer'sbookshelf.
•
•
TableofContents
Index
ApplyingEnterpriseJavaBeans™:Component-BasedDevelopment
fortheJ2EE™Platform,SecondEdition
By
VladaMatena,SanjeevKrishnan,LindaDeMichiel,BethStearns
Publisher :AddisonWesley
PubDate :May30,2003
ISBN :0-201-91466-2
Pages :496
Copyright
TheJava™Series
Foreword
Preface
ConventionsUsedinThisBook
OtherSourcesofInformation
NoteabouttheExampleApplications
ContentsoftheBook
Acknowledgments
Chapter1.
AdvantagesoftheEnterpriseJavaBeans™Architecture
Section1.1.
FromaTwo-TiertoaJ2EEArchitecture
Section1.2.
AdvantagesoftheArchitecture
Section1.3.
Conclusion
Chapter2.
EnterpriseJavaBeansArchitectureOverview
Section2.1.
EnterpriseJavaBeansApplications
Section2.2.
BusinessEntitiesandProcesses,andEnterpriseBeanTypes
Section2.3.
StructureofEnterpriseBeans
Section2.4.
ContainerToolsandServices
Section2.5.
Conclusion
Chapter3.
EnterpriseJavaBeansRoles
Section3.1.
EJBRoles
Section3.2.
Tools
Section3.3.
Conclusion
Chapter4.
WorkingwithSessionBeans
Section4.1.
WhentoUseSessionBeans
Section4.2.
UnderstandingtheStateofaSessionObject
Section4.3.
OverviewoftheExampleApplication
Section4.4.
EnrollmentEJBStatefulSessionBeaninDetail
Section4.5.
PayrollEJBStatelessSessionBean
Section4.6.
DatabaseSchemas
Section4.7.
Container-ProvidedBenefits
Section4.8.
Conclusion
Chapter5.
SessionBeaninItsContainer
Section5.1.
ContainerArtifacts
Section5.2.
HowtheContainerManagesSessionBeansatRuntime
Section5.3.
Conclusion
Chapter6.
UsingMessage-DrivenBeansandConnectors
Section6.1.
JMSandCommunicationModes
Section6.2.
Message-DrivenBeanConcepts
Section6.3.
UsingaMessage-DrivenBeanintheBenefitsApplication
Section6.4.
UsingJMSandConnectorsforCommunication
Section6.5.
Conclusion
Chapter7.
UnderstandingEntityBeans
Section7.1.
ClientViewofanEntityBean
Section7.2.
BeanDeveloperViewofanEntityBean
Section7.3.
TimerService
Section7.4.
Conclusion
Chapter8.
EntityBeanApplicationExample
Section8.1.
ApplicationOverview
Section8.2.
PartsDevelopedbyWombat
Section8.3.
PartsDevelopedatStarEnterprise
Section8.4.
Conclusion
Chapter9.
UsingEnterpriseJavaBeansinWebServices
Section9.1.
IntroductiontoWebServices
Section9.2.
DevelopingaWebServiceUsingStatelessSessionBeans
Section9.3.
StatelessSessionBeanWebServiceExample
Section9.4.
AccessingaWebServicefromanEnterpriseBean
Section9.5.
Document-OrientedWebServices
Section9.6.
Conclusion
Chapter10.
UnderstandingTransactions
Section10.1.
DeclarativeTransactionDemarcation
Section10.2.
ProgrammaticTransactionDemarcation
Section10.3.
Conclusion
Chapter11.
ManagingSecurity
Section11.1.
ResponsibilitiesoftheSystemAdministrator
Section11.2.
ResponsibilitiesoftheContainerProvider
Section11.3.
ApplicationProvider'sViewofSecurity
Section11.4.
Deployer'sResponsibility
Section11.5.
Conclusion
AppendixA.
CodeSamples
SectionA.1.
SessionBeanHelperClasses
SectionA.2.
EnrollmentBeanSourceCode
SectionA.3.
PayrollEJBSessionBeanClass
SectionA.4.
EntityApplicationEnrollmentBeanImplementation
SectionA.5.
SelectionBeanImplementation
SectionA.6.
PlanBeanImplementationClass
SectionA.7.
EmployeeBeanBMPClass
SectionA.8.
PayrollBeanImplementationClassUsingConnectors
SectionA.9.
CCIInterfaceClasses
SectionA.10.
InsurancePlanAdminBeanClass
SectionA.11.
InsurancePlanAdminWSDLDescription
SectionA.12.
ProvidencePlanBeanClass
SectionA.13.
ProvidenceDoctorBeanClass
SectionA.14.
CommandBeans
Glossary
Index
Copyright
Copyright©2003SunMicrosystems,Inc.
4150NetworkCircle,SantaClara,California95054U.S.A.
Allrightsreserved.
Sun,SunMicrosystems,theSunlogo,Java,JavaBeans,the100%Pure
Javalogo,theDukelogoandtheJavaCoffeeCuplogoaretrademarks
orregisteredtrademarksofSunMicrosystems,Inc.intheU.S.andother
countries.UNIXisaregisteredtrademarkintheU.S.andothercountries,
exclusivelylicensedthroughX/OpenCompany,Ltd.Allotherproduct
namesmentionedhereinarethetrademarksoftheirrespectiveowners.
SunMicrosystems,Inc.hasintellectualpropertyrightsrelatingto
technologydescribedinthispublication.Inparticular,andwithout
limitation,theseintellectualpropertyrightsmayincludeoneormoreof
theU.S.patentslistedatandoneormore
additionalpatentsorpendingpatentapplicationsintheU.S.andother
countries.
THISPUBLICATIONISPROVIDED"ASIS"WITHOUTWARRANTYOF
ANYKIND,EITHEREXPRESSORIMPLIED,INCLUDING,BUTNOT
LIMITEDTO,THEIMPLIEDWAR-RANTIESOFMERCHANTABILITY,
FITNESSFORAPARTICULARPURPOSE,ORNON-INFRINGEMENT.
THISPUBLICATIONCOULDINCLUDETECHNICALINACCURACIES
ORTYPOGRAPHICALERRORS.CHANGESAREPERIODICALLY
ADDEDTOTHEINFORMATIONHEREIN;THESECHANGESWILLBE
INCORPORATEDINNEWEDITIONSOFTHEPUBLICATION.SUN
MICROSYSTEMS,INC.,MAYMAKEIMPROVEMENTSAND/OR
CHANGESINTHEPRODUCT(S)AND/ORTHEPROGRAM(S)
DESCRIBEDINTHISPUBLICATIONATANYTIME.
Thepublisheroffersdiscountsonthisbookwhenorderedinquantityfor
specialsales.Formoreinformation,pleasecontact:PearsonEducation
CorporateSalesDivisionOneLakeStreet
UpperSaddleRiver,NJ07458
(800)382-3419
VisitAddison-WesleyontheWeb:www.awprofessional.com
LibraryofCongressControlNumber:2002102513
Allrightsreserved.Nopartofthispublicationmaybereproduced,stored
inaretrievalsystem,ortransmitted,inanyform,orbyanymeans,
electronic,mechanical,photocopying,recording,orotherwise,withoutthe
priorconsentofthepublisher.PrintedintheUnitedStatesofAmerica.
PublishedsimultaneouslyinCanada.
Textprintedonrecycledpaper12345678910CRS0706050403
Firstprinting,May2003
Dedication
TomyfamilyVladaMatena
TomyparentsandKavithaSanjeevKrishnan
ToJimandCarolineLindaDeMichiel
Totwoveryspecialwomen:EdithAujameandJeanneAsheBeth
Stearns
TheJava™Series
LisaFriendly,SeriesEditor
TimLindholm,TechnicalEditor
KenArnold,TechnicalEditorofTheJiniTMTechnologySeries
JimInscore,TechnicalEditorofTheJavaTMSeries,EnterpriseEdition
EricArmstrong,StephanieBodoff,DebbieCarson,MaydeneFisher,Dale
Green,KimHaase
TheJava™WebServicesTutorialKenArnold,JamesGosling,David
Holmes
TheJava™ProgrammingLanguage,ThirdEdition
JoshuaBloch
EffectiveJava™ProgrammingLanguageGuide
MaryCampione,KathyWalrath,AlisonHuml
TheJava™Tutorial,ThirdEdition:AShortCourseontheBasicsMary
Campione,KathyWalrath,AlisonHuml,TutorialTeam
TheJava™TutorialContinued:TheRestoftheJDK™
PatrickChan
TheJava™DevelopersAlmanac1.4,Volume1
PatrickChan
TheJava™DevelopersAlmanac1.4,Volume2
PatrickChan,RosannaLee
TheJava™ClassLibraries,SecondEdition,Volume2:java.applet,
java.awt,java.beansPatrickChan,RosannaLee,DougKramer
TheJava™ClassLibraries,SecondEdition,Volume1:java.io,java.lang,
java.math,java.net,java.text,java.utilPatrickChan,RosannaLee,Doug
Kramer
TheJavaClassLibraries,SecondEdition,Volume1:Supplementforthe
Java™2Platform,StandardEdition,v1.2
KirkChen,LiGong
ProgrammingOpenServiceGatewayswithJava™EmbeddedServer
ZhiqunChen
JavaCard™TechnologyforSmartCards:Architectureand
Programmer'sGuide
MaydeneFisher,JonEllis,JonathanBruce
JDBC™APITutorialandReference,ThirdEdition
LiGong,GaryEllison,MaryDageforde
InsideJava™2PlatformSecurity,SecondEdition:Architecture,API
Design,andImplementationJamesGosling,BillJoy,GuySteele,Gilad
Bracha
TheJava™LanguageSpecification,SecondEditionDougLea
ConcurrentProgramminginJava™,SecondEdition:DesignPrinciples
andPatterns
RosannaLee,ScottSeligman
JNDIAPITutorialandReference:BuildingDirectory-EnabledJava™
ApplicationsShengLiang
TheJava™NativeInterface:Programmer'sGuideandSpecification
TimLindholm,FrankYellin
TheJava™VirtualMachineSpecification,SecondEdition
RogerRiggs,AnteroTaivalsaari,MarkVandenBrink
ProgrammingWirelessDeviceswiththeJava™2Platform,MicroEdition
HenrySowizral,KevinRushforth,MichaelDeering
TheJava3D™APISpecification,SecondEditionSunMicrosystems,Inc.
Java™LookandFeelDesignGuidelines:AdvancedTopics
KathyWalrath,MaryCampione
TheJFCSwingTutorial:AGuidetoConstructingGUIs
SethWhite,MaydeneFisher,RickCattell,GrahamHamilton,Mark
Hapner
JDBC™APITutorialandReference,SecondEdition:UniversalData
AccessfortheJava™2PlatformSteveWilson,JeffKesselman
Java™PlatformPerformance:StrategiesandTactics
TheJini™TechnologySeries
EricFreeman,SusanneHupfer,KenArnold
JavaSpaces™Principles,Patterns,andPractice
TheJava™Series,EnterpriseEdition
StephanieBodoff,DaleGreen,KimHaase,EricJendrock,Monica
Pawlan,BethStearns
TheJ2EE™TutorialRickCattell,JimInscore,EnterprisePartners
J2EE™TechnologyinPractice:BuildingBusinessApplicationswiththe
Java™2Platform,EnterpriseEditionMarkHapner,RichBurridge,Rahul
Sharma,JosephFialli,KimHaase
Java™MessageServiceAPITutorialandReference:Messagingforthe
J2EE™PlatformInderjeetSingh,BethStearns,MarkJohnson,
EnterpriseTeam
DesigningEnterpriseApplicationswiththeJava™2Platform,Enterprise
EditionVladaMatena,SanjeevKrishnan,BethStearns
ApplyingEnterpriseJavaBeans™2.1,SecondEdition:ComponentBasedDevelopmentfortheJ2EE™PlatformBillShannon,MarkHapner,
VladaMatena,JamesDavidson,EduardoPelegri-Llopart,LarryCable,
EnterpriseTeam
Java™2Platform,EnterpriseEdition:PlatformandComponent
SpecificationsRahulSharma,BethStearns,TonyNg
J2EE™ConnectorArchitectureandEnterpriseApplicationIntegration
Foreword
THEserver-sidelandscapehaschangedconsiderablyintheshorttime
sincethefirsteditionofthisbook.AdoptionoftheJava™2Platform,
EnterpriseEdition(J2EE™platform)hasbeenrampant;J2EEhastaken
overthemainstreamofenterprisecomputing;andtheJ2EEtechnologyis
comingofage.TheEnterpriseJavaBeans™(EJB)architecturethecore
componenttechnologyoftheJ2EEplatformhasevolvedsignificantlyfrom
themodeloriginallyreleasedastheEJB1.1specification,andthis
evolutionhasbeendrivenlargelybytheneedsoftheJ2EEcommunity.
TheevolutionoftheEnterpriseJavaBeansarchitectureinthe2.0and2.1
releasesreflectsrecentchangesindistributedcomputingalongwith
changesintheuseofcomponenttechnology.
ThemajorforcesdrivingtheevolutionoftheEJBtechnologyarethe
changeinthewaydistributedapplicationsarenowstructuredandhow
EJBcomponentsareusedtoimplementtheseapplications.
AlthoughtheEnterpriseJavaBeansarchitecturewasoriginallyconceived
asprovidingadistributedbusinesscomponentfacility,developerstendto
useenterprisebeansmorefortheirabilitytoencapsulatebusinesslogic
ratherthantoachievedistribution.Tomeetdeveloperdemandforlightweight,high-performanceaccesstoenterprisebeansinapplications
wheremultitierdistributionisnotdesired,theEJB2.0architecture
introducedtheconceptoflocalenterprisebeans.Localenterprisebeans
providethebenefitofEJBencapsulationcoupledwiththebenefitsof
containerservices(suchastransactions,security,andpersistence),but
withouttheadditionalcomplexityandoverheadassociatedwith
distribution.LocalEJBinterfacesavoidtheperformanceoverheadof
remotemethodinvocation,andenablethedevelopertopassobjects
betweenenterprisebeansusingcall-by-referencesemantics.IntheJ2EE
1.3platform,distributioninapplicationsoccursprimarilyattheWeblayer,
andenterprisebeansareusedprimarilyfortheirbenefitsinstructuringan
application'sbusinesslogic.
AnotherfactorthathasimpactedtheevolutionoftheEnterprise
JavaBeansarchitectureistheexperiencethathasbeengainedbyboth
developersandvendorsusingEJB2.0container-managedpersistence
(CMP).Thisexperiencedemonstratedthepopularityoftheconcept,butit
alsouncoveredlimitationswiththeoriginalEJB1.1design.Theearly
CMParchitecture,bynecessity,wassomewhatlimitedinscope.
ExperienceshowedthatthisearlyCMParchitecturedidnotfullyaddress
theneedsofEJBproductvendorsinensuringahighlevelofscalability
andperformance,northeneedsofdevelopersinfacilitatingmore
sophisticatedmodelingandportability.
ThearchitectsoftheEJB2.0architecturethereforecompletelyrevamped
thearchitecture'sCMPmodel.Thenewarchitectureenablesvendorsto
provideimplementationswithhighperformanceandaddedfeaturesfor
easeofuse.Suchfeaturesincludecontainer-managedrelationshipswith
supportforautomaticreferentialintegritymanagementandaportable
querylanguage,whichallowsdeveloperstospecifyqueriesoverrelated
setsofentitybeansusingaconvenientandportableSQL-likelanguage.
TheEJB2.0CMParchitectureallowsEJBdeveloperstomorerapidly
developsophisticatedapplicationsthatfullyleveragethebenefits
providedbytheEJBarchitecture.Thisnewarchitectureretainsthe
originalEJBbenefitswhileaddingmuchricherpersistencesupportand
bettercontainercontrolofCMPentitybeanstate.
AthirdtrendthathasinfluencedtheEJBarchitecture'sevolutionisthe
interestinmoreloosely-coupled,asynchronousapplications.Thisledto
theintroductionofathirdenterprisebeantypeinEJB2.0themessagedrivenbean.Message-drivenbeansenabletheEJBtechnologyandwith
ittheJ2EEplatformtoentertheworldofasynchronouscomputing.
Message-drivenbeansenableenterprisebeanstoreceiveasynchronous
messages,thusallowingEJBcomponentstointegratewithlegacy
systemsthatusemessagingtoprovideloosely-coupledapplication
integration.BecausethecoremessagingtechnologyoftheJ2EE
platformistheJava™MessageService(JMS),EJB2.0message-driven
beanswereinitiallydirectlytargetedatsupportfortheuseofJMS
messaging.TheEJB2.1architecturecontinuesthissupportfor
asynchronicity.TheEJB2.1architecturefurthergeneralizesmessage-
drivenbeanstosupporttheintegrationofarbitrarymessagingtypes,and
the2.1architecturealsoextendsthetechnologybyincludingtheEJB
timerservice.
TheevolutionoftheEJBarchitecturetakesanotherexcitingshiftin
directionwiththeEJB2.1release.AmajornewWebdistributionmodel
calledWebserviceshasemergedintheindustry.Thisisamodelfor
offeringservicesdesignedtobeaccessedviaprogramsratherthana
browser.ThecentralfocusofthenewEJB2.1architectureisWeb
services.WebservicessupportintheEJB2.1architectureallowsthe
functionalityofEJBapplicationstobeexposedovertheWeb,wherethey
canbedynamicallydiscoveredandaccessedoverHTTP.Most
importantly,Webservicesallowserviceconsumersandproviderstobe
looselyandflexiblycoupled;Webservicessupportusefrom
heterogeneoussystemsandenableintegrationofnon-J2EEsystems.
Initially,developersthoughtthatimplementingaWebservicewas
equivalenttostrippingthebrowser-supportlayerfromanexisting
applicationanddirectlyexposingitsbusinesslogic.Asexperiencewith
Webserviceshasgrown,ithasbecomeclearthatWebservice
applicationsstillrequireanon-browserservicepresentationlayerto
decoupleWebservicesclientsfromthecomplexityofbusinesslogic.
WiththeWebservicesupportitnowprovides,theEJB2.1architectureis
anexcellentfacilityforimplementingaWebservice'spresentationlayer.
TheEJB2.1architecturealsoenablesenterprisebeanstobeclientsof
Webservices,makingitpossibleforapplicationdeveloperstocompose
EJBapplicationsfromaggregationsofsuchservices.Theimplementation
ofWebserviceswiththeEJB2.1architectureiseasyand
straightforward,andleveragesthefamiliarstatelesssessionbeanmodel.
TheglobalaccessandinteroperabilitycurrentlyprovidedbytheSimple
ObjectAccessProtocol(SOAP)andWebServicesDescriptionLanguage
(WSDL)Webservicesstandardsaddssignificantvaluetoenterprise
beancomponentsandtheEJBarchitecture.WithWebservices,theEJB
architecturegainsglobalreach.Accesstoaserviceimplementedwith
enterprisebeancomponentsisnolongerrestrictedtoEJB-awareclients;
thisservicecannowbeaccessedwiththesameglobal,heterogeneous
modelthatempoweredbrowser-basedservices.Inadditiontoitsnew
roleinimplementingtheservicepresentationlayerforWebservices,the
EJB2.1architecturecontinuestodeliverarobustbusinesscomponent
modelforimplementingthebusinesslogicanddomainmodelsofboth
WebsitesandWebservices.
TheEnterpriseJavaBeansarchitecture,atthecoreoftheJ2EEplatform,
hasplayedakeyroleinitsevolutionexpandingitsscopeinproviding
scalableandreliableenterprisecomputing,andaddingnewfeaturesto
promotemorerapiddevelopmentofenterpriseapplications.Inadditionto
fulfillingitsoriginalgoalsofprovidingtheportablecomponentmodelfor
enterpriseapplications,theEJBarchitecturehasexpandedto
encompassthekeytechnologicalunderpinningstosupportintegration
withlegacysystems,asynchronouscommunication,andthe
infrastructureforWebservicestechnologies.
TheEJBarchitectureanditscomponentshavethusmaturedtosupport
today'sstyleofapplicationsapplicationsthatfocusontheWebfor
distribution,requireloosely-coupledmessagingforintegratingbusiness
flows,anddesireformalcomponentsforbetterencapsulationofbusiness
logicwithinmultipleservicetiers.
TheEJBarchitectureteamandexpertgrouphavedoneagreatjob
shepherdingtheEJBtechnologythroughthisprocessofevolution.They
haveensuredthattheEJBarchitecturehasretainedallofitsoriginal
essentialbenefitswhileatthesametimekeepingitcloselyintunewith
today'sevolvingneeds.
MarkHapner
LeadArchitect,J2EEplatform
SunMicrosystems
Preface
THISbook,nowinitssecondedition,providesin-depthcoverageofthe
EnterpriseJavaBeans™(EJB)2.1architecture,explaininghowto
developanddeployenterpriseapplicationsbyusingthelatestEJB
componentarchitecture.Thissecondeditioncoversthenew2.0and2.1
featuresoftheEJBarchitecture,includingmessage-drivenbeansand
asynchronouscommunication,enhancedcontainer-managed
persistence,supportforWebservices,andtheEJB™QueryLanguage
(EJBQL).
ThisbookispartofthesuccessfulJavaBluePrintsprogramcreatedby
SunMicrosystemswiththeintroductionoftheJava™2Platform,
EnterpriseEdition(J2EE™platform).TheJavaBluePrintsprogramhas
beenusedbythousandsofapplicationarchitects,developers,and
studentstoattainabetterunderstandingoftheprogrammingmodel
inherentintheJ2EEplatform.
ThisbookandtheJavaBluePrintsprogramdonotprovideinformationon
howtouseindividualJavatechnologiestowriteapplicationsthat'sthe
roleofthecompanionJavaTutorialprogram.Instead,JavaBluePrints
focusesonguidelinesforapplicationarchitecture.
ReadersofthisbookshouldbefamiliarwiththeJava™programming
language,shouldhaveabasicknowledgeoftheJ2EEplatform,and
shouldhavehadsomeexposuretoenterprisebeansandtheEJB
architecture.AlthoughwebrieflycoverthebasicsoftheEJBarchitecture,
thisbookisnotmeanttobeatutorialforthosejustgettingstartedwith
enterprisebeans.Instead,thebookprovidesin-depthcoverageofthe
EJB2.0and2.1architecturesforinformationtechnology(IT)personnel
implementingapplicationsin-houseandforindependentsoftware
vendors(ISVs)developinggenericapplicationsforsaletoenterprises.
TheEJBarchitecturedefinesacomponentmodelforenterprise
applications,focusingonthefollowing:
Howtodesignanapplicationasasetofcomponents
Howthecomponentsinteractwitheachother
HowthecomponentsinteractwiththeirEJBcontainer
TheEJBarchitecturedefinestheseinteractionsascontracts,which
enableapplicationstousecomponentsfromdifferentsources.Because
EJBcomponentsmustadheretothesecontracts,anapplicationcan
consistofsoftwarecomponentsfrommultiplevendors.
TheEJBspecificationdefinesthearchitecturecontractsmainlyfromthe
pointofviewofthecontainervendor.Incontrast,thisbookpresentsthe
EJBarchitecturefromthepointofviewoftheapplicationdeveloperthat
is,thepersonwhodevelopsEJBapplications.
Adetaileddescriptionofthedevelopmentoftwoenterpriseapplications
formsthebackboneofthebook.Althoughtheexampleapplicationsare
relativelysimple,theyillustratemanyofthetypicalproblemsencountered
inenterpriseapplicationdevelopment.Weusetheseexamplestoshow
howtheEJBarchitecturehelpsdeveloperssolvetheseproblems.
Thefirstexampleisabenefitsenrollmentapplicationdevelopedin-house
byanITdepartment.Thisapplicationworkswellforexplaininghowa
sessionbeanworksandforillustratinghowdevelopersusesession
beans.
Thesecondexampleturnsthebenefitsapplicationfromthefirstexample
intoanapplicationdevelopedbyanISV.AnISV'sdesigngoalsdifferfrom
thoseofanin-houseITdepartment.TheISVmustdesigntheapplication
sothatitcanbeeasilydeployedinmanydifferentcustomers'operational
environments.Becauseeachcustomerhasauniqueoperational
environment,theISVmustaddressanumberofchallenges.Inaddition,
anISVtypicallyneedstodesigntheapplicationsothatitcanbe
extendedbyacustomerorintegrator.Weillustratehowtheentitybean
architecturehelpsISVstoovercomethesechallenges.
TheEJB2.1architecturemakesitpossibletoimplementapplicationsas
Webservices.Thisupdatededitionofthebookincludesachapterthat
describeshowtoincorporateanduseenterprisebeansinaWebservice.
Theseannotatedexamplesillustratemanyofthetechniquesforapplying
theEJBarchitecturetospecificproblemsinenterpriseapplication
development.Inaddition,wedescribetheindividualfeaturesoftheEJB
architectureanddiscusswhenandhowtheyshouldbeusedin
applications.
Althoughthetypicalapplicationdeveloperdoesnotneedtoknowhow
theEJBcontainerworks,weillustratesomeoftheinnerworkingsofthe
EJBcontainer.Wedothismainlytogivethereaderanappreciationof
howmuchworkthecontainerperformsonbehalfoftheapplication.
ConventionsUsedinThisBook
Thefollowingaretheconventionsusedinthisbook.
Graphics
ManyofthegraphicsinthisbookdepictUnifiedModelingLanguage
(UML)diagrams.Theconventionsusedinthesediagramsfollowthe
UMLstandard.Briefly,FigureP.1illustratesthearrowsandconnectors
usedinstandardUMLdiagrams.
FigureP.1.UMLSymbols
TypographicConventions
TableP.1describesthetypographicconventionsusedinthisbook.
TableP.1.TypographicConventions
TableP.1.TypographicConventions
Typeface
orSymbol
Meaning
AaBbCc123 Thenamesofcommands,files,anddirectories;interface,class,
method,variable,anddeploymentdescriptorelementnames;
programminglanguagekeywords
Example
Editthefile
AccountBean.java.
Usesan
AccountHomeobject.
Invokesthemethod
ejbCreate.
AaBcCc123 Booktitles,newwordsorterms,orwordstobeemphasized
ReadChapter2in
EJB1.1Specification.
Thisisastateless
sessionbean.
Youmustbecareful
whenusingthis
option.