
package tests.ProviderClientTest;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.tree.*;
import org.snia.wbem.client.CIMClient;
import org.snia.wbem.cim.*;

//import connect.*;
public class ProviderClient
{

//===========================================================
//   M A I N
//===========================================================
  public static void main(String args[])
  {
        String managedSystem="localhost";
	String className=null;
	String propertyName=null;
	String nameSpace = "root/cimv2";
        int portNo=CIMNameSpace.DEFAULT_PORT;
        String protocol = null;

        System.setProperty("org.snia.wbem.cimom.properties", "./cim.properties");
        if (args.length == 6) 
        {
  	  managedSystem = args[0];
    	  nameSpace=args[1];
  	  portNo=Integer.parseInt(args[2]);
          protocol=args[3];
	  className = args[4];
	  propertyName = args[5];
        } 
        else 
        {
             String USAGE="USAGE: java ProviderClient hostname namespace portNo ssl/nossl className propertyName";
             String EXAMPLE1="java ProviderClient localhost root/cimv2 5989 ssl PG_ComputerSystem Name";
             String EXAMPLE2="java ProviderClient sequoia root/cimv2 5989 ssl PG_OperatingSystem Version ";
             String EXAMPLE3="java ProviderClient sequoia root 5988 nossl PG_OperatingSystem Version ";

             System.err.println("\n" + USAGE);
             System.err.println("Example:");
             System.err.println("\t" +EXAMPLE1);
             System.err.println("\t" +EXAMPLE2);
             System.err.println("\t" +EXAMPLE3);
             System.exit(1);
        }

	XMLConnect connect = new XMLConnect();
	WBEMValue  val = new WBEMValue();


	connect.setManagedSystem(managedSystem);
	connect.setPort(portNo);
	connect.setNamespace(nameSpace);
	connect.setProtocol(protocol);
	connect.connectSystem();

        CIMClient cc=null;
	cc = connect.getConnectHandle();
	System.out.println("Connection Handle: "+cc);

	String value;
        value = val.getPropertyValue(cc, nameSpace, className, propertyName);

	System.out.println("Value: "+value);
	//system.exit(0);
   }
}
