![]() | |
|
WebSphere Application Server provides a scripting interface based on the Bean Scripting
Framework (BSF). This interface is called wsadmin
. BSF is an open source project that is
used to implement an architecture for incorporating scripting into Java applications and
applets. The BSF architecture works as an interface between Java applications and scripting
languages. Using this framework allows scripting languages to complete the following tasks:
Look up a preregistered bean and access a predeclared bean.
Register a newly created bean.
Perform all bean operations.
Bind events to scripts in the scripting language.
Because wsadmin
uses BSF, it can make various Java objects available through
language-specific interfaces to scripts. Figure below shows the major components that are
involved in the wsadmin
scripting solution.
You can use the following programming languages to write wsadmin scripts:
Jython
Jacl
With WebSphere Application Server V7, the deprecation process for the Jacl syntax began. The script library and the command assistance on the administrative console support only Jython.
If you have existing Jacl scripts and want to start migrating to Jython, you can use the Jacl-to-Jython conversion utility to convert the scripts. This conversion assistant typically achieves 95-98% of a preliminary conversion. In most cases, the resulting conversion is syntactically and runtime equivalent.
However, verify each line to ensure that the code functions as you originally intended. When
Jacl and Jython language differences result in lines of code that are difficult to convert
automatically, the converted lines are flagged with a #?PROBLEM?
tag. This tag provides
assistance in finding areas that are most likely in need of manual conversion.
The wsadmin tool management objects
The wsadmin tool has the following administrative objects that provide server configuration and management capabilities:
Help
The Help
object provides a quick way to get information about methods, operations, and
attributes using scripting. For example, to get a list of the public methods that are available for
the AdminControl
object, enter the following command:
wsadmin>print Help.AdminConfig()
To get a detailed description of a specific object method and the parameters that it requires,
invoke the help(...)
method of the target object with the method name as the option to the
help(...)
method, as shown below:
wsadmin>print AdminConfig.help("createClusterMember") WASX7284I: Method: createClusterMember Arguments: cluster id, node id, member attributes Description: Creates a new Server object on the node specified by "node id." This Server is created as a new member of the existing cluster specified by "cluster id," and has attributes specified in "member attributes." One attribute is required: "memberName." The Server is created using the default template for Server objects, and has the name and specified by the "memberName" attribute. Method: createClusterMember Arguments: cluster id, node id, member attributes, template id Description: Creates a new Server object on the node specified by "node id." This Server is created as a new member of the existing cluster specified by "cluster id," and has attributes specified in "member attributes." One attribute is required: "memberName." The Server is created using the Server template specified by "template id," and has the name specified by the "memberName" attribute. wsadmin>
The AdminTask
object also supports searching for the specific command by using a wildcard
character under help. For example, listing below shows the command to get a list of the
command names that start with the term create
:
wsadmin>print AdminTask.help("-commands", "create*") WASX8004I: Available admin commands: createAllActivePolicy - Create a policy that automatically activates all group members. createApplicationServer - Command that creates a server createApplicationServerTemplate - creates a server Template based on a server configuration createAuditEncryptionConfig - Configures audit record encryption. createAuditEventFactory - Creates an entry in the audit.xml to reference the configuration of an audit event factory implementation of the Audit Event Factory interface. createAuditFilter - Creates an entry in the audit.xml to reference an Audit Specification. Enables the specification by default. createAuditKeyStore - Creates a new Key Store. createAuditNotification - Configures an audit notification. createAuditNotificationMonitor - Configures an audit notification monitor. createAuditSelfSignedCertificate - Create a new self-signed certificate and store it in a key store. createAuditSigningConfig - Configures audit record signing. [......]
AdminControl
The AdminControl
object is used for operational control. It communicates with MBeans that
represent live objects running a WebSphere server process. It includes commands to query
existing running objects and their attributes and to invoke operations on the objects. In
addition to the operational commands, the AdminControl
object supports commands to query
information about the connected server, to trace clients, to reconnect to a server, and to start
and stop a server.
Note that because the AdminControl
object operates on live MBeans, you cannot use it to
start a deployment manager, node agent, or stand-alone application server.
AdminConfig
The AdminConfig
object is used to manage the configuration information that is stored in the
repository. This object communicates with the WebSphere Application Server configuration
service component to make configuration inquiries and changes. You can use it to query
existing configuration objects, create configuration objects, modify existing objects, and
remove configuration objects. In a distributed server environment, the AdminConfig
commands are available only if a scripting client is connected to the deployment manager.
When connected to a node agent or a managed application server, the AdminConfig
commands are not available because the configuration for these server processes are copies
of the master configuration that resides in the deployment manager.
AdminApp
The AdminApp
object can update application metadata, map virtual hosts to web modules,
and map servers to modules for applications already installed. Changes to an application,
such as specifying a library for the application to use or setting session management
configuration properties, are performed using the AdminConfig
object.
AdminTask
The AdminTask
object is used to access a set of task-oriented administrative commands that
provide an alternative way to access the configuration commands and the running object
management commands. The administrative commands run simple and complex commands.
The administrative commands are discovered dynamically when the scripting client is started.
The set of available administrative commands depends on the edition of WebSphere
Application Server that you install. You can use the AdminTask
object commands to access
these commands.
Two run modes are always available for each administrative command, namely the batch and
interactive mode. When you use an administrative command in interactive mode, you go
through a series of steps to collect your input interactively. This process provides users a
text-based wizard and a similar user experience to the wizard in the administrative console.
You can also use the help
command to obtain help for any of the administrative commands
and the AdminTask
object.
Example, list available servers:
wsadmin>print AdminTask.listServers('[-serverType APPLICATION_SERVER ]') server1(cells/ilc03zNode01Cell/nodes/ilc03zNode01/servers/server1|server.xml)
![]() ![]() ![]() |