|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectGenericServlet
HttpServlet
TextServlet
DynaXML
TestableDynaXML
public class TestableDynaXML
Extends the DynaXML servlet slightly to allow programmatic testing of the servlet. Authentication always succeeds. Any exceptions will be thrown upward rather than generating an error page.
Field Summary | |
---|---|
private String |
baseDir
|
private String |
indexDirOverride
|
private IndexWarmer |
indexWarmer
|
private ThreadLocal<Integer> |
nHits
|
Fields inherited from class TextServlet |
---|
stylesheetCache |
Constructor Summary | |
---|---|
TestableDynaXML(String baseDir)
Simplified initialization for use outside a real servlet container. |
Method Summary | |
---|---|
protected boolean |
authenticate(DocRequest docReq,
HttpServletRequest req,
HttpServletResponse res)
Performs user authentication for a request, given the authentication info for the document. |
DocLocator |
createDocLocator()
Create a DocLocator. |
QueryProcessor |
createQueryProcessor()
For test mode, allow override of index warmer. |
protected void |
genErrorPage(HttpServletRequest req,
HttpServletResponse res,
Exception exc)
Would normally generate an error page. |
protected Source |
getSourceDoc(DocRequest docReq,
Transformer transformer)
Perform the normal dynaXML getSourceDoc() operation, then record the resulting number of hits (if any) that came out. |
int |
nHits()
Return the number of hits in the last request processed by this thread |
void |
overrideIndexDir(String dir)
Allows overriding the directory specified in future query requests. |
protected DocRequest |
runDocReqParser(HttpServletRequest req,
AttribList attribs)
Allow overriding the index directory |
void |
service(String url)
Simplified method to test-get the given URL. |
void |
setIndexWarmer(IndexWarmer warmer)
Allows overriding default index warmer. |
protected void |
setupTrace(TextConfig config)
For test mode, do nothing to the current trace flags. |
Methods inherited from class DynaXML |
---|
doGet, getConfig, getConfigName, getServletInfo, readConfig, setProfiling |
Methods inherited from class HttpServlet |
---|
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service |
Methods inherited from class GenericServlet |
---|
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, init, log, log |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private String baseDir
private String indexDirOverride
private IndexWarmer indexWarmer
private ThreadLocal<Integer> nHits
Constructor Detail |
---|
public TestableDynaXML(String baseDir) throws ServletException
baseDir
- the XTF home directory.
ServletException
- if anything goes wrong.Method Detail |
---|
public void overrideIndexDir(String dir)
public void setIndexWarmer(IndexWarmer warmer)
public int nHits()
protected void setupTrace(TextConfig config)
setupTrace
in class TextServlet
protected DocRequest runDocReqParser(HttpServletRequest req, AttribList attribs) throws Exception
runDocReqParser
in class DynaXML
req
- The original HTTP requestattribs
- Attributes to pass to the stylesheet.
Exception
public QueryProcessor createQueryProcessor()
createQueryProcessor
in class TextServlet
public void service(String url) throws ServletException, IOException
url
- the URL to test-get
ServletException
IOException
protected Source getSourceDoc(DocRequest docReq, Transformer transformer) throws InvalidDocumentException, IOException, SAXException, ParserConfigurationException
getSourceDoc
in class DynaXML
docReq
- Tells which document to load, the query to
apply, tec.transformer
- The XSLT transformer that will be used on the
document.
IOException
- If a problem is encountered loading a file or URL
SAXException
- If the document cannot be parsed as valid XML
ParserConfigurationException
- Miscellaneous configuration
problems
InvalidDocumentException
protected boolean authenticate(DocRequest docReq, HttpServletRequest req, HttpServletResponse res) throws Exception
authenticate
in class DynaXML
docReq
- Info structure containing authentication parametersreq
- The request being processedres
- Where to send results if authentication fails
Exception
protected void genErrorPage(HttpServletRequest req, HttpServletResponse res, Exception exc)
genErrorPage
in class TextServlet
req
- The HTTP request we're responding tores
- The HTTP result to write toexc
- The exception producing the error. If it's a
DynaXMLException, the attributes will be passed to
the error stylesheet.public DocLocator createDocLocator()
DynaXML
DefaultDocLocator
is
created.
createDocLocator
in class DynaXML
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |