package com.javahonk.client;

import com.javahonk.servent.LoadReadPropertyFile;

import firstHelloWorld.HelloWorldPrx;
import firstHelloWorld.HelloWorldPrxHelper;

public class Client {

	
	public static void main(String[] args) {
		
		LoadReadPropertyFile.loadPropertyFile();
		Ice.Communicator ic = null;
		try {
			// Initialize Ice run time
			ic = Ice.Util.initialize(args);

			// Access to remote adapter JavaHonk agent
			Ice.ObjectPrx base = ic.stringToProxy("JavaHonk:"+System.getProperty("JavaHonkAdapter.Endpoints"));

			// Convert proxy
			HelloWorldPrx helloWorld = HelloWorldPrxHelper.checkedCast(base);

			// Check if conversion proxy is valid
			if (helloWorld == null) {
				throw new Error("Proxy is invalid");
			}

			// Call the method and pass the value
			helloWorld.greeting("Hello World");
			helloWorld.testAnotherOperation("Java Honk Hello World!");
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if (ic != null) {
				ic.destroy();
			}
		}
		System.exit(1);
	}

}
