Package tcg.syscontrol

Source Code of tcg.syscontrol.GenericAgentTest

package tcg.syscontrol;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
import org.omg.CORBA.Object;

import tcg.common.CorbaHelper;
import tcg.syscontrol.cos.ICosManagedProcess;
import tcg.syscontrol.cos.ICosManagedProcessHelper;

public class GenericAgentTest {

  public static Logger logger_ = Logger.getLogger(GenericAgentTest.class.toString());
 
  /**
   * @param args
   */
  public static void main(String[] args)
  {
    BasicConfigurator.configure();

//    //reset the static reference. just in case
//    ORB orb_ = null;
//    POA rootPOA_ = null;
//
//    //initialize corba service
//    Properties props = new Properties();
//    try {
//      //initialization params
//      props.setProperty("org.omg.CORBA.ORBClass",
//                    org.jacorb.orb.ORB.class.getName());
//      props.setProperty("org.omg.CORBA.ORBSingletonClass",
//                    org.jacorb.orb.ORBSingleton.class.getName());
//
//      //initialize the service
//      orb_ = org.omg.CORBA.ORB.init( args, props );
//      if (orb_ == null) return;
//     
//      //get rootPOA
//      org.omg.CORBA.Object obj = orb_.resolve_initial_references( "RootPOA" );           
//            rootPOA_ = org.omg.PortableServer.POAHelper.narrow( obj );
//            if (rootPOA_ == null) return;
//    }
//    catch (Exception ex)
//    {
//      logger_.error("Can not initialize CORBA service. Exception " + ex.toString());
//      return;
//    }

    CorbaHelper.getInstance();
   
    String ior = "corbaloc::localhost:7777/GenericAgent";

    ICosManagedProcess process = null;
    try
    {
      //Object obj = orb_.string_to_object(ior);
      Object obj = CorbaHelper.stringToObject(ior);
      process = ICosManagedProcessHelper.narrow(obj);
    }
    catch (Exception ex)
    {
      logger_.error("Can not get reference to process manager: " + ior + ". "
          + "Exception: " + ex.toString());
      return;
    }
   
    if (process == null)
    {
      logger_.error("Can not get reference to process manager: " + ior);
      return;
    }
   
    String statusStr = "";
    for (int i=0; i<10; i++)
    {
      try
      {
        statusStr = process.cosGetStatusString();
      }
      catch (Exception ex)
      {
        logger_.warn("Can not get status string. Exception: " + ex.toString());
        continue;
      }
      logger_.info("Status: " + statusStr);
     
      try
      {
        Thread.sleep(1000);
      }
      catch(InterruptedException ie)
      {
        //ignore
      }
    }
   
    return;
  }

}
TOP

Related Classes of tcg.syscontrol.GenericAgentTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.