Integration Toolbox
for IBM® TIVOLI® Storage Manager

package query; import hu.user.toolbox.tsm.ITSMSession; import hu.user.toolbox.tsm.ManagementClass; import hu.user.toolbox.tsm.Toolbox; import hu.user.toolbox.tsm.exception.ToolboxException; import java.util.List; /** * <b>Function:</b><br> * Queries defined management classes. * <p> * The following operations are performed: * <ol> * <li>Initializing a single-threaded TSM API environment.</li> * <li>Creating a new TSMSession instance. * Setting default connection options. Connecting to the server using * the node name "TOOLBOX" and password "PASSWORD".</li> * <li>Querying all management classes</li> * <li>Iterating through the returned list. Printing the name of each management * class.</li> * <li>Disconnecting from the server and cleaning up the resources.</li> * </ol> * <p> * <b>Compile:</b> * <pre> * javac -d bin -cp ../lib/toolboxfortsm.jar query/QueryManagementClasses.java * </pre> * <p> * <b>Execute:</b><br> * You should first set the environment variables to point to the correct * files/directories. * <pre> * set DSMI_CONFIG={Full path of your dsm.opt} * set DSMI_DIR={Tivoli Storage Manager API installation directory} * set DSMI_LOG={Any arbitrary directory} * </pre> * Then use the java command to execute the program: * <p> * <pre> * java -cp bin:../lib/toolboxfortsm.jar:../lib/ext/log4j-1.2.17.jar:../config * -Djava.library.path=../lib query.QueryManagementClasses * </pre> */ public class QueryManagementClasses { private static final String NODE_NAME = "TOOLBOX"; private static final String PASSWORD = "PASSWORD"; public static void main(final String args[]) throws ToolboxException { ITSMSession session = null; try { // Initializing a single-threaded environment Toolbox.initSingleThreading(); // Connecting to the server with the default connection options session = Toolbox.createSession(NODE_NAME, PASSWORD); // Getting the list of all management classes List<ManagementClass> managementClasses = session .queryManagementClasses(); // Printing the name of the management classes System.out.printf("Management classes available for node '%s':\n\n", NODE_NAME); for (ManagementClass managementClass : managementClasses) { System.out.println(managementClass.getName()); } } catch (ToolboxException e) { e.printStackTrace(); } finally { // Disconnecting session.disconnect(); // Cleaning up the environment Toolbox.cleanUp(); } } }