The .NET Framework for Java Developers - Whitepaper

33
The.NETFramework ...for Java developers  Informationinth isdocument,inclu dingURLandotherIn ternetWeb sitereferences,issubje cttochangewithou tnotice.Unlessotherwise noted,theexamp lecompanies,or ganizations,produ cts,domainnames,e-mailaddresses,logos,p eople,places,andev entsdepictedherein arefictitious,andnoasso ciationwithanyrealcomp any,organization ,product,do mainname,e-mailadd ress,logo,person ,placeoreventis intendedorshouldbeinferred .Complyingwithallapplicable copyrightlawsistheresp onsibilityoftheuser.With outlimitingtherightsun der copyright,nopart ofthisdocumen tmaybereproduced,storedino rintroducedintoar etrievalsystem, ortransmittedinanyform orbyany means(electronic,m echanical,photoco pying,recording ,orotherwise),orfo ranypurpose,w ithouttheexpress writtenpermissiono fMicrosoft Corporation. Microsoftmayha vepatents,paten tapplications,trademarks,copyrights,or otherintellectualpro pertyrightscov eringsubjectmatterinthis document.Excep tasexpresslyprovide dinanywrittenlicenseagr eementfro mMicrosoft,th efurnishingofthisdo cumentdoesn otgiveyou anylicensetothesepa tents,trademarks,c opyrights,orotherintellectualproperty. ®2011MicrosoftCorporation.Allrightsreserved. Microsoftiseitheraregisteredtrademarkortrademark ofMicrosoftCorporationintheUnitedStatesand /orothercoun tries. Thenamesofactual companiesandp roductsmention edhereinmayb ethetrademark softheirrespectiv eowners.

Transcript of The .NET Framework for Java Developers - Whitepaper

Page 1: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 1/33

The.NETFramework

...for Java developers 

Informationinthisdocument,includingURLandotherInternetWebsitereferences,issubjecttochangewithoutnotice.Unlessotherwisenoted,theexamplecompanies,organizations,products,domainnames,e-mailaddresses,logos,people,places,andeventsdepictedherein

arefictitious,andnoassociationwithanyrealcompany,organization,product,domainname,e-mailaddress,logo,person,placeoreventis

intendedorshouldbeinferred.Complyingwithallapplicablecopyrightlawsistheresponsibilityoftheuser.Withoutlimitingtherightsunder

copyright,nopartofthisdocumentmaybereproduced,storedinorintroducedintoaretrievalsystem,ortransmittedinanyformorbyanymeans(electronic,mechanical,photocopying,recording,orotherwise),orforanypurpose,withouttheexpresswrittenpermissionofMicrosoft

Corporation.

Microsoftmayhavepatents,patentapplications,trademarks,copyrights,orotherintellectualpropertyrightscoveringsubjectmatterinthisdocument.ExceptasexpresslyprovidedinanywrittenlicenseagreementfromMicrosoft,thefurnishingofthisdocumentdoesnotgiveyou

anylicensetothesepatents,trademarks,copyrights,orotherintellectualproperty.

®2011MicrosoftCorporation.Allrightsreserved.

MicrosoftiseitheraregisteredtrademarkortrademarkofMicrosoftCorporationintheUnitedStatesand/orothercountries.

Thenamesofactualcompaniesandproductsmentionedhereinmaybethetrademarksoftheirrespectiveowners.

Page 2: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 2/33

Introduction

Developersbuildingmodernapplicationshavea

rangeoftoolsandtechnologiesthattheycan

employ.Commonly,developersbuildingapplicationsfortheWindows®platformarefaced

withchoosingbetweenselectingJavaandits

associatedtechnologies,ortheMicrosoft®.NET

Framework.Javaandthe.NETFrameworkboth

supporttoolsforbuildingarangeofsoftware,

frommobileapplicationsrunningonasmart

phone,throughdesktopapplicationswith

graphicaluserinterfaces(GUIs),tolarge-scale

enterpriseapplicationsthatareusedtounderpin

thebusinessfunctionsofanorganization.In

theory,thereisalotofcommonalitybetweenthe

featuresandfacilitiesthatJavaandthe.NET

Frameworkprovide.However,therearesome

significantdifferencesinthewayinwhichthese

environmentsoperate,andthewayinwhichyou

design,build,andhostapplications.

IfyouareanexperiencedJavadeveloper,youwill

alreadybefamiliarwiththearchitectureofatypical

Javaenterprisesolutionandthetechnologiesthat

youusetoconstructit.Thepurposeofthispaperis

todescribetheequivalentstructureofatypical

.NETFrameworkapplication,andtoprovidea

mappingfromthetechnologiesthatarefrequently

usedintheJavaworldtotheir.NETFramework

brethren.

ContentsIntroduction.....................................................................ii  Contents................................. ........................................ ...ii ComparingJavaand.NETFrameworkArchitectures..............................................................................................3 Scenario:TheHotelReservationSystem..............5 TheJavaImplementationoftheHotelReservation

System................................................................................6  CoreSystem..................................................... ..........7 CustomerAccess................................................... ...8 ReceptionStaffAccess....................................... ....8 Reporting....................................................................9 BatchProcessing..................................... .................9 IntegrationwithThird-PartySystems..............9 

The.NETFrameworkImplementationoftheHotel

ReservationSystem.....................................................10  CoreSystem............................................................11 CustomerAccess...................................................24 ReceptionStaffAccess........................................25 Reporting.................................................................27 BatchProcessing...................................................28 IntegrationwithThird-PartySystems...........28  

NonfunctionalRequirementsoftheHotel

ReservationSystem.....................................................29  Security......................................................................30  Performance,Scalability,andReliability......31  ManagementandMonitoring.........................32 VisualStudioProfiling........................................ .33 

Summary....................................... ..................................33  

Page 3: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 3/33

Comparing Java and .NET Framework Architectures

3 The .NET Framework

Comparing Java and .NET Framework Architectures

Theterm“Java”coversseveralitems,rangingfromtheprogramminglanguagewiththe

samenamethroughtothevarioustechnologiesthatunderpinatypicalsolutionthatis

builtbyusingthislanguage.However,itisimportanttounderstandthatJavaisprincipallythedefinitionofasetofspecificationsandnotaproductinitsownright.

ManyvendorsimplementaJavacompiler,aJavavirtualmachine(JVM),andaJavaclass

library.Theseimplementationsprovidethecorefunctionalityandruntimeenvironment

thatarenecessarytobuildportableJavaapplications.Aslongasdevelopersavoidusing

anyvendor-specificextensionsintheirapplications,theirJavacodewillrununchanged

onanycomputerthathasaconformantimplementationoftheJVMandJavaclasslibrary

installed.Tosupportthewiderangeofsolutionsthatmodernorganizationscommonly

require,JavadefinesalargenumberofspecificationscoveringitemssuchasGUIs,data

access,security,Webservices,scalableenterprisecomponents,andsoon.Figure1

depictsthecommonspecificationsandotherelementsthatmostenterpriseJavasolutionsutilize.Thefigurepartitionstheitemsbetweenthoseusedbyclientandmobile

applications,andthoseusedtobuildserver-sidecomponents.

Server-sidecomponentsexecuteinanenvironmentthatanapplicationserverprovides.It

