xmlBlaster 2.2.0 API

org.xmlBlaster.client.script
Class XmlScriptClient

java.lang.Object
  extended by org.xmlBlaster.util.SaxHandlerBase
      extended by org.xmlBlaster.client.script.XmlScriptInterpreter
          extended by org.xmlBlaster.client.script.XmlScriptClient
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler, I_Callback

public class XmlScriptClient
extends XmlScriptInterpreter
implements I_Callback

XmlScriptClient

Example for usage:

java javaclients.XmlScript -requestFile inFile.xml -responseFile outFile.xml -updateFile updFile.xml

Author:
Michele Laghi
See Also:
The client.script requirement

Field Summary
private  I_XmlBlasterAccess access
           
private  boolean allowImplicitConnect
           
private  I_Callback callback
           
private  ConnectQosSaxFactory connectQosFactory
           
private  DisconnectQosSaxFactory disconnectQosFactory
           
private  Global glob
           
private  boolean isConnected
           
private static java.util.logging.Logger log
           
private  java.lang.String ME
           
private  I_MsgUnitCb msgUnitCb
           
private  boolean throwAllExceptions
           
 
Fields inherited from class org.xmlBlaster.client.script.XmlScriptInterpreter
cdata, CONTENT_TAG, contentData, ECHO_TAG, forceReadable, inhibitContentCDATAWrapping, INPUT_TAG, key, KEY_TAG, messageList, needsRootEndTag, out, qos, QOS_TAG, response, ROOT_TAG, ROOTRESPONSE_TAG, sendSimpleExceptionFormat, simpleExceptionFormatList, updateCounter, WAIT_TAG, waitMutex, waitNumUpdates
 
Fields inherited from class org.xmlBlaster.util.SaxHandlerBase
character, locator, xmlLiteral, xmlSource
 
Constructor Summary
XmlScriptClient(Global glob, I_XmlBlasterAccess access, I_Callback callback, java.util.HashMap attachments, java.io.OutputStream out)
          This constructor is the most generic one (more degrees of freedom)
XmlScriptClient(Global glob, I_XmlBlasterAccess access, java.io.OutputStream cbStream, java.io.OutputStream responseStream, java.util.HashMap attachments)
          This is a convenience constructor which takes the default I_Callback implementation provided (StreamCallback).
XmlScriptClient(Global glob, java.io.OutputStream out)
          Convenience constructor which takes a minimal amount of parameters.
 
Method Summary
 boolean fireMethod(MethodName methodName, java.lang.String sessionId, java.lang.String requestId, byte type)
          On each remote method invocation this function is called.
 boolean isThrowAllExceptions()
           
static void main(java.lang.String[] args)
           
 void registerMsgUnitCb(I_MsgUnitCb msgUnitCb)
          You can register a callback which can manipulate the MsgUnit just before it is sent.
 void setProperty(java.lang.String key, java.lang.String value)
          Set a property into Global scope.
 void setThrowAllExceptions(boolean throwAllExceptions)
           
 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
private  void writeResponse(MethodName methodName, java.lang.String message)
          Write respone message to OutputStream.
private  void writeResponse(MethodName methodName, java.lang.String[] messages)
           
 
Methods inherited from class org.xmlBlaster.client.script.XmlScriptInterpreter
buildMsgUnit, characters, dumpToFile, endCDATA, endElement, flushResponse, initialize, parse, replaceVariable, serialize, simplifiedErrorCode, startCDATA, startElement, wrapForScripting, wrapForScripting, wrapForScripting, writeElementStart
 
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

ME

private final java.lang.String ME
See Also:
Constant Field Values

log

private static java.util.logging.Logger log

access

private I_XmlBlasterAccess access

isConnected

private boolean isConnected

msgUnitCb

private I_MsgUnitCb msgUnitCb

glob

private final Global glob

callback

private I_Callback callback

connectQosFactory

private ConnectQosSaxFactory connectQosFactory

disconnectQosFactory

private DisconnectQosSaxFactory disconnectQosFactory

