<?xml version="1.0" encoding="ISO-8859-1"?>
<project 
    xmlns:j="jelly:core" 
    xmlns:ant="jelly:ant" 
    xmlns:artifact="artifact" 
    xmlns:license="license" 
    xmlns:maven="jelly:maven" 
    xmlns:util="jelly:util" 
    default="default">

    <goal name="default" prereqs="ejb:ejb">
        <attainGoal name="ejb:stage"/>        
        <attainGoal name="ds:stage"/>        
    </goal>

    <goal name="deploy">
        <attainGoal name="ejb:deploy"/>        
        <attainGoal name="ds:deploy"/>        
    </goal>

    <goal name="undeploy">
        <attainGoal name="ejb:undeploy"/>        
        <attainGoal name="ds:undeploy"/>        
    </goal>
    
    <goal name="sendq" prereqs="setclasspath">
        <java classname="com.panacya.platform.service.bus.client.JmsSimpleClient" fork="yes">
            <classpath refid="test.classpath"/>
            <arg value="send"/> 
            <arg value="queue.testQueue"/>
            <arg value="-1"/>
            <arg value="100"/>
        </java>
    </goal>

    <goal name="sendt" prereqs="setclasspath">
        <java classname="com.panacya.platform.service.bus.client.JmsSimpleClient" fork="yes">
            <classpath refid="test.classpath"/>
            <arg value="send"/> 
            <arg value="topic.testTopic"/> 
        </java>
    </goal>

    <goal name="listen" prereqs="setclasspath">
        <java classname="com.panacya.platform.service.bus.client.JmsSimpleClient" fork="yes">
            <classpath refid="test.classpath"/>
            <arg value="receive"/>             
            <arg value="topic.testTopic"/>              
        </java>
    </goal>

    <goal name="receive" prereqs="setclasspath">
        <java classname="com.panacya.platform.service.bus.client.JmsSimpleClient" fork="yes">
            <classpath refid="test.classpath"/>
            <arg value="receive"/>        
            <arg value="queue.outbound"/>  
            
        </java>
    </goal>

    <goal name="receive-non-stop" prereqs="setclasspath">
        <java classname="com.panacya.platform.service.bus.client.JmsSimpleClient" fork="yes">
            <classpath refid="test.classpath"/>
            <arg value="receive-non-stop"/>        
            <arg value="queue.outbound"/>    
        </java>
    </goal>

    <goal name="sendq-receive" prereqs="setclasspath">
        <java classname="com.panacya.platform.service.bus.client.JmsSimpleClient" fork="yes">
            <classpath refid="test.classpath"/>
            <arg value="send-receive"/>
            <arg value="queue.testQueue"/> 
        </java>
    </goal>
    
    <goal name="sendt-receive" prereqs="setclasspath">
        <java classname="com.panacya.platform.service.bus.client.JmsSimpleClient" fork="yes">
            <classpath refid="test.classpath"/>
            <arg value="send-receive"/>
            <arg value="topic.testTopic"/>  
        </java>
    </goal>
    
    <goal name="setclasspath">
        <maven:get var="maven.test.dest" plugin='maven-test-plugin' property='maven.test.dest'/>
        <path id="test.classpath">
            <pathelement location="${maven.test.dest}"/>
            <pathelement location="${maven.build.dest}"/>
            <path refid="maven.dependency.classpath"/>
        </path>
    </goal>
    
    <j:set var="activemq.jboss.deploy" value="${activemq.jboss.home}/deploy"/>
    <j:set var="activemq.jboss.deploy.bak" value="${activemq.jboss.home}/deploy.bak"/>

    <goal name="ejb:stage">
        <ant:copy todir="${activemq.jboss.deploy.bak}">
            <ant:fileset file="${maven.build.dir}/${maven.final.name}.jar"/>
        </ant:copy>
    </goal>

    <goal name="ejb:deploy">
        <ant:move file="${activemq.jboss.deploy.bak}/${maven.final.name}.jar" todir="${activemq.jboss.deploy}" overwrite="false" preservelastmodified="true"/>
    </goal>

    <goal name="ejb:undeploy">
        <ant:move file="${activemq.jboss.deploy}/${maven.final.name}.jar" todir="${activemq.jboss.deploy.bak}" overwrite="false" preservelastmodified="true"/>
    </goal>

    <goal name="ds:stage">
        <ant:copy todir="${activemq.jboss.deploy.bak}">
            <ant:fileset file="${basedir}/src/main/jboss-datasource/panacya-jms-ds.xml"/>
            <ant:fileset file="${maven.repo.local}/activemq/rars/activemq-ra-3.1-SNAPSHOT.rar"/>
        </ant:copy>
    </goal>

    <goal name="ds:deploy">
        <ant:move todir="${activemq.jboss.deploy}" overwrite="false" preservelastmodified="true">
            <ant:fileset file="${activemq.jboss.deploy.bak}/panacya-jms-ds.xml"/>
            <ant:fileset file="${activemq.jboss.deploy.bak}/activemq-ra-3.1-SNAPSHOT.rar"/>
        </ant:move>
    </goal>

    <goal name="ds:undeploy">
        <ant:move todir="${activemq.jboss.deploy.bak}" overwrite="false" preservelastmodified="true">
            <ant:fileset file="${activemq.jboss.deploy}/panacya-jms-ds.xml"/>
            <ant:fileset file="${activemq.jboss.deploy}/activemq-ra-3.1-SNAPSHOT.rar"/>
        </ant:move>
    </goal>

</project>
