WebSphere Application Server V7 基於屬性的配置

CloudSpace發表於2009-07-30

John Chang, 顧問軟體工程師, IBM
Amy Lin, 軟體工程師, IBM
Vishwanath Venkataramappa, 高階軟體工程師, IBM
Syed-Muasir Khalil, 軟體工程師, IBM

引言

IBM WebSphere Application Server 配置主要由 XML 格式檔案以及一些非 XML 格式檔案組成。這些配置檔案分佈在 WebSphere Application Server 安裝或配置樹的多個目錄中。這些檔案的內容是以特定於 WebSphere 的格式構造的,目的是為了遵循基礎配置模型。

可以使用許多管理工具(如 wsadmin 命令、管理控制檯和公共 Java™ API)訪問和操作這些配置物件。每種工具都提供獨特的任務來修改配置的不同部分。例如,wsadmin 包含 AdminConfig、AdminTask、AdminApp 和 AdminControl 任務,用於查詢和修改 WebSphere Application Server 配置中的不同物件。利用這些 wsadmin 功能以及其他可用的 wsadmin 功能通常要求管理員全面瞭解所有可用的任務。

WebSphere Application Server V7.0 引入了簡單的基於屬性檔案的配置功能,可以將其用作單個常規工具來查詢和修改 WebSphere Application Server 配置中的配置物件。使用此實用工具,可以檢查配置並通過將配置元素提取到可讀的屬性檔案中來更新配置,根據需要修改提取的屬性檔案,然後將修改應用回配置。歸根結底,這意味著您現在只需知道一個命令集(而不是每個工具一組命令集),就能配置 WebSphere Application Server。

本文將提供一些示例來演示如何將 WebSphere Application Server 配置資訊提取到簡單的屬性檔案,如何修改提取的屬性檔案,最後,將演示如何將修改應用回 WebSphere Application Server 配置。

基於屬性的配置

基於屬性的配置能夠將環境配置為與屬性檔案中指定的內容相匹配。屬性檔案通過從現有配置提取屬性名稱和值來建立。通過在檔案中修改、新增或刪除物件和屬性可以配置環境,然後通過呼叫 apply 和 delete 命令將屬性檔案應用到配置中。

屬性檔案包含屬性名稱和屬性值對的列表。可以使用此資料配置計算單元、節點、叢集、伺服器、應用程式或任何其他配置物件。不過,屬性檔案不是配置檔案,因此,在使用基於屬性檔案的配置將此檔案應用到配置之前,對此檔案的修改不會影響系統的配置。

基於屬性的配置可以在 WebSphere Application Server 配置儲存庫中的複雜資料,及包含相應配置資訊的基於屬性的簡單檔案格式之間提供雙向轉換。使用基於屬性檔案的配置能夠:

  • 從配置儲存庫提取資料來建立屬性檔案。
  • 根據需要更新屬性檔案以操作配置。
  • 將屬性檔案中的更新資料應用到目標配置儲存庫。

可以將 WebSphere Application Server 配置提取到單個檔案,並將任何配置屬性以名稱/值對屬性的形式放入該檔案中。而現有工具(如 wsadmin 或管理控制檯)要求您呼叫特定的命令或導航多個皮膚才能獲得所需的配置屬性,此新增功能實用工具使您能夠通過將其提取到一個屬性檔案來獲得整個配置,甚至可以僅提取配置物件及其屬性的一個例項。

使用基於屬性的配置的兩個主要優點是:

  • 將配置資料與 WebSphere Application Server 不同版本之間的基礎配置和物件模型更改相分離。
  • 與分佈在多個配置儲存庫的 XML 和其他格式的混合相比,管理人員使用屬性檔案更方便。

因此,該工具可以進行從屬性檔案配置資料到該版本的基礎配置模型的正確轉換,並提供在不同版本中使用同一配置資料的靈活性。也許更為重要的是,可以將配置的新增更改指定為屬性檔案的一部分並快速應用,而無需瞭解基礎配置或物件模型。為了更易於使用,您可以使用一個命令(該命令可以應用屬性檔案中指定的配置屬性)將工作配置快速地應用到另一個系統,而無需使用需要呼叫多個命令才能達到類似結果的其他工具,如 wsadmin。

基於屬性的配置不是替代配置存檔工具,而是對它們的補充。從配置提取的屬性僅包含最常用的配置屬性,而不包含整個配置。但是,配置存檔包含一個精確的配置副本,並可以應用到另一個系統以實現精確複製。由於屬性檔案僅包含最常用的關鍵屬性,因此在匯入存檔後,可以將此工具與配置存檔結合使用以進行任何必要的配置更改。


圖 1. 基於屬性檔案的配置
圖 1. 基於屬性檔案的配置 

基於屬性檔案的配置命令

基於屬性檔案的配置可實現為 AdminCommand 集,如下表所示。可以在 wsadmin 或 Java 客戶端程式中使用這些命令。(在 WebSphere Application Server V7.0 中對基於屬性的配置不提供任何管理控制檯支援。)


表 1. extractConfigProperties

命令 描述 目標物件 引數 返回值
extractConfigProperties 以簡單的屬性檔案的形式提取配置資料。如果未指定配置物件,則將整個配置檔案的配置資料提取到屬性檔案。將所有特定於環境的值(cellName、serverName、nodeName、clusterName、coreGroup、nodeGroup、authorizationGroup 等)表示為變數。這些變數儲存在生成的屬性檔案的末尾。 配置物件的 Configld如果使用 configData 引數,則不需要它。
  • propertiesFileName(字串,可選):屬性檔案的名稱。這是一個必需引數。
  • configData(字串,可選):表單中的配置物件例項 (Node=node1)。
  • filterMechanism(字串,可選):有效值為 All(預設)、NO_SUBTYPES 和 SELECTED_SUBTYPES。
  • selectedSubTypes(String[],可選):如果為 filterMechanism 選擇 SELECTED_SUBTYPES,則應提供此引數。configData 引數下選擇的配置物件中的 Subtypes(配置型別)。
使用配置屬性填充的 propertiesFile
示例:

互動模式 (Jython):
AdminTask.extractConfigProperties ('[-interactive]')

批處理模式 (Jython):
AdminTask.extractConfigProperties('[‘-propertiesFileName’ ‘my.props’, ‘-configData’ ‘Node=node1’]')


表 2. applyConfigProperties
命令 描述 目標物件 引數 返回值
applyConfigProperties 將屬性檔案中指定的屬性應用到配置。使用新值修改與屬性檔案中指定的每個屬性對應的屬性。如果配置中不存在與指定的屬性對應的屬性,則在配置中建立新屬性。如果配置中不存在屬性檔案中指定的配置物件,則建立新的配置物件。
  • propertiesFileName(字串,必需):屬性檔案的名稱
  • variablesMapFile(字串,可選):變數對映檔案的名稱。此檔案應包含屬性檔案中使用的變數值。
  • variablesMap(屬性,可選):為屬性檔案中使用的變數提供值的變數對映。
  • reportFile(字串,可選):包含操作報告的報告檔案。
  • reportFilterMechanism(字串,可選):有效值為 All(預設)、Errors 和 Errors_And_Changes。
  • Validate(Boolean,可選):其預設值為 true。應用之前驗證屬性檔案。
