Java Reference
In-Depth Information
L ISTING 6.4 Continued
6
}
String policy = clientRecord[0];
String installedVersion = clientRecord[1];
String replaceItems = clientRecord[2];
String launchClass = clientRecord[3];
if (launchClass==null)
launchClass = “”;// for protocol's sake
System.out.println( header + “CHECK: for client: “+
clientId+”,\n\t policy: “+
policy+”,\n\t installedVersion: “+
installedVersion+”,\n\t replaceItems=”+
replaceItems+”,\n\t
launchClass=”+launchClass);
if (policy.equals(NEWEST_POLICY)) {
// the client is required to download the new version
String[] items = getItems(replaceItems);
out.writeInt(items.length);
File f;
for (int i = 0; i < items.length; i++) {
f = new File(SERVER_DIR + items[i]);
out.writeUTF(items[i]);
int size = (int)f.length();
out.writeInt(size);
FileInputStream fis = new FileInputStream;
sendToClient(new DataInputStream(fis), items[i]);
}
} else if (policy.equals(NO_DOWNLOADS_POLICY)) {
out.writeInt(0);
}
//last, notify to the client the new main class, if any
out.writeUTF(launchClass);
} catch (IOException e) {
System.out.println( header + “executeCheck: “+e);
System.exit(1);
}
}
/**
* It obtains tokens from a string
*/
private String[] getItems(String s){
Search WWH ::




Custom Search