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

  <description>Orchestra Weather 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>Weather 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">
    <zip destfile="weather.bar">
      <fileset dir="." includes="*.bpel"/>
      <fileset dir="." includes="*.wsdl"/>
    </zip>
  </target>


  <target name="deploy">
    <java classpathref="base.classpath" classname="org.ow2.orchestra.jmxclient.JMXClient" fork="yes" failonerror="true">
      <arg value="--deploy" />
      <arg value="--bpel" />
      <arg value="${basedir}/weather.bpel" />
      <arg value="--wsdls" />
      <arg value="${basedir}/weatherArtifacts.wsdl" />
    </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://orchestra.ow2.org/weather}weather" />
    </java>
  </target>

  <target name="launch">
    <input message="Location (City,Country)" addproperty="weather.location" defaultvalue="Grenoble,France" />

    <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}/weatherPT"/>
      <arg value="--soapAction" />
      <arg value="http://orchestra.ow2.org/weatherArtifacts/process" />
      <arg value="--soapMessage" />
      <arg value="
        &lt;weatherRequest xmlns='http://orchestra.ow2.org/weather'&gt;
          &lt;input&gt;${weather.location}&lt;/input&gt;
        &lt;/weatherRequest&gt;
      "/>
    </java>
  </target>
</project>