Tải bản đầy đủ - 0 (trang)
Chapter 1. Introduction to Enterprise Applications

Chapter 1. Introduction to Enterprise Applications

Tải bản đầy đủ - 0trang

TheEnterpriseJavaBeansArchitecture

TheEJB2.0SpecificationdefinesEnterpriseJavaBeans(EJB)as

anarchitectureforcomponent-baseddistributedcomputing.

Althoughthisdefinitionworkswellifyouarealreadyfamiliar

withtermssuchascomponent-basedanddistributed

computing,thedefinitiondoesn'thelpmuchifyouarebrandnewtoEnterpriseJavaBeansorenterpriseapplication

development.Itmightevenbehelpfultodefinewhatismeant

byanenterpriseapplication.Beforewedothat,however,let's

getapictureofwhattheEJBarchitecturelookslike.Thisway,

you'llhaveanimageinyourheadaswegothroughthis

discussion.Figure1.1illustratestheEJBarchitecturefroma

highlevel.

Figure1.1.Ahigh-levelviewoftheEJBarchitecture.



Ifyouweretoask100softwaredevelopersorarchitectswhat

anenterpriseapplicationis,youprobablywouldget101

differentdefinitions.It'snotbecausesoftwaredeveloperscan't

count,it'sbecausethedefinitionofanenterpriseapplication

canbesomewhatambiguous.Eachdevelopmentorbusiness

organizationmighthaveitsowndefinitionofwhatanenterprise

applicationis.However,itwouldbeniceifwecouldgetasingle

definitionthatthemajorityofsoftwaredeveloperscouldagree

on.

EnterprisedevelopmentdidnotbeginwiththeadventofEJB,or

Javaforthatmatter.Infact,ithasbeenaroundformanyyears

andwasatermthatwasusedoftenwhenmainframe

developmentwasalltherage.However,itmightbeanew

conceptforsomeofyou,whomighthavebeeninvolvedonly

withapplicationsthatperformedarelativelysmallbusinesstask

andthatwereusuallycontainedwithinasingleaddressspace.

AlthoughcompanieshavebeenusingtheCommonObject

RequestBrokerArchitecture(CORBA)sincetheearly'90s,due

totheboomoftheInternetandthedecentralizationofthe

InformationTechnology(IT)departmentswithinorganizations,

moreandmoreapplicationsarebeingdevelopedthatcrossthe

networkboundariesandencompassmoreofthebusiness'sdayto-dayfunctionality.Atthesametime,theseapplicationsare

beingspreadoutfurtherandfurtherfromothercomponentsor

applicationsthatexistintheenterprise.Byenterprise,weare

referringtoallthesoftwareapplicationsorservicesthatan

organizationhasbuilt,bought,andacquiredthatprovide

servicetoanorganization.Theseservicesmightbedealingwith

inventorymanagement,pricing,oranythingelsethat

organizationsmustmanageonaregularbasis.Enterprise

applicationsarenotboundbythefourwallsofthedatacenter

liketheyusedtobe.Now,componentsandservicesarebeing

decentralizedthroughouttheorganization.

Ridingrightonthebackofthisdecentralizationisanentire

posseofnewtechnicalchallengesandcomplexitiesthatmust



bedealtwithbythedevelopmentorganization.Thesenew

technicalchallengesmustbeconsideredduringdesignand

developmentbecauseofthisspreadingoutoftheservicesover

thenetwork.It'snolongertruethatanorganization'sdataor

businessprocessesarelocatedinasinglephysicallocation.

Mostcompaniesmustnowbeglobalandcannolongerassume

thatcustomerswillbewithinthesamegeographicallocation.

Therefore,theapplicationsmustbeflexibleandextensibleto

accommodatecustomersandotherbusinesspartnersfrom

aroundtheworldandatanytimeofthedayornight.Addto

thisthat,hopefully,newcustomersandpartnersarebeing

addedeveryday,andthiscanhaveatremendouseffectonthe

scalabilityandperformanceoftheapplication.

Asyoucanstarttosee,enterprisedevelopersmustdealwith

manycomplextechnologicalissuesthatjustarenotpresentin

manysmallerapplications.Enterpriseapplicationsmustsupport

multiplesitesthatcanbegeographicallyseparated,dealwith

customersandpartnersthatcanusuallyaccessanapplication

atallhoursofthedayandnight,supportmultiplelanguages

andconcurrentuseraccess,andtakeintoaccountthecomplex

