import java.rmi.*; import java.rmi.server.*; public class remoteMath_impl extends UnicastRemoteObject implements remoteMath { private static Arithmetic board; public remoteMath_impl() throws RemoteException // Constructor for this class; the board object is instantiated here. // that way, there is only one board object per server, and response time // is better than if a new one is created for each query. { board = new Arithmetic(); //setLog(System.out); // use this to log rmi security output to stdout } // end of method "remoteMath_impl" public int AddTwoC( int one, int two ) throws RemoteException { int result; String client; // let's find out who is using us. try { client = new String(getClientHost()); System.out.println("\nServicing " + client ); } catch (ServerNotActiveException se) { System.out.println(se); } // Here is where we use the native method result = board.Add(one, two); System.out.println("remote software add performed: " + one + " + " + two + " = " + result ); return result; } // end of method "AddTwoC" public int SubTwoC( int one, int two ) throws RemoteException { int result; String client; // let's find out who is using us. try { client = new String(getClientHost()); System.out.println("\nServicing " + client ); } catch (ServerNotActiveException se) { System.out.println(se); } // Here is where we use the native method result = board.Sub(one, two); System.out.println("remote software subtraction performed: " + one + " + " + two + " = " + result ); return result; } // end of method "AddTwoC" public int MulTwoC( int one, int two ) throws RemoteException { int result; String client; // let's find out who is using us. try { client = new String(getClientHost()); System.out.println("\nServicing " + client ); } catch (ServerNotActiveException se) { System.out.println(se); } // Here is where we use the native method result = board.Mul(one, two); System.out.println("remote software multiplication performed: " + one + " + " + two + " = " + result ); return result; } // end of method "AddTwoC" public int DivTwoC( int one, int two ) throws RemoteException { int result; String client; // let's find out who is using us. try { client = new String(getClientHost()); System.out.println("\nServicing " + client ); } catch (ServerNotActiveException se) { System.out.println(se); } // Here is where we use the native method result = board.Div(one, two); System.out.println("remote software division performed: " + one + " + " + two + " = " + result ); return result; } // end of method "AddTwoC" public int AddTwoJava( int one, int two ) throws RemoteException { int result; String client; // let's find out who is using us. try { client = new String(getClientHost()); System.out.println("\nServicing " + client ); } catch (ServerNotActiveException se) { System.out.println(se); } // Here is where we use the native method result = board.JavaAdd(one, two); System.out.println("remote software add performed: " + one + " + " + two + " = " + result ); return result; } // end of method "AddTwoJava" public int SubTwoJava( int one, int two ) throws RemoteException { int result; String client; // let's find out who is using us. try { client = new String(getClientHost()); System.out.println("\nServicing " + client ); } catch (ServerNotActiveException se) { System.out.println(se); } // Here is where we use the native method result = board.JavaSub(one, two); System.out.println("remote software subtraction performed: " + one + " + " + two + " = " + result ); return result; } // end of method "AddTwoJava" public int MulTwoJava( int one, int two ) throws RemoteException { int result; String client; // let's find out who is using us. try { client = new String(getClientHost()); System.out.println("\nServicing " + client ); } catch (ServerNotActiveException se) { System.out.println(se); } // Here is where we use the native method result = board.JavaMul(one, two); System.out.println("remote software multiplication performed: " + one + " + " + two + " = " + result ); return result; } // end of method "AddTwoJava" public int DivTwoJava( int one, int two ) throws RemoteException { int result; String client; // let's find out who is using us. try { client = new String(getClientHost()); System.out.println("\nServicing " + client ); } catch (ServerNotActiveException se) { System.out.println(se); } // Here is where we use the native method result = board.JavaDiv(one, two); System.out.println("remote software division performed: " + one + " + " + two + " = " + result ); return result; } // end of method "AddTwoJava" // Hardware Calls!!! public int AddTwoHW( int one, int two ) throws RemoteException { int result; String client; // let's find out who is using us. try { client = new String(getClientHost()); System.out.println("\nServicing " + client ); } catch (ServerNotActiveException se) { System.out.println(se); } // Here is where we use the native method result = board.HW_Add(one, two); System.out.println("Remote Hardware add performed " + one + " + " + two + " = " + result ); return result; } // end of method "AddTwoJava" public int SubTwoHW( int one, int two ) throws RemoteException { int result; String client; // let's find out who is using us. try { client = new String(getClientHost()); System.out.println("\nServicing " + client ); } catch (ServerNotActiveException se) { System.out.println(se); } // Here is where we use the native method result = board.HW_Sub(one, two); System.out.println("Remote Hardware add performed " + one + " + " + two + " = " + result ); return result; } // end of method "AddTwoJava" public int MulTwoHW( int one, int two ) throws RemoteException { int result; String client; // let's find out who is using us. try { client = new String(getClientHost()); System.out.println("\nServicing " + client ); } catch (ServerNotActiveException se) { System.out.println(se); } // Here is where we use the native method result = board.HW_Mul(one, two); System.out.println("Remote Hardware add performed " + one + " + " + two + " = " + result ); return result; } // end of method "AddTwoJava" public int DivTwoHW( int one, int two ) throws RemoteException { int result; String client; // let's find out who is using us. try { client = new String(getClientHost()); System.out.println("\nServicing " + client ); } catch (ServerNotActiveException se) { System.out.println(se); } // Here is where we use the native method result = board.HW_Div(one, two); System.out.println("Remote Hardware add performed " + one + " + " + two + " = " + result ); return result; } // end of method "AddTwoJava" } // end of class "RemoteMath_impl"