WhiteBoard Using RMI
WSU CEG 7370 WhiteBoard Using Java RMI
Static Public Member Functions | Static Public Attributes | Static Private Attributes | List of all members
WhiteBoard.Invoke Class Reference

Static Public Member Functions

static void javaVM (char c, String args)
 Invoke java on the given class in a separate process. More...
 
static Remote lookup (String url)
 
static void main (String[] args)
 
static String makeURL (char c, String id)
 
static void myPrint (String who, String what)
 
static String promptAndGet (String msg)
 
static void setJavaCmdPath (String s)
 

Static Public Attributes

static int verbosity = 1
 

Static Private Attributes

static final String classNames [] = {serverClass, clientClass,linesClass}
 
static final String clientClass = "WhiteBoard.WbClientImpl"
 
static String javaCmd = "java"
 The following Srings isolate path related issues. More...
 
static final String linesClass = "WhiteBoard.LinesFrameImpl"
 
static int pid = 0
 
static final String rmiRegistryPfx = "//localhost/"
 
static final String serverClass = "WhiteBoard.WbServerImpl"
 
static BufferedReader stdIn
 

Detailed Description

Definition at line 8 of file Invoke.java.

Member Function Documentation

static void WhiteBoard.Invoke.javaVM ( char  c,
String  args 
)
static

Invoke java on the given class in a separate process.

Also, take care of any exceptions.

Definition at line 54 of file Invoke.java.

References WhiteBoard.Invoke.classNames, WhiteBoard.Invoke.javaCmd, WhiteBoard.Invoke.myPrint(), and WhiteBoard.Invoke.pid.

54  {
55  pid ++;
56  String classNm = classNames[c == 'S'? 0 : c == 'C' ? 1 : 2];
57  String cmd = javaCmd + " " + classNm + " " + pid + " " + args;
58 
59  try {
60  Runtime r = Runtime.getRuntime();
61  myPrint("Runtime " + r, cmd);
62  try {
63  Process p = r.exec(cmd);
64  myPrint("Process", "" + p);
65  } catch(Exception e) {
66  System.out.println("Error executing r.exec(" + cmd + ")");
67  }
68  } catch(Exception e) {
69  System.out.println("Runtime Error executing [" + cmd + "]");
70  }
71  }
static void myPrint(String who, String what)
Definition: Invoke.java:31
static final String classNames[]
Definition: Invoke.java:24
static String javaCmd
The following Srings isolate path related issues.
Definition: Invoke.java:15
static int pid
Definition: Invoke.java:11

+ Here is the call graph for this function:

static Remote WhiteBoard.Invoke.lookup ( String  url)
static

Definition at line 77 of file Invoke.java.

References WhiteBoard.Invoke.myPrint().

Referenced by WhiteBoard.LinesFrameImpl.LinesFrameImpl(), and WhiteBoard.WbClientImpl.WbClientImpl().

77  {
78  for (int j = 0; j < 10; j++)
79  try {
80  return Naming.lookup(url);
81  } catch (Exception e) {
82  myPrint("Naming.lookup(", url + ") not found yet ...");
83  try {Thread.sleep(1000);}
84  catch (Exception x) {x.printStackTrace();}
85  }
86  return null;
87  }
static void myPrint(String who, String what)
Definition: Invoke.java:31

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void WhiteBoard.Invoke.main ( String[]  args)
static

Definition at line 89 of file Invoke.java.

89  {
90  Invoke.javaVM('S', "");
91  }
static String WhiteBoard.Invoke.makeURL ( char  c,
String  id 
)
static

Definition at line 73 of file Invoke.java.

References WhiteBoard.Invoke.rmiRegistryPfx.

73  {
74  return rmiRegistryPfx + c + id;
75  }
static final String rmiRegistryPfx
Definition: Invoke.java:19
static void WhiteBoard.Invoke.myPrint ( String  who,
String  what 
)
static

Definition at line 31 of file Invoke.java.

References WhiteBoard.Invoke.verbosity.

Referenced by WhiteBoard.Invoke.javaVM(), and WhiteBoard.Invoke.lookup().

31  {
32  if (verbosity > 0)
33  System.out.println(who + ": " + what);
34  }
static int verbosity
Definition: Invoke.java:9

+ Here is the caller graph for this function:

static String WhiteBoard.Invoke.promptAndGet ( String  msg)
static

Definition at line 37 of file Invoke.java.

References WhiteBoard.Invoke.stdIn.

37  {
38  if (stdIn == null)
39  stdIn = new BufferedReader(new InputStreamReader(System.in));
40 
41  String s = null;
42  try {
43  System.out.print(msg + ": ");
44  System.out.flush();
45  s = stdIn.readLine();
46  } catch (Exception e) {e.printStackTrace();}
47  if (s == null || s == "") s = "empty";
48  return s;
49  }
static BufferedReader stdIn
Definition: Invoke.java:10
static void WhiteBoard.Invoke.setJavaCmdPath ( String  s)
static

Definition at line 26 of file Invoke.java.

References WhiteBoard.Invoke.javaCmd.

26  {
27  javaCmd = s;
28  }
static String javaCmd
The following Srings isolate path related issues.
Definition: Invoke.java:15

Member Data Documentation

final String WhiteBoard.Invoke.classNames[] = {serverClass, clientClass,linesClass}
staticprivate

Definition at line 24 of file Invoke.java.

Referenced by WhiteBoard.Invoke.javaVM().

final String WhiteBoard.Invoke.clientClass = "WhiteBoard.WbClientImpl"
staticprivate

Definition at line 21 of file Invoke.java.

String WhiteBoard.Invoke.javaCmd = "java"
staticprivate

The following Srings isolate path related issues.

Definition at line 15 of file Invoke.java.

Referenced by WhiteBoard.Invoke.javaVM(), and WhiteBoard.Invoke.setJavaCmdPath().

final String WhiteBoard.Invoke.linesClass = "WhiteBoard.LinesFrameImpl"
staticprivate

Definition at line 22 of file Invoke.java.

int WhiteBoard.Invoke.pid = 0
staticprivate

Definition at line 11 of file Invoke.java.

Referenced by WhiteBoard.Invoke.javaVM().

final String WhiteBoard.Invoke.rmiRegistryPfx = "//localhost/"
staticprivate

Definition at line 19 of file Invoke.java.

Referenced by WhiteBoard.Invoke.makeURL().

final String WhiteBoard.Invoke.serverClass = "WhiteBoard.WbServerImpl"
staticprivate

Definition at line 20 of file Invoke.java.

BufferedReader WhiteBoard.Invoke.stdIn
staticprivate

Definition at line 10 of file Invoke.java.

Referenced by WhiteBoard.Invoke.promptAndGet().

int WhiteBoard.Invoke.verbosity = 1
static

Definition at line 9 of file Invoke.java.

Referenced by WhiteBoard.Invoke.myPrint().


The documentation for this class was generated from the following file:
Copyright © 2014 www.wright.edu/~pmateti;   thanks to doxygen