Fido Alpha 3.2

fido.frontend
Class FidoMessage

java.lang.Object
  |
  +--fido.frontend.FidoMessage

public class FidoMessage
extends java.lang.Object

Singleton class used by classes in the FidoServer to send debug messages back to the client. This class contains all static methods that can be accessed without an instance of FidoMessage.

The FidoMessage class uses the name of Java thread as a key into a Hashtable that maps to a FidoSession object. The FidoSession object holds the PrintWriter that is used to communicate debug messages back to the client.

Each call from a client creates a new Java thread in the server. A call to bindFrontEnd() stores the name of the Java thread in the hash table with a new instance of FidoMessageWriter. Within the thread, a call to either log() or logException() will print the string to the PrintWriter for the client.

See Also:
FidoMessageWriter, FidoSession

Method Summary
static void bindFrontEnd(java.io.PrintWriter out)
          Binds the name of the current Java thread to a PrintWriter so any message genereated within this thread will be passed back to the client.
static void bindFrontEnd(java.io.PrintWriter out, java.lang.String htmlContext)
          Binds the name of the current Java thread to a PrintWriter so any message genereated within this thread will be passed back to the client.
static void log(java.lang.String msg)
          Logs a string message back to the client.
static void logException(java.lang.Exception ex)
          Logs an exception back to the client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

bindFrontEnd

public static void bindFrontEnd(java.io.PrintWriter out)
Binds the name of the current Java thread to a PrintWriter so any message genereated within this thread will be passed back to the client.

First, sets the name of the current Java thread within the server to the current time in milliseconds, converted to a string. This is used as a key into a hashtable to retrieve an instance of a FidoMessageWriter. There is one one FidoMessageWriter for each user connected to the server.

The PrintWriter parameter can be the stream passed to a servlet, as in the DebugFrontEnd, or System.out, which will print any message to the system console where the application server is running. This is used for debug programs such as ART.

Parameters:
out - The PrintWriter class that will send the message back to the client.
See Also:
FidoMessageWriter

bindFrontEnd

public static void bindFrontEnd(java.io.PrintWriter out,
                                java.lang.String htmlContext)
Binds the name of the current Java thread to a PrintWriter so any message genereated within this thread will be passed back to the client.

This method performs the same task as bindFrontEnd(PrintWriter), except an htmlContext is passed. This parameter is used to generate relative links for web pages, such as links to the help pages.

Parameters:
out - The PrintWriter class that will send the message back to the client.
htmlContext - The html context, which is the part of the URL between the hostname and the sevlet which is running.
See Also:
bindFrontEnd(PrintWriter)

log

public static void log(java.lang.String msg)
Logs a string message back to the client. If the client is an HTML page, a <BR> tag is appended.

Parameters:
msg - String to pass back to the client.

logException

public static void logException(java.lang.Exception ex)
Logs an exception back to the client. If the client is an HTML page, the exception is converted to HTML by converting the exception name to a link into the help system, then displaying the stack trace with <BR> tags appended to each line.

This is the method that uses the htmlContext from the constructor to reference the correct HTTP path to the help system.

This classes uses an HtmlExceptionWriter to convert the Exception.

Parameters:
ex - Exception to pass back to the client.
See Also:
HtmlExceptionWriter

Fido Alpha 3.2