xmlBlaster 2.2.0 API

org.xmlBlaster.contrib.ant
Class XmlBlasterTask

java.lang.Object
  extended by Task
      extended by org.xmlBlaster.contrib.ant.XmlBlasterTask

public class XmlBlasterTask
extends Task

Access xmlBlaster from within ant.

The usage is simple, here are the steps to follow.
Edit your build.xml file and register the xmlBlaster task:

<project name="xmlBlaster" default="publish" basedir=".">

  <taskdef name="xmlBlasterScript"
          classname="org.xmlBlaster.contrib.ant.XmlBlasterTask"
          classpath="lib/xmlBlaster.jar"/>

  ...

</project>
 
The only tricky part is to choose the classpath setting, it must include at least the xmlBlaster client library and this class itself.

Example task using files:

<target name="usingFiles">
   <xmlBlasterScript
       scriptFile="myXblScript.xml"
       responseFile="methodReturn.xml"
       updateFile="asyncResponses.xml"/>
</target>
 
You have to provide the myXblScript.xml file content, its format is defined in the requirement client.script.
The other two files are generated during execution.

Example task with embedded script and output to console.
We set a property to run without database on client side, then we connect and subscribe to topic Hello. After you press a key we publish such a message and receive it asynchronously:

  <target name="publish">
    <xmlBlasterScript>
      <!-- This is the script executed -->
      <![CDATA[
        <xmlBlaster>
          <property name="queue/connection/defaultPlugin">RAM,1.0</property>
          <connect/>
          <subscribe><key oid="Hello"/><qos/></subscribe>
          <input message="Subscribed to 'hello', press a key to publish"/>
          <publish><key oid="Hello"></key><content>Hallo from ANT></content></publish>
          <wait delay="2000" />
          <erase><key oid="Hello"/><qos/></erase>
          <wait delay="500" />
          <disconnect />
        </xmlBlaster>
      ]]> 
   </xmlBlasterScript>
 </target>
 

In the following example we set verbosity to 3 (max), use the given xmlBlaster.properties, configure the JDK 1.4 logging for the xmlBlaster client library and inherit all properties from ant to xmlBlaster-Global scope:

<target name="usingFiles">
   <xmlBlasterScript
       scriptFile="myXblScript.xml"
       responseFile="methodReturn.xml"
       updateFile="asyncResponses.xml"
       verbose="3"
       propertyFile="/tmp/xmlBlaster.properties"
       loggingFile="logging.properties"
       inheritAll="true"
       />
</target>
 

Note that the ant properties are weakest, followed by xmlBlaster.properties settings and the <property> tags in the script are strongest.

Classloader problem:

Loading classes like the JDBC driver (hsqldb.jar) or loading of customized JDK1.4 logging classes from logging.properties fails.
The reason is that ant uses an own Classloader and the failing classes to load seem to be loaded by the system Classloader (ClassLoader.getSystemClassLoader().loadClass(word);), but this doesn't know our classes to load!
The workaround is to set LOCALCLASSPATH before startig ant, for example:
export LOCALCLASSPATH=$CLASSPATH:$HOME/apache-ant-1.6.5/lib/ant.jar
which resolves the issue (assuming that your CLASSPATH contains all needed classes already).

Author:
Marcel Ruff
See Also:
http://www.xmlblaster.org/xmlBlaster/doc/requirements/client.script.html, http://ant.apache.org/manual/index.html

Field Summary
private  Global glob
           
private  boolean inheritAll
           
private  XmlScriptClient interpreter
           
private  java.lang.String loggingFile
           
private  boolean prepareForPublish
           
private  java.lang.String propertyFile
           
private  java.io.Reader reader
           
private  java.lang.String responseFile
           
private  java.io.OutputStream responseStream
           
private  java.lang.String scriptFile
           
private  java.lang.String updateFile
           
private  java.io.OutputStream updateStream
           
private  int verbose
           
private  java.lang.String xmlBlasterScript
           
 
Constructor Summary
XmlBlasterTask()
           
 
Method Summary
 void addText(java.lang.String text)
          Set the task body text, we expect a valid xmlBlaster xml script.
 void execute()
           
 void setInheritAll(boolean inheritAll)
          If set to true all properties from the ant build file are inheretid to the Global scope as properties.
 void setLoggingFile(java.lang.String loggingFile)
          The logging.properties to use.
 void setPrepareForPublish(boolean prepareForPublish)
          Fake the sender address, this is useful to resend dead messages.
 void setPropertyFile(java.lang.String propertyFile)
          The xmlBlaster.properties to use.
 void setResponseFile(java.lang.String responseFile)
          The file whereto dump the method invocation return values.
 void setScriptFile(java.lang.String scriptFile)
          Pass the name of a file which contains XmlBlaster script markup.
 void setUpdateFile(java.lang.String updateFile)
          Where shall the update messages be dumped to.
 void setVerbose(int level)
          Set verbosity from 0 (silent) to 3 (chatterbox).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

verbose

private int verbose

glob

private Global glob

xmlBlasterScript

private java.lang.String xmlBlasterScript

scriptFile

private java.lang.String scriptFile

responseFile

private java.lang.String responseFile

updateFile

private java.lang.String updateFile

propertyFile

private java.lang.String propertyFile

loggingFile

private java.lang.String loggingFile

reader

private java.io.Reader reader

inheritAll

private boolean inheritAll

responseStream

private java.io.OutputStream responseStream

updateStream

private java.io.OutputStream updateStream

interpreter

private XmlScriptClient interpreter

prepareForPublish

private boolean prepareForPublish
Constructor Detail

XmlBlasterTask

public XmlBlasterTask()
Method Detail

execute

public void execute()
             throws BuildException
Throws:
BuildException

setVerbose

public void setVerbose(int level)
Set verbosity from 0 (silent) to 3 (chatterbox).

Parameters:
level - defaults to 1

addText

public void addText(java.lang.String text)
Set the task body text, we expect a valid xmlBlaster xml script.

Parameters:
text -

setResponseFile

public void setResponseFile(java.lang.String responseFile)
The file whereto dump the method invocation return values.

Parameters:
responseFile - The outFile to set, for example "/tmp/responses.xml"

setScriptFile

public void setScriptFile(java.lang.String scriptFile)
Pass the name of a file which contains XmlBlaster script markup.

Parameters:
scriptFile - The scriptFile to set.

setUpdateFile

public void setUpdateFile(java.lang.String updateFile)
Where shall the update messages be dumped to.

Parameters:
updateFile - The updateFile to set, for example "/tmp/updates.xml"

setPrepareForPublish

public void setPrepareForPublish(boolean prepareForPublish)
Fake the sender address, this is useful to resend dead messages.

Parameters:
prepareForPublish - The prepareForPublish to set.

setPropertyFile

public void setPropertyFile(java.lang.String propertyFile)
The xmlBlaster.properties to use.

Parameters:
propertyFile - The propertyFile to set, e.g. "/tmp/xmlBlaster.properties"

setLoggingFile

public void setLoggingFile(java.lang.String loggingFile)
The logging.properties to use.

Set the JDK1.4 logging configuration for the xmlBlaster client library

Parameters:
loggingFile - The loggingFile to set, e.g. "/tmp/logging.properties"

setInheritAll

public void setInheritAll(boolean inheritAll)
If set to true all properties from the ant build file are inheretid to the Global scope as properties.

Parameters:
inheritAll - The inheritAll to set, defaults to false

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.