next up previous
Next: Advice for Future Project Up: External Interface Previous: External Interface

InterfaceExample.java (template code, doesn't compile)

 

package telephony.manager;

import telephony.manager.ManagementClient; 

import telephony.exceptions.*;

import java.util.Date; 

import java.rmi.*; 

import java.rmi.server.*;

public class sampleManagementCalls {

  private static final String ModuleType = "ModuleName"; 

  private static final String ClientName = ModuleType + (new Date()).getTime();

  private void <FunctionName>(<Arg1Type> <Arg1Name>, 

                              <Arg2Type> <Arg2Name>) { 

    String KeyArgs = new String("<FunctionName>!

                                 <Arg1Type>#<Arg1Name>=<Arg1Val>!

                                 <Arg2Type>#<Arg2Name>=<Arg2Val>"); 

    int RV = -1; 

    try { 

      RV = ManagementClient.manageFunctionInvocation(

                             ClientName, ModuleType, KeyArgs); 

    } catch (ManagementSystemErrorException e1) { 

      System.err.println(e1.getMessage()); 

    } catch (ManagementAccessDeniedException e2) { 

      System.err.println(e2.getMessage()); 

    } finally { 

      System.out.println("function() invocation : "+RV); 

    } 

    //function() does some stuff 

    try { 

      RV = ManagementClient.manageFunctionTermination(

                              ClientName, ModuleType, KeyArgs); 

    } catch (ManagementSystemErrorException e1) { 

      System.err.println(e1.getMessage()); 

    } catch (ManagementAccessDeniedException e2) { 

      System.err.println(e2.getMessage()); 

    } finally { 

      System.out.println("function() termination: "+RV); 

    } 

  } 

  public static void main(String argv[]) { 

    int RV = -1; int i = -1; testFaxGate m; String args;

    try { 

      RV = ManagementClient.manageFunctionInvocation(

                             ClientName, ModuleName, "main"); 

      } catch (ManagementSystemErrorException e1) { 

        System.err.println(e1.getMessage()); 

      } catch (ManagementAccessDeniedException e2) { 

        System.err.println(e2.getMessage()); 

      } finally { 

        System.out.println("main() invocation: "+RV); 

      }

    i = -1; 

    m = new sampleManagementCalls(); 

    while (++i < 10) { 

      m.<FunctionName>(Arg1, Arg2);

    }

    try { 

      RV = ManagementClient.manageFunctionTermination(

                              ClientName, ModuleName, "main"); 

    } catch (ManagementSystemErrorException e1) { 

      System.err.println(e1.getMessage()); 

    } catch (ManagementAccessDeniedException e2) { 

      System.err.println(e2.getMessage()); 

    } finally { 

      System.out.println("main() termination: "+RV); 

    } 

    //shouldn't need this if the library is done right, 

    //but there is some subtle bug

    System.exit(0); 

  } 

}



David L. Roxe
1998-12-18