istheapplicationserverthatimplementsthevariousserver-sidespecifications,suchas

thosecoveringEnterpriseJavaBeans(sessionbeansandmessage-drivenbeans).The

applicationserveralsoworksincooperationwithotherproviders,suchastheJava

DatabaseConnectivity(JDBC)interfacetoadatabasemanagementsystem,toaccess

theirtechnologiesthroughthesespecifications.Frequentlyusedapplicationservers

includeTomcatandOpenEJBfromApache,andJBoss.Additionally,manyJavaapplicationserversprovideadditionalfacilitiesthatthevariousJavaspecificationsdonot

currentlycover;aprimeexampleisworkflowmanagement,andJBossprovidesjBPMto

implementthisfeature.

IncomparisontoJava,the.NETFrameworkisaconcrete(andfree)productthatis

developedbyMicrosoftandintegratedintotheWindowsoperatingsystem.Itdoesnot

relyonthird-partyvendorstoprovideanimplementation,althoughitishighlyextensible

andmanythird-partyadditionsareavailable.The.NETFrameworkalsoincludesthe

equivalentofmanyofthefeaturesbeyondthoseoftheJavaspecifications,but

commonlyimplementedbyJavaapplicationservervendors;forexample,itprovidesaworkflowengine.Figure2illustratesthetechnologiesthatconstitutethe.NET

Framework,followingthesamestructureasfaraspossibleasFigure1.Inthisway,you

canseehowelementsthatyouconstructbyusingthe.NETFrameworkmightmaptothe

correspondingJavacomponents.

Page 4: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 4/33

Comparing Java and .NET Framework Architectures

4 The .NET Framework

Enterprise Components

JAX-WS,

JAX-RS

Message-

Driven

Beans

Timer

Service

Web Apps and Services

Session

Beans

JSF, JSP/

Servlets

Applets,

JavaFX

Swing

Desktop User Interface

AWT

JDBC

Data Access

JDO, JPA JTA RMI

Integration, Interoperability and

Security

JMS JCA JNDI JAAS

Java Class Library

Java Application Server

Java Client

Java ME

     J     V     M

     J     V     M

Console

App

Mobile App

Tomcat

OpenEJB

JBoss

...

Java ME APIs (CLDC,

MIDP, OpenGL,

Java2D,…)

Figure1.CommonJavaspecificationsandtechnologies

Enterprise Components

WCF Web

Services

Microsoft

Message

Queue

Custom

Windows

Services

Web Apps and Services

Windows Communication

Foundation/Windows

Workflow Foundation

Windows

Presentation

Foundation

Desktop User Interface

Windows

Forms

ADO.NET

Data Access

Entity

Framework

Enterprise

ServicesWCF

Integration, Interoperability and Security

MSMQ COM

Interop

Active

Directory

Windows Authentication

Service, Windows Identity

Foundation

.NET Framework Class Library

Windows Application Server (IIS/WAS)

.NET Framework Client

Windows Phone 7   C

   o   m   m   o   n

   L   a   n   g   u   a   g   e

   R

   u   n   t   i   m   e

   C   L   R

Console

App

Mobile App

Silverlight, XNA

Framework, ...

ASP.NET,

ASP.NET MVCSilverlight

Figure2..NETFrameworkarchitecture

Page 5: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 5/33

Scenario: The Hotel Reservation System

5 The .NET Framework

Scenario: The Hotel Reservation System

TofullyunderstandthesimilaritiesanddifferencesbetweenJavaandthe.NET

Framework,considertheexampleofaHotelReservationSystem.Thelogicalmodel

showninFigure3depictsthefunctionalitythatthissystemimplements.

Security – Access Control and Encryption

Hotel Reservation System

Customer Query and

Maintenance

Booking Query and

Maintenance

Room Query and

Maintenance

Hotel

Information

Database

Customer (Web Browser)

Hotel Reception Staff (Desktop)

Reporting

(Query Only)

Integration with

External Systems

(Web Services/BPM)

Batch Processes

(Mailshots, Promotions – 

Query Only)

Customer (Mobile Application)

Figure3.LogicalmodelfortheHotelReservationSystem

Theprincipalusersofthesystemarecustomers,whocanaccessthesystemfromaWebbrowserormobilephoneacrosstheInternet,andreceptionstaffwhorundesktop

applicationson-premisesinsidethehotel.

Theoperationsthatcustomerscanperforminclude:

  Registeringthemselves,andsavingtheirdetailssuchasname,billingaddress,

telephonenumber,ande-mailaddress.

  Queryingtheavailabilityofroomsaccordingtovariouscriteriasuchasdate,styleof

room(standardorexecutive),andoccupancy(singleordouble).

 Makingabookingandreservingaroom,andalsoqueryingandcancelingbookingsthathavealreadybeenmade.

Hotelreceptionstaffhaveaccesstoextendedfunctionality.Theycanregistercustomers,

queryroomavailability,andmakeandcancelbookingsforanycustomer,buttheycan

alsocheckcustomersinwhentheyarriveatthehotel,generatebills,andrecord

payment.

Page 6: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 6/33

The Java Implementation of the Hotel Reservation System

6 The .NET Framework

Allinformationaboutcustomers,bookings,androomavailabilityisheldinthehotel

informationdatabase.

Apartfromthefeaturesthatareavailabletocustomersandhotelreceptionstaff,the

HotelReservationSystemalsosupports:

  Managementreporting.Thesearearangeofreports,standardandadhoc,thata

hotelmanagercanrequestaboutroomoccupancy,customerpreferences,

reservations,andsoon.Thereportsaregeneratedbyaseriesofmodulesthatquery

thehotelinformationdatabaseandgeneratespreadsheetsandotherdocuments.

  Batchprocessing.Ahotelmanagercanusethesystemtogeneratemailshots,

promotions,andotheritems.Theseoperationsarerunasbatchjobs.

  Integrationwithexternalsystems.Thehotelfrequentlyneedstoexchangedata

andcooperatewithsystemsthatareimplementedexternally,suchaspartner

organizationsofthehotel,externalservicesthathandlecustomerpayments,andthird-partyprovidersthatimplementhotelreservationbrokerageservicesacrossthe

Internet.

The Java Implementation of the Hotel Reservation System

Figure4illustratesthearchitectureofonepossibleimplementationoftheHotel

ReservationSystem,constructedbyusingJavatechnologies.

Page 7: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 7/33

The Java Implementation of the Hotel Reservation System

7 The .NET Framework

Java Virtual Machine

Java MEAndroid

Java Virtual Machine

Java Virtual Machine

Swing

Spring Framework

Hotel Reception Staff 

- Desktop Application

Apache HTTP

Server

HTML over

HTTP/SSL

Apache Tomcat and OpenEJB

Java Virtual Machine

Apache CXF

(JAX-WS

and JAX-RS)

JavaServer Faces (JSP

and Servlets)

3rd

Party

Web Service Client

SOAP/XML

over HTTP/SSL

Customer

Service

Session

Bean

Room

Service

Session

Bean

Message

Driven

Beans

JPA/Hibernate

Customer Entities

Booking Entities

Room Entities

MySQL Database

JDBC

RMI

over TCP/IP

Customer

- Mobile Application

HTML over

HTTP/SSL

