|
xmlBlaster 2.2.0 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 | |
---|---|
private java.util.HashMap |
attachments
the attachments (some contents can be in the attachments) |
protected java.lang.StringBuffer |
cdata
|
private java.util.HashSet |
commandsToFire
a set of names of allowed commands |
private java.lang.StringBuffer |
content
|
java.lang.String |
CONTENT_TAG
|
protected EncodableData |
contentData
Encapsulates the content of the current message (useful for encoding) |
private java.lang.String |
contentUrl
|
java.lang.String |
ECHO_TAG
|
protected boolean |
forceReadable
|
protected Global |
glob
|
private int |
inCDATA
|
private int |
inContent
|
protected boolean |
inhibitContentCDATAWrapping
|
private int |
inKey
|
private boolean |
inProperty
|
java.lang.String |
INPUT_TAG
|
private int |
inQos
|
protected java.lang.StringBuffer |
key
|
java.lang.String |
KEY_TAG
|
private java.lang.String |
link
|
private static java.util.logging.Logger |
log
|
private java.lang.String |
ME
|
protected java.util.ArrayList |
messageList
used to accumulate all messages to be sent with publishArr |
protected boolean |
needsRootEndTag
|
protected java.io.OutputStream |
out
|
private java.lang.String |
propertyName
|
protected java.lang.StringBuffer |
qos
|
java.lang.String |
QOS_TAG
|
private boolean |
replaceContentTokens
|
private boolean |
replaceFileContentTokens
|
private boolean |
replaceKeyTokens
|
private boolean |
replaceQosTokens
Replace e.g. |
private boolean |
replaceTokens
Replace tokens in wait or echo markup |
private java.lang.String |
requestId
|
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 |
private java.lang.String |
sessionId
|
protected java.lang.String |
simpleExceptionFormatList
|
private byte |
type
|
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 | |
---|---|
private void |
appendEndOfElement(java.lang.StringBuffer buf,
java.lang.String qName)
Appends the end stream to the current StringBuffer |
protected MsgUnit |
buildMsgUnit()
|
void |
characters(char[] ch,
int start,
int length)
Characters. |
private void |
checkNestedTags()
|
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)
|
private void |
fireCommand(java.lang.String qName)
Fires the given xmlBlaster command and sends the response to the output stream |
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()
|
private static java.util.Set<java.lang.String> |
getSimpleExceptionFormatList(java.lang.String list)
|
private void |
incrementInElementCounters(java.lang.String qName)
Increments the corresponding counter only if it is already in one such element |
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. |
private java.lang.String |
replaceVariables(java.lang.String template)
|
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 |
---|
private final java.lang.String ME
private static java.util.logging.Logger log
protected Global glob
private java.util.HashSet commandsToFire
protected java.lang.StringBuffer qos
protected java.lang.StringBuffer key
private java.lang.StringBuffer content
protected java.lang.StringBuffer cdata
private boolean replaceQosTokens
private boolean replaceKeyTokens
private boolean replaceContentTokens
private boolean replaceFileContentTokens
private boolean replaceTokens
protected EncodableData contentData
private int inQos
private int inKey
private int inContent
private int inCDATA
private java.lang.String link
private java.lang.String contentUrl
private java.lang.String sessionId
private java.lang.String requestId
private byte type
private java.lang.String propertyName
private boolean inProperty
private java.util.HashMap attachments
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
private void incrementInElementCounters(java.lang.String qName)
qName
- 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
private java.lang.String replaceVariables(java.lang.String template)
private void appendEndOfElement(java.lang.StringBuffer buf, java.lang.String qName)
buf
- the StringBuffer to be usedqName
- the name of the commandpublic 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
private void fireCommand(java.lang.String qName) throws XmlBlasterException
qName
-
XmlBlasterException
protected void flushResponse() throws XmlBlasterException
XmlBlasterException
protected MsgUnit buildMsgUnit() throws XmlBlasterException
XmlBlasterException
private void checkNestedTags()
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
-
private static java.util.Set<java.lang.String> getSimpleExceptionFormatList(java.lang.String list)
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 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |