Show Model Variable Lists



/* Example Program :

     Display model variable lists and their contents.

     Compile: javac -classpath sconfig.jar;jaas.jar;wcp.jar ShowMVLs.java

     Run: java -classpath sconfig.jar;jaas.jar;wcp.jar ShowMVLs <AADSName><ServerName>

	 Before running this program, run the 'ObtainAADSCertificates' program to obtain certificates
       for the AADS servers of interest.
*/
import java.io.IOException;
import java.util.*;
import com.wrq.vhi.sconfig.*;

class ShowMVLs
{
	public static final String CERTFILE = "certificates.aads";
	public static final String DIVIDER = "========================================";

	public static final String username = ""; // Can modify these if security is On.
	public static final String password = "";

	/* Display the contents of a single model variable list. */
	static void showMVL( IMvlBrowser mvlb, String mvlname )
	{
		VhiMvl mvl = mvlb.getMvl(mvlname);

		/* For each MVL entry */
		for(int i=0; i<mvl.size(); i++) {
			Map mvle = mvl.get(i);
			/* For each variable/value pair in the MVL entry */
			for(Iterator it=mvle.entrySet().iterator(); it.hasNext(); ) {
				Map.Entry item = (Map.Entry)it.next();
				String vname = (String)item.getKey();
				String vval = (String)item.getValue();
				System.out.println("   Entry " + (i+1) + " :  Variable : " + vname + "  Value : " + vval );
			}
			System.out.println("");
		}
	}

	/* Display all of the MVLs defined on a Host Integrator Server. */
	static void displayMVLs(String AADSName, String serverName)
		throws SCException, IOException, ClassNotFoundException
	{
 		IAADSConnection aadsConn =
			ServerConfig.newAADSConnection( AADSName, CERTFILE );
 		IServerAdminSession sas =
			ServerConfig.newServerAdminSession( serverName, aadsConn, username, password );


 		sas.open(); /* Connect to the Host Integrator Server */

		System.out.println( DIVIDER );
		System.out.println("AADS: " + AADSName);
		System.out.println("Server: " + serverName);

		IMvlBrowser mvlb = ServerConfig.newMvlBrowser( sas );

		/* Read the MVL configuration from the Host Integrator Server. */
		mvlb.readConfiguration();

		/* Get a list of the names of MVLs defined on this server. */
		List mvlnames = mvlb.getMvlNames();
		System.out.println("Number of MVLs : " + mvlnames.size() );

		/* Display the variables/values for each MVL */
		for(Iterator it1=mvlnames.iterator(); it1.hasNext(); ) {
			String mvlname = (String)it1.next();
			System.out.println( DIVIDER );
			System.out.println("MVL Name: " + mvlname);
			showMVL( mvlb, mvlname );
		}

		sas.close(); /* Disconnect from the Host Integrator Server. */

	}

	static public void main(String [] args)
	{
		if(args.length != 2) {
			System.out.println("Usage: ShowMVLs <AADSName> <Servername>");
			return;
		}
		try {
			displayMVLs( args[0], args[1] );
		}
		catch(Exception e) {
			System.err.println("Exception caught: " + e);
			e.printStackTrace();
		}
	}
}






 

 

  Attachmate