InfoCenter Home > 6.6.0.2.2.7: Using the wscpCommand interfaceUse the com.ibm.ejs.sm.ejscp.wscpcommand.WscpCommand interface to embed wscp operations in Java applications. This enables applications to evaluate wscp operations without repeated startup costs. The interface is linked through the product_installation_root/lib/wscp.jar file. The typical use of this class is to instantiate it once, and reuse the object to successively poll the WebSphere Administrative Server. ConstructorsWscpCommand(String node, String port) where:
WscpCommand() The default values for this constructor are localhost for node and 900 for port (the default port number of the administrative server). Public methodsWscpResult evalCommand(String command) This method evaluates a wscp operation and returns the results. Use the same syntax as you do for interactive or scripted wscp operations. Using abbreviated command names is not recommended. The results of the evalCommand method are encoded in a com.ibm.ejs.sm.ejscp.wscpcommand.WscpResult object. The following methods on this object can be used to evaluate the returned value:
String getErrorInfo() This method returns the status of an evalCommand method whose results are returned in a WscpResult object.
The following is an example of how to use the evalCommand and getErrorInfo methods. String cmd = "ApplicationServer list"; WscpResult results = wscpCommand.evalCommand(cmd); if (!results.success()) { System.out.println("command failed; exception information: " + results.getErrorInfo()); } Utility classThe WscpCommand interface contains a utility class, WscpQualifiedName, that allows the manipulation of fully qualfied wscp object names. The constructor is as follows: WscpQualifiedName(fullyqualifiedname) where fullyqualifiedname is the fully-qualified wscp name of an object. The methods for this class are as follows:
The WscpQualifiedName class contains the following constants, which define the containment levels at which various components are named.
An example of how this class is used is as follows: String name = "{/Node:MyNode/ApplicationServer:MyAppServer/}" WscpQualfiedName qName = new WscpQualifiedName(name); qName.numberOfLevels() returns 2 qName.getObject(2) returns "ApplicationServer" qName.getName(2) returns "MyAppServer" qName.getName(WscpQualifiedName.APPLICATION_SERVER) returns "MyAppServer" SecurityThe wscp command-line tool runs with security enabled because it is started by using SAS from the command line, as you can see in the wscp.bat (Windows) and wscp.sh (Unix) files. However, the WscpCommand interface cannot guarantee support for a server with security enabled because it is used in client programs. If the Java program is started using SAS, WscpCommand methods execute with security enabled. |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|