org.spicefactory.cinnamon.service
Class ServiceMessage

java.lang.Object
  extended by org.spicefactory.cinnamon.service.ServiceMessage
All Implemented Interfaces:
Externalizable
Direct Known Subclasses:
ServiceRequest, ServiceResponse

public abstract class ServiceMessage
extends Object
implements Externalizable

Common abstract base class for ServiceRequest and ServiceResponse. Implements org.spicefactory.cinnamon.io.Externalizable so that subclasses can be mapped to the corresponding ActionScript 3 classes. Allows retrieving and modifying of message headers. Those headers do not relate to HTTP headers or AMF0 headers. They can be set on the client side with Cinnamons Client API and can be used on the server side in ServiceInterceptors. This allows to add information like credentials without polluting the API of the services with those parameters.

Author:
Jens Halm

Constructor Summary
protected ServiceMessage()
          Creates a new ServiceMessage.
 
Method Summary
 Set<String> getHeaderNames()
          Returns an unmodifiable Set containing all header names for this message.
 Object getHeaderValue(String name)
          Returns the header value for the given name.
 void readExternal(DataInput in)
          Restores the content of this object from the DataInput instance.
 void removeHeader(String name)
          Removes the header for the given name.
 void setHeader(String name, Object value)
          Sets a header for this message.
 void writeExternal(DataOutput out)
          Saves the content of this object to the DataOutput instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceMessage

protected ServiceMessage()
Creates a new ServiceMessage.

Method Detail

setHeader

public void setHeader(String name,
                      Object value)
Sets a header for this message. This is a custom message header and does not relate to HTTP headers or AMF0 headers.

Parameters:
name -
value -

removeHeader

public void removeHeader(String name)
Removes the header for the given name.

Parameters:
name - the name of the header to remove

getHeaderNames

public Set<String> getHeaderNames()
Returns an unmodifiable Set containing all header names for this message.

Returns:
an unmodifiable Set containing all header names for this message

getHeaderValue

public Object getHeaderValue(String name)
Returns the header value for the given name. This is a custom message header and does not relate to HTTP headers or AMF0 headers.

Parameters:
name - the name of the header
Returns:
the header value for the given name or null if no such header exists

readExternal

public void readExternal(DataInput in)
Description copied from interface: Externalizable
Restores the content of this object from the DataInput instance. Values must be read in the same sequence as they were written on the client side.

Specified by:
readExternal in interface Externalizable
Parameters:
in - the AMF3 data to read from

writeExternal

public void writeExternal(DataOutput out)
Description copied from interface: Externalizable
Saves the content of this object to the DataOutput instance.

Specified by:
writeExternal in interface Externalizable
Parameters:
out - the output to write to