throwAllExceptions

private boolean throwAllExceptions

allowImplicitConnect

private boolean allowImplicitConnect
Constructor Detail

XmlScriptClient

public XmlScriptClient(Global glob,
                       I_XmlBlasterAccess access,
                       I_Callback callback,
                       java.util.HashMap attachments,
                       java.io.OutputStream out)
This constructor is the most generic one (more degrees of freedom)

Parameters:
glob - the global to use
access - the I_XmlBlasterAccess to use (can be different from the default given by the global.
callback - The I_Callback implementation to be used (you can provide your own desidered behaviour)
attachments - 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 xmlBlaster

XmlScriptClient

public XmlScriptClient(Global glob,
                       I_XmlBlasterAccess access,
                       java.io.OutputStream cbStream,
                       java.io.OutputStream responseStream,
                       java.util.HashMap attachments)
This is a convenience constructor which takes the default I_Callback implementation provided (StreamCallback).

Parameters:
glob - the global to use
access - the I_XmlBlasterAccess to use (can be different from the default given by the global.
cbStream - the OutputStream where to send the information coming in asynchroneously via the update method (could be different from the synchroneous output stream).
responseStream - the synchroneous OutputStream
attachments - the attachments where to find attached contents
See Also:
StreamCallback

XmlScriptClient

public XmlScriptClient(Global glob,
                       java.io.OutputStream out)
Convenience constructor which takes a minimal amount of parameters. The accessor taken is the one provided by the given global. The I_Callback implementation used is the StreamCallback. The asynchroneous output is sent to the same stream as the synchroneous one.

Parameters:
glob - the global to use. The I_XmlBlasterAccess will be taken from it.
out. - The OutputStream used for all outputs (sync and async).
Method Detail

registerMsgUnitCb

public void registerMsgUnitCb(I_MsgUnitCb msgUnitCb)
You can register a callback which can manipulate the MsgUnit just before it is sent.


setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)
                 throws XmlBlasterException
Description copied from class: XmlScriptInterpreter
Set a property into Global scope.

Specified by:
setProperty in class XmlScriptInterpreter
Throws:
XmlBlasterException

fireMethod

public boolean fireMethod(MethodName methodName,
                          java.lang.String sessionId,
                          java.lang.String requestId,
                          byte type)
                   throws XmlBlasterException
Description copied from class: XmlScriptInterpreter
On each remote method invocation this function is called.

Specified by:
fireMethod in class XmlScriptInterpreter
type - 'I'=invoke 'R'=response 'E'=exception
Returns:
true: The methodName was known and is successfully processed false: The methodName is not known and nothing is processed
Throws:
XmlBlasterException - Will lead to stop parsing further

writeResponse

private void writeResponse(MethodName methodName,
                           java.lang.String message)
                    throws XmlBlasterException
Write respone message to OutputStream.

Parameters:
methodName - Can be null
message - A well formed XML message or null
Throws:
XmlBlasterException

writeResponse

private void writeResponse(MethodName methodName,
                           java.lang.String[] messages)
                    throws XmlBlasterException
Throws:
XmlBlasterException

main

public static void main(java.lang.String[] args)

update

public java.lang.String update(java.lang.String cbSessionId,
                               UpdateKey updateKey,
                               byte[] content,
                               UpdateQos updateQos)
                        throws XmlBlasterException
Description copied from class: XmlScriptInterpreter
If a callback handler was registered, we will be notified here about updates as well

Specified by:
update in interface I_Callback
Overrides:
update in class XmlScriptInterpreter
Parameters:
cbSessionId - The session ID specified by the client which registered the callback. You can specify a cbSessionId during connection (with ConnectQos) and this is bounced back here so you can authenticate the message.
updateKey - The arrived key containing the topic name
content - The arrived message content. This is your payload.
Throws:
XmlBlasterException
See Also:
I_XmlBlasterAccess

isThrowAllExceptions

public boolean isThrowAllExceptions()

setThrowAllExceptions

public void setThrowAllExceptions(boolean throwAllExceptions)

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.