issuesthatgohandinhandwiththiswideseparation.Other

issues,suchasinterfacingwithexistingapplicationsinthe

enterprise,arealsoverycommonandmustbesupported.It's

alsotruethatthephysicalhardwareandsoftwareapplications

withintheenterpriseareveryheterogeneous.Forexample,

someenterpriseapplicationsmightrequireaUnixoperating

systemtofunction,whileothersrunonlyonaWindows

platform.Thisdiversesetofconstraintsonlyaddstothe

complexityfortheenterprisedevelopers.

GoingbacktotheEJBdefinitionthatwasprovidedfromthe

specificationandconsideringadifferentdefinitionofwhat

enterpriseapplicationdevelopmentis,let'strytocomeupwith

ourownEJBdefinition.Weneedadefinitionthatwecan

intuitivelygraspandunderstandwithoutagreatdealof

confusionandbeabletocommunicateittoothers.Sohereis



anattemptatadefinitionthatyoushouldbeabletounderstand

withalittlebitofthought:

"EnterpriseJavaBeansareJavacomponentsthataJava

developerwritesandinstallsintoanapplicationserver,

whichprovidesnaming,security,transactional,andother

enterpriseservicesforthecomponents.

Theseinstalledcomponentscanbeutilizedoveranetwork

inadistributedmanner."

Althoughthepreviousdefinitioncontainsafewtermsthat

mightbenewtoyou,itshouldtakeyoualittlecloserto

understandinghowtheEJBarchitecturehelpsyoubuild

enterpriseapplications.

Note

Theapplicationserverthatwasmentionedinthe

definitionistypicallybuiltbyathirdpartyand

installedintoyourenvironment.



Thereareothercharacteristicsthatyouwillneedtounderstand

whenbuildingenterpriseapplicationsusingEJBs.Theseinclude

suchthingsasscalability,multi-user,loadbalancing,faulttolerance,andmanymore.Theproblemisthatthereisso

muchtolearnthatyouwillhaveaneasiertimegraspingall

theseconceptsifyouareexposedtothemattherightpaceand

attherighttime.That'soneofthemaingoalsofthisbook:to

introduceconceptsgraduallyandwhenitmakessenseto

introducethem.LearningEnterpriseJavaBeanscansometimes

seemoverwhelmingbecauseofthesupportingconceptsand

technologiesthataccompanyit.Hopefully,youwilllearnbythe

timeyouarefinishedwiththisbookthatoneofthegreatest

benefitsfromusingEJBanditssupportingtechnologiesisthat

muchoftheinfrastructureisprovidedforyou.



Component-BasedDistributedComputing

Whatiscomponent-baseddistributedcomputingandwhyisit

soimportant?Thisisanexcellentquestiontoanswerbefore

goingmuchfurther.Thefirstquestiontoansweris"Whatisa

componentandwhatvaluedocomponentsoffertoenterprise

applicationdevelopers?"



QuickSoftwareComponentRefresher

Whenwetalkaboutacomponent,whatarewereferringto?We

couldsaythatanEJBisacomponent.WecouldalsocallaJava

classacomponent.Tryingtocomeupwithasingledefinitionof

acomponentthateveryoneinthesoftwarecommunitywould

agreeonwouldbeprettytough.Foryears,softwaredevelopers

andarchitectsallovertheworldhaveattemptedtodescribe

whatacomponentis.In1996,theEuropeanWorkshopon

Component-OrientedProgramming(ECOOP)cameupwiththis

definition:

"Asoftwarecomponentisaunitofcompositionwith

contractuallyspecifiedinterfacesandexplicitcontext

dependenciesonly.Asoftwarecomponentcanbe

deployedindependentlyandissubjecttocompositionby

thirdparties."

NoticetherewasnomentionofJavaorEJBinthedefinition.

That'sbecausetheconceptofacomponenthasbeenaround

longerthanJava.AlthoughJavasupportstheideaof

components,itsuredidn'tinventthem.Therearereallythree

importantfeaturestotakeawayfromthepreviouscomponent

definition:

Specifiedinterfaces



Explicitdependencies

Deploymentcapabilities

Acomponentgenerallyprovidesoneormorebusinessservices

toitsclients.AclientcouldbeaGUIinterface(Web-basedor

otherwise)orinmanycases,anothercomponent.Theservices

thatacomponentcanoffercouldbeassimpleasreturningthe

e-mailaddressforacustomertoascomplicatedascalculating

