org.spicefactory.cinnamon.io
Class RequestProcessor

java.lang.Object
  extended by org.spicefactory.cinnamon.io.RequestProcessor

public class RequestProcessor
extends Object

The core processing class of the framework. Processes incoming AMF3 requests and returns the corresponding AMF3 results. The implementation is completely independent of the Servlet API and HTTP protocol. So this class may be used in Unit Tests that run outside a Servlet container or in unusual deployment scenarios. For example the Cinnamon framework may also be used for a Socket server, since the new binary Socket class introduced in Flash Player 9 supports AMF3 too.

Author:
Jens Halm

Constructor Summary
RequestProcessor(CinnamonConfig config)
          Creates a new RequestProcessor.
 
Method Summary
 CinnamonConfig getConfig()
          Returns the Cinnamon configuration instance this RequestProcessor uses.
 org.apache.mina.common.ByteBuffer process(org.apache.mina.common.ByteBuffer in)
          Processes a single AMF request.
 MessageHolder process(MessageHolder requestMessage, Exception ex)
          Processes a single service request and returns the result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestProcessor

public RequestProcessor(CinnamonConfig config)
Creates a new RequestProcessor.

Parameters:
config - the Cinnamon configuration instance to use
Method Detail

getConfig

public CinnamonConfig getConfig()
Returns the Cinnamon configuration instance this RequestProcessor uses.

Returns:
the Cinnamon configuration instance this RequestProcessor uses

process

public org.apache.mina.common.ByteBuffer process(org.apache.mina.common.ByteBuffer in)
Processes a single AMF request. The given ByteBuffer contains the full AMF request, consisting of the AMF0 shell/envelope containing one or more AMF3 bodies (the Flash Player may wrap multiple request in a single AMF0 envelope). As the core framework operates indepentently from the Servlet API and HTTP protocol the ByteBuffer does not contain any HTTP headers. The returned ByteBuffer must contain the serialized service result for each AMF3 body of the request wrapped in a single AMF0 envelope. Like the request the response must not contain any HTTP headers. The implementation calls ServiceResponse process (ServiceRequest request) for each AMF3 encoded ServiceRequest instance contained in the AMF0 envelope.

Parameters:
in - the AMF3 request
Returns:
the AMF3 result

process

public MessageHolder process(MessageHolder requestMessage,
                             Exception ex)
Processes a single service request and returns the result. For an AMF request sent by the Flash Player through a NetConnection instance this method may be invoked multiple times, as the Player may bundle multiple request into a single envelope.

Parameters:
requestMessage - the decoded request message to process
ex - an Exception that was caught while processing the message (null if processing succeeded)
Returns:
the response message