Java Virtual Machine

Reporting

- OpenOffice Application

Batch Requests

- Java Applications

ActiveMQ 

JMS Messagesover OpenWire

Apache/

Tomcat

Connector

(mod_jk)

JBoss ESB

Partner Systems

MySQL Connector

for OpenOffice

Java Virtual Machine

JavaFX

Customer

- Web Browser

JBoss jBPM

booking

payment

workflow

Booking

Service

Session

Bean

JBoss jBPM

booking

transfer

workflow

Figure4.ArchitectureoftheJavaimplementationoftheHotelReservationSystem

Core System

ThecoreofthesystemisimplementedbyusingtheApacheOpenEJBservertohosta

collectionofsessionbeansthatimplementthebusinesslogicformanagingcustomers,

rooms,andbookings.Thesessionbeanscontainthebusinesslogicforthevarious

services,andmakeuseofasetofJavaclassesthatmodelthedataforcustomers,rooms,

andbookings;thesearetheCustomer,Booking,andRoomentityclasses,whichare

persistedbyusingtheJavaPersistenceapplicationprogramminginterface(API)ontop

ofHibernate,whichinturnsavesandretrievesdatatoaMySQLdatabase.Inthis

implementation,HibernateusesJDBCtoconnecttotheMySQLdatabase.

Thebusinesslogicbehindmakingabookingandreservingaroomisapotentiallylong-running,complex,multistepprocessthatinvolvesthecustomerprovidingpayment

details,andsendingthecustomeraconfirmatione-mailmessage.TheBookingsession

beanencapsulatesthislogicinajBPMworkflow,whichincludesthenecessarysupport

forsuspendingandresumingthebookingprocessifrequired.AnotherjBPMworkflow

handlesrequeststhatarereceivedfrompartnerhotelsfortransferringbookingsmadeat

thosehotelsintotheHotelReservationSystem(seelater).

Page 8: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 8/33

The Java Implementation of the Hotel Reservation System

8 The .NET Framework

ThecoreofthesystemmakesuseoftheSpringFrameworkanditsconfigurationand

dependencyinjectionfunctionalitytodeploy,instantiate,andmanagethevarious

componentsthatconstitutethesolution.

Customer Access

CustomersconnecttotheapplicationeitherbyusingaWebbrowser,orfromacustom

mobileapplication.TheWebbrowserrunsaJavaapplicationthatusesJavaFXtoprovide

arichuserinterface.

Twoversionsofthemobileapplicationareavailable.TheoriginalversionisbasedonJava

Platform,MicroEdition(JavaME),whichisintendedforuseonhandhelddevices.Alater

versionhasbeenconstructedfortheAndroidplatformandisintendedforuseonmore

recentmobilephones.Bothapplicationsprovidethesamefunctionality,and

communicatewiththeHotelReservationSystemoverastandardHTTPconnection,using

SecureSocketsLayer(SSL)toprotectanysensitiveinformation,asdoesthebrowser-basedversionoftheapplication.

TheWebbrowserandmobileapplicationsbothconnecttoanApacheHTTPserverthat

thehotelhosts.TheHTTPserverservesrequestsforstaticHTMLpagesandCGI-

generatedoutput.However,thebulkofthetrafficfromcustomersinvolvesprocessing

requeststhatareimplementedbyusingJavaServerPages(JSP)pages.TheHTTPserveris

configuredwiththemod_jkApache/Tomcatconnectortoforwardtheserequeststoa

Tomcatserver.TheuserinterfacelogicisactuallyimplementedbyusingJavaServerFaces

(employingJSPpagesandservletsbehindthescenes),andthebusinesslogicis

delegatedtothevarioussessionbeansdescribedearlier.

Note:

ThearchitectsalsoconsideredimplementingtheWebfront-endbyusingApacheStruts,

butoptedforJavaServerFacesduetoitsextensibility(itprovidesarelativelysimpleway

topluginmodulesthatsupportnon-HTMLclients),anditsabilitytohandlecomplex

userinterfacesinanarguablymoreorganizedmannerthanStruts.

Reception Staff Access

HotelreceptionstaffrunaJavadesktopapplicationthatmakesuseofauserinterface

thatwasdevelopedbyusingSwing.ThisapplicationactsasanEnterpriseJavaBeans(EJB)

client,makinguseofthesessionbeansthattheOpenEJBserverhosts.Thedesktop

applicationconnectstotheOpenEJBserverbyusingJavaRemoteMethodInvocation

(JavaRMI)overTCP/IP(thesearelocalconnectionsinsidethehotel).

Page 9: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 9/33

The Java Implementation of the Hotel Reservation System

9 The .NET Framework

Reporting

TheReportingapplicationisimplementedbyusingtheOpenOfficesuite,utilizingthe

MySQLconnectorforOpenOfficetoconnecttothedatabaseandextractdata.The

Reportingapplicationdoesnotmakeuseoftheentityclassesorthesessionbeans

becauseitsimplyneedstoquerydatainthedatabase.Thisstructureisfastandsupports

ad-hocqueryingaslongastheemployeewhoisgeneratingareportunderstandshowto

phraseStructuredQueryLanguage(SQL)statements.

Batch Processing

Thebatchprocessingelementsareasmallsetofstand-alonecustomJavaapplications

thatinitiateasetofbackgroundtasksintheHotelReservationSystem.Someofthese

applicationsareexecutedonaregularbasis(suchasmailshots),whileothersarecreated

ondemandtosupportaspecificmarketingcampaign(suchashotelpromotionsandspecialoffers).Duetothepotentialprocessingrequirementsoftheseapplications,andto

avoidadverselyaffectingthequalityofservicetocustomersandhotelreceptionstaff,

theseapplicationssimplypostrequeststoaJavaMessageService(JMS)queue

(implementedbyusingApacheActiveMQ).Acollectionofmessage-drivenbeans(each

designedtosupportaspecificbatchjob)hostedbyOpenEJBreceivestheserequestsand

processesthemduringoff-peakhours.

Note:

AnalternativeapproachwouldbetousetheSpringBatchframeworkandacollectionof

regularJavaclassesratherthanmessage-drivenbeanstoimplementthebatchprocessingelements.

Integration with Third-Party Systems

TheHotelReservationSystemexposesdataaboutroomavailabilityandpricingthrough

asmallsetofWebservices.Third-partyWebclientapplicationscaninvoketheseWeb

services,andusetheinformationthatisretrievedaspartoftheirownsolutions,actingas

hotelroombrokerageservicesorportals.TheHotelReservationSystemimplements

theseservicesbyusingtheApacheCXFframework.

TheHotelReservationSystemalsosupportsexchangeofdataandinteractionwith

systemsthatpartnerorganizationsrun,includingotherhotelsthatmayrequestto

transferbookingsfromtheirownpremises(ifacustomerrequeststoswitchhotels,for

example),andorganizationsthatimplementsecurepaymentservices.Suchexchanges

involveaninterchangeandpossibletransformationofdocumentation(differenthotels

mayusedifferentdataformatsandschemas),andmayinvolvemultiplesites.Thehotel

Page 10: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 10/33

The .NET Framework Implementation of the Hotel Reservation

System

10 The .NET Framework

exchangesdatawithothersystemsthroughasetofwell-definedprocesses,butrequires

