Java Reference
In-Depth Information
(see lines 104-106 in Listing 6.4). This is only a cosmetics operation that will help us only to
clarify the role of the two different server threads. Now, “ Thread-0 ”in line 2 of Listing 6.9
becomes “ Deployment-Thread-0 ”in the following lines.
In lines 3-11 of Listing 6.9, the CHECK command is carried out by the server. Consequently,
the files sent by the server are saved in the client cache (lines 1-4 in Listing 6.8).
The client execution continues, and the application classes are loaded in, using our
BankClientLoader (lines 5-8 in Listing 6.8). Then, the client application is launched (line 9 of
Listing 6.8), and a connection with another server thread (only for business transactions) is
established (line 12 of Listing 6.9). From now on, the BankClient class is executed (or, to be
precise, created, as reported in lines 22-23 of Listing 6.8).
The example transaction is composed of three steps:
1.
Requesting a resource from the classloader (that resource is not present in cache at first,
so it has to be downloaded from the server, see lines 15, 16 of Listing 6.8). Then, the file
content is printed on the output stream (line 18 of Listing 6.8).
2.
A class is loaded using the Java dynamic loading feature (see line 37 in Listing 6.7). This
was done essentially to fool the compiler during development time. Otherwise, it would
have asked for the class Clazz , which would complicate the deployment stage because
we should have had to separate this compiled class from the others.
3.
Finally, a sample business command is issued at line 39 in Listing 6.7. The server
receives the POST command at line 15 of Listing 6.9.
Then, after the BankClient class ends the transaction, all data structures are shut down, and the
ApplicationHelper itself finishes execution (last line of Listing 6.8) while the server process
will wait for accepting new connections.
L ISTING 6.9 The Server Output
BankServer - Waiting for Connections.
BankServer[Thread-0] - Connection Accepted.
BankServer[Deployment-Thread-0] - CHECK: for client: client0,
policy: newest,
installedVersion: 1.0,
replaceItems=BankClient.class;downloadPolicy.properties;Clazz.class;
BankClientLoader.java,
launchClass=com.marinilli.b2.c6.bank.BankClientBankServer[Deployment-
Thread-0] - sendToClient. BankClient.class
BankServer[Deployment-Thread-0] - sendToClient. downloadPolicy.properties
BankServer[Deployment-Thread-0] - sendToClient. Clazz.class
BankServer[Deployment-Thread-0] - sendToClient. BankClientLoader.java
Search WWH ::




Custom Search