theshippingchargesforanorderbeingshippedto

Berchtesgaden.Nomatterwhatservicesthecomponent

provides,itprovidesthemthroughapubliclyspecifiedinterface.

Thismeansthataclientwhointeractswithacomponentisnot

showntheinternalsofthecomponent,butonlytheresultofthe

requestthattheclientmadeonthecomponent.Thisis

sometimesalsoreferredtoasencapsulation.

Acomponentusuallyhasoperations(methods),properties

(state),andsometypeofevents(possiblyasynchronous

notifications)thatitgenerates.Agoodcomponentwillhidethe

detailsofhowitmaintainsitsinternalstatefromtheclient.This

helpstodecoupletheclientfromthecomponent.Forexample,

ifthelogicofhowacomponentcalculatedtheshippingcharges

changed,theclientwouldnotcareaslongasitstillprovided

thesameinterfaceandchargedthecorrectamount.Whether

theamountwascalculatedbytheShippingcomponentorthe

Shippingcomponentcommunicatedacrossthenetworktoa

legacysystemtogettheamount,theclientshouldn'tcare.

Youcanthinkofthepublicinterfacesthatthecomponent

providestoaclientasacontractbetweentheclientandthe

component.Thecomponentissaying,"I'llcalculatetheamount

toshiptheorder,ifyou'llgivemetheorderIDsoIcanlookat

theweightofwhatyouareshipping."Thesetofinterfacesa

componentexposestoaclientiswhatmakesupthecontract

betweentheclientandthecomponent.Thisissometimes

referredtoasthecomponentinterface.



Thenextconceptthatisimportantfromthedefinitionisthata

componentmayhavedependenciesonanothercomponentto

completeitsbusinessservices.Thesedependenciesshouldbe

explicitanddocumented.Inourexample,theShipping

componentthatcallsonthemainframesystemtocalculatethe

amounttoshiptheorderdependsonthemainframe

application.Ithasadependencyonit.Withoutthatmainframe

systembeingabletoprovidetheamount,theShipping

componentwouldhavetoinformthecustomerthatitcan't

completetheorderatthistime,andthatcanmeanlossof

revenuetothebusiness.There'snothingincorrectorwrong

abouthavingthesedependenciesbetweencomponentsaslong

aseveryoneunderstandsthem.Havingcomponentsdependon

othercomponentsisverynormalinanenterpriseapplication.

Theyjustneedtobecomprehensibleandcohesive.By

understandingthedependencies,youareabletoquickly

determinewhichothercomponentsareaffectedwhenoneof

thepublicinterfacesneedstochangeorberemoved.

Thelastconcepttotakefromthedefinitionistheoneof

deployment.Thisisalittleambiguousbecausethedefinitionof

deploymenthasnotbeengivenandprobablymeansmany

differentthingstodifferentpeople.Javaclassesmustbe

deployed.Theymustbeinthecorrectpackageandinthe

systemclasspath.CORBAclassesaredeployed,butinan

entirelydifferentmanner.Nonetheless,acomponenthassome

typeofdeploymentthatmustbeperformedbeforeitsservices

aremadeavailabletoclients.Withsometechnologiesor

architectures,adistinctionismaderegardingwhoisresponsible

fordeployment.Theoriginaldeveloperisusuallytheone

responsiblefordeployingastandardJavaclass,althoughit

sometimescanbepartofamuchlargerdeployment.Asyou'll

seeinthesection"EJBRolesandTheirResponsibilities"in

Chapter3,EJBdefinestherolesandresponsibilitiesforthe

componentprovider,deployer,andothernecessaryroleswith

theapplication.



FormoreonEJBrolesandtheirresponsibilities,see"EJB

RolesandTheirResponsibilities,"p.37.

Figure1.2showsanexampleofacomponentthatsupportsall

threefeaturesthatwedescribed.

Figure1.2.Acomponenthaspublicinterfacesand

dependenciesandcanbedeployed.



AssemblingComponentsintoanArchitecture

Afteryouhavebeguntocreateindividualcomponents,thenext

stepistoassemblethemintoalargersetofcomponents.This

largersetisknownasacomponentarchitecture.Acomponent

architectureusuallyconsistsofasetofcomponentsand

servicesforbuildingapplicationsandcanutilizeoneormore

frameworks.Aframeworkisalibraryofothercomponentsthat

canbereusedthroughoutmultipleapplicationsandsave

developmenttimebyprovidingprovenandtestedservicesand

