WebSphere Extended Deployment V6.0.x     操作系统:

在指令行上執行 ObjectGrid 範例應用程式

這個主題說明如何在 Java 指令行上執行啟用 ObjectGrid 的應用程式。

在您开始之前

您必須已安裝 Java Development Kit (JDK)。您也必須具備 ObjectGrid 範例應用程式的存取權。如需相關資訊,請參閱 ObjectGrid 入門

关于本任务

這項作業可讓您快速執行一個啟用物件格線的應用程式。有關使用 ObjectGrid API 的詳細說明, 請參閱 WebSphere Extended Deployment Library 網頁中的 ObjectGrid Programming Guide。

过程

  1. 檢查您的 Java Development Kit (JDK) 版本。 物件格線需要 JDK 1.42(或更新的版本)。在執行 ObjectGrid 範例應用程式前,若要測試您的 Java 環境, 請執行下列步驟:
    1. 開啟一個指令行提示畫面。
    2. 請輸入下面這個指令:
      java -version
      如果指令執行正確, 會顯示類似如下的文字:
      java version "1.4.2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2) 
      Classic VM (build 1.4.2, J2RE 1.4.2 IBM Windows 32 build cn142-20040820 (JIT enabled: jitc))
      如果顯示錯誤,請確定已安裝 JDK 且位於您的 CLASSPATH 中。
  2. 執行物件格線範例應用程式。 範例應用程式說明一個涉及員工、 辦公室和工作地點的簡單案例。範例應用程式會使用對映, 為每一種物件類型各建一個 ObjectGrid 實例。每一項對映各會插入項目並加以操作,以示範 ObjectGrid 快取功能。
    1. 請開啟指令行,並導覽至工作目錄。 如果是在本端機器上執行,請將 .jar 檔複製到工作目錄中。如果您使用 WebSphere Extended Deployment, 可導覽至 <install_root>/optionalLibraries/ObjectGrid 目錄。
    2. 發出下列指令:
      cd working_directory
      java -cp "objectgridSA.jar;objectgridSample.jar" com.ibm.websphere.samples.objectgrid.basic.ObjectGridSample
      系統會顯示類似如下文字的輸出:
      Initializing ObjectGridSample ...
      resourcePath: META-INF/objectgrid-definition.xml
      objectgridUrl: jar:file:/C:/temp/objg/objectgridSample.jar!/META-INF/objectgrid-definition.xml
      
      EmployeeOptimisticCallback returning version object for employee = Perry Cheng, version = 0
      EmployeeOptimisticCallback returning version object for employee = Hao Lee, version = 0
      EmployeeOptimisticCallback returning version object for employee = Ken Huang, version = 0
      EmployeeOptimisticCallback returning version object for employee = Jerry Anderson, version = 0
      EmployeeOptimisticCallback returning version object for employee = Kevin Bockhold, version = 0
      ---------------------------------------------
      com.ibm.websphere.samples.objectgrid.basic.ObjectGridSample status:
      ivObjectGrid Name = clusterObjectGrid
      ivObjectGrid      = com.ibm.ws.objectgrid.ObjectGridImpl@187b81e4
      ivSession = com.ibm.ws.objectgrid.SessionImpl@6b0d81e4
      ivEmpMap     = com.ibm.ws.objectgrid.ObjectMapImpl@6b1841e4
      ivOfficeMap  = com.ibm.ws.objectgrid.ObjectMapImpl@6ba081e4
      ivSiteMap    = com.ibm.ws.objectgrid.ObjectMapImpl@6bae01e4
      ivCounterMap = com.ibm.ws.objectgrid.ObjectMapImpl@697b41e4
      ---------------------------------------------
      interactiveMode = false
      
      Action = populateMaps
      CounterOptimisticCallback returning version object for counter name = Counter1, version = 0
      CounterOptimisticCallback returning version object for counter name = Counter2, version = 0
      CounterOptimisticCallback returning version object for counter name = Counter3, version = 0
      ivCounterMap operations committed
      ivOfficeMap operations committed
      EmployeeOptimisticCallback returning version object for employee = Ken Huang, version = 0
      
      Action = updateMaps
      EmployeeOptimisticCallback returning version object for employee = Ken Huang, version = 0
      emp = employee name = Ken Huang   department = ABC   employee id = 1   manager id = 1   optimistic seqno = 0
      office = Office Type: Cubicle, site code: ROCHLOC, building: BLD102, floor: 1, hall: A, office number : 101, capacity: 9
      9, occupants: NONE
      Committing change to two maps completed successfully
      EmployeeOptimisticCallback returning version object for employee = Kevin Bockhold, version = 0
      emp = employee name = Kevin Bockhold   department = ABC   employee id = 5   manager id = 1   optimistic seqno = 0
      dump of employee 5: employee name = Kevin Bockhold   department = ABC   employee id = 5   manager id = 1   optimistic seqno = 0
      CounterOptimisticCallback returning version object for counter name = Counter4, version = 0
      EmployeeOptimisticCallback returning version object for employee = Kevin Bockhold, version = 0
      EmployeeOptimisticCallback updating employee = Kevin Bockhold with new version = 1
      EmployeeOptimisticCallback returning version object for employee = Kevin Bockhold, version = 1
      Committing change to two maps completed successfully
      
      Action = updateMapsAndRollback
      EmployeeOptimisticCallback returning version object for employee = Jerry Anderson, version = 0
      rollback change to two maps completed successfully
      EmployeeOptimisticCallback returning version object for employee = Kevin Bockhold, version = 1
      emp = employee name = Kevin Bockhold   department = ABC   employee id = 5   manager id = 2   optimistic seqno = 1
      dump of employee 5: employee name = Kevin Bockhold   department = ABC   employee id = 5   manager id = 2   optimistic seqno = 1
      CounterOptimisticCallback returning version object for counter name = Counter5, version = 0
      rollback change to two maps completed successfully
      
      Action = displayObjectGridData
      --------------------------------
      Map = offices
      --------------------------------
      Key=2,  value=Office Type: Home Office, site code: AUSTINLOC, building: null, floor: 0, hall:  , office number : 0, capa
      city: 0, occupants: NONE
      Key=4,  value=null
      Key=1,  value=Office Type: Cubicle, site code: ROCHLOC, building: BLD102, floor: 1, hall: A, office number : 101, capaci
      ty: 99, occupants: 1
      Key=3,  value=Office Type: Traditional Office , site code: POKLOC, building: BLD307, floor: 3, hall: L, office number :
      208, capacity: 99, occupants: 3
      Key=5,  value=null
      --------------------------------
      Map = employees
      --------------------------------
      EmployeeOptimisticCallback returning version object for employee = Perry Cheng, version = 0
      Key=2,  value=employee name = Perry Cheng   department = ABC   employee id = 2   manager id = 1   optimistic seqno = 0
      EmployeeOptimisticCallback returning version object for employee = Hao Lee, version = 0
      Key=4,  value=employee name = Hao Lee   department = NBC   employee id = 4   manager id = 2   optimistic seqno = 0
      EmployeeOptimisticCallback returning version object for employee = Ken Huang, version = 0
      Key=1,  value=employee name = Ken Huang   department = ABC   employee id = 1   manager id = 1   optimistic seqno = 0
      EmployeeOptimisticCallback returning version object for employee = Jerry Anderson, version = 0
      Key=3,  value=employee name = Jerry Anderson   department = NBC   employee id = 3   manager id = 2   optimistic seqno =0
      EmployeeOptimisticCallback returning version object for employee = Kevin Bockhold, version = 1
      Key=5,  value=employee name = Kevin Bockhold   department = ABC   employee id = 5   manager id = 2   optimistic seqno =1
      --------------------------------
      Map = sites
      --------------------------------
      Key=TORLOC,  value=City = Toronto Ontario   State = Ontario   Country = Canada   Address = 8200 Warden Ave.   PostalCode = L6G 1C7
      Key=POKLOC,  value=City = Poughkeepsie New York   State = New York   Country = USA   Address = 2455 South Rd.   PostalCode = 12601
      Key=AUSTINLOC,  value=City = Austin Texas   State = Texas   Country = USA   Address = 11501 Burnet Rd.   PostalCode = 78758
      Key=DURHAMLOC,  value=City = Durham North Carolina   State = North Carolina   Country = USA   Address = 4205 S Miami Blvd.   PostalCode = 27709
      Key=ROCHLOC,  value=City = Rochester Minnesota   State = Minnesota   Country = USA   Address = 3605 HWY 52 N   PostalCode = 55901
      --------------------------------
      Map = counters
      --------------------------------
      CounterOptimisticCallback returning version object for counter name = Counter2, version = 0 Key=2,  value=count = 20 optimistic sequence number = 0
      CounterOptimisticCallback returning version object for counter name = Counter4, version = 0 Key=4,  value=count = 40 optimistic sequence number = 0
      CounterOptimisticCallback returning version object for counter name = Counter1, version = 0 Key=1,  value=count = 10 optimistic sequence number = 0
      CounterOptimisticCallback returning version object for counter name = Counter3, version = 0 Key=3,  value=count = 30 optimistic sequence number = 0 Key=5,  value=null
      
      Action = cleanup
      CounterOptimisticCallback returning version object for counter name = Counter1, version = 0
      EmployeeOptimisticCallback returning version object for employee = Ken Huang, version = 0
      CounterOptimisticCallback returning version object for counter name = Counter2, version = 0
      EmployeeOptimisticCallback returning version object for employee = Perry Cheng, version = 0
      CounterOptimisticCallback returning version object for counter name = Counter3, version = 0
      EmployeeOptimisticCallback returning version object for employee = Jerry Anderson, version = 0
      CounterOptimisticCallback returning version object for counter name = Counter4, version = 0
      EmployeeOptimisticCallback returning version object for employee = Hao Lee, version = 0
      EmployeeOptimisticCallback returning version object for employee = Kevin Bockhold, version = 1
      DONE cleanup

结果

您是在 Java 指令行上執行 ObjectGrid 範例應用程式。

下一步做什么

如果您想檢視此範例的程式碼,可在 objectgridSamples.jar 檔(亦即, com\ibm\websphere\samples\objectgrid\basic\ObjectGridSample.java 檔)中找到。



相關工作
ObjectGrid 入門
任务主题    

使用条款 | 反馈

最近更新日期: Aug 14, 2006 2:04:24 PM EDT
http://publib.boulder.ibm.com/infocenter/wxdinfo/v6r0/index.jsp?topic=/com.ibm.websphere.xd.doc/info/objectgrid/tobgstart.html

© Copyright IBM Corp. 2005, 2006. All Rights Reserved.
本信息中心基于 Eclipse 技术。(http://www.eclipse.org)