Jython 脚本库

查找脚本库中各个 Jython 脚本的用法信息。Jython 脚本库提供了一组过程,可自动执行最常见的应用程序服务器管理功能。 例如,可以使用该脚本库轻松配置服务器、应用程序、邮件设置、资源、节点、业务级应用程序、集群、授权组等。可以逐个运行每个脚本过程,也可以将几个过程组合在一起来快速开发新脚本。

脚本库提供了一组过程,可自动执行最常见的应用程序服务器管理功能。 使用 Jython 脚本库的方式有三种。
  • 使用 wsadmin 工具从 Jython 脚本库以交互方式运行脚本。可以启动 wsadmin 工具,并使用以下语法来运行包括在脚本库中的各个脚本:
    wsadmin>AdminServerManagement.createApplicationServer("myNode", "myServer", "default")
  • 使用文本编辑器组合 Jython 脚本库中的若干个脚本,如下例所示:
    #
    # My Custom Jython Script - file.py
    #
    AdminServerManagement.createApplicationServer("myNode", "Server1", "default")
    AdminServerManagement.createApplicationServer("myNode", "Server2", "default")
    
    # Use one of them as the first member of a cluster
    AdminClusterManagement.createClusterWithFirstMember("myCluster", "APPLICATION_SERVER",
        "myNode", "Server1")
    
    # Add a second member to the cluster
    AdminClusterManagement.createClusterMember("myCluster", "myNode", "Server3")
    
    # Install an application
    AdminApplication.installAppWithClusterOption("DefaultApplication",
        "..\installableApps\DefaultApplication.ear", "myCluster") 
    
    # Start all servers and applications on the node
    AdminServerManagement.startAllServers("myNode")
    保存定制脚本并从命令行运行该脚本,如以下语法所示:
    bin>wsadmin -language jython -f path/to/your/jython/file.py
  • 将 Jython 脚本库代码用作样本语法来编写定制脚本。脚本库中的每个脚本示例都演示了编写 wsadmin 脚本的最佳实践。脚本库代码位于 app_server_root/scriptLibraries 目录中。在此目录中,脚本按照功能组织到各个子目录中。例如,app_server_root/scriptLibraries/application/V70 子目录包含执行应用程序管理任务的过程,这些过程可用于产品的 V7.0 和更高版本。脚本库路径中的子目录 V70 并不表示该子目录中的脚本是 V7.0 脚本。
避免故障 避免故障: 如果在调用 WebSphere Application Server MBean 操作的 wsadmin 脚本中发出 Jython 命令,并且 MBean 方法返回了一个其中包含一些 NLS 翻译的字符(例如法语重音字符)的字符串,那么 Jython 会自动将此字符串转换为 Python Unicode 字符串,并将转换后的字符串返回给 wsadmin。如果将 Jython print output 命令包括在调用 MBean 方法的脚本中,那么将在 MBean 方法返回给 wsadmin 的字符串中包括 NLS 翻译的字符,而不是 Python Unicode 值。为了避免显示 NLS 翻译的字符,请使用 MBean return 的变量(例如,output = AdminControl.invoke(mbean)),然后使用 print output。 使用 Jython print 命令来正确地转换包含 NLS 翻译的字符的字符串。gotcha

指示主题类型的图标 概念主题



时间戳记图标 最近一次更新时间: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=welc_ref_adm_jython
文件名:welc_ref_adm_jython.html