org.w3c.www.protocol.http.cache.push
Class Client

java.lang.Object
  extended by org.w3c.www.protocol.http.cache.push.Client

public class Client
extends java.lang.Object

PushCache Client - send messages to push cache server


Field Summary
static java.lang.String DEFAULT_SERVER
          Default hostname - localhost
static int FAILED
          Return/exit values
static int MAX_TRIES
          How many times should we try to reconnect? 10
static int NO
          Return/exit values
static int OK
          Return/exit values
static java.lang.String VC_ID
          Version Control Id
static java.lang.String VC_REVISION
          Version Control Revision
 
Constructor Summary
Client()
          Construct a Client for the default hostname and port number
Client(java.lang.String[] argv)
          Construct client with command line arguments and execute command.
Client(java.lang.String hostname, int port)
          Construct a Client for the specified hostname and port number
 
Method Summary
 void add(java.lang.String path, java.lang.String url)
          Add file into cache as url
protected  void checkCommand(java.lang.String com)
          Throws IllegalArgumentException iff com is not a null terminated string of the correct length
 void clean()
          Clean cache - remove all entries
protected  void cleanup()
          Cleanup, shutdown and close socket and streams
protected  void connect()
          Connect to server - try up to MAX_TRIES times, then give up
 void del(java.lang.String url)
          Remove url from cache
protected  void handleArgs(java.lang.String[] argv)
          Interpret command line arguments
 boolean isPresent(java.lang.String url)
          True iff url is present in cache
static void main(java.lang.String[] argv)
          For use as stand alone program - constructs Client with argv
 void nop()
          Send a NOP packet
protected  void readPayload()
          Read remaining payload length bytes into buffer
protected  void readReply()
          Await reply packet
 void sendBye()
          Send a BYE packet, and cleanup
protected  void serverError()
          Handle an ERR message from server - cleanup, throw IOException
 void simpleCommand(java.lang.String com)
          Send a simple packet with specified command
protected  void unexpectedReply()
          Handle an unexpected message from server - send BYE, throw IOException
 void urlCommand(java.lang.String com, java.lang.String url)
          Send a packet with specified command and a url
protected  void usage()
          Display usage/help message
protected  void version()
          Display version information
protected  void writeHeader()
          Write header information into packet buffer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OK

public static final int OK
Return/exit values

See Also:
Constant Field Values

NO

public static final int NO
Return/exit values

See Also:
Constant Field Values

FAILED

public static final int FAILED
Return/exit values

See Also:
Constant Field Values

MAX_TRIES

public static final int MAX_TRIES
How many times should we try to reconnect? 10

See Also:
Constant Field Values

DEFAULT_SERVER

public static final java.lang.String DEFAULT_SERVER
Default hostname - localhost

See Also:
Constant Field Values

VC_REVISION

public static final java.lang.String VC_REVISION
Version Control Revision

See Also:
Constant Field Values

VC_ID

public static final java.lang.String VC_ID
Version Control Id

See Also:
Constant Field Values
Constructor Detail

Client

public Client()
Construct a Client for the default hostname and port number


Client

public Client(java.lang.String hostname,
              int port)
Construct a Client for the specified hostname and port number


Client

public Client(java.lang.String[] argv)
       throws java.io.IOException
Construct client with command line arguments and execute command. Called by main, for use as stand alone program - calls System.exit at the end of execution

Throws:
java.io.IOException
Method Detail

version

protected void version()
Display version information


usage

protected void usage()
Display usage/help message


handleArgs

protected void handleArgs(java.lang.String[] argv)
                   throws java.io.IOException
Interpret command line arguments

Throws:
java.io.IOException

connect

protected void connect()
                throws java.net.UnknownHostException,
                       java.io.IOException
Connect to server - try up to MAX_TRIES times, then give up

Throws:
java.net.UnknownHostException
java.io.IOException

writeHeader

protected void writeHeader()
                    throws java.io.IOException
Write header information into packet buffer

Throws:
java.io.IOException

readPayload

protected void readPayload()
                    throws java.io.IOException
Read remaining payload length bytes into buffer

Throws:
java.io.IOException

readReply

protected void readReply()
                  throws java.io.IOException
Await reply packet

Throws:
java.io.IOException

serverError

protected void serverError()
                    throws java.io.IOException
Handle an ERR message from server - cleanup, throw IOException

Throws:
java.io.IOException

unexpectedReply

protected void unexpectedReply()
                        throws java.io.IOException
Handle an unexpected message from server - send BYE, throw IOException

Throws:
java.io.IOException

cleanup

protected void cleanup()
Cleanup, shutdown and close socket and streams


sendBye

public void sendBye()
             throws java.io.IOException
Send a BYE packet, and cleanup

Throws:
java.io.IOException

add

public void add(java.lang.String path,
                java.lang.String url)
         throws java.io.IOException,
                java.lang.IllegalArgumentException
Add file into cache as url

Throws:
java.io.IOException
java.lang.IllegalArgumentException

checkCommand

protected void checkCommand(java.lang.String com)
                     throws java.lang.IllegalArgumentException
Throws IllegalArgumentException iff com is not a null terminated string of the correct length

Throws:
java.lang.IllegalArgumentException

urlCommand

public void urlCommand(java.lang.String com,
                       java.lang.String url)
                throws java.io.IOException,
                       java.lang.IllegalArgumentException
Send a packet with specified command and a url

Throws:
java.io.IOException
java.lang.IllegalArgumentException

del

public void del(java.lang.String url)
         throws java.io.IOException
Remove url from cache

Throws:
java.io.IOException

isPresent

public boolean isPresent(java.lang.String url)
                  throws java.io.IOException
True iff url is present in cache

Throws:
java.io.IOException

simpleCommand

public void simpleCommand(java.lang.String com)
                   throws java.io.IOException
Send a simple packet with specified command

Throws:
java.io.IOException

nop

public void nop()
         throws java.io.IOException
Send a NOP packet

Throws:
java.io.IOException

clean

public void clean()
           throws java.io.IOException
Clean cache - remove all entries

Throws:
java.io.IOException

main

public static void main(java.lang.String[] argv)
For use as stand alone program - constructs Client with argv