|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object mmhttp.server.ResponderFactory
public class ResponderFactory
The spawning place of all Responders.
Every Server will have an instance of a ResponderFactory. The role of the ResponderFactory is to create a Responder based on the resource requested. Users must therefore register their customer Responders along with a regular expresion to describe resources that should be handled by the Responder.
Responder
,
Server
Field Summary | |
---|---|
java.lang.Class |
defaultResponder
Used in the event that none of the registered Responders match a request. |
Constructor Summary | |
---|---|
ResponderFactory()
|
Method Summary | |
---|---|
void |
register(java.lang.String regex,
java.lang.Class klass)
Use this method to register your custom Responders. |
java.lang.Class |
responderClassFor(java.lang.String resource)
This method is used to retreives the first matching Responder class for a given resource. |
Responder |
responderFor(java.lang.String resource)
This will find the correct Responder for the resource and construct it using the default constructor. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public java.lang.Class defaultResponder
Constructor Detail |
---|
public ResponderFactory()
Method Detail |
---|
public void register(java.lang.String regex, java.lang.Class klass)
Use this method to register your custom Responders. Note: The Server has a convenience method to register Responders so you need not use this menthod directory.
To register a Responder you pass in a regular expression String and a Responder class.
For example: server.responderFactory.register("abc\d{3}", AlphaNumericResponder.class)
This will cause all incoming requests for 'abc' follow by 3 digits to be handled by an instance of
AlphaNumericResponder.
The order in which Responder are registere is important. Since a given request may match multiple regular expressions, the factory will follow a simple 'first come, first served' policy. That is the first registered Responder to match the requested resource will be instantiated to process the request.
regex
- klass
- public java.lang.Class responderClassFor(java.lang.String resource)
resource
-
public Responder responderFor(java.lang.String resource) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.InstantiationException
resource
-
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.InstantiationException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |