throw new ServiceLocator Exception(ne) i catch(Exception e)i throw new ServiceLocator Exception(e); /將本物件参考傳出 static public ServiceLocator getinstanceoi return me 以下略過. 上迒 Service locator建構子中運用 Collections的 Static Method(靜態函式) synchronizedMapo來產生 Hash Map容器依 J2SDK API文件說法’透過此函式 可產生出具同步化及安全執行緒的 HashMap容器 使用者基本資料瀏覽流程 現在讓我們進人主題- Petstore矞業邏輯’筆者以使用者基本資料瀏覽流程 爲例,請啓動 cloudscape資料庫 cloudscape-star C其rs产m2cmde \Documents and Settings \Adninistrator\ET>cloudscape -start Mon Sep 16 23: 21: 33 CST 2002: [RniJdbc] Starting Cloudscape RmiJdbc Server Versil Mon Sep 16 23: 21: 35 CST 2002: [RniJdbc 1 COM cloudscape core. JDBCDriver registere Mon Sep 16 23: 21: 35 CST 2002: [RniJdbc l Binding RmiJdbc Server Mon Sep 16 23: 21: 35 CST 2002: [RniJdbc No installation of RMI Security Manager Mon Sep 16 23: 21: 36 CST 2002: [RniJdbc l RmiJdbcServer bound in rmi registry
throw new ServiceLocatorException(ne); } catch (Exception e) { throw new ServiceLocatorException(e); } } //將本物件參考傳出 static public ServiceLocator getInstance() { return me; } 以下略過… } 上述 ServiceLocator 建構子中運用 Collections 的 Static Method(靜態函式) synchronizedMap()來產生 HashMap 容器,依 J2SDK API 文件說法,透過此函式 可產生出具同步化及安全執行緒的 HashMap 容器。 使用者基本資料瀏覽流程 現在讓我們進入主題-Petstore 商業邏輯,筆者以使用者基本資料瀏覽流程 為例,請啟動 cloudscape 資料庫: cloudscape –start
圖1啓動資料庫 接著啓動 RI Application Server(應用伺服器) j2ee-verbose Binding nane local/signOn Binding name:java:comp Binding nane: java:com l/Address Binding nane: java: comp/env local/U Binding nane: java: comp/env/jdbc/Catalog DB omp/env/url/CatalogDAOSQLUE reated Context :/petstore Binding nane:java:comp/enu/ejb/remote/OPCAdminFacade Binding name: java: comp/env/ejb/local/As ync Sender Iinfo]http--jax-rpcservletinit d Context :/admin Binding name: java: comp/env/param/xml/validation/Invo i Binding name java:comp/env/param/xml/Xs VAlidation Binding nane: 'java: comp/env/jns/topic/Invoice Topit Binding nane : 'java:comp/enu/url/EntityCatalogURL Binding nane: java: comp/env/jns/topic/Topic Connection Factory LinfOihttp--jax-rpc let: init eated Context :/opc J2EE server startup complete 圖2啓動RI Petstore系統啓動無誤後·請開啓瀏覽器’輸入 http://localhost:8080/petstore/index.jsp
圖 1 啟動資料庫 接著啟動 RI Application Server(應用伺服器): j2ee –verbose 圖 2 啟動 RI Petstore 系統啟動無誤後,請開啟瀏覽器,輸入 http://localhost:8080/petstore/index.jsp
我的桑爱守媒曾④·当三日 JavaTM Pet Store Demo 1.3.1 The Java TM Pet Store Demo i a sample applcation brought to you by the Java M BluePrints for the Enterpnse program at Java TM Software, Sun Microsystems Thas sample applicaton demonstrates how to use the capabilites of the J2EE platform to develop tenable, scalable, cross-platform e-busness applicahons. It ou can experiment with J2EETM technology and lean how to use it to buld your own enterpnse sohutionsomes sing this demo for the very first time, the demos database will be automatical populated (e prepared You may also forcefully repopulate the demos database (Be prepared to wat for a while as the database s populated. y ou can also use the adrmustraor chert About Java BluePrints for the Enterprise hitectural recommendatons for real-world applcaton scenarios to en Applicatians with the J2EBTX CheckouttheJavanBlueprintsfortheEnterpnseWebsteathttp://jsva,auntcom/blueprints/entecpriae Copynght e 2002 Sun Microsystems, Inc. All Rights Reserved. 圖3進入 Petstore系統 進入系統看到那大大的鸚鵡頭·請點選右上魚的ˆ Accoun'連結’進λ使用者登 入流程 输案副面棱概①我的最爱①)工具①明围 址①没 JavaTM Pet Store Search 2EE Blue Prints Sample Application 点CCQU Birds Rept les @ The Jara Pet Store Demo is a fictional sample application from the Java Blue Prints for the Emderpnse For more information. wisn the Java Blue Pints for the Enerprise Java blue Pnns forthe Ertemnse I aa Software Sun Microsystems e h Mocehoata0colpettomekctomerdo 近娱内部
圖 3 進入 Petstore 系統 進入系統看到那大大的鸚鵡頭,請點選右上角的”Account”連結,進入使用者登 入流程:
圖4 Petstore首頁 我們會看到登入畫面,疸接使用預設的使用者(2e)及密碼(2e)·點選' Sign ln 鈕 国棱概①我的最工具①明 中上一页·→·的国我的船景守媒(日 址httpmmocalHoStadedpestmecntamerd 令移至灌 JavaTM Pet Store J2EE BluePrints Sample Applicati Account I cartI Sonin Pets Are you a returning customer? Reptiles No. i would like to sign up for an Password Password Remember My User Name厂 Create New Account The Java Pet Store Demo is a fictional sample application t wsn the Java Blue Pnns for the enterpris ava Bhe Prints for the Entemnse I Jama Software I Sun Microsystems 22001 Sun Microsystems Inc. All rights reserved. Use is subject 圖5登入畫面 看到以下顯示個人資訊畫面就表示我們已登人成功啦
圖 4 Petstore 首頁 我們會看到登入畫面,直接使用預設的使用者(j2ee)及密碼(j2ee),點選”Sign In” 鈕: 圖 5 登入畫面 看到以下顯示個人資訊畫面就表示我們已登入成功啦!
httMocabostsceo-tpes:tbrekusthmerdo 移至洁 JavaTM Pet Store Your Account Information Contact Information Rattlesnake First Name xyz Last Name ABC Street Address 1234 Anywhere Street un555 City Palo Alt Postal Code 94303 Country USA number 565-565-5565 Card Type Meow Card Card Expiry Date 04/04 Profile Information 圖6個人資訊畫面 若此時我們按瀏覽器之”上一頁ˆ鈕返回首頁 aweto 「案面①我的鼎数)工具①明① 中上一·→·的②a国我的鼎要守媒普④日日 址①没 JavaTM Pet Store Search 2EE Blue Prints Sample Application Accoun CartI Sonin Birds Rept les @ The Jara Pet Store Demo is a fictional sample application from the Java Blue Prints for the Emderpnse For more information. wisn the Java Blue Pints for the Enerprise Java blue Pnns forthe Ertemnse I aa Software Sun Microsystems 近娱内部
圖 6 個人資訊畫面 若此時我們按瀏覽器之”上一頁”鈕返回首頁: