|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectthinkmap.server.DataSourceContext
public class DataSourceContext
This class wraps a DataSource and implements the server side of the RemoteDataSource. This class can instantiate the datasource that it uses by reading from an XML file that is located at the URI passed to the constructor.
The DataSource wrapper lazily constructs and configures the datasource (i.e. on the first request).
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. Stream formats are normally negotiated between the client and the server, and the default is only used as a last resort if the server cannot negotiate a protocol. The default format is the BinaryStreamFormat.
This class will only serve Thinkmap clients via the HTTP POST method.
| Nested Class Summary | |
|---|---|
protected class |
DataSourceContext.ServletStreamFactory
|
| Field Summary | |
|---|---|
static int |
INITIALIZING
|
static int |
OFFLINE
|
static int |
OFFLINE_ERROR
|
static int |
ONLINE
|
static int |
STOPPING
|
| Fields inherited from interface thinkmap.context.IThinkmapContext |
|---|
errorLevelNames, MSG_ERROR, MSG_FATAL, MSG_INFO, MSG_WARNING |
| Fields inherited from interface thinkmap.server.rmon.IMonitoredResource |
|---|
RESOURCE_MODIFIED, RESOURCE_REMOVED, RESOURCE_UNMODIFIED |
| Constructor Summary | |
|---|---|
DataSourceContext(DataSourceServlet servlet,
String uri)
Constructs a DataSourceWrapper using the provided DataSourceServlet and reading from the configuration file located at the provided URI. |
|
| Method Summary | |
|---|---|
void |
addContextListener(IContextListener l)
Add a listener to this context. |
void |
clearMessages()
|
protected void |
doBinary(HttpServletRequest request,
HttpServletResponse response)
|
Object |
evalExternal(String code)
Evaluate the given code in the external envorinment. |
ThinkmapServerApplication |
getApplication()
Get the underlying ThinkmapServerApplication. |
Object |
getAttribute(String s)
Returns an object defined by the container in an application specific way. |
IDataSource |
getDataSource()
Get the datasource that is served by this servlet. |
long |
getErrorCount()
|
long |
getHits()
|
DataSourceIndex |
getIndex()
|
MessageLog |
getMessages()
|
int |
getModificationStatus()
This method is called by the DataSourceServlet to determine if the configuration file that created this wrapper has been modified. |
String |
getParameter(String name)
Returns the value of an initialization parameter that was specified to the container. |
DataSourceServlet |
getServlet()
Returns a reference to the DataSourceServlet that is serving this DataSourceWrapper. |
String |
getStatus()
|
int |
getStatusCode()
|
String |
getType()
|
String |
getURI()
|
boolean |
isStarted()
|
protected boolean |
processRequest(HttpServletRequest request,
InputStream is,
IStreamReader sr,
StreamWriter sw)
|
void |
removeContextListener(IContextListener l)
Remove a listener from this context. |
void |
reportError(int level,
String message,
Throwable e)
Report an error for the application / applet to display to the user. |
void |
resetStatistics()
Reset the statistics. |
void |
restart()
|
protected void |
service(HttpServletRequest request,
HttpServletResponse response)
|
void |
showDocument(String url,
String frame)
Open the document at the given URL in the given frame. |
void |
start()
|
void |
stop()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int OFFLINE
public static final int INITIALIZING
public static final int ONLINE
public static final int STOPPING
public static final int OFFLINE_ERROR
| Constructor Detail |
|---|
public DataSourceContext(DataSourceServlet servlet,
String uri)
throws MalformedURLException,
FileNotFoundException
servlet - a reference to the DataSourceServleturi - the uri of the configuration file
MalformedURLException - if the uri is malformed
FileNotFoundException - if the uri does not exist| Method Detail |
|---|
public String getType()
public String getURI()
public void addContextListener(IContextListener l)
IThinkmapContext
addContextListener in interface IThinkmapContextl - the listener to addpublic void removeContextListener(IContextListener l)
IThinkmapContext
removeContextListener in interface IThinkmapContextl - the listener to removepublic String getParameter(String name)
IThinkmapContext
getParameter in interface IThinkmapContextname - the name of the parameter to get
public Object getAttribute(String s)
IThinkmapContext
getAttribute in interface IThinkmapContext
public void showDocument(String url,
String frame)
throws IOException
IThinkmapContext
showDocument in interface IThinkmapContexturl - the URL of the document to showframe - the name of the frame to populate with the document
IOException - if this context is not running inside a browser or
is unable to display a document
public Object evalExternal(String code)
throws Exception
IThinkmapContext
evalExternal in interface IThinkmapContextcode - the code to execute in the external environment
Exception - if there was an error, or if this context does not
support external evaluation.@JSONTransient public int getModificationStatus()
getModificationStatus in interface IMonitoredResource@JSONTransient public DataSourceServlet getServlet()
@JSONTransient public IDataSource getDataSource()
@JSONTransient public ThinkmapServerApplication getApplication()
public long getHits()
public long getErrorCount()
public DataSourceIndex getIndex()
public void resetStatistics()
public MessageLog getMessages()
public void clearMessages()
public void start()
throws Exception
Exceptionpublic void stop()
public void restart()
throws Exception
Exceptionpublic boolean isStarted()
public String getStatus()
public int getStatusCode()
protected void service(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,
IOException
ServletException
IOException
protected void doBinary(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,
IOException
ServletException
IOException
protected boolean processRequest(HttpServletRequest request,
InputStream is,
IStreamReader sr,
StreamWriter sw)
throws IOException
IOException
public void reportError(int level,
String message,
Throwable e)
IThinkmapContext
reportError in interface IThinkmapContextlevel - the warning level of the error being reportedmessage - a human readable message describing the errore - the Throwable that caused the error (may be null)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||