thinkmap.datasource.stream
Class RemoteDataSource

java.lang.Object
  extended by thinkmap.datasource.util.AbstractDataSource
      extended by thinkmap.datasource.stream.RemoteDataSource
All Implemented Interfaces:
EventListener, IContextListener, IDataSource

public class RemoteDataSource
extends AbstractDataSource
implements IContextListener

The remote datasource acts as a proxy for another datasource over a network. The other datasource does the actual work of answering requests; all this does is package and stream requests and responses over the network.

Version:
$Revision: 1.13 $

Nested Class Summary
protected  class RemoteDataSource.URLStreamFactory
           
 
Field Summary
static String INITIAL_REQUEST
           
 
Constructor Summary
RemoteDataSource()
          Creates a new RemoteDataSource object.
RemoteDataSource(URL url)
          Creates a new RemoteDataSource object.
 
Method Summary
 void contextDestroyed(IThinkmapContext itc)
          Called when the given context has been destroyed.
 void contextInitializing(IThinkmapContext context)
          Called when the given context is initializing.
 void contextStarting(IThinkmapContext itc)
          Called when the given context is starting.
 void contextStopping(IThinkmapContext itc)
          Called when the given context is stopping.
 IEntityHandler createRequest(IEntityHandler callback)
          Create a request.
protected  IStreamFactory createStreamFactory(IEntityHandler callback)
           
 boolean getCompressed()
          Determine if requests are compressed when possible.
 URL getURL()
          Get the URL this datasource communicates with.
 void setCompatabilityMode(boolean b)
          Set compatibility mode on or off.
 void setCompressed(boolean b)
          Set whether or not the request should be compressed when possible.
 void setConfig(ThinkmapConfig config)
           
 void setStreamFormat(IStreamFormat streamFormat)
          Set the stream format this RemoteDataSource uses to serialize requests.
 void setURL(URL url)
          Set the URL this datasource communicates with.
 
Methods inherited from class thinkmap.datasource.util.AbstractDataSource
processCustomRequest, processEntityRequest, processIdRequest, processMetadataRequest, processRelatedRequest, processRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_REQUEST

public static final String INITIAL_REQUEST
See Also:
Constant Field Values
Constructor Detail

RemoteDataSource

public RemoteDataSource(URL url)
Creates a new RemoteDataSource object.

Parameters:
url - URL of the other end

RemoteDataSource

public RemoteDataSource()
Creates a new RemoteDataSource object.

Method Detail

setCompatabilityMode

public void setCompatabilityMode(boolean b)
Set compatibility mode on or off. In compatibility mode, the remote datasource will work with a thinkmap 2.0 server.

Parameters:
b - true for compatibility mode

setStreamFormat

public void setStreamFormat(IStreamFormat streamFormat)
Set the stream format this RemoteDataSource uses to serialize requests.

Parameters:
streamFormat - stream format

setCompressed

public void setCompressed(boolean b)
Set whether or not the request should be compressed when possible.

Parameters:
b - true to compress

getCompressed

public boolean getCompressed()
Determine if requests are compressed when possible.

Returns:
true if compressed

setURL

public void setURL(URL url)
Set the URL this datasource communicates with. It should be an instance of DataSourceServlet, or something that behaves the same way.

Parameters:
url - the remote URL

getURL

public URL getURL()
Get the URL this datasource communicates with.

Returns:
the remote URL

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
Overrides:
createRequest in class AbstractDataSource
Parameters:
callback - The IEntityHandler that will recieve the response.
Returns:
The IEntityHandler for sending a request.

setConfig

public void setConfig(ThinkmapConfig config)

contextInitializing

public void contextInitializing(IThinkmapContext context)
                         throws Exception
Description copied from interface: IContextListener
Called when the given context is initializing. Listeners should construct and configure objects that depend on the context at this time. This method will only be called once per context.

Specified by:
contextInitializing in interface IContextListener
Parameters:
context - the context that is initializing
Throws:
Exception - if an error occurs while processing this event.

contextStarting

public void contextStarting(IThinkmapContext itc)
Description copied from interface: IContextListener
Called when the given context is starting. All objects that depend on the context should have been initialized before this method is called. Listeners should start any services they offer at this time. A context may be started, stopped, and started again many times.

Specified by:
contextStarting in interface IContextListener
Parameters:
itc - the context that is starting

contextStopping

public void contextStopping(IThinkmapContext itc)
Description copied from interface: IContextListener
Called when the given context is stopping. Listeners should stop any services they offer at this time.

Specified by:
contextStopping in interface IContextListener
Parameters:
itc - the context that is starting

contextDestroyed

public void contextDestroyed(IThinkmapContext itc)
Description copied from interface: IContextListener
Called when the given context has been destroyed. Listeners should dispose and de-register objects that depend on the context at this time. This method will only be called once per context.

Specified by:
contextDestroyed in interface IContextListener
Parameters:
itc - the context that is being destroyed

createStreamFactory

protected IStreamFactory createStreamFactory(IEntityHandler callback)


Copyright © 2013 Thinkmap, Inc. All Rights Reserved.