示例:

互動模式 (Jython):
AdminTask.applyConfigProperties ('[-interactive]')

批處理模式 (Jython):
AdminTask.applyConfigProperties('[‘-propertiesFileName’ ‘my.props’]')


表 3. validateConfigProperties
命令 描述 目標物件 引數 返回值
validateConfigProperties 驗證屬性檔案中指定的屬性。此命令將驗證每個屬性,以確保在配置上應用屬性時不發生任何錯誤。還將驗證語法並檢查型別是否正確。將屬性檔案中的所有錯誤記錄到指定的報告檔案。還將記錄以下資訊:將建立哪些配置物件、將修改哪些配置物件等。
  • propertiesFileName(字串,必需):屬性檔案的名稱
  • variablesMapFile(字串,可選):變數對映檔案的名稱。此檔案應包含屬性檔案中使用的變數值。
  • variablesMap(屬性,可選):為屬性檔案中使用的變數提供值的變數對映。
  • reportFile(字串,必需):包含操作報告的報告檔案。
  • reportFilterMechanism(字串,可選):有效值為 All(預設)、Errors 和 Errors_And_Changes。
示例:

互動模式 (Jython):
AdminTask.validateConfigProperties ('[-interactive]')

批處理模式 (Jython):
AdminTask.validateConfigProperties('[‘-propertiesFileName’ ‘my.props’ ‘-reportFile’ ‘report.ext’]')


表 4. deleteConfigProperties
命令 描述 目標物件 引數 返回值
deleteConfigProperties 從配置刪除屬性檔案中指定的屬性。移除屬性檔案中每個屬性的屬性。如果屬性具有預設值,則將屬性值設定為預設值。
  • propertiesFileName(字串,必需):屬性檔案的名稱
  • variablesMapFile(字串,可選):變數對映檔案的名稱。此檔案應包含屬性檔案中使用的變數值。
  • variablesMap(屬性,可選):為屬性檔案中使用的變數提供值的變數對映。
  • reportFile(字串,可選):包含操作報告的報告檔案。
  • reportFilterMechanism(字串,可選):有效值為 All(預設)、Errors 和 Errors_And_Changes。
  • Validate(Boolean,可選):其預設值為 true。刪除之前驗證屬性檔案。
示例:

互動模式 (Jython):
AdminTask.deleteConfigProperties ('[-interactive]')

批處理模式 (Jython):
AdminTask.deleteConfigProperties('[‘-propertiesFileName’ ‘my.props’]')


表 5. createPropertiesFileTemplates
命令 描述 目標物件 引數 返回值
createPropertiesFileTemplates 建立可用於建立或刪除指定物件型別的例項的模板屬性檔案。
  • propertiesFileName(字串,必需):屬性檔案的名稱
  • configType(字串,必需):需要為其建立模板檔案的資源型別
示例:

互動模式 (Jython):
AdminTask. createPropertiesFileTemplates ('[-interactive]')

