thinkmap.datasource.util
Class AbstractDataSource

java.lang.Object
  extended by thinkmap.datasource.util.AbstractDataSource
All Implemented Interfaces:
IDataSource
Direct Known Subclasses:
CompositeDataSource, DatabaseDataSource, FlatFileDataSource, RemoteDataSource

public abstract class AbstractDataSource
extends Object
implements IDataSource

AbstractDataSource helps with the creation of new datasources. It handles an incoming request by packaging it into a Message, which can be used to easily craft a response. It also calls beginMessage and endMessage, dispatching to request-type-specific methods which implement the logic of the datasource.

Version:
$Revision: 1.4 $
See Also:
Message

Constructor Summary
AbstractDataSource()
          Creates a new AbstractDataSource object.
 
Method Summary
 IEntityHandler createRequest(IEntityHandler callback)
          Create a request.
protected  void processCustomRequest(Message message, IEntityHandler callback)
          Handle a custom request.
protected  void processEntityRequest(Message message, IEntityHandler callback)
          Handle an Entity request.
protected  void processIdRequest(Message message, IEntityHandler callback)
          Handle an ID request.
protected  void processMetadataRequest(Message message, IEntityHandler callback)
          Handle a metadata request.
protected  void processRelatedRequest(Message message, IEntityHandler callback)
          Handle a related request.
protected  void processRequest(Message message, IEntityHandler callback)
          Dispatches to the request-type-specific method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDataSource

public AbstractDataSource()
Creates a new AbstractDataSource object.

Method Detail

createRequest

public IEntityHandler createRequest(IEntityHandler callback)
Description copied from interface: IDataSource
Create a request. The server and client's IEntityHandlers are linked.

Specified by:
createRequest in interface IDataSource
Parameters:
callback - The IEntityHandler that will recieve the response.
Returns:
The IEntityHandler for sending a request.

processRequest

protected void processRequest(Message message,
                              IEntityHandler callback)
Dispatches to the request-type-specific method.

Parameters:
message - The request as packaged into a message.
callback - The IEntityHandler which will receive the response.

processMetadataRequest

protected void processMetadataRequest(Message message,
                                      IEntityHandler callback)
Handle a metadata request.

Parameters:
message - The incoming request, packaged into a handy object.
callback - The IEntityHandler which will receive the response.

processIdRequest

protected void processIdRequest(Message message,
                                IEntityHandler callback)
Handle an ID request.

Parameters:
message - The incoming request, packaged into a handy object.
callback - The IEntityHandler which will receive the response.

processEntityRequest

protected void processEntityRequest(Message message,
                                    IEntityHandler callback)
Handle an Entity request.

Parameters:
message - The incoming request, packaged into a handy object.
callback - The IEntityHandler which will receive the response.

processRelatedRequest

protected void processRelatedRequest(Message message,
                                     IEntityHandler callback)
Handle a related request.

Parameters:
message - The incoming request, packaged into a handy object.
callback - The IEntityHandler which will receive the response.

processCustomRequest

protected void processCustomRequest(Message message,
                                    IEntityHandler callback)
Handle a custom request. Does nothing by default. Override this to handle requests that are not one of the four for which there are already specific methods.

Parameters:
message - The incoming request, packaged into a handy object.
callback - The IEntityHandler which will receive the response.


Copyright © 2013 Thinkmap, Inc. All Rights Reserved.