|
xmlBlaster 2.2.0 client API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xmlBlaster.util.SaxHandlerBase org.xmlBlaster.client.script.XmlScriptInterpreter
public abstract class XmlScriptInterpreter
Abstract class to parse and construct a XML represantation of xmlBlaster invocations for scripting.
Example for command line scripting usage:
java javaclients.XmlScript -requestFile inFile.xml -responseFile outFile.xml -updateFile updFile.xml
Field Summary | |
---|---|
protected java.lang.StringBuffer |
cdata
|
java.lang.String |
CONTENT_TAG
|
protected EncodableData |
contentData
Encapsulates the content of the current message (useful for encoding) |
java.lang.String |
ECHO_TAG
|
protected boolean |
forceReadable
|
protected Global |
glob
|
protected boolean |
inhibitContentCDATAWrapping
|
java.lang.String |
INPUT_TAG
|
protected java.lang.StringBuffer |
key
|
java.lang.String |
KEY_TAG
|
protected java.util.ArrayList |
messageList
used to accumulate all messages to be sent with publishArr |
protected boolean |
needsRootEndTag
|
protected java.io.OutputStream |
out
|
protected java.lang.StringBuffer |
qos
|
java.lang.String |
QOS_TAG
|
protected java.lang.StringBuffer |
response
buffer used as a place holder for the responses of the xmlBlaster invocations |
static java.lang.String |
ROOT_TAG
|
static java.lang.String |
ROOTRESPONSE_TAG
|
protected boolean |
sendSimpleExceptionFormat
Set true to send a simple exception format like |
protected java.lang.String |
simpleExceptionFormatList
|
protected long |
updateCounter
|
java.lang.String |
WAIT_TAG
|
protected java.lang.Object |
waitMutex
|
protected int |
waitNumUpdates
|
Fields inherited from class org.xmlBlaster.util.SaxHandlerBase |
---|
character, locator, xmlLiteral, xmlSource |
Constructor Summary | |
---|---|
XmlScriptInterpreter()
You need to call initialize() if using this default constructor. |
|
XmlScriptInterpreter(Global glob,
java.util.HashMap attachments,
java.io.OutputStream out)
This constructor is the most generic one (more degrees of freedom) |
Method Summary | |
---|---|
protected MsgUnit |
buildMsgUnit()
|
void |
characters(char[] ch,
int start,
int length)
Characters. |
static java.lang.String |
dumpToFile(java.lang.String path,
java.lang.String fn,
java.lang.String xml)
|
void |
endCDATA()
Report the end of a CDATA section. |
void |
endElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName)
|
abstract boolean |
fireMethod(MethodName methodName,
java.lang.String sessionId,
java.lang.String requestId,
byte type)
On each remote method invocation this function is called. |
protected void |
flushResponse()
|
void |
initialize(Global glob,
java.util.HashMap attachments,
java.io.OutputStream out)
|
static void |
main(java.lang.String[] args)
|
void |
parse(java.io.Reader in)
Parses the given reader and executes the specified commands. |
java.lang.String |
replaceVariable(java.lang.String text)
Replace e.g. |
protected void |
serialize(MethodName methodName,
java.lang.String sessionId,
java.lang.String requestId,
MsgUnitRaw[] msgUnits,
java.lang.String header,
java.lang.String comment,
java.lang.String schemaDecl,
java.io.OutputStream out,
byte type)
Dump the given MsgUnitRaw to XML. |
abstract void |
setProperty(java.lang.String key,
java.lang.String value)
Set a property into Global scope. |
static java.lang.String |
simplifiedErrorCode(java.lang.String codeList,
java.lang.String errCode)
made public only for testing purposes |
void |
startCDATA()
Report the start of a CDATA section. |
void |
startElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes atts)
Receive notification of the beginning of an element. |
java.lang.String |
update(java.lang.String cbSessionId,
UpdateKey updateKey,
byte[] content,
UpdateQos updateQos)
If a callback handler was registered, we will be notified here about updates as well |
java.lang.String |
wrapForScripting(MsgUnit msgUnit,
java.lang.String comment)
|
static java.lang.String |
wrapForScripting(java.lang.String rootTag,
MsgUnit[] msgUnitArr,
java.lang.String comment)
|
static java.lang.String |
wrapForScripting(java.lang.String rootTag,
MsgUnit msgUnit,
java.lang.String comment)
Dump the MsgUnit to XML, the dump includes the xml header (UTF-8). |
protected java.lang.String |
writeElementStart(java.lang.String qName,
org.xml.sax.Attributes attr)
converts the tag sctart to a string |
Methods inherited from class org.xmlBlaster.util.SaxHandlerBase |
---|
comment, endDocument, endDTD, endEntity, endPrefixMapping, error, fatalError, getUseLexicalHandler, ignorableWhitespace, init, init, init, notationDecl, processingInstruction, setDocumentLocator, setUseLexicalHandler, skippedEntity, startDocument, startDTD, startEntity, startPrefixMapping, toString, toXml, unparsedEntityDecl, warning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Global glob
protected java.lang.StringBuffer qos
protected java.lang.StringBuffer key
protected java.lang.StringBuffer cdata
protected EncodableData contentData
protected java.util.ArrayList messageList
protected java.lang.StringBuffer response
protected boolean needsRootEndTag
protected java.io.OutputStream out
protected java.lang.Object waitMutex
protected long updateCounter
protected int waitNumUpdates
protected boolean sendSimpleExceptionFormat
<update type='E'> <qos><state id='ERROR' info='user'/></qos> </update>
Note: The errorCode is stripped to the main category
protected java.lang.String simpleExceptionFormatList
protected boolean forceReadable
protected boolean inhibitContentCDATAWrapping
public static final java.lang.String ROOT_TAG
public static final java.lang.String ROOTRESPONSE_TAG
public final java.lang.String KEY_TAG
public final java.lang.String CONTENT_TAG
public final java.lang.String QOS_TAG
public final java.lang.String ECHO_TAG
public final java.lang.String INPUT_TAG
public final java.lang.String WAIT_TAG
Constructor Detail |
---|
public XmlScriptInterpreter()
public XmlScriptInterpreter(Global glob, java.util.HashMap attachments, java.io.OutputStream out)
glob
- the global to useattachments
- the attachments where to search
when a content is stored in the attachment
(with the 'link' attribute); can be nullout
- the OutputStream where to send the responses of the invocations done to xmlBlasterMethod Detail |
---|
public void initialize(Global glob, java.util.HashMap attachments, java.io.OutputStream out)
glob
- the global to useattachments
- the attachments where to search when a content is stored in the attachment (with the 'link' attribute)out
- the OutputStream where to send the responses of the invocations done to xmlBlasterprotected java.lang.String writeElementStart(java.lang.String qName, org.xml.sax.Attributes attr)
qName
- attr
-
public void parse(java.io.Reader in) throws XmlBlasterException
in
- the reader from which to read the xml input.
XmlBlasterException
public void characters(char[] ch, int start, int length)
SaxHandlerBase
characters
in interface org.xml.sax.ContentHandler
characters
in class SaxHandlerBase
public void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
SaxHandlerBase
Example:
With a namespace: <database:adapter xmlns:database='http://www.xmlBlaster.org/jdbc'/>
uri=http://www.xmlBlaster.org/jdbc localName=adapter name=database:adapter
Without a namespace: <adapter/>
uri= localName=adapter name=adapter
startElement
in interface org.xml.sax.ContentHandler
startElement
in class SaxHandlerBase
public java.lang.String replaceVariable(java.lang.String text)
text
- The complete string which may contain zero to many ${...}
variables, if null we return null
public abstract boolean fireMethod(MethodName methodName, java.lang.String sessionId, java.lang.String requestId, byte type) throws XmlBlasterException
methodName
- type
- 'I'=invoke 'R'=response 'E'=exception
XmlBlasterException
- Will lead to stop parsing furtherpublic abstract void setProperty(java.lang.String key, java.lang.String value) throws XmlBlasterException
XmlBlasterException
protected void flushResponse() throws XmlBlasterException
XmlBlasterException
protected MsgUnit buildMsgUnit() throws XmlBlasterException
XmlBlasterException
public void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
endElement
in interface org.xml.sax.ContentHandler
endElement
in class SaxHandlerBase
public void startCDATA()
SaxHandlerBase
startCDATA
in interface org.xml.sax.ext.LexicalHandler
startCDATA
in class SaxHandlerBase
public void endCDATA()
SaxHandlerBase
endCDATA
in interface org.xml.sax.ext.LexicalHandler
endCDATA
in class SaxHandlerBase
public java.lang.String wrapForScripting(MsgUnit msgUnit, java.lang.String comment)
public static java.lang.String wrapForScripting(java.lang.String rootTag, MsgUnit msgUnit, java.lang.String comment)
String xml = XmlScriptInterpreter.wrapForScripting( XmlScriptInterpreter.ROOT_TAG, msgUnit, "XmlScripting dump");
rootTag
- Usually XmlScriptInterpreter.ROOT_TAG="xmlBlaster"msgUnit
- null is OKcomment
- Some comment you want to add or null
public static java.lang.String wrapForScripting(java.lang.String rootTag, MsgUnit[] msgUnitArr, java.lang.String comment)
protected void serialize(MethodName methodName, java.lang.String sessionId, java.lang.String requestId, MsgUnitRaw[] msgUnits, java.lang.String header, java.lang.String comment, java.lang.String schemaDecl, java.io.OutputStream out, byte type) throws java.io.IOException
<-- A comment --> <publish> <qos> <key oid='1'/> <rcvTimestamp nanos='1131654994574000000'/> <isPublish/> </qos> </publish>
methodName
- The method to invoke, like "publishArr"sessionId
- An optional sessionId or nullrequestId
- An optional requestId or nullmsgUnits
- The msgUnits to serializeheader
- For example
comment
- An optional comment to add, can be nullschemaDecl
- Used for root tag, for example
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:noNamespaceSchemaLocation='xmlBlasterPublish.xsd'out
- The output sink for the resulttype
- 'I' is for invoke, 'R' for reply and 'E' for exception
XmlBlasterException
java.io.IOException
public static java.lang.String simplifiedErrorCode(java.lang.String codeList, java.lang.String errCode)
errCode
-
public static java.lang.String dumpToFile(java.lang.String path, java.lang.String fn, java.lang.String xml) throws XmlBlasterException
XmlBlasterException
public java.lang.String update(java.lang.String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) throws XmlBlasterException
cbSessionId
- updateKey
- content
- updateQos
-
XmlBlasterException
public static void main(java.lang.String[] args)
|
xmlBlaster 2.2.0 client API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |