com.franz.jlinker
Class LispConnector

java.lang.Object
  |
  +--com.franz.jlinker.LispConnector

public class LispConnector
extends java.lang.Object

The purpose of this class is to hold in one place all the parameters that determine a connection between Lisp and Java.

One way to use this class is to modify the parameters as needed, and then call the go() method.

Another is to create a sub-class with method that modifies the values in this class and then calls the go() method in this class.

There are four ways for Lisp and Java to establish a connection:

Field ABCD
lispAdvertises true true falsefalse
advertInFile falsetrue falsetrue
lispFile --- used --- ---
lispHost used --- --- ---
lispPort used --- --- ---
javaFile --- --- --- used
javaHost used used --- used
javaPort used used used used
pollInterval used used --- ---
pollCount used used --- ---
javaTimeout --- --- used used


Field Summary
static boolean advertInFile
          Who advertises and who connects.
static boolean debug
          Debug flag.
static java.lang.String javaFile
          The file where Java advertises a connection.
static java.lang.String javaHost
          The host where the Java application is running.
static int javaPort
          A port number.
static int javaTimeout
          How long should Java advertise.
static boolean lispAdvertises
          The value of this field determines who advertises and who connects to the advertised connection.
static java.lang.String lispFile
          The file where Lisp advertises a connection.
static java.lang.String lispHost
          The host where Lisp expects a connection.
static int lispPort
          The port where Lisp expects a connection.
static int pollCount
          How many times to attempt making a connection.
static int pollInterval
          How often to attempt making a connection.
 
Constructor Summary
LispConnector()
           
 
Method Summary
static boolean go()
          Connect to a Lisp process.
static boolean go(boolean ver)
          Connect to a Lisp process.
static boolean go(boolean ver, java.lang.String[] throwErr)
          Connect to a Lisp process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lispAdvertises

public static boolean lispAdvertises
The value of this field determines who advertises and who connects to the advertised connection.

If the value is true (the initial value), then Lisp advertises and the Java program connects to the advertised connection.

If the value is false, then Java must advertise and the Lisp program will connect.


advertInFile

public static boolean advertInFile
Who advertises and who connects. The value of this field determines how a connection is advertised.

If the value is false (the initial value), then the host and port of the connection are known to the client application.

If the value is true, then the host and port of the connection are stored in a file visible to the client application.


lispFile

public static java.lang.String lispFile
The file where Lisp advertises a connection. The value of this field is used if lispAdvertises is true and advertInFile is true.

The value must be a string containing the path to the file.

The inital value is "", the empty string, which denotes the built-in default file "JavaToLisp.trp".


lispHost

public static java.lang.String lispHost
The host where Lisp expects a connection. The value of this field is the name of the host where the Lisp application is running. The value of this field is used if lispAdvertises is true and advertInFile is false.

The value must be a string containing a hostname.

The inital value is "", the empty string, which denotes the built-in default host "localhost".


lispPort

public static int lispPort
The port where Lisp expects a connection. The value of this field is the integer port number where the Lisp application is advertising. The value of this field is used if lispAdvertises is true and advertInFile is false.

The value must be a positive integer.

The initial value is 4321.


pollInterval

public static int pollInterval
How often to attempt making a connection. The value of this field is the integer number of milliseconds between attempts to connect when the Lisp application is advertising.

The initial value is 1000.

A value of -1 specifies that only one attempt will be made.


pollCount

public static int pollCount
How many times to attempt making a connection. The value of this field is the number of connection attempts when the Lisp application is advertising and pollInterval is positive.

javaTimeout

public static int javaTimeout
How long should Java advertise. The value of this field is an integer, the number of seconds the Java application will advertise.

The initial value is -1. This value denotes an indefinite time.


javaFile

public static java.lang.String javaFile
The file where Java advertises a connection. The value of this field is used if lispAdvertises is false and advertInFile is true.

The value must be a string containing the path to the file.

The inital value is "", the empty string, which denotes the built-in default file "LispToJava.trp".


javaHost

public static java.lang.String javaHost
The host where the Java application is running.

The inital value is "", the empty string, which denotes the built-in default host "localhost".

If Lisp advertises and Java connects, then this field must be set correctly to allow Lisp to complete the connection.

If Java advertises at a pre-determined port, then this field is not used.

If Java advertises in a file, then this field must be set correctly to allow Lisp to complete the connection.


javaPort

public static int javaPort
A port number.

The initial value is 0 to allow the operating system to allocate a port number.

If Lisp advertises and Java connects, then this field may be set to 0.

If Java advertises at a pre-determined port, then this field must be set to that port number.

If Java advertises in a file, then this field may be set to 0.


debug

public static boolean debug
Debug flag.

When the value of this field is true, the jlinker methods print status messages to show the progress of a connection.

The initial value is false.

Constructor Detail

LispConnector

public LispConnector()
Method Detail

go

public static boolean go()
Connect to a Lisp process. The static fields in the class determine how to connect.
Equivalent to go(false, null);

If the connection succeeds, the method returns true.

If the connection fails, the method throw an instance of IllegalArgumentException.

Returns:
true when the connection is made.
Throws:
java.lang.IllegalArgumentException - if the connection attempt fails.

go

public static boolean go(boolean ver)
Connect to a Lisp process. The static fields in the class determine how to connect.
Equivalent to go(ver, null);
Parameters:
ver - A boolean value that specifies whether the connection should be verified.

If true, verify the connection with a rount-trip message.

If false, return as soon as the connection is made.

Returns:
true when the connection is made.
Throws:
java.lang.IllegalArgumentException - if the connection attempt fails.

go

public static boolean go(boolean ver,
                         java.lang.String[] throwErr)
Connect to a Lisp process. The static fields in the class determine how to connect.
Parameters:
ver - A boolean value that specifies whether the connection should be verified.

If true, verify the connection with a rount-trip message.

If false, return as soon as the connection is made.

throwErr - If this parameter is null, throw an instance of IllegalArgumentException if the attempt to connect fails.

If the parameter is an array of String with at least one element, then store an error message in throwErr[0].

Returns:
If the connection was made, return true. Otherwise return false.