<!--
 -
 - 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="qpid-jca-example-glassfish-properties" basedir="." default="">

    <property name="jndi.scheme" value="name"/>
    <property name="jndi.prefix" value=""/>

    <property name="qpid.xacf.jndi.name" value="QpidJMSXA"/>
    <property name="qpid.hello.topic.jndi.name" value="HelloTopic"/>
    <property name="qpid.goodbye.topic.jndi.name" value="GoodByeTopic"/>
    <property name="qpid.hello.queue.jndi.name" value="HelloQueue"/>
    <property name="qpid.goodbye.queue.jndi.name" value="GoodByeQueue"/>
    <property name="qpid.request.queue.jndi.name" value="QpidRequestQueue"/>
    <property name="qpid.response.queue.jndi.name" value="QpidResponseQueue"/>
    <property name="qpid.ejb.jndi.name" value="mappedName=&quot;QpidTestEJB&quot;"/>
    <property name="qpid.ejb.ref.name" value="QpidTestBean/local"/>
    <property name="qpid.ejb.name" value="QpidTestBean#org.apache.qpid.jca.example.ejb.QpidTestRemote"/>
    <property name="qpid.client.cf.jndi.name" value="QpidConnectionFactory"/>
    <property name="qpid.client.dest.jndi.name" value="${qpid.hello.queue.jndi.name}"/>

    <property name="jndi.context" value="com.sun.enterprise.naming.SerialInitContextFactory"/>
    <property name="server.host" value="iiop://localhost:3700"/>
    <property name="glassfish.home" value="${env.GLASSFISH_HOME}"/>
    <property name="glassfish.domain" value="domain1"/>
    <property name="glassfish.user" value=""/>
    <property name="glassfish.password" value=""/>

    <path id="compile.classpath">
        <fileset dir="${glassfish.home}/glassfish/modules">
            <include name="javax.ejb.jar"/>
            <include name="javax.transaction.jar"/>
            <include name="javax.jms.jar"/>
            <include name="javax.resource.jar"/>
            <include name="javax.servlet.jar"/>
        </fileset>

        <fileset dir="${glassfish.home}/glassfish/domains/${glassfish.domain}/lib/ext">
            <include name="slf4j-api-*.jar"/>
        </fileset>
    </path>

    <path id="run.classpath">
        <fileset dir="${lib.dir}">
            <include name="qpid-jca-*.jar"/>
            <include name="qpid-client-*.jar"/>
            <include name="qpid-common-*.jar"/>
            <!-- Old jar, for examples compatibility -->
            <include name="qpid-ra-*.jar"/>
        </fileset>

        <fileset dir="${glassfish.home}/glassfish/lib/">
            <include name="gf-client.jar"/>
        </fileset>

        <fileset dir="${glassfish.home}/glassfish/modules">
            <include name="javax.ejb.jar"/>
            <include name="javax.transaction.jar"/>
            <include name="javax.jms.jar"/>
            <include name="javax.resource.jar"/>
            <include name="javax.servlet.jar"/>
        </fileset>
        <fileset dir="${glassfish.home}/glassfish/domains/${glassfish.domain}/lib/ext">
            <include name="slf4j-api-*.jar"/>
        </fileset>
    </path>

    <filterset id="extra.filterset">
        <filter token="rar.ver" value="${qpid.ver}"/>
    </filterset>

    <macrodef name="glassfish">
        <attribute name="user" default="${glassfish.user}"/>
        <attribute name="password" default="${glassfish.password}"/>
        <attribute name="action" default="list-applications"/>
        <attribute name="module"/>
        <attribute name="plan" default=""/>
        <sequential>
            <exec executable="${glassfish.home}/bin/asadmin">
                <arg line="@{action} @{module} @{plan}"/>
            </exec>
        </sequential>
    </macrodef>

    <target name="package-rar" depends="compile">
        <jar destfile="${build.dir}/${rar.name}"/>
    </target>

    <target name="deploy-rar" depends="package-rar" description="Deploy the RAR file.">
        <glassfish action="deploy" module="${qpid.jca.dir}/${rar.name}"/>
        <glassfish action="add-resources" module="${gen.dir}/glassfish-resources.xml"/>
    </target>


    <target name="undeploy-resources">
        <glassfish action="delete-admin-object" module="${qpid.hello.topic.jndi.name}"/>
        <glassfish action="delete-admin-object" module="${qpid.goodbye.topic.jndi.name}"/>
        <glassfish action="delete-admin-object" module="${qpid.hello.queue.jndi.name}"/>
        <glassfish action="delete-admin-object" module="${qpid.goodbye.queue.jndi.name}"/>
        <glassfish action="delete-admin-object" module="${qpid.request.queue.jndi.name}"/>
        <glassfish action="delete-admin-object" module="${qpid.response.queue.jndi.name}"/>
        <glassfish action="delete-connector-connection-pool" module="--cascade true QpidJMSXAPool"/>
        <glassfish action="delete-connector-connection-pool" module="--cascade true QpidJMSPool"/>
        <glassfish action="delete-resource-adapter-config" module="QpidResourceAdapter"/>
    </target>

    <target name="undeploy-rar" description="Deploy the RAR file.">
        <glassfish action="undeploy" module="--cascade true qpid-ra-${qpid.ver}"/>
    </target>

    <target name="deploy-ear" description="Deploy the EAR file." depends="package-ear">
        <glassfish action="deploy" module="${build.dir}/${ear.name}"/>
    </target>

    <target name="undeploy-ear" description="Undeploy the EAR file.">
        <glassfish action="undeploy" module="qpid-jcaex"/>
    </target>
</project>