thecarefuluseofenterpriseapplicationintegrationtechnologiestomaintainconsistency

andsecurity,andtopreventdataloss.Thelogicfortheseexchangesisencapsulatedina

setofbusinessprocessorchestrationsthatareimplementedbyusingthejBPMworkflowsdescribedearlier(bookingpaymentandbookingtransfer)inconjunctionwithJBossESB

toconnecttotheseexternalsystems.

The .NET Framework Implementation of the Hotel Reservation System

TheMicrosoft.NETFrameworkisasoftwareframeworkfordevelopingandexecuting

applicationsonWindowsclientandserveroperatingsystems.Itprovidesfeaturesand

functionalitythataredesignedspecificallyforcreatingandrunningapplicationsonthe

Windowsplatform,butalsosupportsconnectivitywithnon-Windowssystems..NET

Frameworkapplicationsareexecutedbyusingthecommonlanguageruntime(CLR).TheCLRimplementsanabstractionlayerovertheoperatingsystemandprovides.NET

Frameworkapplicationswithcontrolledaccesstomachineresources;itsroleissimilarto

thatoftheJVMthatJavaapplicationsuse.Figure5showsanimplementationofthe

HotelReservationSystem,butthistimebasedonthe.NETFrameworkandincorporating

Windowstechnologiesandservices.

Page 11: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 11/33

The .NET Framework Implementation of the Hotel Reservation

System

11 The .NET Framework

CLR

CLR

Silverlight

CLR

WPF

Hotel Reception Staff 

- Desktop Application

HTML over

HTTP/SSL

Internet Information Services/Windows Process Activation Service

CLR

ASP.NET/

ASP.NET MVC

3rd

Party

Web Service Client

SOAP/XML

over HTTP/SSL

Partner Systems

WCF

Customer

Service

Room

Service

ADO.NET/Entity

Framework

Customer Entities

Booking Entities

Room Entities

SQL Server Database

Tabular Data Stream

TCP/IP

Customer

- Mobile Application

(Windows Phone 7)

HTML over

HTTP/SSL

CLR

Reporting

- Microsoft Office

Application

Batch Requests

- C# Applications

MSMQ 

WCF SOAP

and REST

Web

Services

WF

Booking

Service

BizTalk Server

CLR

Silverlight

Customer

- Web Browser

Custom

Windows

Service

Batch

Processing

Services

Booking Payment

Orchestration

Booking Transfer

Orchestration

Figure5.Architectureofthe.NETFrameworkimplementationofthe

HotelReservationSystem

Core System

Inthissolution,theCustomer,Booking,andRoomservicesprovidethecorefunctionality.

TheseitemsareWindowsCommunicationFoundation (WCF)services.WCFprovidesa

frameworkforbuildingservicesthatcanoperateinamannerthatisverysimilartoEJB

sessionbeans.Likeasessionbean,aWCFservicecanbestatefulorstateless.WCF

enablesyoutodefinethelogicforaservicebyusingordinaryapplicationcode,orby

usingWindowsWorkflowFoundation (WF)workflows.Listings1and2showpartofthe

implementationoftheWCFCustomerService,providingoperationsforcreatingand

managingcustomers,followedbytheequivalentelementsfromthecorrespondingJava

sessionbeaninListings3and4.Notethatbothimplementationsfollowasimilar

approach,definingtheoperationsinaninterfaceandprovidingaclassthatimplements

thisinterface.

using System;

Page 12: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 12/33

The .NET Framework Implementation of the Hotel Reservation

System

12 The .NET Framework

using System.Collections.Generic;using System.ServiceModel;

namespace HotelReservationSystemServices{

[ServiceContract]public interface ICustomerService{

[OperationContract]int CreateNewCustomer(string foreName, string middleInitial, string lastName,

DateTime dateOfBirth);

[OperationContract]bool DeleteCustomer(int customerID);

[OperationContract]List<Booking> FindBookings(int customerID, DateTime fromDate, DateTime toDate);

}

}

Listing1.TheWCFinterfacefortheCustomerService

using System;using System.Collections.Generic;using System.Transactions;

