package edu.gmit.rmi;
import static java.lang.System.out;
import java.rmi.RemoteException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import edu.gmit.cyhper.Result;
/**
* <p>
* <b> Insert description of the classes responsibility/role. NOT what uses it. </b>
* </p>
*/
public class Client extends Thread {
/**
* <p>
* <b> Insert description of the methods responsibility/role. NOT what uses it. </b>
* </p>
*
* @param args
* @throws InterruptedException
*/
public static void main(String[] args) throws InterruptedException {
out.println("Client Begin!");
ApplicationContext ctx = new ClassPathXmlApplicationContext("ClientConfig.xml");
CypherService service = (CypherService) ctx.getBean("clientInvoke");
try {
// User inputs the plain text
String plainText = args[0];
Result result = service.encrypt(plainText);
do {
Thread.sleep(1000);
if (result.isProcessed() == true) {
System.out.println("The cypher text is: " + result.getResult());
} else {
System.out.println("Still not get result!");
}
} while (!result.isProcessed());
} catch (RemoteException e) {
e.printStackTrace();
}
out.println("Client End!");
}
}