|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.cometway.props.Props
com.cometway.ak.Agent
com.cometway.ak.ServiceAgent
com.cometway.httpd.WebServerExtension
com.cometway.httpd.HTTPFileServerAgent
com.cometway.httpd.HTTPThrottledFileServer
public class HTTPThrottledFileServer
This agent is used by the WebServer to handle requests for HTML files and other static documents from the file system. It is a subclass of the HTTPFileServerAgent and used in place of the HTTPFileServerAgent when content needs to be throttled at a certain bandwidth. This agent provides additional options for logging the amount of bandwidth used, limiting the maximum number of concurrent downloading sessions, and the ammount of bandwidth each connection can use.
| Field Summary | |
|---|---|
protected int |
currentSessions
|
protected java.lang.String |
html_directory
|
protected java.io.FileWriter |
logOut
|
protected java.lang.Object |
sync
|
| Fields inherited from class com.cometway.ak.Agent |
|---|
agent_id, agentController, CREATING_STATE, debugReporter, DESTROYED_STATE, DESTROYING_STATE, errorReporter, FAILED_STATE, printlnReporter, props, RUNNING_STATE, STARTING_STATE, STOPPED_STATE, STOPPING_STATE, warningReporter |
| Constructor Summary | |
|---|---|
HTTPThrottledFileServer()
|
|
| Method Summary | |
|---|---|
protected boolean |
addSession()
This method is used to internally track the number of active sessions. |
void |
initProps()
Initializes this agent's properties by providing default values for each of the following missing properties: "service_name" is used to register this agent with the Service Manager (default: HTTPThrottledFileServer), "html_directory" points to the root directory where HTML files are served (default: ./), "default_index" is the default file served when no filename is specified (default: index.html), "allow_directory_lists" when enabled, allows this agent to display links to files in a directory (default: yes) "max_sessions" denotes the maximum amount of concurrent connections downloading content at a single time (default: 4) "max_bandwidth" denotes the amount of bytes per second allowed for each connection (default: 5000) "log_file" denotes the file which bandwidth usage is to be logged (default: downloads.log) |
protected void |
printLog(java.lang.String logString,
HTTPAgentRequest request)
This method is used by this Agent to log bandwidth related information to the log file. |
protected void |
printTryAgain(HTTPAgentRequest request)
This method generates the message when the maximum number of connections has been reached. |
protected void |
removeSession()
This method is used to internally track the number of active sessions. |
protected void |
sendFile(java.io.File file,
HTTPAgentRequest request)
|
void |
start()
Registers Server and sets up directories, url's, etc. |
void |
stop()
Unregisters this instance with the service manager using the service_name property. |
| Methods inherited from class com.cometway.httpd.HTTPFileServerAgent |
|---|
generateDirectoryList, handleRequest, isKeepAlive, printRedirect |
| Methods inherited from class com.cometway.ak.Agent |
|---|
currentStateEquals, debug, destroy, error, error, getAgentController, getDateTimeStr, getProps, getServiceImpl, getStateMachineModel, println, register, registerService, setAgentController, setProps, toString, unregister, unregisterService, warning, warning |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String html_directory
protected int currentSessions
protected java.lang.Object sync
protected java.io.FileWriter logOut
| Constructor Detail |
|---|
public HTTPThrottledFileServer()
| Method Detail |
|---|
public void initProps()
initProps in interface AgentInterfaceinitProps in class HTTPFileServerAgentpublic void start()
start in interface AgentInterfacestart in class HTTPFileServerAgentpublic void stop()
ServiceAgent
stop in interface AgentInterfacestop in class ServiceAgentprotected boolean addSession()
protected void removeSession()
protected void sendFile(java.io.File file,
HTTPAgentRequest request)
throws java.io.IOException
sendFile in class HTTPFileServerAgentjava.io.IOExceptionprotected void printTryAgain(HTTPAgentRequest request)
protected void printLog(java.lang.String logString,
HTTPAgentRequest request)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||