Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class KlientRMI {
- public static void main(String[] args) {
- double wynik;
- ResultType wynik2;
- CalcObject zObiekt;
- CalcObject2 zObiekt2;
- InputType inObj;
- inObj = new InputType();
- inObj.x1 = 123;
- inObj.x2 = 435;
- inObj.operation = "add";
- if (args.length == 0) {
- System.out.println("You have to enter RMI object address in the form:" +
- "//host_address/service_name");
- return;
- }
- String adres = args[0];
- String adres2 = args[1];
- // if (System.getSecurityManager() == null) {
- // System.setSecurityManager(new SecurityManager());
- // }
- try {
- zObiekt = (CalcObject) java.rmi.Naming.lookup(adres);
- } catch (Exception e) {
- System.out.println("Nie mozna pobrac referencji do " + adres);
- e.printStackTrace();
- return;
- }
- System.out.println(("referencja do " + adres + " jest pobrana."));
- try {
- zObiekt2 = (CalcObject2) java.rmi.Naming.lookup(adres2);
- } catch (Exception e) {
- System.out.println("Nie mozna pobrac referencji do " + adres2);
- e.printStackTrace();
- return;
- }
- System.out.println("referencja do " + adres2 + " jest pobrana.");
- try {
- wynik = zObiekt.calculate(1.1, 2.2);
- wynik2 = zObiekt2.calculate(inObj);
- } catch (Exception e) {
- System.out.println("Blad zdalnego wywolania.");
- e.printStackTrace();
- return;
- }
- System.out.println("Wynik = " + wynik);
- System.out.println("Wynik2 " + wynik2.result_description + " " +wynik2.result);
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement