Enterprise ApplicationsWilliam PughEnterprise applications• E-bay• Amazon• Campus course registration systemArchitectureWeb clientWeb clientWeb clientWAP clientWAP clientwebserverwebserverwebserverWAPserverDatabaseAppServerAppServerDatabaseDatabaseLegacyApplicationWebService ClientFeatures of EnterpriseApplications• Persistent data– databases– integrity– transactions• Interfaces– web clients– web services– legacy applicationsMore features• Distribution and scaling– some enterprise applications may be deployed in lowactivity environment– should be possible to scale them if demand warrants it– often means distribution across multiple machines– often geographically distributed• Resiliency to failure– one machine failure cannot shutdown an enterpriseapplicationDatabases• Relational databases the standardmechanism– scales well to very large data sizes– handles transactions and failure well• SQL the standard language for talking tothemJDBC• Java standard for talking to databases• Allows efficient mechanisms for talkingSQL to databases– doesn’t just read/write text streamsPersistent Objects• It is a pain to have to use SQL querieswhenever you want to touch persistent state• Better to have objects that reflect persistentstate– and can check integrity rules and other businesslogicPersistent Object solutions• EJB (Enterprise Java Beans)– BMP - Beans managed persistence– CMP - Container managed persistence• AppServer provides mapping between beans and database• Java Data Objects– Good for small stuff• Hibernate– an alternative to JDODatabases in five slidesTransactions• Atomicity - indivisible set of actions• Consistency - respects database invariants– typically domain specific• Isolation - ignorant of other, uncommittedtransactions• Durability - persistent, even in case of systemfailureSong databaseAlbumtitlecategoryyearArtistnameSongtitlelengthA song database• Album:albumIDtitlecategoryyear• Artist:artistIDname• Song:songIDalbumIDtitlelength• Performance:songIDartistIDLocking• Transaction 1 reads current balance– sees $100• Transaction 2 reads current balance– sees $100• Transaction 2 adds $10– sets current balance to $110• Transaction 1 adds $10– sets current balance to $110How to handle• In threads, we would just use locks• In databases, can use pessimistic oroptimistic concurrency– pessimistic concurrency similar to standardlocking– optimistic: don’t lock• fail when committing if anyone else changed datayou depended onWeb Presentations• OK, it is great to have all this informationavailable• How do we present it over the web?Servlets and JSP• Servlets are an API for writing Java codethat handles HTTP requests– provides easy access to all of the HTTPfunctionality (cookies, forms, …)• JSP are a way that allows you to embedJava code inside a HTML document– compiled at the server, runs efficientlyNot the whole story• extension mechanisms for JSP– just use special tags, no Java code, in your JSP• static documents and images served via astandard web server– although a JSP server will do in a pinch• Additional mechanisms to handle controlflow and page composition– Struts, Java Server Faces, …Rest of today• Overview of Servlets• Overview of
View Full Document