批處理模式 (Jython):
AdminTask. createPropertiesFileTemplates (‘[‘-propertiesFileName’ ‘serverTemplate.props’ ‘-configType’ ‘Server’]')


屬性檔案剖析

由於屬性檔案可包含多個配置物件的屬性,並且每個配置物件可包含多個屬性,因此將屬性檔案劃分為多個部分。每個部分包含一個配置物件的屬性。每個部分包含一個部分標題,後跟名稱/值屬性對。部分標題標識配置物件,屬性部分包含配置物件的屬性。

清單 1 顯示了屬性檔案的示例,該檔案顯示了物件的標題和屬性。


清單 1. 顯示屬性檔案的示例

				
#
# Section 1.0 ## cells/myCell|cell.xml#Cell_1
#

#
# SubSection 1.0 # Cell level attributes (Header)
#
ResourceType=Cell
ImplementingResourceType=Cell
ResourceId=Cell=!{cellName}
#

#
#Properties section
#
cellType=DISTRIBUTED
name=!{cellName}
...

EnvironmentVariablesSection
#
#Environment Variables
#
cellName=MyCell

屬性檔案標題包含:

  • ResourceType,表示資源的型別。
  • ResourceId,是唯一地標識資源或配置物件的名稱。僅當需要將同一屬性應用到同一型別的其他物件時才對它進行修改。
  • ImplementingResourceType,表示實現屬性到屬性轉換的類。

標題中的資訊是自動生成的,只會修改 ResourceId。顯示此資訊,以便基於屬性檔案的配置工具知道使用哪些實現來呼叫和應用屬性。

屬性部分包含標題以名稱/值對形式標識的配置物件的屬性。每個名稱和值都與配置物件的屬性對應。

環境變數部分包含屬性檔案中使用的變數值。將特定於環境的屬性(如 cellName、serverName、nodeName 等)表示為變數,並將這些變數的當前值放置在屬性檔案的末尾。

可以將多個引數和規則應用到屬性檔案來操作配置。下面是一些最常見和最重要的引數和規則:

  • 複雜屬性

    正如前面描述的,屬性檔案包含多個部分。每個部分包含一個標識配置物件的部分標題,後跟屬性。在大多數情況下,部分中的屬性與配置物件的屬性對應。不過,在其他情況下,可以將多個屬性合併來形成單個屬性,以減少生成的屬性檔案的大小。將多個屬性合併以形成單個屬性時,可使用標題中的 AttributeInfo 來描述合併多個屬性的方式。清單 2 顯示瞭如何將多個屬性合併為單個屬性的示例。



    清單 2. 將多個屬性合併為單個屬性
    						
    #
    # Section 1.0.0 ## cells/myCell|virtualhosts.xml#VirtualHost_1
    #
    
    #
    # SubSection 1.0 # Virtual Hosts
    #
    ResourceType=VirtualHost
    ImplementingResourceType=VirtualHost
    ResourceId=Cell=myCell:VirtualHost=ID#VirtualHost_1
    #
    
    #
    #Properties
    #
    name=default_host
    ...
    #
    # SubSection 1.2 # HostAlias section
    #
    ResourceType=VirtualHost
    ImplementingResourceType=VirtualHost
    ResourceId==myCell:VirtualHost=ID#VirtualHost_1
    AttributeInfo=aliases(port,hostname)
    #
    
    #
    #Properties
    #
    9472=*
    9443=*
    9468=*
    9096=*
    80=*
    ...

    標題部分中的 AttributeInfoin 包含將每個 HostAlias 對映到單個屬性必需的資訊 (port=hostname)。您無需瞭解系統如何在內部處理 AttributeInfo 以便將這些屬性對映到配置屬性,但是需要重點注意的是,一定不要從標題中刪除該資訊。要新增新的別名,只需在列表的末尾新增一個新條目;當應用屬性檔案時,將建立新的主機別名。

  • 值列表

    在 { } 符號中指定作為值列表的屬性值。作為列表的 classpath 屬性的表示形式如清單 3 所示。將空列表指定為 {}。



    清單 3.列表的 classpath 屬性表示形式
    						
    #
    # SubSection 1.0 # JDBCProvider attributes
    #
    ResourceType=JDBCProvider
    ImplementingResourceType=JDBCProvider
    ResourceId=Cell=myCell:JDBCProvider=ID#builtin_jdbcprovider
    #
    
    #
    #Properties
    #
    classpath={${DERBY_JDBC_DRIVER_PATH}/derby.jar,/my.jar}
    implementationClassName=org.apache.derby.jdbc.EmbeddedXADataSource
    name=Derby JDBC Provider (XA)
    nativepath={}
    description=Built-in Derby JDBC Provider (XA)
    providerType=Derby JDBC Provider (XA)
    xa=true #boolean

  • 未設定值(空值)

    如果在配置中未設定屬性的值,則該屬性值將表示為空值(清單 4)。



    清單 4. 屬性為空值的設定
    						
    #
    # SubSection 1.0 # ServerCluster attributes
    #
    ResourceType=ServerCluster
    ImplementingResourceType=ServerCluster
    ResourceId=Cell=myCell:Cluster=MMc1
    #
    
    #
    #Properties
    #
    name=MMc1
    preferLocal=true #boolean
    nodeGroupName=null
    stateManagement=null
    enableHA=false #boolean
    uniqueId=null
    serverType=APPLICATION_SERVER #ENUM
    shortName=null
    description=null
    statisticsProvider=null
    					

  • 屬性的型別

    屬性的型別(int、long、float 等)的表示形式如清單 5 所示。如果未提及型別,則其預設值為字串。



    清單 5. 屬性的型別的表示形式
    						
    #
    # SubSection 1.0.2.0.2 # Monitoring Policy Section
    #
    ResourceType=MonitoringPolicy
    ImplementingResourceType=Server
    ResourceId=Cell=myCell:Node=myNode:Server=server1:
    	MonitoringPolicy=ID#MonitoringPolicy_1
    AttributeInfo=monitoringPolicy
    #
    
    #
    #Properties
    #
    maximumStartupAttempts=3 #integer
    pingTimeout=300 #integer
    pingInterval=60 #integer
    autoRestart=true #boolean
    nodeRestartState=STOPPED #ENUM
    					

  • 建立新物件所需的屬性

    如果給定的物件需要屬性,則其表示形式如清單 6 所示。此屬性應存在於建立新物件所使用的屬性檔案中。



    清單 6. 為給定的物件設定屬性
    						
    #
    # Create parameters
    # These parameters should be set to create a new instance of the following type 
    # of object.
    # Replace the line `CreateTemplate=true` with 'CreateDeleteCommandProperties=true'
    # and set actual values for the following properties to create a new object.
    #
    ResourceType=Server
    ImplementingResourceType=Server
    ResourceId=Server=
    CreateTemplate=true
    #
    
    #
    #Properties
    #
    name=name #String,required
    templateLocation=null #javax.management.ObjectName
    genUniquePorts=null #Boolean
    commandName=createApplicationServer
    specificShortName=null #String
    clusterName=null #String
    targetObject=targetObject #ObjectName,required
    templateName=null #String
    genericShortName=null #String

  • Readonly 屬性

    Readonly 屬性是不能更改的。在清單 7 中,taskName、mutables 和 row0 屬性都是不可改變的。所有其他屬性(行)都可以修改。



    清單 7. Readonly 屬性
    						
    #
    # SubSection 1.1 # MapModulesToServers Section. taskName,mutables and row0 should 
    # not be edited.
    #
    ResourceType=Application
    ImplementingResourceType=Application
    ResourceId=Cell=myCell:Application=ivtApp
    #
    
    #
    #Properties
    #
    taskName=MapModulesToServers #readonly
    mutables={false false true false false false} #readonly
    row0={module uri server ModuleVersion moduletype moduletypeDisplay} #readonly
    row2={"IVT Application" ivt_app.war,WEB-INF/web.xml WebSphere:cell=myCell:
    	node=myNode,server=server1 12 moduletype.web "Web Module"}
    row1={"IVT EJB Module" ivtEJB.jar,META-INF/ejb-jar.xml WebSphere:cell=myCell,
    	node=myNode,server=server1 12 moduletype.ejb "EJB Module"}

  • 指向另一個物件的屬性值引用

    如果屬性值包含指向另一個物件的引用,則將該物件的顯示名稱設定為它的值(清單 8)。如果被引用的物件沒有顯示名稱,則將完整的 configId 設定為其值。



    清單 8. 物件之間屬性值的引用
    						
    #
    # SubSection 1.0.1.2 # TCP Inbound Transport Channels
    #
    ResourceType=TCPInboundChannel
    ImplementingResourceType=Server
    ResourceId=Cell=myCell:Node=myNode:Server=serve
    r1:TCPInboundChannel=ID#TCPInboundChannel_1
    #
    
    #
    #Properties
    #
    maxOpenConnections=20000 #integer
    name=TCP_3
    hostNameIncludeList={}
    hostNameExcludeList={}
    endPointName=WC_adminhost_secure
    inactivityTimeout=60 #integer
    discriminationWeight=0 #integer
    ddressIncludeList={}
    addressExcludeList={}
    threadPool=WebContainer #ObjectName(ThreadPool)
    					

  • 包含空格或其他特殊字元的屬性值

    包含空格或其他特殊字元的屬性值用“ ”括起來(清單 9)。



    清單 9. 空格或其他特殊字元的屬性值設定
    						
    #
    # SubSection 1.1 # TimerManagerInfo section
    #
    ResourceType=TimerManagerInfo
    ImplementingResourceType=TimerManagerProvider
    ResourceId=Cell=myCell:Cluster=MMc1:TimerManagerInfo=ID#TimerMana
    gerInfo_Default
    #
    
    #
    #Properties
    #
    name=DefaultTimerManager
    referenceable=null
    category=null
    defTranClass=null
    providerType=null
    numAlarmThreads=2 #integer
    jndiName="tm/default"
    serviceNames={}
    provider=TimerManagerProvider #ObjectName(TimerManagerProvider)
    description=WebSphere Default TimerManager

  • 特殊屬性

    可以將下面的特殊屬性新增到屬性檔案,以指示在將屬性檔案應用到配置時是跳過還是處理給定的部分:

    • SKIP

      可以將每個部分的 SKIP 屬性設定為 true 或 false。此屬性只能由 applyConfigProperties 和 deleteConfigProperties 命令使用。預設值為 false。當此屬性在某一部分中存在並設定為 true 時,則跳過該部分。

      當使用 applyConfigProperties 命令處理某一部分時,如果與該部分對應的配置物件丟失,則系統會自動建立它。當使用 deleteConfigProperties 命令處理某一部分時,如果與該部分對應的配置資料丟失,則系統不會採取任何操作。

      示例:SKIP=true

    • SKIPSUBSECTIONS

      當此屬性在某一部分中存在並設定為 true 時,將跳過所有子部分。預設值為 false。通過遍歷該部分(包含此變數引數)中包含的所有部分來確定子部分。

      示例:SKIPSUBSECTIONS=true

    • DELETE

      當此屬性在某一部分中存在設定為 true 時,該部分將從配置中完全刪除。與該部分對應的配置物件也將被刪除。

      示例:DELETE=true

      用例

      現在您已大致瞭解了屬性檔案的用途以及使用方式,下面是一些具體示例,這些示例將演示如何使用基於屬性檔案的配置實用工具:

      提取配置屬性

      可以使用 ExtractConfigProperties 命令以屬性的形式從系統中提取配置資料。使用此命令可以提取整個計算單元的配置或僅提取配置的一部分。

      • 示例 1:提取整個計算單元配置

        使用以下命令可提取整個計算單元的配置。提取的檔案類似於清單 10。

        wsadmin> AdminTask.extractConfigProperties('[-propertiesFileName cell.props ]')



        清單 10. 使用命令提取整個計算單元的配置
        						
        # Cell.props
        
        #
        # SubSection 1.0 # Cell level attributes
        #
        ResourceType=Cell
        ImplementingResourceType=Cell
        ResourceId=Cell=!{cellName}
        #
        
        #
        #Properties
        #
        shortName=null
        cellType=DISTRIBUTED #ENUM(UDP|TCP|MULTICAST|DISTRIBUTED|STANDALONE),readonly
        name=!{cellName}
        multicastDiscoveryAddressEndpointName=null
        discoveryAddressEndpointName=null
        cellDiscoveryProtocol=TCP #ENUM(UDP|TCP|MULTICAST)
        
        ...
        ...  Properties of nodes,servers, clusters, applications, etc.
        ... 
        
        
        EnvironmentVariablesSection
        #
        #
        #Environment Variables
        #Thu Apr 17 05:38:01 CDT 2008
        cellName=MyCell

        請注意 !{cellName} 變數。屬性檔案不會有實際的 cellName、nodeName、serverName、clusterName、applicationName、coreGroup 或 nodeGroup 值。而是將這些值表示為變數。檔案底部的 EnvironmentVariables 部分包含屬性檔案中使用的所有變數。

      • 示例 2:提取伺服器配置

        使用下面的命令可提取伺服器配置。提取的檔案類似於清單 11。

        wsadmin> AdminTask.extractConfigProperties('[-propertiesFileName server.props -configData Server=dmgr ]')



        清單 11. 使用命令提取伺服器配置
        						
        #
        # SubSection 1.0 # Server Section
        #
        ResourceType=Server
        ImplementingResourceType=Server
        ResourceId=Cell=!{cellName}:Node=!{nodeName}:Server=!{serverName}
        #
        
        #
        #Properties
        #
        shortName=null
        serverType=DEPLOYMENT_MANAGER #readonly
        developmentMode=false #boolean
        parallelStartEnabled=true #boolean
        name=!{serverName}
        clusterName=null
        uniqueId=null
        modelId=null
        
        …
        … Properties of other inner objects ( EJBContainer, WebContainer, ORB etc) 
        …  and  subtypes not shown.
        …
        
        EnvironmentVariablesSection
        #
        #Environment Variables
        #
        cellName=MyCell
        nodeName=MyNodeManager
        hostName=MyHost
        serverName=dmgr

      • 示例 3:提取伺服器的 EJBContainer 和 WebContainer 屬性

        可以使用下面的命令僅提取伺服器的 EJBContainer 屬性:

        wsadmin> AdminTask.extractConfigProperties('[-propertiesFileName ejbcontainer.props -configData Server=dmgr -filterMechanism SELECTED_SUBTYPES -selectedSubTypes [EJBContainer ] ]')

        可以使用下面的命令提取 EJBContainer 和 WebContainer 屬性:

        wsadmin> AdminTask.extractConfigProperties('[-propertiesFileName container.props -filterMechanism SELECTED_SUBTYPES –selectedSubTypes [EJBContainer WebContainer ] ]')

        提取的屬性檔案將僅包含 EJBContainer 和 WebContainer 的屬性,如清單 12 所示。



        清單 12. 提取相關屬性檔案中的屬性
        						
        #
        # SubSection 1.0 # EJBContainer
        #
        ResourceType=EJBContainer
        ImplementingResourceType=EJBContainer
        ResourceId=Cell=!{cellName}:Node=!{nodeName}:Server=!{serverName}:
        ApplicationServer=ID#ApplicationServer_1:EJBContainer=ID#EJBContainer_1
        AttributeInfo=components
        #
        
        #
        #Properties
        #
        EJBTimer={} #ObjectName*(null)
        name=null
        defaultDatasourceJNDIName=null
        inactivePoolCleanupInterval=30000 #long
        passivationDirectory="${USER_INSTALL_ROOT}/temp"
        enableSFSBFailover=false #boolean
        server=null
        parentComponent=Network Deployment Server
        
        #
        # SubSection 1.0 # WebContainer 
        #
        ResourceType=WebContainer
        ImplementingResourceType=WebContainer
        ResourceId=Cell=!{cellName}:Node=!{nodeName}:Server=!{serverName}:
        ApplicationServer=ID#ApplicationServer_1:WebContainer=ID#WebContainer_1
        AttributeInfo=components
        #
        
        #
        #Properties
        #
        enableServletCaching=false #boolean
        name=null
        defaultVirtualHostName=null
        server=null
        maximumPercentageExpiredEntries=15 #integer
        asyncIncludeTimeout=60000 #integer
        parentComponent=Network Deployment Server
        disablePooling=false #boolean
        sessionAffinityFailoverServer=null
        maximumResponseStoreSize=100 #integer
        allowAsyncRequestDispatching=false #boolean
        sessionAffinityTimeout=0 #integer
        	
        EnvironmentVariablesSection
        #
        #Environment Variables
        #
        cellName=MyCell
        nodeName=MyCellManager
        hostName=MyHost
        serverName=dmgr

        請注意 ResourceId 行中的 EJBContainer=ID#EJBContainer_1 語句。它唯一地表示伺服器中的 EJBContainer 物件。由於此案例中的名稱欄位為空,因此您必須使用 xmi ID 才能表示此物件。而且,xmi ID 是在配置中唯一地標識物件的唯一方法,因為在大多數情況下可以使用同一名稱建立多個物件。不過,將屬性檔案應用到配置之前,如果配置中的名稱欄位被設定為 myContainer,則可以將此欄位修改為 EJBContainer=myContainer。

      • 示例 4:提取節點屬性,而無需遍歷節點的內容(子型別)

        下面的命令可以提取節點的屬性,而無需提取其子型別的屬性(如伺服器和資源)。產生的屬性檔案將類似於清單 13,其中沒有任何子型別資訊。

        wsadmin> AdminTask.extractConfigProperties('[-propertiesFileName node.props -configData Node=MyCellManager -filterMechanism NO_SUBTYPES]')



        清單 13. 提取節點屬性
        						
        #
        # SubSection 1.0 # Node Section
        #
        ResourceType=Node
        ImplementingResourceType=Node
        ResourceId=Cell=!{cellName}:Node=!{nodeName}
        #
        
        #
        #Properties
        #
        shortName=null
        name=!{nodeName}
        maxFilePermissionForApps=".*\.dll=755#.*\.so=755#.*\.a=755#.*\.sl=755
        "
        discoveryProtocol=TCP #ENUM(UDP|TCP|MULTICAST)
        hostName=!{hostName}
        
        #
        ## Section 1.0_1#Cell=!{cellName}:Node=!{nodeName}
        #
        ResourceType=Node
        ImplementingResourceType=Node
        ExtensionId=NodeMetadataExtension
        ResourceId=Cell=!{cellName}:Node=!{nodeName}
        
        #
        nodeOS=distributed
        nodeVersion=7.0.0.0
        
        #
        # End of Section 1.0# Cell=!{cellName}:Node=!{nodeName}
        #
        
        EnvironmentVariablesSection
        #
        #Environment Variables
        #Thu Apr 17 14:27:01 CDT 2008
        cellName=MyCell
        nodeName=MyCellManager

      • 示例 5:提取節點屬性,而無需遍歷該節點的內容(子型別)和呼叫任何擴充套件

        可以使用下面的命令提取節點屬性,而無需包括擴充套件的屬性。清單 14 是執行此命令的結果。請注意,NodeMetadataExtension 部分不見了,因為該部分是對節點資源的擴充套件。

        wsadmin> AdminTask.extractConfigProperties('[-propertiesFileName node.props -configData Node=MyCellManager -filterMechanism NO_SUBTYPES_AND_EXTENSIONS]')



        清單 14. 執行提取節點屬性命令的結果
        						
        #
        # SubSection 1.0 # Node Section
        #
        ResourceType=Node
        ImplementingResourceType=Node
        ResourceId=Cell=!{cellName}:Node=!{nodeName}
        #
        
        #
        #Properties
        #
        shortName=null
        name=!{nodeName}
        maxFilePermissionForApps=".*\.dll=755#.*\.so=755#.*\.a=755#.*\.sl=755
        "
        discoveryProtocol=TCP #ENUM(UDP|TCP|MULTICAST)
        hostName=!{hostName}
        
        
        #
        # End of Section 1.0_1# Cell=!{cellName}:Node=!{nodeName}
        #
        
        EnvironmentVariablesSection
        #
        #Environment Variables
        #
        cellName=MyCell
        nodeName=MyCellManager

      修改提取的屬性檔案並將其應用回配置

      提取配置檔案後,可以使用任何文字編輯器修改一個或多個屬性值,然後使用 applyConfigProperties 命令將其應用回該配置。

      • 示例 1:修改一個或多個屬性,並將屬性檔案應用到配置

        在本例中,將屬性檔案中的 EJBContainer 的 enableSFSBFailover 屬性從 false 更改為 true。



        清單 15. 修改相關屬性
        						
        #
        # File : ejbcontainer.props
        #
        # SubSection 1.0 # EJBContainer
        #
        ResourceType=EJBContainer
        ImplementingResourceType=EJBContainer
        ResourceId=Cell=!{cellName}:Node=!{nodeName}:Server=!{serverName}:
        ApplicationServer=ID#ApplicationServer_1:EJBContainer=ID#EJBContainer_1
        AttributeInfo=components
        #
        
        #
        #Properties
        #
        EJBTimer={} #ObjectName*(null)
        name=null
        defaultDatasourceJNDIName=null
        inactivePoolCleanupInterval=30000 #long
        passivationDirectory="${USER_INSTALL_ROOT}/temp"
        enableSFSBFailover=true #boolean
        server=null
        parentComponent=Network Deployment Server
        
        EnvironmentVariablesSection
        #
        #Environment Variables
        #
        hostName2=*
        hostName1=localhost
        cellName=MyCell
        nodeName=MyCellManager
        hostName=MyHost
        serverName=dmgr
        enableSSB=true

        修改屬性檔案後,可以執行此命令以將屬性應用到系統。然後可以再次提取屬性來驗證這些更改。

        wsadmin> AdminTask.applyConfigProperties('[-propertiesFileName ejbcontainer.props ]')

      • 示例 2:使用其他使用者定義的變數

        在本例中,通過使用變數 !{enableSSB} 的值來修改同一屬性 (enableSFSBFailover)。在部分標題中或該部分的屬性區域中可以使用該變數。另外,屬性值可以由多個變數組成,如 ResourceId 所示。在清單 16 中,應修改 EnvironmentVariableSection 以包括使用的任何新變數。



        清單 16. 使用其他使用者定義的變數
        						
        #
        # File : ejbcontainer.props
        #
        # SubSection 1.0 # EJBContainer
        #
        ResourceType=EJBContainer
        ImplementingResourceType=EJBContainer
        ResourceId=Cell=!{cellName}:Node=!{nodeName}:Server=!{serverName}:
        ApplicationServer=ID#ApplicationServer_1:EJBContainer=ID#EJBContainer_1
        AttributeInfo=components
        #
        
        #
        #Properties
        #
        EJBTimer={} #ObjectName*(null)
        name=null
        defaultDatasourceJNDIName=null
        inactivePoolCleanupInterval=30000 #long
        passivationDirectory="${USER_INSTALL_ROOT}/temp"
        enableSFSBFailover=!{enableSSB} #boolean
        server=null
        parentComponent=Network Deployment Server
        
        EnvironmentVariablesSection
        #
        #
        #Environment Variables
        #
        hostName2=*
        hostName1=localhost
        ellName=MyCell
        nodeName=MyCellManager
        hostName=MyHost
        serverName=dmgr
        enableSSB=true
        					

        更改屬性檔案後,可以使用同一命令應用屬性檔案。

        wsadmin> AdminTask.applyConfigProperties('[-propertiesFileName ejbcontainer.props ]')

      • 示例 3:使用其他 variableMap 檔案,而不是屬性檔案中的該檔案

        在本例(清單 17)中,所有變數都被放入不同的檔案中(清單 18)。



        清單 17. 使用其他 variableMap 檔案
        						
        # File : ejbcontainer.props
        #
        # SubSection 1.0 # EJBContainer
        #
        ResourceType=EJBContainer
        ImplementingResourceType=EJBContainer
        ResourceId=Cell=!{cellName}:Node=!{nodeName}:Server=!{serverName}:
        ApplicationServer=ID#ApplicationServer_1:EJBContainer=ID#EJBContainer_1
        AttributeInfo=components
        #
        
        #
        #Properties
        #
        EJBTimer={} #ObjectName*(null)
        name=null
        defaultDatasourceJNDIName=null
        inactivePoolCleanupInterval=30000 #long
        passivationDirectory="${USER_INSTALL_ROOT}/temp"
        enableSFSBFailover=!{enableSSB} #boolean
        server=null
        parentComponent=Network Deployment Server



        清單 18. 所有變數都被放入不同的檔案中
        						
        #File : ejbprops.vars:
        
        #
        #
        #Environment Variables
        #
        hostName2=*
        hostName1=localhost
        cellName=MyCell
        nodeName=MyCellManager
        hostName=MyHost
        serverName=dmgr
        enableSSB=true
        					

        現在可以使用此命令應用使用其他變數對映檔案的屬性檔案:

        wsadmin>AdminTask.applyConfigProperties('[-propertiesFileName ejbcontainer.props -variablesMapFileName ejbprops.vars ]')

      驗證屬性檔案

      將檔案應用到配置之前,應驗證使用文字編輯器修改的屬性檔案。為此操作提供了單獨的命令。不過,applyConfigProperties 命令將屬性應用到配置之前,還以預設方式執行驗證。如果已驗證屬性檔案,那麼通過在 applyConfigProperties 命令中選擇一個選項可以禁用在應用過程中進行的驗證。

      • 示例 1:驗證屬性檔案

        在預設情況下,應用屬性檔案時,應對整個屬性檔案執行驗證。不過,您可以使用下面的命令單獨驗證屬性檔案。該命令將生成類似於清單 19 的報告檔案。

        wsadmin> AdminTask.validateConfigProperties('[-propertiesFileName ejbcontainer.props -variablesMapFileName ejbprops.vars -reportFileName report.txt ]')



        清單 19. 報告檔案
        						
        ADMG0820I: Start applying properties from file ejbcontainer.props
        ADMG0818I: Processing section EJBContainer:ApplicationServer.
        ADMG0810I: Not changing value for this property EJBTimer. New value specified 
        is same as current value {}.
        ADMG0810I: Not changing value for this property defaultDatasourceJNDIName. New 
        value specified is same as current value null.
        ADMG0811I: Changing value for this property enableSFSBFailover. New value specified 
        is true. Old value was false.
        ADMG0810I: Not changing value for this property inactivePoolCleanupInterval. New 
        value specified is same as current value 30000.
        ADMG0810I: Not changing value for this property name. New value specified is same 
        as current value null.
        ADMG0807I: Property parentComponent is readonly. Will not be modified
        ADMG0810I: Not changing value for this property passivationDirectory.
         New value specified is same as current value ${USER_INSTALL_ROOT}/temp.
        ADMG0807I: Property server is readonly. Will not be modified
        ADMG0819I: End Processing section EJBContainer:ApplicationServer.

        清單 19 中顯示的報告檔案非常詳細。該檔案報告了以下內容:

        • 對屬性值的任何更改(配置中的值與屬性檔案中的值不同)。
        • 未更改的屬性值(配置中的值與屬性檔案中的值相同)。
        • 無法更改的只讀型別的屬性。
        • 其他錯誤。

        要使生成的報告檔案變得更簡潔,可以指定 reportFilterMechanism 引數來報告:

        • 僅報告錯誤
        • 錯誤和對配置的任何更改
        • 全部。

        例如,可以使用下面的命令僅報告錯誤和更改。生成的報告檔案僅包含清單 20 中所示的資訊(本案例中有一條錯誤和一個配置更改)。

        wsadmin> AdminTask.validateConfigProperties('[-propertiesFileName ejbcontainer.props -variablesMapFileName ejbprops.vars -reportFileName report.txt -reportFilterMechanism Errors_And_Changes ]')



        清單 20. 生成的錯誤報告和配置更改資訊
        						
        ADMG0820I: Start applying properties from file ejbcontainer.props
        ADMG0811I: Changing value for this property enableSFSBFailover. New value 
        specified is true. Old value was false. 
        ADMG0831I: Value specified for property inactivePoolCleanupInterval is not 
        a valid type. Specified value asdf, Required type long.
        ADMG0821I: End applying properties from file ejbcontainer.props.

        清單 20 包含一條有關對配置進行更改的訊息,以及另一條有關為屬性指定了無效值的訊息。它包含一個配置更改和一條錯誤。

      • 示例 2:在應用過程中驗證屬性檔案

        在預設情況下,應用屬性檔案時,將對整個屬性檔案執行驗證。如果屬性檔案中存在任何問題,則對配置不進行任何更改。如果屬性檔案中沒有任何問題,則按計劃應用屬性檔案。如果在應用之前已驗證屬性檔案,則可以將驗證引數設定為 false,如下所示:

        wsadmin> AdminTask.applyConfigProperties('[-propertiesFileName ejbcontainer.props -variablesMapFileName ejbprops.vars -validate false]')

      • 示例 3:在應用過程中生成報告

        通過指定報告檔名引數可以將應用屬性檔案時造成的所有配置更改都記錄在報告檔案中,如下所示。生成的報告檔案類似於清單 21。

        wsadmin> AdminTask.applyConfigProperties('[-propertiesFileName ejbcontainer.props -variablesMapFileName ejbprops.vars –reportFileName report.txt ]')



        清單 21. 在應用過程中生成報告
        						
        ADMG0820I: Start applying properties from file ejbcontainer.props
        ADMG0818I: Processing section EJBContainer:ApplicationServer.
        ADMG0810I: Not changing value for this property EJBTimer. New value specified is
        same as current value {}.
        ADMG0810I: Not changing value for this property defaultDatasourceJNDIName. New 
        value specified is same as current value null.
        ADMG0811I: Changing value for this property enableSFSBFailover. New value specified
        is true. Old value was false.
        ADMG0810I: Not changing value for this property inactivePoolCleanupInterval. New
        value specified is same as current value 30000.
        ADMG0810I: Not changing value for this property name. New value specified is same
        as current value null.
        ADMG0807I: Property parentComponent is readonly. Will not be modified
        ADMG0810I: Not changing value for this property passivationDirectory.
         New value specified is same as current value ${USER_INSTALL_ROOT}/temp.
        ADMG0807I: Property server is readonly. Will not be modified
        ADMG0819I: End Processing section EJBContainer:ApplicationServer.

        與清單 19 一樣,清單 21 中顯示的報告檔案也非常詳細。您可以指定 reportFilterMechanism 引數,使生成的報告更簡潔。例如,您可以使用此命令僅報告錯誤和更改,生成的報告將類似於清單 22。

        wsadmin>AdminTask.applyConfigProperties('[-propertiesFileName ejbcontainer.props -variablesMapFileName ejbprops.vars –reportFileName report.txt -reportFilterMechanism Errors_And_Changes ]')



        清單 22. 生成的錯誤和更改報告
        						
        ADMG0820I: Start applying properties from file ejbcontainer.props
        ADMG0811I: Changing value for this property enableSFSBFailover. New value 
        specified is true. Old value was false. 
        ADMG0831I: Value specified for property inactivePoolCleanupInterval is not a valid 
        type. Specified value asdf, Required type long.
        ADMG0821I: End applying properties from file ejbcontainer.props.

        清單 22 包含一條有關對配置進行更改的訊息,以及另一條有關為屬性指定了無效值的訊息。它包含一個配置更改和一條錯誤。

      建立新物件

      要建立伺服器、叢集、應用程式和 authorizationgroup 等型別的物件,應首先使用 createPropertiesFileTemplates 命令建立屬性檔案模板。您應修改此模板屬性檔案(如生成檔案的註釋部分中描述的),然後使用 applyConfigProperties 命令建立新物件。例如,您可以按照以下三個步驟建立新的 AuthorizationGroup:

      1. 生成屬性檔案模板

        請使用下面的命令建立稍後用來建立新物件的屬性檔案模板。此命令將建立清單 23 所示的模板檔案。

        wsadmin>AdminTask.createPropertiesFileTemplates('[-propertiesFileName ag.template -configType AuthorizationGroup ]')



        清單 23. 生成屬性檔案模板
        						
        #
        # Create parameters
        # Replace the line `SKIP=true` with 'SKIP=false' under each section that is needed
        # Set necessary parameters under each command or step sections
        # Invoke applyConfigProperties command using this properties file.
        #
        ResourceType=AuthorizationGroup
        ImplementingResourceType=AuthorizationGroup
        ResourceId=AuthorizationGroup=
        SKIP=true
        CreateDeleteCommandProperties=true
        #
        
        #
        #Properties
        #
        authorizationGroupName=authorizationGroupName #String,required
        commandName=createAuthorizationGroup

      2. 修改生成的模板檔案

        通過設定所需的引數(至少)並將 SKIP=true 更改為 SKIP=false 來修改生成的檔案(清單 23)。修改的檔案應該類似於清單 24。



        清單 24. 修改生成的模板檔案
        						
        #
        # Create parameters
        # Replace the line `SKIP=true` with 'SKIP=false' under each section that is needed
        # Set necessary parameters under each command or step sections
        # Invoke applyConfigProperties command using this properties file.
        #
        ResourceType=AuthorizationGroup
        ImplementingResourceType=AuthorizationGroup
        ResourceId=AuthorizationGroup=
        SKIP=false
        CreateDeleteCommandProperties=true
        #
        
        #
        #Properties
        #
        authorizationGroupName=ag1 #String,required
        commandName=createAuthorizationGroup

      3. 使用修改的模板檔案應用配置

        使用 applyConfigProperties 命令建立新的許可權組物件。這將建立新的許可權組 (ag1)。

        AdminTask.applyConfigProperties('[-propertiesFileName ag.template ]')

      刪除現有物件

      要刪除伺服器、叢集、應用程式或 authorizationgroup 等型別的物件,應首先使用 createPropertiesFileTemplates 命令建立屬性檔案模板。修改此模板屬性檔案(如生成檔案的註釋部分中描述),然後使用 deleteConfigProperties 命令刪除現有物件。例如,要刪除現有 AuthorizationGroup,請執行以下操作:

      1. 生成屬性檔案模板

        請使用下面的命令建立屬性檔案模板,以供稍後建立新物件使用。此命令將建立清單 25 所示的模板檔案。

        wsadmin>AdminTask.createPropertiesFileTemplates('[-propertiesFileName ag.template -configType AuthorizationGroup ]')



        清單 25. 生成屬性檔案模板
        						
        #
        # Delete parameters
        # Replace the line `SKIP=true` with 'SKIP=false' under each section that is needed
        # Set necessary parameters under each command or step sections
        # Invoke deleteConfigProperties command using this properties file.
        #
        ResourceType=AuthorizationGroup
        ImplementingResourceType=AuthorizationGroup
        ResourceId=AuthorizationGroup=
        SKIP=true
        CreateDeleteCommandProperties=true
        #
        
        #
        #Properties
        #
        authorizationGroupName=authorizationGroupName #String,required
        commandName=deleteAuthorizationGroup

      2. 修改生成的模板檔案

        通過設定所需的引數(至少)並將 SKIP=true 更改為 SKIP=false 來修改生成的檔案。修改的檔案應該類似於清單 26。



        清單 26. 修改生成的模板檔案
        						
        #
        # Delete parameters
        # Replace the line `SKIP=true` with 'SKIP=false' under each section that is needed
        # Set necessary parameters under each command or step sections
        # Invoke deleteConfigProperties command using this properties file.
        #
        ResourceType=AuthorizationGroup
        ImplementingResourceType=AuthorizationGroup
        ResourceId=AuthorizationGroup=
        SKIP=false
        CreateDeleteCommandProperties=true
        #
        
        #
        #Properties
        #
        authorizationGroupName=ag1 #String,required
        commandName=deleteAuthorizationGroup

      3. 使用修改的模板檔案刪除配置

        請使用 deleteConfigProperties 命令刪除現有許可權組物件。此命令將刪除許可權組 (ag1):

        AdminTask.deleteConfigProperties('[-propertiesFileName ag.template ]')

      建立和刪除物件

      如前所述,要建立伺服器、叢集、應用程式或許可權組型別的物件,請使用模板屬性檔案。不過,通過修改提取的屬性檔案和 ResourceId 欄位可以建立其他大多數型別的物件,這樣,配置中不會存在該 ResourceId 表示的資源。當使用包含非現有資源 ID 的屬性檔案呼叫 applyConfigProperties 命令時,該命令將嘗試建立新的物件。

      • 示例 1:使用屬性檔案建立新的 ThreadPool(使用不在配置中的 ID)

        假設清單 27 是提取的屬性檔案中的一部分。在這裡,配置中已存在該物件。



        清單 27. 使用屬性檔案建立新的 ThreadPool
        						
        #
        # SubSection 1.0.1.4 # Thread pools
        #
        ResourceType=ThreadPool
        ImplementingResourceType=Server
        ResourceId=Cell=!{cellName}:Node=!{nodeName}:Server=!{serverName}:Thr
        eadPoolManager=ID#ThreadPoolManager_1:ThreadPool=ID#builtin_ThreadPool_4
        #
        
        #
        #Properties
        #
        maximumSize=20 #integer
        name=Default
        inactivityTimeout=5000 #integer
        minimumSize=5 #integer
        isGrowable=false #boolean

        您可以修改 ResourceId,這樣該 ResourceId 表示的執行緒池不會存在。在清單 28 中,配置中不存在此執行緒池 ThreadPool_9999 ID。



        清單 28. 修改 ResourceId
        						
        #
        # SubSection 1.0.1.4 # Thread pools
        #
        ResourceType=ThreadPool
        ImplementingResourceType=Server
        ResourceId=Cell=!{cellName}:Node=!{nodeName}:Server=!{serverName}:Thr
        eadPoolManager=ID#ThreadPoolManager_1:ThreadPool=ThreadPool_99999
        #
        
        #
        #Properties
        #
        maximumSize=20 #integer
        name=myThreadPool
        inactivityTimeout=5000 #integer
        minimumSize=5 #integer
        isGrowable=false #boolean

        現在,如果使用此屬性檔案呼叫 applyConfigProperties 命令,則會建立新的 ThreadPool:

        wsadmin> AdminTask.applyConfigProperties('[-propertiesFileName thp.props ]')

      • 示例 2:使用屬性檔案建立新的 ThreadPool(使用不在配置中的執行緒池名稱)

        與使用配置中沒有的隨機 ID 不同,如果該物件具有名稱屬性,並且指定的名稱還未存在於配置中,則還可以指定物件的名稱。清單 29 顯示了使用名稱而非 ID 的屬性檔案。



        清單 29. 顯示了使用名稱而非 ID 的屬性檔案
        						
        #
        # SubSection 1.0.1.4 # Thread pools
        #
        ResourceType=ThreadPool
        ImplementingResourceType=Server
        ResourceId=Cell=!{cellName}:Node=!{nodeName}:Server=!{serverName}:Thr
        eadPoolManager=ID#ThreadPoolManager_1:ThreadPool=myThreadPool
        #
        
        #
        #Properties
        #
        maximumSize=20 #integer
        name=myThreadPool
        inactivityTimeout=5000 #integer
        minimumSize=5 #integer
        isGrowable=false #boolean

        使用此屬性檔案呼叫 applyConfigProperties 命令時,該命令將建立新的執行緒池:

        wsadmin> AdminTask.applyConfigProperties('[-propertiesFileName thp.props ]')

      • 示例 3:使用 deleteConfigProperties 命令刪除現有物件

        要刪除物件,請使用 deleteConfigProperties 命令。例如,要刪除剛才在示例 2 中建立的執行緒池,您可以使用建立命令所使用的同一屬性檔案來執行該命令,但是在標題中使用 DELETE=true,如清單 30 所示。



        清單 30. 使用 deleteConfigProperties 命令刪除現有物件
        						
        #
        # SubSection 1.0.1.4 # Thread pools
        #
        ResourceType=ThreadPool
        ImplementingResourceType=Server
        ResourceId=Cell=!{cellName}:Node=!{nodeName}:Server=!{serverName}:Thr
        eadPoolManager=ID#ThreadPoolManager_1:ThreadPool=myThreadPool
        DELETE=true
        #
        
        #
        #Properties
        #
        maximumSize=20 #integer
        name=myThreadPool
        inactivityTimeout=5000 #integer
        minimumSize=5 #integer
        isGrowable=false #boolean

        或者,不使用 ThreadPool=myThreadPool,而改為使用 ThreadPool=ID#ThreadPool_12345。您必須確保輸入的 ID(這裡為“ThreadPool_12345”)是此物件的配置中的實際 ID。

        將 deleteConfigProperties 命令與上述屬性檔案一起使用來刪除該物件。它將從配置中刪除屬性檔案表示的執行緒池:

        wsadmin> AdminTask.deleteConfigProperties('[-propertiesFileName thp.props ]')

        請注意,如果未指定 DELETE,則 deleteConfigProperties 命令將嘗試刪除每個屬性,並將物件保留在配置中。從物件移除每個屬性時,屬性將重設為預設值(如果存在預設值)或者被移除。

      更多示例

      下面是您可以使用基於屬性檔案的配置執行的其他功能的一些示例:

      • 使用屬性檔案安裝應用程式

        使用 applyConfigProperties 命令應用清單 31 中的屬性檔案時,將安裝屬性檔案中指定的應用程式。



        清單 31. 使用屬性檔案安裝應用程式
        						
        # Header
        ResourceType=Application
        ImplementingResourceType=Application
        ResourceId=Deployment=
        
        # Properties
        Name=hello
        TargetServer=server1
        TargetNode=node1
        EarFileLocation=/temp/Hello.ear
        #TargetCluster=cluster1

      • 使用屬性檔案解除安裝應用程式

        使用 deleteConfigProperties 命令應用清單 32 中的屬性檔案時,將解除安裝屬性檔案中指定的應用程式。



        清單 32. 使用 deleteConfigProperties 命令 解除安裝屬性檔案中指定的應用程式
        						
        # Header
        ResourceType=Application
        ImplementingResourceType=Application
        ResourceId=Deployment=hello
        
        # Properties
        Name=hello

      • 使用屬性檔案更新應用程式

        要更新已安裝的應用程式,您可以使用 applyConfigProperties 命令通過屬性檔案執行各種更新。要新增單個檔案,請使用屬性檔案(如清單 33 所示的屬性檔案)呼叫 applyConfigProperties 命令。



        清單 33. 使用屬性檔案更新應用程式
        						
        # Header
        ResourceType=Application
        ImplementingResourceType=Application
        ResourceId=Deployment=hello
        
        # Properties
        Name=hello
        Update=true
        perationType=add
        contentType=file
        contentURI=test.war/com/ibm/addMe.jsp
        contentFile=c:/temp/addMe.jsp

        要刪除單個檔案,請使用屬性檔案(如清單 34 所示的屬性檔案)呼叫 applyConfigProperties 命令。



        清單 34. 刪除單個檔案
        						
        # Header
        ResourceType=Application
        ImplementingResourceType=Application
        ResourceId=Deployment=hello
        
        # Properties
        Name=hello
        Update=true
        perationType=delete
        contentType=file
        contentURI=test.war/com/ibm/addMe.jsp

        要新增模組,請使用屬性檔案(如清單 35 所示的屬性檔案)呼叫 applyConfigProperties 命令。



        清單 35. 新增模組
        						
        # Header
        ResourceType=Application
        ImplementingResourceType=Application
        ResourceId=Deployment=hello
        
        # Properties
        Name=hello
        Update=true
        perationType=add
        contentType=moduleFile
        #contextRoot=”/mywebapp” # required for webmodule only
        contentURI= Increment.jar
        contentFile= c:/apps/app1/Increment.jar
        deployEJB=false

        要刪除模組,請使用屬性檔案(如清單 36 所示的屬性檔案)呼叫 applyConfigProperties 命令。



        清單 36. 刪除模組
        						
        # Header
        ResourceType=Application
        ImplementingResourceType=Application
        ResourceId=Deployment=hello
        
        # Properties
        Name=hello
        Update=true
        perationType=delete
        contentType=moduleFile
        contentURI= test.war

        要執行部分更新,請使用屬性檔案(如清單 37 所示的屬性檔案)來呼叫 applyConfigProperties 命令。



        清單 37. 執行部分更新
        						
        # Header
        ResourceType=Application
        ImplementingResourceType=Application
        ResourceId=Deployment=hello
        
        # Properties
        Name=hello
        Update=true
        perationType=update
        contentType=partialapp
        contentFile= c:/temp/MyApp/myAppPartial.zip

        要執行完全更新,請使用屬性檔案(如清單 38 所示的屬性檔案)呼叫 applyConfigProperties 命令。



        清單 38. 執行完全更新
        						
        # Header
        ResourceType=Application
        ImplementingResourceType=Application
        ResourceId=Deployment=hello
        
        # Properties
        Name=hello
        Update=true
        perationType=update
        contentType=app
        contentFile= c:/apps/app1/newApp1.ear
        useDefaultBindings=true





      回頁首


      總結

      基於屬性的配置是監視和管理 IBM WebSphere Application Server V7.0 配置的新的獨特方法。它為管理 WebSphere Application Server 環境提供了一種更為方便的方法,因為該配置不需要深入瞭解複雜的配置模型或重要的程式設計技能。不過,在更新配置時仍要多加小心,因為應用伺服器的行為直接取決於這些配置引數。本文通過一些示例說明了使用基於屬性的配置可以進行哪些配置以及如何進行配置。您可以在WebSphere Application Server 資訊中心中找到有關此主題和此功能的詳細資訊。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/14789789/viewspace-610844/,如需轉載,請註明出處,否則將追究法律責任。

相關文章