Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

raining.server
Class AdvServer  view AdvServer download AdvServer.java

java.lang.Object
  extended byraining.core.NioSocket
      extended byraining.server.AdvServer

public class AdvServer
extends raining.core.NioSocket

A more functional server that permits handlers and protocols to be defined and passed in. TODO: refactor the http processing out of here, so it can be reused. TODO: read from priority file TODO: handle different mime-types. ?? TODO: handle errors 400: if request not a GET TODO: 304 if not modified since TODO: send last-modified TODO: try later, and close if beyond a limit TODO: flow control, if beyond a limit, rather than just close conn TODO: take care of absolute URL


Field Summary
protected  int conf_max_connections
           
protected  int conf_try_later
           
static java.lang.String defaultfile
          the name of the default file to be served in / given in http request.
 boolean handle_priority_on_accept
          flag to denote whether priority handling is to be done.
static byte[] http503response
           
private static java.lang.String P
           
static boolean precalcheaders
          are we precalculating headers, are we using "stale" headers.
 PriorityHandler priorityHandler
           
protected  int rejectcount
           
static java.util.Properties serverProps
           
 
Fields inherited from class raining.core.NioSocket
acceptcount, acceptctr, activeSocketCount, ADD_EVENT, conncount, connctr, crcount, ctcount, debug, DEL_EVENT, id, READ_BUFFER_SIZE, readcount, REPORT_AFTER, rsb, selector, stopWhenIdle, totalBytesRead, WRITE_BUFFER_SIZE, writecount
 
Constructor Summary
AdvServer(java.lang.String host, int port)
          Constructor taking port and host of server to connect to.
 
Method Summary
 void handle_accept()
          when a connection is accepted, create a new NIO object for the incoming socket.
static void main(java.lang.String[] args)
           
 void setPriorityHandler(PriorityHandler ph)
          set the given handler as a priorityHandler.
 void setServerProperties(java.util.Properties props)
          Set the properties file to be used by the server.
 
Methods inherited from class raining.core.NioSocket
accept_accounting, accept, add_to_map, channel, clear_read_buffer, conn_reset_handler, conn_time_out_handler, connect_accounting, create_client_socket, create_client_socket, create_server_socket, del_from_map, getReadData, getReadDataAsBuffer, getReadDataAsString, handle_close, handle_connect, handle_read_complete, handle_read_complete, handle_read_event, handle_read, handle_terminator, handle_write_complete, handle_write_event, handle_write, is_read_complete, nio_close, on_exit_handler, readable, recv, resetSocketCounter, send, serverflag, setDebug, setReadBufferSize, setSendData, setSendData, setSendData, setWriteBufferSize, socketCount, socketCountChangeEvent, start, start, stop_now, stopWhenIdle, stopWhenIdle, writeable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

http503response

public static final byte[] http503response

P

private static final java.lang.String P
See Also:
Constant Field Values

handle_priority_on_accept

public boolean handle_priority_on_accept
flag to denote whether priority handling is to be done.


priorityHandler

public PriorityHandler priorityHandler

precalcheaders

public static final boolean precalcheaders
are we precalculating headers, are we using "stale" headers. this should be from a props file.

See Also:
Constant Field Values

defaultfile

public static final java.lang.String defaultfile
the name of the default file to be served in / given in http request. TODO this is to be picked from server.properties.

See Also:
Constant Field Values

serverProps

public static java.util.Properties serverProps

rejectcount

protected int rejectcount

conf_try_later

protected int conf_try_later

conf_max_connections

protected int conf_max_connections
Constructor Detail

AdvServer

public AdvServer(java.lang.String host,
                 int port)
          throws java.lang.Exception
Constructor taking port and host of server to connect to. It will listen on port on localhost.

Method Detail

main

public static void main(java.lang.String[] args)

setServerProperties

public void setServerProperties(java.util.Properties props)
Set the properties file to be used by the server.


handle_accept

public void handle_accept()
when a connection is accepted, create a new NIO object for the incoming socket.


setPriorityHandler

public void setPriorityHandler(PriorityHandler ph)
set the given handler as a priorityHandler.