com.cometway.httpd
Class HTTPSetProperty

java.lang.Object
  extended by com.cometway.props.Props
      extended by com.cometway.ak.Agent
          extended by com.cometway.ak.ServiceAgent
              extended by com.cometway.httpd.WebServerExtension
                  extended by com.cometway.httpd.HTTPSetProperty
All Implemented Interfaces:
AgentInterface, HasStateMachineModel

public class HTTPSetProperty
extends WebServerExtension

This WebServerExtension reads in a file of patterns and properties pairs, separated by a space. The patterns are regular expressions and will be applied to the entire request header (the 'request' property in the HTTPAgentRequest). If there is a match the name/value pair given will be set in the HTTPAgentRequest. If the value of the name/value pair is '$MATCH', the value will be the matched String. All patterns are checked even if there are multiple matches. This WebServerExtension will always pass through regardless of any matches. Example match file: Firefox/2.0.0.8 browser_type=newest firefox Mozilla/[0-9]\.[0-9] mozilla_version=$MATCH The 'browser_tyoe' property will be set to 'newest firefox' if the String 'Firefox/2.0.0.8' appears anywhere in the HTTP request header. The 'mozilla_version' property will be set to the matching String if 'Mozilla/[0-9\.[0-9]' matches anything in the HTTP request header.


Field Summary
 
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
HTTPSetProperty()
           
 
Method Summary
 boolean handleRequest(HTTPAgentRequest request)
          This will be called by the WebServer (specifically the ConnectionKMethod) to handle an HTTPAgentRequest.
 void initProps()
          Override this method to initialize this agent's properties before it is started.
 void readMatchFile()
           
 void start()
          This method inherited from com.cometway.ak.ServiceAgent includes functionality to register itself with the WebServer (temporary).
 void stop()
          Unregisters this instance with the service manager using the service_name property.
 
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 com.cometway.props.Props
addListener, append, copy, copyFrom, copyTo, decrementInteger, dump, enableListeners, enumerateKeys, format, getBoolean, getByteArray, getCharacter, getDate, getDate, getDateString, getDouble, getFloat, getHexString, getInteger, getKeys, getLong, getNextKey, getProperty, getProperty, getPropsContainer, getSize, getString, getString, getTokens, getTokens, getTrimmedString, getVector, hasProperty, incrementInteger, insertProps, loadProps, notifyPropsChanged, notifyPropsChangedIgnore, notifyPropsChangedIgnore, parse, propertyMatchesRegEx, readFromFile, regExPropertyMatches, removeAll, removeListener, removeProperty, resumeNotify, saveProps, set, setBoolean, setCharacter, setDefault, setDouble, setFloat, setInteger, setLong, setProperty, setProperty, setProperty, setPropsContainer, suspendNotify, writeToFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HTTPSetProperty

public HTTPSetProperty()
Method Detail

initProps

public void initProps()
Description copied from class: Agent
Override this method to initialize this agent's properties before it is started.

Specified by:
initProps in interface AgentInterface
Overrides:
initProps in class Agent

start

public void start()
Description copied from class: WebServerExtension
This method inherited from com.cometway.ak.ServiceAgent includes functionality to register itself with the WebServer (temporary).

Specified by:
start in interface AgentInterface
Overrides:
start in class WebServerExtension

stop

public void stop()
Description copied from class: ServiceAgent
Unregisters this instance with the service manager using the service_name property.

Specified by:
stop in interface AgentInterface
Overrides:
stop in class ServiceAgent

readMatchFile

public void readMatchFile()

handleRequest

public boolean handleRequest(HTTPAgentRequest request)
Description copied from class: WebServerExtension
This will be called by the WebServer (specifically the ConnectionKMethod) to handle an HTTPAgentRequest. If the request has been handled, true is returned and no other WebServerExtensions will be used.

Overrides:
handleRequest in class WebServerExtension