|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Task org.xmlBlaster.contrib.ant.XmlBlasterTask
public class XmlBlasterTask
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
.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.
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).
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 |
---|
private int verbose
private Global glob
private java.lang.String xmlBlasterScript
private java.lang.String scriptFile
private java.lang.String responseFile
private java.lang.String updateFile
private java.lang.String propertyFile
private java.lang.String loggingFile
private java.io.Reader reader
private boolean inheritAll
private java.io.OutputStream responseStream
private java.io.OutputStream updateStream
private XmlScriptClient interpreter
private boolean prepareForPublish
Constructor Detail |
---|
public XmlBlasterTask()
Method Detail |
---|
public void execute() throws BuildException
BuildException
public void setVerbose(int level)
level
- defaults to 1public void addText(java.lang.String text)
text
- public void setResponseFile(java.lang.String responseFile)
responseFile
- The outFile to set, for example "/tmp/responses.xml"public void setScriptFile(java.lang.String scriptFile)
scriptFile
- The scriptFile to set.public void setUpdateFile(java.lang.String updateFile)
updateFile
- The updateFile to set, for example "/tmp/updates.xml"public void setPrepareForPublish(boolean prepareForPublish)
prepareForPublish
- The prepareForPublish to set.public void setPropertyFile(java.lang.String propertyFile)
xmlBlaster.properties
to use.
propertyFile
- The propertyFile to set, e.g. "/tmp/xmlBlaster.properties"public void setLoggingFile(java.lang.String loggingFile)
logging.properties
to use.
Set the JDK1.4 logging configuration for the xmlBlaster client library
loggingFile
- The loggingFile to set, e.g. "/tmp/logging.properties"public void setInheritAll(boolean inheritAll)
true
all properties from the ant build file
are inheretid to the Global scope as properties.
inheritAll
- The inheritAll to set, defaults to false
|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |