HOWTO's Home Development CORK Current users: guest (web) guest (web) guest (web) |
Starting a ServerAll CORK-based applications require that a server object be created to listen for client connections, manage persistent copies of replicated objects, handle requests for replicated object retrieval, and process modifications to replicated objects. The key components of the CORK server are the same across all CORK-based applications. This example below shows how to write a simple CORK server application. The standard CORK server implementation is class edu.vt.cs.collab.cork.impl.inet.ServerImpl. This class uses file-based storage and listens for both HTTP and TCP connections. Its constructor requires five arguments:
1 import edu.vt.cs.collab.cork.impl.inet.ServerImpl;
2
3 /**
4 * Simple CORK server, with little error handling. Should be
5 * executed with port number as an argument.
6 */
7 public class Server {
8
9 public Server(int port) {
10 try {
11 ServerImpl server = new ServerImpl(
12 port, // port the server listens on
13 "DATA", // directory the server stores object data in
14 2, // Depth of storage directories
15 true, // support http connections
16 10 * 60); // purge idle objects every 10 minutes
17 }
18 catch(Exception e) {
19 System.err.println("Server startup failed: ");
20 e.printStackTrace();
21 }
22 }
23
24 public static void main(String[] args) {
25 int port = Integer.parseInt(args[0]);
26 Server s = new Server(port);
27 }
28
29
30 }
Executing:csh> java Server 1500would start a CORK server that listened on port 1500. Note that it is not necessary to inform the server of the kinds of objects that it will be replicating. It is, however, necessary that the class definitions ( .class files) be available in the server's classpath on the first request to retrieve an object of a given class.The server shown in Server.java includes no authentication support, so users could log on using any user id and password. To add authentication, an appropriate Authenticator class could be constructed and set using ServerImpl's setAuthenticator method. |
| /public/chci/howto/cork/server.html | Login | Web Editor | Full Editor |
| Last modified 5/22/03 3:15 PM by isenhour (history) Site contents | |