namespace HotelReservationSystemServices{

public class CustomerService : ICustomerService{

public int CreateNewCustomer(string foreName, string middleInitial, string lastName,

DateTime dateOfBirth)

{int customerID = -1;Customer customer = null;

 // The HotelReservationSystemDBEntities class is an Entity Framework context object // that provides the connection to the database, and provides the // necessary transaction managementHotelReservationSystemDBEntities context = new HotelReservationSystemDBEntities();

using (TransactionScope transaction = new TransactionScope()){

try

{ // Create a new Customer entity object

customer = new Customer{

ForeName = foreName,MiddleInitial = middleInitial,LastName = lastName,DateOfBirth = dateOfBirth

};

 // Save the Customer entity to the databasecontext.Customers.AddObject(customer);

Page 13: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 13/33

The .NET Framework Implementation of the Hotel Reservation

System

13 The .NET Framework

context.SaveChanges();customerID = customer.CustomerID;transaction.Complete();context.AcceptAllChanges();

}

 // If an error occurs, the transaction is aborted and the customer is not saved // Set the customerID to -1 to indicate that no customer was createdcatch (Exception e){

customerID = -1;}

}

context.Dispose();return customerID;

}

public bool DeleteCustomer(int customerID)

{

... // Implementation not shown}

public List<Booking> FindBookings(int customerID, DateTime fromDate, DateTime toDate){

... // Implementation not shown}

}}

Listing2.TheWCFimplementationoftheCustomerService

import HotelReservationSystemEntities.Booking;import java.util.Date;import java.util.List;import javax.ejb.Remote;

@Remotepublic interface CustomerServiceRemote {

int createNewCustomer(String foreName, char middleInitial, String lastName,Date dateOfBirth);

boolean deleteCustomer(int customerID);

List<Booking> findBookings(int customerID, Date fromDate, Date toDate);

}

Listing3.TheremoteinterfacefortheEJBversionoftheCustomerService

package HotelReservationSystemEnterpriseBeans;

Page 14: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 14/33

The .NET Framework Implementation of the Hotel Reservation

System

14 The .NET Framework

import HotelReservationSystemEntities.Customer;import HotelReservationSystemEntities.Booking;import java.util.Date;import java.util.List;

import javax.ejb.Stateless;

import org.hibernate.Transaction;import org.hibernate.Session;

@Statelesspublic class CustomerService implements CustomerServiceRemote {

@Overridepublic int createNewCustomer(String foreName, char middleInitial, String lastName,

Date dateOfBirth) {

Integer customerID = null;

Customer customer = null;Transaction transaction = null;

 // The HibernateManagment class (not shown) provides the static getSessionFactory // method which returns an org.hibernate.SessionFactory object for creating and // managing Hibernate sessionsSession session = HibernateManagement.getSessionFactory().openSession();

try {transaction = session.beginTransaction();

 // Create and save the new booking

customer = new Customer();customer.setForeName(foreName);

customer.setMiddleInitial(middleInitial);customer.setLastName(lastName);customer.setDateOfBirth(dateOfBirth);

customerID = (Integer)session.save(customer);transaction.commit();

} // If an error occurs, rollback the transactioncatch (Exception e) {

customerID = null;if (transaction != null) {

transaction.rollback();}

}finally {

session.close();if (customerID == null) {

return -1;

}else {

return customerID.intValue();}

}

Page 15: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 15/33

The .NET Framework Implementation of the Hotel Reservation

System

15 The .NET Framework

}

@Overridepublic boolean deleteCustomer(int customerID) {

... // Implementation not shown }

@Overridepublic List<Product> findBookings(int customerID, Date fromDate, Date toDate) {

... // Implementation not shown }}

Listing4.TheEJBimplementationoftheCustomerService

IntheJavaversionoftheHotelReservationSystem,theBookingServicesessionbean

employedajBPMworkflowforthereasonsdescribedearlier(thebookingprocessisa

potentiallylong-runningandcomplexmultistepprocess).Inthe.NETFrameworkversion,

theBookingServiceisimplementedasaWFworkflow.Long-runningWFservicescanbe

persistedtoadatabaseandtheirstaterestoredatalaterdatetoresumerunning.

MicrosoftVisualStudio®(theprimarydevelopmenttoolforbuilding.NETFramework

applications)providesagraphicaldesignerthatyoucanusetobuildandtestyour

workflows.Figure6showsanexample.

Page 16: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 16/33

The .NET Framework Implementation of the Hotel Reservation

System

16 The .NET Framework

Figure6.TheWorkflowDesignerinVisualStudio

AnimportantdifferencebetweenaWFserviceandajBPMworkflowconcerns

integrationwithexternalsystems.WFservicesareintendedtohandletheinternal

businesslogicinsideanorganization.Youcanusethemtoorchestrateinterbusinessprocesses,butMicrosoftprovidesMicrosoftBizTalk®Serverasabettersolutionforthis

purpose(anorchestrationmayinvolvecomplexdatatransformationsandintegration

withexternalsecurityservices,forwhichBizTalkServerisideallysuited).Therefore,inthe

.NETFrameworkversionoftheHotelReservationSystem,onlytheinternalpartofthe

logicassociatedwithreservingaroomisimplementedbyusingaWFworkflow;the

Page 17: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 17/33

The .NET Framework Implementation of the Hotel Reservation

System

17 The .NET Framework

interactionwiththeexternalpaymentserviceishandledbytheBizTalkServerBooking

PaymentOrchestration,whichisinvokedfromtheWFBookingService.

TheWCFservicesarehostedbyusingtheWindowsProcessActivationService(WAS)in

conjunctionwithInternetInformationServices(IIS).IISprovidesahostenvironmentforWebservicesandWebapplications,andisroughlyequivalenttoTomcatwithOpenEJBin

theJavasolution.WASextendsIISbysupportingnon-WebprotocolssuchasTCP,named

pipes,andmessagequeues.

AsintheJavasolution,theWCFservicesdependonacollectionofentityclasses(the

BookingandCustomertypesreferencedinListings1and2)toretrievedatafrom,and

update,thedatabase.The.NETFrameworkprovidesavarietyofdataaccesstechnologies

thatyoucanusetoimplementthisfunctionality.ThesetechnologiesincludeADO.NET

andtheEntityFramework.ADO.NETimplementsaprogrammaticmodelthatissimilarin

concepttoJDBC,andthatcanconnecttoavarietyofdatasourcesbypluggingintheappropriatedatabasedriver.TheEntityFrameworkimplementsanObject-Relational

Managementsystem,whichissimilartothatprovidedbytheJavaPersistenceAPI(JPA)

andHibernate.TheEntityFrameworkincludesasuiteofVisualStudiotemplatesand

othercode-generationelementsthatyoucanusetoconstructanentitymodelfroma

database.Thesetoolscangenerateasetofentityclasses,togetherwiththenecessary

infrastructureclassesforretrievingdataintoanentitycollection;creating,deleting,and

updatingentitiesinacollection;andsavingtheseentitiesbacktothedatabase.Figure7

showstheEntityDesignerinVisualStudio,whichyoucanusetodefinetheentitiesfora

solutionandmanagetherelationshipsbetweenthem.

Page 18: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 18/33

The .NET Framework Implementation of the Hotel Reservation

System

18 The .NET Framework

Figure7.TheEntityDesignerinVisualStudio

Listings5and6showpartofthecodethatisgeneratedbyusingtheEntityFramework.

TheEntityFrameworkgeneratestwoprincipaltypesofclasses:

  Entityclasses.Thesemodelthedatafromthedatasourceandaredirectlyequivalent

totheentityclassesthatJPAandHibernateuse.ThecodeinListing5showsthedetail

forsomeselectedpropertiesintheCustomerentityclass.Notethattheseproperties

providecontrolledaccesstofieldsintheclass,butthattheyalsoinvokemethods

alertingtheEntityFrameworkandtheuserapplicationofanychangesmadetothe

data.

  Contextclasses.Theseareusedtoconnecttotheunderlyingdatasourcetofetch,

insert,update,anddeletedata.TheyfulfillarolethatissimilartothatofaHibernate

Sessionobject.ThecontextobjectcontainsanObjectSetcollectionforeachtypeof

entityclass,andpopulatesthiscollectionwiththedatafromthedatasource.The

ObjectSetcollectionclassexposesmethodssuchasAddObjecttoaddanentity

Page 19: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 19/33

The .NET Framework Implementation of the Hotel Reservation

System

19 The .NET Framework

objecttoanObjectSetcollection.Listing2showedanexample,addinganewly

createdCustomerobjecttotheCustomer’sObjectSetforacontextobject.

ContextclassesarederivedfromtheObjectContextclass,whichprovidesmostofthe

corefunctionalityforinteractingwithadatasource.Forexample,theSaveChangesmethod(alsoillustratedinListing2)propagatesanychangesmadetoentitiesthat

areheldinanObjectSetcollectionassociatedwithacontextobjectbacktothedata

source.ThecodeinListing6showstheHotelReservationSystemDBEntitiescontext

classthattheEntityFrameworkgenerates,illustratinghowsuchaclassisstructured.

namespace HotelReservationSystemServices{

[EdmEntityTypeAttribute(NamespaceName="HotelReservationSystemDBModel",Name="Address")]

[Serializable()][DataContractAttribute(IsReference=true)]

public partial class Address : EntityObject{

...}

[EdmEntityTypeAttribute(NamespaceName="HotelReservationSystemDBModel",Name="Booking")]

[Serializable()][DataContractAttribute(IsReference=true)]public partial class Booking : EntityObject{

...}

[EdmEntityTypeAttribute(NamespaceName="HotelReservationSystemDBModel",Name="Customer")]

[Serializable()][DataContractAttribute(IsReference=true)]public partial class Customer : EntityObject{

public static Customer CreateCustomer(global::System.Int32 customerID,

global::System.String foreName,global::System.String lastName,global::System.DateTime dateOfBirth,global::System.Int32 addressAddressID)

{Customer customer = new Customer();

customer.CustomerID = customerID;

customer.ForeName = foreName;customer.LastName = lastName;customer.DateOfBirth = dateOfBirth;customer.AddressAddressID = addressAddressID;return customer;

}

[EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)][DataMemberAttribute()]public global::System.Int32 CustomerID

Page 20: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 20/33

The .NET Framework Implementation of the Hotel Reservation

System

20 The .NET Framework

{get{

return _CustomerID;}

set{

if (_CustomerID != value){

OnCustomerIDChanging(value);ReportPropertyChanging("CustomerID");

 _CustomerID = StructuralObject.SetValidValue(value);ReportPropertyChanged("CustomerID");OnCustomerIDChanged();

}}

}private global::System.Int32 _CustomerID;

partial void OnCustomerIDChanging(global::System.Int32 value);

partial void OnCustomerIDChanged();

[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)][DataMemberAttribute()]public global::System.String ForeName{

get{

return _ForeName;}set{

OnForeNameChanging(value);ReportPropertyChanging("ForeName");

 _ForeName = StructuralObject.SetValidValue(value, false);ReportPropertyChanged("ForeName");OnForeNameChanged();

}}private global::System.String _ForeName;partial void OnForeNameChanging(global::System.String value);partial void OnForeNameChanged();

...[XmlIgnoreAttribute()][SoapIgnoreAttribute()][DataMemberAttribute()][EdmRelationshipNavigationPropertyAttribute("HotelReservationSystemDBModel",

"FK_Booking_Customer", "Booking")]public EntityCollection<Booking> Bookings{

get{

return((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<Booking>("HotelReservationSystemDBModel.FK_Booking_Customer", "Booking");

}set

Page 21: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 21/33

The .NET Framework Implementation of the Hotel Reservation

System

21 The .NET Framework

{if ((value != null)){

((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<Booking>("Hot

elReservationSystemDBModel.FK_Booking_Customer", "Booking", value);}

}}

… }

[EdmEntityTypeAttribute(NamespaceName="HotelReservationSystemDBModel",Name="Room")]

[Serializable()][DataContractAttribute(IsReference=true)]public partial class Room : EntityObject

{

...}

}

Listing5.EntityclassesgeneratedbyusingtheEntityFramework

namespace HotelReservationSystemServices{

public partial class HotelReservationSystemDBEntities : ObjectContext{

 /// <summary> /// Initializes a new HotelReservationSystemDBEntities object using the connection string /// found in the 'HotelReservationSystemDBEntities' section of the application

 /// configuration file.

 /// </summary>public HotelReservationSystemDBEntities() :

base("name=HotelReservationSystemDBEntities", "HotelReservationSystemDBEntities"){

this.ContextOptions.LazyLoadingEnabled = true;OnContextCreated();

}

...

public ObjectSet<Booking> Bookings{

get{

if ((_Bookings == null)){

 _Bookings = base.CreateObjectSet<Booking>("Bookings");}return _Bookings;

}}private ObjectSet<Booking> _Bookings;

public ObjectSet<Customer> Customers

Page 22: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 22/33

The .NET Framework Implementation of the Hotel Reservation

System

22 The .NET Framework

{get{

if ((_Customers == null)){

 _Customers = base.CreateObjectSet<Customer>("Customers");}return _Customers;

}}private ObjectSet<Customer> _Customers;

...}...

}

Listing6.ContextgeneratedbyusingtheEntityFramework

ForcomparisonpurposeswithListing5,Listing7showstheequivalentJavaCustomer

entityclassgeneratedbyusingtheJPAtoolswithNetBeans.

package HotelReservationSystemEntities;...@Entity@Table(name = "Customer")...public class Customer implements Serializable {

private static final long serialVersionUID = 1L;@Id@Basic(optional = false)@Column(name = "CustomerID")

private Integer customerID;@Basic(optional = false)@Column(name = "ForeName")private String foreName;@Column(name = "MiddleInitial")private String middleInitial;@Basic(optional = false)

@Column(name = "LastName")private String lastName;@Basic(optional = false)@Column(name = "DateOfBirth")@Temporal(TemporalType.DATE)private Date dateOfBirth;

@OneToMany(mappedBy = "customer")

private Collection<Booking> bookingCollection;...

public Customer() {}

public Customer(Integer customerID) {this.customerID = customerID;

}

Page 23: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 23/33

The .NET Framework Implementation of the Hotel Reservation

System

23 The .NET Framework

public Customer(Integer customerID, String foreName, String lastName, Date dateOfBirth) {this.customerID = customerID;this.foreName = foreName;this.lastName = lastName;this.dateOfBirth = dateOfBirth;

}

public Integer getCustomerID() {return customerID;

}

public void setCustomerID(Integer customerID) {this.customerID = customerID;

}

public String getForeName() {return foreName;

}

public void setForeName(String foreName) {this.foreName = foreName;

}

...public Collection<Booking> getBookingCollection() {

return bookingCollection;}

public void setBookingCollection(Collection<Booking> bookingCollection) {this.bookingCollection = bookingCollection;

}

...

}Listing7.JPACustomerentityclassgeneratedbyusingNetBeans

TheEntityFrameworkisbuiltontopofADO.NET,andassuchitcanconnecttoanydata

sourceforwhichanADO.NETdriverisavailable.IntheHotelReservationSystem,the

hotelinformationdatabaseisimplementedbyusingMicrosoftSQLServer®,andthe

EntityFrameworkconnectstothedatabasebyusingthenativeSQLServerdriver,which

implementstheTabularDataStreamprotocol.

Inanymultiusersystemthatinvolvesdatamanagement,dataconsistencyisanissue.

Mostdatabasemanagementsystemssupportconsistencythroughtheuseof

transactions..NETFrameworkapplicationsthataccesstransactionaldatasourcescan

employTransactionScopeobjectsthatwrapthemethodcallsthatdefinetheoperations

inatransaction.Whencontrolreachestheendofatransactionscope,thechangesthat

aremadetodataheldinvariousdatabasesbytheseoperationscaneitherbecommitted

orrolledback,dependingontheoutcomeoftheunderlyingtransaction.The

CreateNewCustomermethodintheWCFimplementationoftheCustomerServiceclass

Page 24: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 24/33

The .NET Framework Implementation of the Hotel Reservation

System

24 The .NET Framework

inListing2showedanexampleofusingaTransactionScopeobject;thepertinent

detailsarereproducedinListing8.

public class CustomerService : ICustomerService{

public int CreateNewCustomer(string foreName, string middleInitial, string lastName,DateTime dateOfBirth)

{...using (TransactionScope transaction = new TransactionScope()){

try{

 // Create a new Customer entity objectcustomer = new Customer{ ... };

 // Save the Customer entity to the database...transaction.Complete();...

}...

}

}}

Listing8.ATransactionScopeobjectdelineatingatransaction

TheJavaversionoftheHotelReservationSystemmadeuseoftheSpringFrameworkto

implementcommondesignpatternsandreduceclose-couplinganddependenciesbetweencomponents.A.NETFrameworkversionoftheSpringFramework(Spring.NET)

isavailablefromSpringSource,butdesignersanddevelopersbuilding.NETFramework

applicationsshouldalsoconsultthepatternsandbestpracticesthataredocumentedon

theMicrosoftPatternsandPracticesWebsite.Akeyresourcethatisworthexaminingon

thissiteistheMicrosoftEnterpriseLibrary,whichprovidesasetofprebuiltmodulesthat

aredesignedtoaiddevelopersfacingcommonenterprisedevelopmentchallenges.The

EnterpriseLibraryincludestheUnityApplicationBlock,whichisanextensible

dependencyinjectioncontainerthatsupportsconstructorinjection,propertyinjection,

andmethodcallinjection.

Customer Access

LiketheJavaimplementation,customerscanconnecttotheHotelReservationSystem

andmakebookingsbyusingaWebbrowseroraWindowsPhone7device.Customers

accessingthesystemthroughaWebbrowserrunaMicrosoftSilverlight®application,

whichprovidesagraphicallyappealinguserinterface,andactsinamannersimilarto

Page 25: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 25/33

The .NET Framework Implementation of the Hotel Reservation

System

25 The .NET Framework

thatoftheJavaFXinterfaceintheJavasolution.TheapplicationthatrunsonWindows

Phone7devicesisalsoSilverlight-based.Itprovidesthesamefunctionalityasthe

browserapplication,butitisadaptedfortheformfactorofthemobiledevice.

TheWebbrowserandmobileapplicationsbothconnecttotheIISserverthatthehotelhosts.IISsupportsseveralmodelsforimplementingcontent,includingstaticHTML,CGI,

anddynamicallygeneratedpages.ThekeyMicrosofttechnologyinthisareaisASP.NET,

whichprovidesfunctionalitysimilartothatavailablewithJSPpagesandservlets,butwith

severalextensions.DeveloperscanusetheASP.NETModel-View-Controller(MVC)

frameworktoimplementcomplexWebapplications.Additionally,Webapplicationscan

invokeWCFservicestoretrievedataandperformthevariousbusinessoperationsthat

thesystemimplements.

Reception Staff Access

HotelreceptionstaffrunadesktopapplicationthatisimplementedbyusingWindows

PresentationFoundation(WPF)toprovidetheuserinterface.WPFenablesyouto

separatethelayoutoftheuserinterfacefromthecodethatprovidestheuserinterface

logicthroughtheuseofdatabinding.VisualStudioprovidesaGUIdesignwindowthata

developercanusetolayoutauserinterface.Alternatively,aspecialistgraphicsdesigner

candefineacomplexuserinterfacebyusingaseparatetoolsuchasMicrosoft

Expression®.TheuserinterfaceforaWPFapplicationisdefinedbyusingalanguage

calledXAML.XAMLemploysanXML-likesyntaxtodescribetheelementsofauser

interface,andtherelationshipsbetweenthem.Figure8showsanexampleoftheXAMLmarkupandlayoutforpartoftheuserinterface,intheVisualStudiodesignview

window.

Page 26: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 26/33

The .NET Framework Implementation of the Hotel Reservation

System

26 The .NET Framework

Figure8.TheXAMLmarkupforaWPFuserinterface

Youcanimplementtheuserinterfacelogicbyusingaprogramminglanguagesuchas

C#;likeSwing,aWPFuserinterfaceisevent-drivenandyouwritecodethatrespondsto

thevariouseventsthatcanoccurastheuserinteractswiththevarioususerinterface

elements.Databindingisapowerfulmechanismthatenablesadeveloperto

declarativelyassociatethevisualelementsinauserinterfacewithsetsofdata,and

displaythisdataintheseelements.Asthedatachanges,theuserinterfaceautomatically

updates.

Page 27: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 27/33

The .NET Framework Implementation of the Hotel Reservation

System

27 The .NET Framework

TheWPFapplicationconnectstotheWCFservicesthatIISandWAShosttoretrievedata

andperformthebusinessoperations.TheWPFapplicationandtheWCFservicesare

bothlocatedonthesamesite(thehotel),sotheWPFapplicationcanconnecttothe

WCFservicesbyusingTCP/IPratherthanHTTP.AkeyfeatureofWCFandWASistheabilitytoexposemultipleendpointsforaservice,witheachendpointassociatedwitha

differentnetworkprotocol.

Reporting

TheReportingapplicationfollowsaverysimilarpatterntothatemployedintheJava

solution.ItisimplementedbyusingtheMicrosoftOfficesuite,connectingtotheSQL

Serverdatabaseholdingthehotelinformationtoextractdata.Figure9showsan

exampleofaMicrosoftExcel®spreadsheetbeingconfiguredtoretrievedatafromaSQL

Serverdatabase.

Figure9.ConnectinganExcelspreadsheettoSQLServer

Page 28: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 28/33

The .NET Framework Implementation of the Hotel Reservation

System

28 The .NET Framework

Batch Processing

ThebatchprocessinginfrastructureoftheHotelReservationSystemconsistsofaseriesof

stand-aloneC#applications(somewrittentosupportaspecificmarketingcampaign,otherscreatedtosupportregular,repeatedcampaigns)thatpostrequeststoaqueuein

MessageQueuing(alsoknownasMSMQ).AcustomWindowsserviceisscheduledtorun

atoff-peakhours,retrievethejobsfromthisqueue,andsendthemtotheappropriate

batchprocessingservicerunningunderWCF.Aswiththemessage-drivenbeansinthe

Javasolution,thereisacollectionoftheseservices,eachonedevelopedtosupporta

specificbatchjob.

Integration with Third-Party Systems

WCFservicescanbeexposedinternallyinsideanorganization(likeEJBsessionbeans),buttheycanalsobemadeavailablethroughHTTPendpointstotheoutsideworldas

Webservices.TheHotelReservationSystemfollowsthisapproachtoimplementtheWeb

servicesthatenablethird-partyWebclientapplicationsandbrokerageservicestoquery

roomavailabilityandpricing.

Finally,tosupportthesecurepaymentandbookingstransferrequirementsfrompartner

hotels,theHotelReservationSystemimplementsasetofbusinessorchestrationsand

datatransformationsbyusingBizTalkServer.BizTalkServerincludesacollectionofVisual

Studiotoolsandtemplatesfordefiningorchestrationsandtransformations,asshownin

Figure10.BizTalkServeralsoprovidesseveralconnectorsandadaptersforsendingdatato,andreceivingdatafrom,avarietyofsystems.

Page 29: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 29/33

Nonfunctional Requirements of the Hotel Reservation System

29 The .NET Framework

Figure10.DesigningaBizTalkServerorchestration

Nonfunctional Requirements of the Hotel Reservation System

ThediscussionsofarhasconcentratedonthefunctionalimplementationoftheHotel

ReservationSystem,butthenonfunctionalrequirementsofanyenterpriseareequallyimportant.Theserequirementsincludesecurity,performanceandscalability,system

reliability,andmanagementandmonitoring.

Page 30: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 30/33

Nonfunctional Requirements of the Hotel Reservation System

30 The .NET Framework

Security

Securityisasomewhatnebuloustermthatcoversavarietyofrequirementsconcerning

protectingresourcesonacomputerandlimitingaccesstodataandoperationsthata

usercanrequestwhilerunninganapplication.Thesecurityfeaturesthatareprovided

withthe.NETFrameworkandWindowsservicesinclude:

  Codesigning.A.NETFrameworkapplicationconsistsofaseriesofexecutablefiles

calledassemblies—anassemblyissimilartoaJARfileinaJavaapplication.A

developercansignanassemblywithaprivatekey,anddistributethecorresponding

publickeytoeachapplicationthatreferencestheassembly.Whentheapplication

loadsanassembly,theCLRautomaticallyverifiesthesignatureoftheassemblyby

usingthepublickeytoestablishtheprovenanceoftheassembly.Iftheverification

fails,theassemblyisdeemedtobesuspectandisnotloaded,andtheapplication

throwsanexception.

  Sandboxing.Toprotecttheresourcesonacomputerfromroguecode,a.NET

FrameworkassemblythatisdownloadedaspartofanASP.NETWebapplication,or

anapplicationthatisinvokedfromaremotenetworklocation,canbeexecutedina

restrictedenvironmentthatlimitstheoperationsthatitcanperform,suchaswriting

tofilesondisk.Anadministratorcanconfigurethepermissionsthatareavailabletoa

sandboxedapplication.

  Role-basedsecurity.Thisisanauthorizationmechanism.Youcanannotatethe

methodsthatmakeupanapplication,orthatimplementtheoperationsinaservice,

withattributesthatspecifywhetherauserorrolehasaccesstothosemethods.Whenauserrunstheapplicationorinvokesanoperation,theCLRcheckstheuser'sidentity

againsttheseattributesandonlyperformsthemethodifthereisamatch,throwing

anexceptionotherwise.

Note:

Attributesinthe.NETFrameworkaresimilartoannotationsinJava.Youcanusethemto

specifyadditionalmetadataorindicatenonfunctionalcross-cuttingconcernsofaclassor

method.The.NETFrameworkimplementsalargenumberofattributesthataddressa

varietyofconcerns,andyoucanalsodefineyourowncustomattributes.

The.NETFrameworkalsoprovidesaseriesofAPIsthatanapplicationcanemployto

implementafinergrainofaccesscontrolinsidemethods.Role-basedsecurityworksin

conjunctionwithmostWindowsauthenticationmechanisms.

Note:

Page 31: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 31/33

Nonfunctional Requirements of the Hotel Reservation System

31 The .NET Framework

Ifyouimplementaclaims-basedfederatedsecuritymodel,youcanincorporateWindows

IdentityFoundationintoyoursolution.

  Transport-levelsecurity.ThisisafeatureofIISandWAS,andenablesahost

environmenttolimitaccesstotheservicesrunninginthatenvironmentbasedonthe

identityoftheuserorprocessinvokingtheservice.Transport-levelsecurityis

transparenttotheservice.

  Encryption.Informationpassingbetweenaclientapplicationandaservicecanbe

encryptedtoreducethechancesoftamperingbyathirdpartywhoismonitoringthe

network.WCFservicessupportencryptionatthemessagelevelandthetransport

level,anditistransparenttothecoderunninginclientapplicationsandWCFservices.

Performance, Scalability, and Reliability

WindowsServer®2008isanexcellentbaseforenterprise-scaleapplications.Itprovidesseveralservicesthatyoucanusetoimplementahighlyscalableandreliableplatform.

Theseservicesinclude:

  Failoverclustering.Thisservicecanbuildredundancyintoasystemandhelpto

eliminatesinglepointsoffailure.

  NetworkLoadBalancing.ThisserviceenablesyoutodistributeTCP/IPrequestsacross

multipleserverstooptimizeresourceutilization,decreasecomputingtime,and

ensuresystemavailability.

 WindowsServerAppFabric.ThisserviceprovidesascalableandreliablehostingenvironmentforpersistentWCFworkflowservices,andadistributedcachesolution.

AppFabricimplementsaclusteredenvironmentforhostingworkflowservices,which

canbepersistedtoadatabaseatkeypointsintheirexecution.Iftheserviceorits

hostenvironmentsubsequentlyfails,theservicecanberesumedonanothernodein

anAppFabricclusterfromthepointatwhichitwaslastpersisted.Thedistributed

cachehelpstoimproveperformancebykeepingcacheddatalocaltotheworkflow

servicesthatuseit.

.NETFrameworkapplicationscanmakeuseoflogginganddiagnosticfunctionalitythatis

builtintotheWindowsoperatingsystemandprovidesfeaturesthatareanalogousto

thosefoundintheJavaloggingAPIandtheLog4jframework.Anadministratorcan

configurea.NETFrameworkapplicationtorecorddiagnosticinformationabout

significanteventsandfailurestoeventlogsandfiles.TheLoggingApplicationBlockin

theMicrosoftPatternsandPracticesEnterpriseLibraryillustratesbestpracticesfor

incorporatingloggingfunctionalityintoa.NETFrameworkapplication.Thelogging

Page 32: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 32/33

Page 33: The .NET Framework for Java Developers - Whitepaper

8/3/2019 The .NET Framework for Java Developers - Whitepaper

http://slidepdf.com/reader/full/the-net-framework-for-java-developers-whitepaper 33/33

Summary

anenterpriseenvironment,triggeralertsifavailableresourcesdropbelowspecified

thresholds,andrunscriptsthatcantakethenecessarycorrectiveactionbeforea

situationbecomescritical.

Visual Studio Profiling

Tohelplocatethesourceofpotentialbottlenecksinanapplicationandreducethe

chancesofanapplicationexhibitingconsistentpoorperformance,anapplication

developerusingVisualStudiocanmakeuseofapplicationprofiling.TheVisualStudio

ProfilerattachestoanapplicationrunninginDebugmodeandperiodicallyinspectsthe

stateoftheapplication,notingwhichmethodsarebeinginvokedandcollectingother

dataconcerningthehealthoftheapplication.Usingthisinformation,VisualStudiocan

generatereportshighlightingwhichmethodsarebeinginvokedmostfrequently.Visual

Studioalsosupportsprobing;itcangenerateinstructionsthatrecordwheneachmethod

startsandfinishes,enablingittogenerateareportthatindicateshowlongeachmethodcalltakes.

Summary

The.NETFramework,togetherwithtoolssuchasVisualStudio,providesa

comprehensivedevelopmentenvironmentforquicklydesigning,building,anddeploying

applicationsthatrunontheWindowsplatform.Usingthe.NETFramework,youcan

constructthewholegamutofapplications,incorporatingmobile,desktop,andenterprise

technologiesaccordingtotherequirementsofyourorganization.

Inthispaper,youhaveseenhowthe.NETFrameworkimplementationoftheHotelReservationSystemmapstothecorrespondingsystembuiltbyusingJava.Thisisjustone

possiblerendition,butitillustrateshowthe.NETFrameworkinconjunctionwithother

servicesavailablefromMicrosoftcanbecombinedintoafullyfunctionalsolution.

The.NETFrameworkprovidesanoptimizedandintegratedenvironmentforWindows,

enablingyoutomoreeasilybuildapplicationsthatcombinedisparatecomponentsand

communicatewithservicesacrossthenetwork,minimizingtheneedtoincorporate

technologiesfromthirdparties.GuidancesuchasthatavailableontheMicrosoft

PatternsandPracticesWebsitedescribebestpracticesfordesigningsolutionsbasedon

the.NETFramework.Additionally,toolssuchasVisualStudiothataredesignedspecificallytoworkwiththe.NETFrameworkcangreatlyenhancedeveloperproductivity

whenbuildingcomplexsolutions.

Formoreinformationaboutbuildingapplicationsbyusingthe.NETFramework,visitthe

.NETFrameworkDeveloperCenter.