|
SONIVIS v0.9 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.sonivis.tool.mwapiconnector.ThreadedMWApiBot
public class ThreadedMWApiBot
HTTP client for querying the MediaWiki API.
This new bot is based on Apache HttpClient in Version 4.0beta2 that went through a code rewrite and fixed a lot of bugs of the older versions.
The second difference is that it offers a method for threaded execution of a Collection
of requests, namely performAllRequests(String).
| Field Summary | |
|---|---|
static java.lang.String |
CHARSET
Request response content encoding. |
static int |
MAX_TOTAL_CONNECTIONS
Number of maximum active threads in threaded execution mode. |
static java.lang.String |
NAME
Name of the bot. |
static java.lang.String |
VERSION
Version information. |
| Constructor Summary | |
|---|---|
protected |
ThreadedMWApiBot()
Constructor. |
|
ThreadedMWApiBot(java.lang.String url)
Constructor. |
|
ThreadedMWApiBot(java.net.URL url)
Constructor. |
| Method Summary | |
|---|---|
protected HttpGetThread |
createQueryThread(IWikiApiRequest iwar)
Turn an IWikiApiRequest into an HttpGetThread. |
void |
finalize()
|
HttpClient |
getClient()
Retrieve the HttpClient. |
HttpHost |
getTarget()
Retrieve the target HttpHost. |
java.lang.String |
getWikiPath()
Return the path to the wiki to examine. |
void |
performAllRequests(java.lang.String comment)
Execute all requests pending in HttpRequestQueue. |
void |
performRequest(IWikiApiRequest war)
Execute an HTTP request. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String CHARSET
public static final java.lang.String NAME
public static final java.lang.String VERSION
public static final int MAX_TOTAL_CONNECTIONS
| Constructor Detail |
|---|
protected ThreadedMWApiBot()
Groups the basic setup activities for the bot. It takes care of the socket connections, the
protocol schemes, the connection management setup, the user agent string, the request
response content encoding and creates the internal HttpClient.
public ThreadedMWApiBot(java.net.URL url)
Specify the URL to the base directory of a MediaWiki
installation. Do not provide something like index.php or
Main_Page in the URL. Whether the trailing slash is present or not
doesn't matter. Note, that the wiki path (anything else than the domain
name or IP) will be statically tied to the class.
The constructor currently has no way to tell if it is really a MediaWiki} installation URL that was provided. If not so, the
url - A URL to a MediaWiki installation.ThreadedMWApiBot(),
wikiConnect(URL)
public ThreadedMWApiBot(java.lang.String url)
throws java.net.MalformedURLException
Basically the same as ThreadedMWApiBot(URL) except for the format of the parameter.
url - The String holding the URL to a MediaWiki installation.
java.net.MalformedURLException - if specified url cannot be transformed into a URL.ThreadedMWApiBot(URL)| Method Detail |
|---|
public final void performAllRequests(java.lang.String comment)
HttpRequestQueue.
The method loops through the HttpRequestQueue and polls for the top-most pending
IWikiApiRequest and creates a HttpGet request with the internal wiki path
settings of this class. Based on the successful creation of the request and the configured
target a HttpGetThread is instanced and
started.
When the {@link HttpRequestQueue} is empty then, this thread goes to {@link Thread#sleep(long) sleep} for some seconds before it checks the queue again. This way, follow-up requests produced by the {@link IWikiApiRequest}s should also be covered. If the thread nap happens to be interrupted the method calls itself recursively.
The argument is supposed to be a short string providing printable information on what kinds of queries are to be executed within the loop. The method is set to produce some progress information on standard out.
comment - Information on the queries to be executed. Will be used for progress output.HttpGetThread,
HttpRequestQueueprotected final HttpGetThread createQueryThread(IWikiApiRequest iwar)
IWikiApiRequest into an HttpGetThread.
iwar - The IWikiApiRequest to transform.
HttpGetThread created from the argumentpublic final void performRequest(IWikiApiRequest war)
The specified IWikiApiRequest is turned into an HttpRequest with the
executable query string of the
IWikiApiRequest having the wiki path prepended. The
IWikiApiRequest defines the request method
itself.
After the request was executed the bot inspects the server status and frees the connection in
case of error. The error information is preserved and put out, the returned server
status code is
associated with the
IWikiApiRequest.
The response content is streamed into a reader and on success passed to the
XMLPreparer to create an XML document from the content that is
fed back to the
IWikiApiRequest.
war - The IWikiApiRequest to be executed.IWikiApiRequestpublic final java.lang.String getWikiPath()
public final HttpClient getClient()
HttpClient.
public final HttpHost getTarget()
HttpHost.
public void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.ThrowableObject.finalize()
|
SONIVIS v0.9 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||