functionality.Youmighthaveheardthesaying,"Don'treinvent

thewheel."That'sthepurposeofaframework.Manycompanies

areinthebusinessofprovidingframeworks,butoftentheyare

builtbytheorganizationbuildingtheapplication.

Therearemanydifferentstylesandclassificationsof

architectures.Youcanhavesystemarchitectures,application



architectures,networkarchitectures,databasearchitectures,

andthelistcouldgoon.

IfyoudoasearchontheInternetfor"Whatisanarchitecture?"

youwillseeresultsrangingfromspacedefensecontract

informationtoahundreddifferentthesispapersdescribingwhat

theauthors'ideasofanarchitectureare.Forourpurposes,an

architectureisjustasetofrelatedcomponentsandframeworks

thathelpdescribewhatdependenciesexistbetweenthe

componentsandhowtheyshouldreacttoeventsduringthe

lifecycleoftheapplication.ThisisinasensewhattheEJB

specificationdescribes.



N-TieredArchitectures

Anotherclassificationthatarchitecturesfallintoisthenumber

ofdifferentlayers,ortiers,thearchitecturehas.Atierisa

groupingofsoftwareandpossiblyhardware,components,and

services.Thisgroupingcanbebothlogicalandphysical.The

purposeofusingtiersistoenablethesoftwarecomponentsand

servicestobedistributedacrossmultiplecomputersfor

scalabilityandsecurity.Forexample,asyou'llseeinChapter

19,"BuildingaPresentationTierforEJB,"theWebserver

componentsandservicesaresometimesdistributedina

differenttierthantheapplicationservices.Thisaddssecurityto

theapplicationbecausemoreoftheapplicationcanbelocated

deeperinaprotectednetwork.Thethreemostcommon

architecturesthatyouwillhearaboutare

Two-tier

Three-tier

Theubiquitousn-tier

Note

Then-tiernameisreferredtohereasubiquitous

becausethistermisusedtodescribemanydifferent

typesofenterpriseapplicationarchitectures.



Thenreferstohowmanytiersthearchitecturehas,from1to

somenumber(n).Inmostcases,nisusually3,4,ormore.

Mostoften,developersusetheterm"n-tiered"torefertoa

three-tieredarchitecture.Let'stakeaquicklookatafewofthe

typicalarchitecturesandhowtheyareusedtoday.



Two-TierComponentArchitectures

Notechnicalbookwouldbeworthitsweightinsaltifitdidn'tat

leastmentionthetwo-tieredclient/serverarchitecture.It's

oftensaid,"Thosewhoforgetthemistakesofthepastare

doomedtorepeatthem."Thetwo-tierorclient/server

application-programmingmodelwasverybigupthroughthe

early1990s.Infact,it'sstillaverypopulararchitecturefor

certaintypesofapplications.Theproblemisthatitjustdoesn't

scalewhenmanyusersareusingthesystematthesametime.

I'msuretherearemanyofyouscreamingrightnowbecause

youfoundawaytomakeitscale,butgenerallyspeakingit

doesn'tscaleverywellwhenthenumberofconcurrentusers

startstoclimb.Thistypicallyisduetotheinabilityofthe

databasetohandlelargenumbersofclientconnections.

Thetwo-tierarchitecturehadotherproblemsaswell.To

distributeanewversionofthesoftware,allclientshadtobe

updatedwiththenewclientsoftware,whichcontainedallthe

businesslogic,databaselogic,andeverythingelse.Thisalso

meantthatverycomplexcode,suchassecurityanddatabase

interaction,wasdoneineveryclient.Thisaddedoverheadto

theclientapplicationandincreasedthenetworktraffic.The

processofdistributionbecameeasierwithJavaapplets,butthe

appletstillcontainedsomelogicthatcouldbebetterlocated

elsewhere.Withsomeofthesecurityrestrictionsthatwere

placedontheapplet,thisparticulartechnologystilldoesnot

workforallapplications.

Thisarchitectureisusuallyreferredtoinanegativewayasafat

clientbecauseitcontainsvirtuallyallthecomponentswithin

thisonetier.Thesecondtierwasusuallyadatabaseofsome

type,mostoftenarelationaldatabase.Figure1.3illustratesa

typicaltwo-tieredclient/serverarchitecture.

Figure1.3.Anexampleofatypicalclient/server

architecture.



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Chapter 1. Introduction to Enterprise Applications

Tải bản đầy đủ ngay(0 tr)

×