Java Reference
In-Depth Information
public abstract class
DParser {
protected
DProcess process
#
null
;
// a reference to the control module
public void
setProcess(DProcess process) {
this
.process
#
process;
}
public abstract
DActivity getActivity(String parameters);
public abstract void
decode(String message);
public abstract
StringBuffer encode(DEvent event);
}
19.6.4
Test
The test case develops the web-based version of the client
server applica-
tion presented in the previous prototypes. The client is represented by class
JoggingApplet
, which is an applet embedded in the HTML page reported in
Figure 19.10. When the applet is loaded in a web browser, it loads service
configuration parameters (server URL, socket port and runner's path) from
the HTML file and opens a socket connection with the remote server.
Class
Server
implements method
main()
which creates and starts an
instance of
SocketListener
. Class
RunnerParser
extends class
DParser
to encode
and decode socket messages.
-
package
jogging.server;
import
mmi.*;
import
mmi.sockets.*;
import
java.rmi.RemoteException;
import
java.util.*;
public class
Server
extends
DProcess
implements
ServerInterface{
private
String cells[]
#
{"", "", "", "", "", "", "", ""};
public
Server(String address, String name)
throws
java.rmi.RemoteException {
super
(address, name);
}
html
head
title
Jogging Applet
/title
/head
body
APPLET CODE
"jogging.client.JoggingApplet.class"
CODEBASE
"." WIDTH
"330" HEIGHT
"330"
PARAM NAME
HOST VALUE
"127.0.0.1"
PARAM NAME
PORT VALUE
"2002"
PARAM NAME
PATH VALUE
"4 3 5 6 7 4 3 0 1 2"
/APPLET
/body
/html
Figure 19.10
The HTML code that embeds the applet