<!--
  ~  Licensed to the Apache Software Foundation (ASF) under one
  ~  or more contributor license agreements.  See the NOTICE file
  ~  distributed with this work for additional information
  ~  regarding copyright ownership.  The ASF licenses this file
  ~  to you under the Apache License, Version 2.0 (the
  ~  "License"); you may not use this file except in compliance
  ~  with the License.  You may obtain a copy of the License at
  ~
  ~   http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~  Unless required by applicable law or agreed to in writing,
  ~  software distributed under the License is distributed on an
  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  ~  KIND, either express or implied.  See the License for the
  ~  specific language governing permissions and limitations
  ~  under the License.
  -->

<project name="samples" default="help" basedir=".">
    <target name="help">
    <echo>
    ant stockquote
        Creates and sends a stock quote request. Could execute in 'smart client', 'proxy' and
        'gateway' modes by specifying WSA, transport and HTTP proxy endpoints/URLs. Optionally
        a policy (security) could be applied to the requests. The required stock symbol and
        operation could be specified as follows:

        examples:
        ant stockquote

        ant stockquote [-Dsymbol=IBM|MSFT|SUN|..]
            [-Dmode=quote | customquote | fullquote | placeorder | marketactivity]
            [-Dsoapver=soap11 | soap12]
            [-Daddurl=http://localhost:9000/services/SimpleStockQuoteService]
            [-Dtrpurl=http://localhost:8280]
            [-Dprxurl=http://localhost:8280]
            [-Drest=true]
            [-Dwsrm=true]
            [-Dwsrm11=true]
            [-Dpolicy=../../repository/conf/sample/resources/policy/policy_1.xml]

        Mode :
            quote          - send a quote request for a single stock
            customquote    - send a quote request in a custom format
            fullquote      - get quote reports for a period (i.e. 365 days of the year)
            placeorder     - place an order for stocks using a one way request
            marketactivity - get a market activity report (i.e. quotes for multiple symbols)

    ant jmsclient
        A client which could post a raw JMS text or binary message to a given destination.

        examples:
        ant jmsclient [-Djms_type=text] [-Djms_dest=dynamicQueues/JMSTextProxy][-Djms_payload="24.34 100 IBM"]
        ant jmsclient [-Djms_type=pox] [-Djms_dest=dynamicQueues/JMSPoxProxy] [-Djms_payload=MSFT]
        ant jmsclient [-Djms_type=binary] [-Djms_dest=dynamicQueues/JMSFileUploadProxy]
            [-Djms_payload=./../../repository/conf/sample/resources/mtom/asf-logo.gif]
        ant jmsclient [-Djms_type=pox] [-Djms_dest=dynamicQueues/JMSPoxProxy] [-Djms_payload=MSFT]
            [-Djms_msgcount=10000]

    ant optimizeclient
        A client that could send binary content using MTOM and SwA optimizations

        examples:
        ant optimizeclient [-Dopt_mode=mtom | swa]
            [-Dopt_url=http://localhost:8280/services/MTOMSwASampleService]
            [-Dopt_file=./../../repository/conf/sample/resources/mtom/asf-logo.gif]

    ant fixclient
        A client which could post a FIX message (of type Order-Single) embedded into a SOAP message.

	example:
        ant fixclient -Dsymbol=IBM -Dqty=5 -Dmode=buy -Daddurl=http://localhost:8280/services/FIXProxy

    ant amqpconsumer
        A JMS based amqp consumer that accept orders and generates executions.
        [-Dpropfile=/etc/direct.properties]

	example:
        ant amqpconsumer

    ant mddproducer
        A JMS client to produce market data on binary format seq#|symbol|price|market
        [-Djms_dest=dynamicQueues/JMSTextProxy]
        [-Dsymbol=MSFT] [-Dprice=100.20] [-Dmarket=NYSE]

    example:
        ant mddproducer

    ant eventsubscriber
        A client that subscribes to the Synapse event source

        examples:
        ant eventsubscriber
            [-Dmode=subscribe | unsubscribe | getstatus | renew]
            [-Daddurl=http://localhost:8280/services/eventing]
            [-Daddress=http://localhost:9000/services/SimpleStockQuoteService]
            [-Dtopic=/synapse/sample/topic]
            [-Didentifier=urn:uuid:607498E6483EF9C434122785636889830400199622296]
            [-Dexpires=2008-12-31T21:07:00.000-08:00]

    ant eventsender
        A client that sends Events to the Synapse event sink

        examples:
        ant eventsender
            [-Daddurl=http://localhost:8280/services/eventing]
            [-Dtopic=/synapse/sample/topic]
            [-Dtopicns=http://apache.org/aip]
            [-Daction=urn:event]
            [-Dsymbol=DELL]
            [-Dqty=1000]
            [-Dprice=100.10]

    ant jsonclient
        A client that sends get-quote requests using the JSON content interchange format over HTTP

        example:
        ant jsonclient
            [-Daddurl=http://localhost:8280/services/JSONProxy]
            [-Dsymbol=DELL]

    ant rabbitmqclient
        A simple client for RabbitMQ AMQP broker.

        examples:
        ant rabbitmqclient [-Damqpmode=consumer] [-DqueueName=ConsumerProxy] [-DpayLoad=IBM]
        ant rabbitmqclient [-Damqpmode=producer] [-DqueueName=ConsumerProxy] [-DpayLoad=IBM]
        ant rabbitmqclient [-Damqpmode=producer] [-DexchangeName=subscriber-exchange] [-DpayLoad=IBM]
        ant rabbitmqclient [-Damqpmode=producer] [-DexchangeName=topic-exchange] [-DroutingKey=kern.critical] [-DpayLoad=IBM]

    </echo>
    </target>

    <property name="symbol" value=""/>
    <property name="mode" value=""/>
    <property name="soapver" value=""/>
    <property name="i" value=""/>
    <property name="port" value=""/>
    <property name="addurl" value=""/>
    <property name="trpurl" value=""/>
    <property name="prxurl" value=""/>
    <property name="timeout" value=""/>
    <property name="repository" value=""/>
    <property name="policy" value=""/>
    <property name="rest" value=""/>
    <property name="wsrm" value=""/>
    <property name="wsrm11" value=""/>
    <property name="itr" value=""/>
    <property name="jms_dest" value=""/>
    <property name="jms_type" value=""/>
    <property name="jms_payload" value=""/>
    <property name="jms_msgcount" value=""/>
    <property name="opt_mode" value=""/>
    <property name="opt_url" value=""/>
    <property name="opt_file" value=""/>
    <property name="class.dir" value="target/classes"/>
    <property name="qty" value=""/>
    <property name="propfile" value=""/>
    <property name="sleep" value=""/>
    <property name="session" value=""/>
    <property name="price" value=""/>
    <property name="market" value=""/>
    <property name="jms_topic" value=""/>
    <property name="qty" value=""/>
    <property name="topic" value=""/>
    <property name="address" value=""/>
    <property name="action" value=""/>
    <property name="topicns" value=""/>
    <property name="mode" value=""/>
    <property name="identifier" value=""/>
    <property name="amqpmode" value=""/>
    <property name="queueName" value=""/>
    <property name="payLoad" value=""/>
    <property name="exchangeName" value=""/>
    <property name="routingKey" value=""/>

    <target name="clean">
        <delete dir="target" quiet="true"/>
        <delete dir="${class.dir}" quiet="true"/>
    </target>

    <target name="stockquote" depends="compile">
        <java classname="samples.userguide.StockQuoteClient"
              classpathref="javac.classpath" fork="true">
            <sysproperty key="symbol" value="${symbol}"/>
            <sysproperty key="mode"   value="${mode}"/>
            <sysproperty key="soapver" value="${soapver}"/>
            <sysproperty key="addurl" value="${addurl}"/>
            <sysproperty key="trpurl" value="${trpurl}"/>
            <sysproperty key="prxurl" value="${prxurl}"/>
            <sysproperty key="timeout" value="${timeout}"/>
            <sysproperty key="repository" value="${repository}"/>
            <sysproperty key="policy" value="${policy}"/>
            <sysproperty key="rest" value="${rest}"/>
            <sysproperty key="wsrm" value="${wsrm}"/>
            <sysproperty key="wsrm11" value="${wsrm11}"/>
            <sysproperty key="itr" value="${itr}"/>
            <sysproperty key="javax.net.ssl.trustStore" value="./../../lib/trust.jks"/>
            <sysproperty key="javax.net.ssl.trustStorePassword" value="password"/>
            <sysproperty key="java.io.tmpdir" value="./../../work/temp/sampleClient"/>
            <sysproperty key="i" value="${i}"/>
            <!--
            <jvmarg value="-Xdebug"/>
            <jvmarg value="-Xnoagent"/>
            <jvmarg value="-Djava.compiler=none"/>
            <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"/>
            -->
        </java>
    </target>

    <!-- a simple smoke test -->
    <target name="smoke" depends="compile">
        <property name="addurl" value="http://localhost:9000/services/SimpleStockQuoteService"/>
        <property name="trpurl" value="http://localhost:8280/"/>
        <java classname="samples.userguide.StockQuoteClient"
              classpathref="javac.classpath" fork="true">
            <sysproperty key="addurl" value="http://localhost:9000/services/SimpleStockQuoteService"/>
            <sysproperty key="trpurl" value="http://localhost:8280/"/>
            <sysproperty key="java.io.tmpdir" value="./../../work/temp/sampleClient"/>
        </java>
    </target>

    <target name="amqpconsumer" depends="compile">
        <java classname="samples.userguide.AMQPConsumer"
             classpathref="javac.classpath" fork="true">
            <sysproperty key="propfile" value="${propfile}"/>
        </java>
    </target>

    <target name="mddproducer" depends="compile">
        <java classname="samples.userguide.MDDProducer"
             classpathref="javac.classpath" fork="true">
            <sysproperty key="jms_dest" value="${jms_dest}"/>
            <sysproperty key="symbol" value="${symbol}"/>
            <sysproperty key="price" value="${price}"/>
            <sysproperty key="market" value="${market}"/>
        </java>
    </target>

    <target name="mddconsumer" depends="compile">
        <java classname="samples.userguide.MDDConsumer"
             classpathref="javac.classpath" fork="true">
            <sysproperty key="jms_topic" value="${jms_topic}"/>
        </java>
    </target>

    <target name="jmsclient" depends="compile">
        <java classname="samples.userguide.GenericJMSClient"
              classpathref="javac.classpath" fork="true">
            <sysproperty key="jms_dest"    value="${jms_dest}"/>
            <sysproperty key="jms_type"    value="${jms_type}"/>
            <sysproperty key="jms_payload" value="${jms_payload}"/>
            <sysproperty key="jms_msgcount" value="${jms_msgcount}"/>
            <sysproperty key="java.io.tmpdir" value="./../../work/temp/sampleClient"/>
        </java>
    </target>

    <target name="rabbitmqclient" depends="init">
        <javac srcdir="src" destdir="${class.dir}" includes="**/RabbitMQAMQPClient.java">
            <classpath refid="javac.classpath"/>
        </javac>
        <java classname="samples.userguide.RabbitMQAMQPClient"
              classpathref="javac.classpath" fork="true">
            <sysproperty key="amqpmode"    value="${amqpmode}"/>
            <sysproperty key="queueName"    value="${queueName}"/>
            <sysproperty key="payLoad" value="${payLoad}"/>
            <sysproperty key="exchangeName" value="${exchangeName}"/>
            <sysproperty key="routingKey" value="${routingKey}"/>
        </java>
    </target>

    <target name="fixclient" depends="compile">
        <java classname="samples.userguide.FIXClient"
             classpathref="javac.classpath" fork="true">

            <sysproperty key="symbol" value="${symbol}"/>
            <sysproperty key="mode"   value="${mode}"/>
            <sysproperty key="addurl" value="${addurl}"/>
            <sysproperty key="trpurl" value="${trpurl}"/>
            <sysproperty key="prxurl" value="${prxurl}"/>
            <sysproperty key="timeout" value="${timeout}"/>
            <sysproperty key="qty"    value="${qty}"/>
            <sysproperty key="repository" value="${repository}"/>
            <sysproperty key="java.io.tmpdir" value="./../../work/temp/sampleClient"/>

        </java>
    </target>

    <target name="optimizeclient" depends="compile">
        <java classname="samples.userguide.MTOMSwAClient"
              classpathref="javac.classpath" fork="true">
            <sysproperty key="opt_mode" value="${opt_mode}"/>
            <sysproperty key="opt_url"  value="${opt_url}"/>
            <sysproperty key="opt_file" value="${opt_file}"/>
            <sysproperty key="javax.net.ssl.trustStore" value="./../../lib/trust.jks"/>
            <sysproperty key="javax.net.ssl.trustStorePassword" value="password"/>
            <sysproperty key="java.io.tmpdir" value="./../../work/temp/sampleClient"/>
            <!--
            <jvmarg value="-Xdebug"/>
            <jvmarg value="-Xnoagent"/>
            <jvmarg value="-Djava.compiler=none"/>
            <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"/>
            -->
        </java>
    </target>

    <target name="loadbalancefailover" depends="compile">
        <java classname="samples.userguide.LoadbalanceFailoverClient"
              classpathref="javac.classpath" fork="true">
            <sysproperty key="mode" value="${mode}"/>
            <sysproperty key="port" value="${port}"/>
            <sysproperty key="i" value="${i}"/>
            <sysproperty key="addurl" value="${addurl}"/>
            <sysproperty key="trpurl" value="${trpurl}"/>
            <sysproperty key="timeout" value="${timeout}"/>
            <sysproperty key="prxurl" value="${prxurl}"/>
            <sysproperty key="session" value="${session}"/>
            <sysproperty key="sleep" value="${sleep}"/>
            <sysproperty key="java.io.tmpdir" value="./../../work/temp/sampleClient"/>
        </java>
    </target>

    <target name="threadedclient" depends="compile">
        <java classname="samples.userguide.ThreadedClient"
              classpathref="javac.classpath" fork="true">
            <sysproperty key="epr" value="${epr}"/>
            <sysproperty key="op" value="${op}"/>
            <sysproperty key="req" value="${req}"/>
            <sysproperty key="load" value="${load}"/>
            <sysproperty key="msg" value="${msg}"/>
            <sysproperty key="t" value="${t}"/>
            <sysproperty key="session" value="${session}"/>
            <sysproperty key="java.io.tmpdir" value="./../../work/temp/sampleClient"/>
        </java>
    </target>

    <target name="eventsubscriber" depends="compile">
        <java classname="samples.userguide.EventSubscriber"
             classpathref="javac.classpath" fork="true">
            <sysproperty key="addurl" value="${addurl}"/>
            <sysproperty key="trpurl" value="${trpurl}"/>
            <sysproperty key="prxurl" value="${prxurl}"/>
            <sysproperty key="topic" value="${topic}"/>
            <sysproperty key="address" value="${address}"/>
            <sysproperty key="repository" value="${repository}"/>
            <sysproperty key="mode" value="${mode}"/>
            <sysproperty key="identifier" value="${identifier}"/>
            <sysproperty key="expires" value="${expires}"/>
            <sysproperty key="java.io.tmpdir" value="./../../work/temp/sampleClient"/>
        </java>
    </target>

    <target name="eventsender" depends="compile">
        <java classname="samples.userguide.EventSender"
             classpathref="javac.classpath" fork="true">
            <sysproperty key="symbol" value="${symbol}"/>
            <sysproperty key="price"   value="${price}"/>
            <sysproperty key="addurl" value="${addurl}"/>
            <sysproperty key="trpurl" value="${trpurl}"/>
            <sysproperty key="prxurl" value="${prxurl}"/>
            <sysproperty key="qty"    value="${qty}"/>
            <sysproperty key="repository" value="${repository}"/>
            <sysproperty key="java.io.tmpdir" value="./../../work/temp/sampleClient"/>
            <sysproperty key="topic"    value="${topic}"/>
            <sysproperty key="action"    value="${action}"/>
            <sysproperty key="topicns"    value="${topicns}"/>
        </java>
    </target>

    <target name="jsonclient" depends="compile">
        <java classname="samples.userguide.JSONClient"
              classpathref="javac.classpath" fork="true">
            <sysproperty key="symbol" value="${symbol}"/>
            <sysproperty key="addurl" value="${addurl}"/>
            <sysproperty key="trpurl" value="${trpurl}"/>
            <sysproperty key="prxurl" value="${prxurl}"/>
            <sysproperty key="repository" value="${repository}"/>
        </java>
    </target>

    <target name="init">
        <mkdir dir="${class.dir}"/>
        <mkdir dir="./../../work/temp/sampleClient"/>
        <path id="javac.classpath">
            <pathelement path="${class.dir}"/>
            <pathelement path="../../lib"/>
            <fileset dir="../../lib">
                <include name="**/*.jar"/>
            </fileset>
        </path>
    </target>

    <target name="compile" depends="init" description="Compile all Java">
        <javac srcdir="src" destdir="${class.dir}" excludes="**/RabbitMQAMQPClient.java">
            <classpath refid="javac.classpath"/>
        </javac>
    </target>

</project>
