跳轉到內容

WebObjects/Web 應用程式/部署

來自 Wikibooks,開放世界中的開放書籍

Xcode 預期獲取給定的檔案集,如“組和檔案”窗格中列出的檔案集,並從中構建一個成品或一組產品,例如應用程式、框架、庫或命令列工具。

這裡值得注意的是,此窗格中表示的專案有四種類型:檔案、目錄、包和組。檔案就是檔案,各種型別的檔案,副檔名指示型別,例如 .java、.jpg、.gif、.html。目錄表示檔案系統中某個位置的真實目錄,並以藍色資料夾圖標表示。包是 Mac OX X 中的一個術語,指的是檔案和子目錄的目錄,這些檔案和子目錄要被 Finder 和 Xcode 識別為一個單元。它們通常以與檔案圖示無法區分的圖標表示。如果 Xcode 不熟悉所表示的包型別,則會將其顯示為藍色資料夾。組是這種分類中的奇怪專案,並以黃色資料夾表示。它們在檔案系統中根本不存在。它們純粹是用於您在 Xcode 中使用的組織實體。您可以在 Xcode 組中將檔案分組到“組和檔案”窗格中,這些檔案實際上分佈在您計算機的檔案系統中。您在“組和檔案”窗格中使用它們只是為了將這四種類型中您認為相關的專案分組在一起。

回到 Xcode 的產品,對於典型的、簡單的、非 WebObjects 專案,這些檔案將包含 Java 或 Objective C 原始檔,這些原始檔將被編譯成中間目標檔案,並連結到可載入模組(對於 Objective C)或 .jar 檔案(對於 Java)以供執行。該檔案是為執行而建立的,這就是我所說的產品。Xcode 目標是檔案集以及構建此類產品的必要指令。它將透過 Xcode 構建過程建立。

在 WebObjects 的情況下,情況略微複雜,因為最佳實踐建議使用所謂的“拆分安裝”。也就是說,對於 WebObjects 專案,Xcode 預期構建至少兩個產品。其中一個將是 WebObjects 應用程式,它將由應用程式伺服器提供服務。另一個將是靜態 HTML 頁面、圖形檔案(.jpg 和 .gif 檔案等)和其他可以由 Apache 直接作為靜態資源提供服務的檔案的包。

您新增到專案中的檔案必須被識別為屬於這兩個產品中的一者的構建。第三個目標與您的專案同名,它被稱為聚合目標。它的唯一目的是將其他兩個目標分組到單個構建操作中,透過設定依賴項,使聚合目標依賴於另外兩個目標。這樣,透過構建聚合目標,另外兩個目標將自動一起構建。但是,您也可以要求 Xcode 單獨構建這兩個目標中的任何一個。

雖然您應該將靜態檔案新增到專案中,以便它們包含在專案目錄中,但 Xcode 將構建兩個包,一個用於應用程式伺服器,另一個用於 Web 伺服器,並將建立(例如,透過編譯)或複製相應的檔案到相應的包。如果您的專案名為“MyProject”,並且是在 Mac OS X 上進行部署構建的,那麼這些包將具有以下結構

對於應用程式伺服器

 MyProject.woa
   MyProject - a Unix shell script to which control is initially passed and which sets up the execution environment under Unix
   MyProject.CMD - a DOS command script to which control is initially passed and which sets up the execution environment under DOS/Windows
   WOBootstrap.jar - a jar file containing a single class called JavaArchiveFilter that implements the java.io.FilenameFilter interface
   Contents - a directory containing all of the files necessary to support the execution of the WO app
        Info.plist - a property list file for the application
       MacOS/
           MyProject - a Unix shell script identical to that of the same name at the top level of the project directory
           MacOSClassPath.txt - text file containing the derived Java ClassPath for the project
       PkgInfo - a text file containing the four letter package type (APPL = application) and the application's four letter file types
       Resources/ - a directory containing the WOComponents and other resources in the Resources group of the Groups & Files pane
       UNIX/ - a directory similar to the MacOS directory but used for deployment on Unix systems
       Windows/ - a directory similar to the MacOS directory but used for deployment on Windows systems
       pbdevelopment.plist - an XML file with a single element whose key is PBXProjectSourcePath and whose value is implied by the name.

對於 Web 伺服器

 MyProject.woa
   Contents - a directory containing all of the files necessary to support the execution of the WO app
       WebServerResources/
           Hierarchy of files and folders containing static web resources.

雖然這些包非常不同,但它們具有相同的名稱,具有相似的結構,並且在開發中合併。它們通常只在拆分安裝時才這樣分開。您通常將應用程式伺服器包放在 /Library/WebObjects/Applications(或本地等效項)中,並將 Web 伺服器包放在 /Library/WebServer/Documents/WebObjects 中。

您可以透過各種方式獨立建立這些包。我最近發現(由於 Xcode 不靈活的各種示例),只需像開發一樣構建專案,然後在部署時物理分離這兩個專案就比較容易。其他人有各種咒語來使拆分安裝可靠地工作,我相信他們會在這裡插話。

華夏公益教科書