Extending Wsadmin tools and Jython scripts using XML files
Introduction: Wsadmin is a scripting tool provided by Websphere Application Server that enables developers to manage and configure servers through scripting. This article first introduces wsadmin and scripting language Jython, and this article introduces a method of extending wsadmin and scripting through XML configuration files, which allows the deployer to define server configuration steps and application deployment processes through XML files, thereby improving WSADMI N and the availability of the script.
Before publishing a Java EE application running in WebSphere application server, configuring and deploying the server is an essential process, and the process is very complex. was a visual management Console (Web Admin Console) provided to the user to accomplish this task. Even so, development or deployment personnel still need to be trained and spend a certain amount of time and effort to complete these configuration and deployment tasks. For a development team, if each team member has to manually complete the environment configuration and application deployment, the cost is relatively high.
This article describes using the Wsadmin tool with the Jython script to complete the server's environment configuration and application deployment. Once the configuration and deployment scripts are written, they can be reused multiple times. Using automated scripts instead of manual operations is an important part of improving productivity. Based on this, this paper introduces a method of using XML file to extend the Wsadmin command-line tool and Jython script to implement the server environment configuration and application deployment. We provide a Jython implementation for this method, and the relevant scripts have been validated on the was 6.0 and 7.0 versions. In this article, we will elaborate on this approach and briefly describe the XML file format. In addition, this article will explain the implementation of XML file parsing and running module, so that readers can add the required functional modules.
Introduction to Wsadmin Tools and scripts
Introduction to Wsadmin Tools
The Wsadmin scripting tool is introduced to the IBM WebSphere application Server V5. It is a graphical management tool that accepts scripting language input, and users can use the Wsadmin tool to perform the same tasks that can be performed with the admin console.
Wsadmin currently supports only the two scripting languages of Jython and Jacl. This article selects the Jython script as the sample code, explains the server configuration and management using the automation script. We will use deployment as an example to write Jython scripts, even developers who first contacted Jython scripts can quickly understand and use them.
Start the Wsadmin tool
Developers can start the Wsadmin tool through Wsadmin.bat (Windows) or wsadmin.sh (Linux or AIX). Both types of files can be found in the bin directory (${profile_root}/bin) of the was profile and can be found in the bin directory (${app_server_root}/bin) of was. The start command in the bin directory of was is required to specify the-profilename parameter at run time, while the startup command in the bin directory of a specific profile is not specified.
The Wsadmin tool can be run in either interactive or batch mode. When running interactively, developers can run a single command in the Wsadmin tool. The commands for starting an interactive wsadmin tool in a Windows system are as follows:
Start the Wsadmin tool that supports the JACL command: Wsadmin.bat
Start the Wsadmin tool that supports the Jython command: Wsadmin.bat–lang Jython
In addition, developers can run batch scripts with the Wsamin tool. Batch scripts need to be specified through the-profile parameter:
Run Jacl script: Wsadmin.bat–profile sample.jacl
Run Jython script: Wsadmin.bat–lang jython–profile sample.py
Introduction to Jython language
The Jython language is one of the two scripting languages that Wsadmin currently supports. The Jython interpreter provides control flow support and various auxiliary commands to the script, and Jython extends its functionality through access to the scripting objects provided by the Wsadmin tool, allowing developers to use scripting to implement application deployment, server management, and configuration.