|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.servlet.GenericServlet javax.servlet.http.HttpServlet com.saxonica.deploy.CompiledQueryServlet
public abstract class CompiledQueryServlet
This abstract class acts as a superclass for every query generated by the Saxon code generator in servlet mode. In this mode the generated code is thread-safe: it is possible to have a single instance of the class running in multiple threads concurrently.
It is possible to define a user-defined subclass of this class that specializes the behaviour of the init() and service() methods. When a query is compiled, the -superclass option on the command line determines the immediate superclass of the compiled code. Such a class will be needed, for example, if different queries are to share access to the same in-memory documents.
During servlet initialization, the init() method attempts to determine whether the servlet context
includes an attribute named com.saxonica.servlet.applicationdata
that is an instance of the
interface SharedApplicationDataHandler
. If this object exists, it is called on each servlet request, at which
point it has the opportunity to configure the Controller
for the query execution, for example by supplying
parameter values, setting a URIResolver, or otherwise.
If no SharedApplicationDataHandler
object is available, external variables for the query can be specified
as query parameters in the request URL. The names of query parameters are taken as local names of no-namespace
variables, and the values are treated as UntypedAtomic strings (which will be converted to the declared type
of the variable if necessary). Any query parameters that do not correspond to declared external variables in
the query will be ignored.
Field Summary | |
---|---|
protected Configuration |
config
|
protected Executable |
exec
|
protected NamePool |
namePool
|
protected SharedApplicationDataHandler |
sharedData
|
protected TypeHierarchy |
th
|
Constructor Summary | |
---|---|
CompiledQueryServlet()
|
Method Summary | |
---|---|
void |
doGet(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Run the query as a servlet |
protected void |
dynamicError(String message,
String code,
XPathContext context)
Signal a dynamic error. |
protected boolean |
generalCompare(SequenceIterator iter1,
SequenceIterator iter2,
SimpleAtomicComparer comparer,
XPathContext context)
Helper method to implement a general comparison. |
Configuration |
getConfiguration()
Get the Configuration. |
protected NodeInfo |
getContextNode(Item item)
Helper method to get the context node, throwing appropriate exceptions if there isn't one. |
Executable |
getExecutable()
Get the Executable. |
protected abstract int |
getNumberOfGlobalVariables()
Get a StackFrameMap for the first local stackframe (that is, for the main query body). |
void |
init()
Servlet initialization method |
abstract void |
initializeGlobals()
Run the query-specific initialization code. |
abstract void |
process(XPathContext context)
Run the query, sending the results to the current output destination. |
protected void |
runQuery(Controller controller,
Result result,
Properties outputProperties)
Run the query, sending the results directly to a JAXP Result object. |
void |
setConfiguration(Configuration config)
Supply the configuration in which the query will be executed. |
protected abstract void |
setExternalVariable(String clarkName,
ValueRepresentation value,
Controller controller)
|
protected void |
typeError(String message,
String code,
XPathContext context)
Signal a type error. |
Methods inherited from class javax.servlet.http.HttpServlet |
---|
doDelete, doOptions, doPost, doPut, doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
---|
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, init, log, log |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Configuration config
protected Executable exec
protected NamePool namePool
protected TypeHierarchy th
protected SharedApplicationDataHandler sharedData
Constructor Detail |
---|
public CompiledQueryServlet()
Method Detail |
---|
public void init() throws javax.servlet.ServletException
init
in class javax.servlet.GenericServlet
javax.servlet.ServletException
public abstract void initializeGlobals() throws XPathException
XPathException
public final void setConfiguration(Configuration config)
This method should be called during initialization by the init() method. If a user-defined subclass
of CompiledQueryServlet
is in use, the subclass may call this method directly. In the absence
of such a class, the default implementation will call the SharedApplicationDataHandler
to supply a
Configuration; and in the absence of SharedApplicationDataHandler
it will construct a Configuration
specific to this servlet instance.
config
- the Configuration to be used. If the query is schema-aware, this must be an instance
of EnterpriseConfiguration
public void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletException, IOException
doGet
in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
IOException
protected void runQuery(Controller controller, Result result, Properties outputProperties) throws XPathException
result
- the destination for the results of the query. The query is effectively wrapped
in a document{} constructor, so that the items in the result are concatenated to form a single
document; this is then written to the requested Result destination, which may be (for example)
a DOMResult, a SAXResult, or a StreamResultoutputProperties
- Supplies serialization properties, in JAXP format, if the result is to
be serialized. This parameter can be defaulted to null. Values supplied
here take precedence over any values supplied in the query source using the
saxon:output option declaration.
XPathException
- if the query fails.public final Configuration getConfiguration()
public Executable getExecutable()
protected abstract int getNumberOfGlobalVariables()
protected abstract void setExternalVariable(String clarkName, ValueRepresentation value, Controller controller)
public abstract void process(XPathContext context) throws XPathException
XPathException
protected void typeError(String message, String code, XPathContext context) throws XPathException
message
- code
- context
-
XPathException
protected void dynamicError(String message, String code, XPathContext context) throws XPathException
message
- code
- context
-
XPathException
protected NodeInfo getContextNode(Item item) throws XPathException
XPathException
protected boolean generalCompare(SequenceIterator iter1, SequenceIterator iter2, SimpleAtomicComparer comparer, XPathContext context) throws XPathException
iter1
- iterator over the first operand of the comparisoniter2
- iterator over the second operand of the comparisoncomparer
- object used to compare the two valuescontext
- the XPath dynamic context
XPathException
- if a dynamic error occurs
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |