thinkmap.server
Class DataSourceServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by thinkmap.server.DataSourceServlet
All Implemented Interfaces:
Serializable, Servlet, ServletConfig

public class DataSourceServlet
extends HttpServlet

This servlet implements the server side of the RemoteDataSource. This class instantiates datasources by looking for xml files (typically ending with the extension .tas) that define how the datasource should be configured.

Each datasource is wrapped in a DataSourceWrapper, that is also configured by the ".tas" file. that it uses in two ways. First, it can deserialize a datasource from a file specified using the "datasource" initialization parameter. Alternatively, it can instatiate a class using Class.forName(). The class that is instantiated is specified using the "class" initialization parameter.

The stream format to use for parsing the incoming stream is normally determined dynamically by reading the "Stream-Format-Class" HTTP header which the remote datasource sends with every request. if no stream format header is sent, the DataSourceServlet will fall back to the default format, which can be specified using the "default-format" initialization parameter. By default, there is no default format set, and the server will produce an error if no stream format class is sent with the request.

This servlet will only serve Thinkmap clients via the HTTP POST method. If accessed via the GET method, it will return a short xml document describing the current status of the server.

Version:
$Revision: 1.21 $
See Also:
RemoteDataSource, IStreamFormat, Serialized Form

Field Summary
static String CHECK_INTERVAL
           
static String DEFAULT_STREAM_FORMAT
           
static String STARTUP_URIS
           
protected static String STREAM_FORMAT_CLASS
           
 
Constructor Summary
DataSourceServlet()
           
 
Method Summary
 void destroy()
           
static DataSourceServlet get(ServletContext context)
           
 DataSourceContext getDataSource(String uri)
          Get a reference to a DataSourceContext with the given URI.
 String[] getDataSourceURIs()
          Get the URI's of all the contexts that have been loaded by the Datasource Servlet.
 MessageLog getErrorLog()
           
protected static IStreamFormat getFormat(String format, IStreamFormat myDefault)
           
protected  String getInitParameter(String name, String def)
           
 thinkmap.server.auth.License getLicense()
           
 File getLicenseFile()
           
 ResourceMonitor getResourceMonitor()
           
 void init(ServletConfig config)
           
 void log(int level, String message, Throwable e)
          Log a message to the servlet log and to the memroy error log.
 void reloadDataSource(String uri)
           
 void reloadLicense()
           
 void removeDataSource(String uri)
          Removes the datasource at the given URI.
 void service(HttpServletRequest request, HttpServletResponse response)
           
protected  void startDefaultURIs()
           
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_STREAM_FORMAT

public static final String DEFAULT_STREAM_FORMAT
See Also:
Constant Field Values

CHECK_INTERVAL

public static final String CHECK_INTERVAL
See Also:
Constant Field Values

STARTUP_URIS

public static final String STARTUP_URIS
See Also:
Constant Field Values

STREAM_FORMAT_CLASS

protected static final String STREAM_FORMAT_CLASS
See Also:
Constant Field Values
Constructor Detail

DataSourceServlet

public DataSourceServlet()
Method Detail

get

public static DataSourceServlet get(ServletContext context)

init

public void init(ServletConfig config)
          throws ServletException
Specified by:
init in interface Servlet
Overrides:
init in class GenericServlet
Throws:
ServletException

startDefaultURIs

protected void startDefaultURIs()

removeDataSource

public void removeDataSource(String uri)
Removes the datasource at the given URI.

Parameters:
uri - the URI of the datasource to remove.

getDataSource

public DataSourceContext getDataSource(String uri)
                                throws IOException,
                                       Exception
Get a reference to a DataSourceContext with the given URI. This method will create a DataSourceContext for the URI if it has not been created yet.

Parameters:
uri - the URI of the DataSourceContext to obtain.
Returns:
a reference to a DataSourceContext with the given URI, or null if it does not exist
Throws:
IOException - if the file the URI does not exist, or cannot be read.
Exception

log

public void log(int level,
                String message,
                Throwable e)
Log a message to the servlet log and to the memroy error log.

Parameters:
level - logging level: see MemoryErrorLog for allowed values.
message - the message to log (may be null)
e - the exception to log (may be null)

getErrorLog

public MessageLog getErrorLog()

getDataSourceURIs

public String[] getDataSourceURIs()
Get the URI's of all the contexts that have been loaded by the Datasource Servlet.

Returns:
the URI's of all the contexts that have been loaded by the Datasource Servlet.

reloadDataSource

public void reloadDataSource(String uri)
                      throws Exception
Throws:
Exception

destroy

public void destroy()
Specified by:
destroy in interface Servlet
Overrides:
destroy in class GenericServlet

service

public void service(HttpServletRequest request,
                    HttpServletResponse response)
             throws ServletException,
                    IOException
Overrides:
service in class HttpServlet
Throws:
ServletException
IOException

getFormat

protected static IStreamFormat getFormat(String format,
                                         IStreamFormat myDefault)
                                  throws InstantiationException,
                                         IllegalAccessException,
                                         ClassNotFoundException
Throws:
InstantiationException
IllegalAccessException
ClassNotFoundException

getInitParameter

protected String getInitParameter(String name,
                                  String def)

getResourceMonitor

public ResourceMonitor getResourceMonitor()

getLicenseFile

public File getLicenseFile()

getLicense

public thinkmap.server.auth.License getLicense()

reloadLicense

public void reloadLicense()


Copyright © 2013 Thinkmap, Inc. All Rights Reserved.