<project name="orchestra-echo" default="usage">

  <description>Orchestra Echo example</description>

  <!-- properties files -->
  <property file="../../conf/orchestra.properties" />

  <path id="base.classpath">
    <pathelement location="../../conf"/>
    <fileset dir="../../lib">
      <include name="orchestra-jmxclient*.jar" />
    </fileset>
  </path>

  <target name="usage">
    <echo>Echo example</echo>
    <echo>To deploy the process: ant deploy</echo>
    <echo>To invoke the process: ant launch</echo>
    <echo>To undeploy the process: ant undeploy</echo>
    <echo>Please make sure Orchestra is started before executing this example.</echo>
  </target>

  <target name="createBar">
    <propertyfile file="bar.properties">
      <entry key="bpel" value="echo.bpel"/>
      <entry key="wsdl" value="echo.wsdl"/>
    </propertyfile>
    <zip destfile="echo.bar">
      <fileset dir="." includes="*.bpel"/>
      <fileset dir="." includes="*.wsdl"/>
      <fileset dir="." includes="bar.properties"/>
    </zip>
  </target>

  <target name="deploy" depends="createBar">
    <java  classname="org.ow2.orchestra.jmxclient.JMXClient" classpathref="base.classpath" fork="true" error="error.txt"  failonerror="true">
      <arg value="--deploy" />
      <arg value="--bar" />
      <arg value="echo.bar" />
    </java>
  </target>

  <target name="undeploy">
    <java classpathref="base.classpath" classname="org.ow2.orchestra.jmxclient.JMXClient" fork="yes" failonerror="true">
      <arg value="--undeploy" />
      <arg value="--process" />
      <arg value="{http://enterprise.netbeans.org/bpel/echo/echo_1}echo" />
    </java>
  </target>

  <target name="launch">
    <input message="Enter your message :" addproperty="message" defaultvalue="Default message sent ... and received :D"/>
	
	 <java classpathref="base.classpath" classname="org.ow2.orchestra.jmxclient.JMXClient" fork="yes" failonerror="true">
      <arg value="--call" />
      <arg value="--endpoint" />
      <arg value="http://${orchestra.servlet.host}:${orchestra.servlet.port}/${orchestra.servlet.path}/port1"/>
      <arg value="--soapAction" />
      <arg value="http://orchestra.ow2.org/echo/operation1" />
      <arg value="--soapMessage" />
      <arg value="
        &lt;requestMessage xmlns='http://localhost/echo/echo'&gt;
          &lt;inputType&gt;${message}&lt;/inputType&gt;
        &lt;/requestMessage&gt;
      "/>
    </java>
	
  </target>
</project>