<?xml version="1.0" encoding="UTF-8"?>
<!--
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 - JOnAS: Java(TM) Open Application Server
 - Copyright (C) 2005-2011 Bull S.A.S.
 - Contact: jonas-team@ow2.org
 -
 - This library is free software; you can redistribute it and/or
 - modify it under the terms of the GNU Lesser General Public
 - License as published by the Free Software Foundation; either
 - version 2.1 of the License, or any later version.
 -
 - This library is distributed in the hope that it will be useful,
 - but WITHOUT ANY WARRANTY; without even the implied warranty of
 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 - Lesser General Public License for more details.
 -
 - You should have received a copy of the GNU Lesser General Public
 - License along with this library; if not, write to the Free Software
 - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 - USA
 -
 - Initial developer(s): Florent BENOIT
 -
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 - $Id: build-master.xml 22425 2012-05-04 16:45:46Z cazauxj $
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -->
<!--
 -  build.xml file for creating a new JOnAS_BASE
 -->
<project basedir="" default="create_jonas_base"
  name="JOnAS_BASE tools" xmlns:jant="http://jonas.objectweb.org/ant">
  <!-- Define some properties -->
  <target name="init">
    <!-- properties -->
    <property environment="myenv"/>
    <property name="jonas.root" value="${myenv.JONAS_ROOT}"/>
    <property name="jonas.base" value="${myenv.JONAS_BASE}"/>
    <!-- tasks classpath="${jonas.root}/lib/common/ow_jonas_ant.jar" -->
    <!-- tasks -->
    <typedef resource="org/ow2/jonas/antmodular/antlib.xml" uri="http://jonas.objectweb.org/ant">
      <!--
        The Java EE API and JAXB2 JARs need to be included since the JDBC XML
        tasks require JAXB2, not included in the Java 5 runtime. These can be
        removed when running on Java 6.
        -->
      <classpath>
        <fileset dir="${jonas.root}/repositories/maven2-internal/org/ow2/jonas/osgi/javaee-api">
          <include name="**/*.jar"/>
        </fileset>
        <fileset dir="${jonas.root}/repositories/maven2-internal/org/ow2/bundles/ow2-bundles-externals-jaxb2">
          <include name="**/*.jar"/>
        </fileset>
        <pathelement location="${jonas.root}/lib/common/ow_jonas_ant.jar"/>
      </classpath>
    </typedef>
    <!-- Define directories -->
    <property name="conf.dir" value="${user.home}/jb.config/conf"/>
    <!-- Load user properties -->
    <property file="${conf.dir}/jonas-newjb.properties"/>
    <property file="./build-jb.properties"/>
  </target>
  <!-- jonas_base control -->
  <target name="init_jonasbase">
    <input addproperty="jonas.base"
      defaultvalue="${myenv.JONAS_BASE}" message="Choose your jonas_base : [default : ${myenv.JONAS_BASE}] :"/>
    <input addproperty="carol.protocol"
      defaultvalue="${carol.defaultprotocol}"
      message="Choose your protocol : [default : ${carol.defaultprotocol}] :" validargs="jrmp,iiop,irmi"/>
    <input addproperty="webcontainer.service.name"
      defaultvalue="${webcontainer.service.defaultname}"
      message="Choose your WebContainer : [default : ${webcontainer.service.defaultname}] :" validargs="tomcat7"/>
    <antcall target="init_jonas_services"/>
  </target>
  <!-- init jonas services -->
  <target name="init_jonas_services">
    <condition property="tomcat7_selected">
      <equals arg1="${webcontainer.service.name}" arg2="tomcat7"/>
    </condition>
  </target>
  <!-- New JOnAS Base-->
  <target depends="init, init_jonasbase"
    description="Create a new JOnAS Base" name="create_jonas_base">
    <antcall target="internal_create_jonas_base"/>
    <antcall target="after_create_jonas_base"/>
  </target>
  <!-- Internal creation of new JOnAS Base-->
  <target depends="init" name="internal_create_jonas_base">
    <jant:newjonasbase skipOptionalDeployablesCopy="false" update="off"/>
  </target>
  <target depends="init_jonas_services" name="after_create_jonas_base">
    <antcall target="set_jonas_properties"/>
    <antcall target="set_carol"/>
    <antcall target="set_security"/>
    <antcall target="set_smartclient"/>
    <antcall target="set_web_container"/>
  </target>
  <target depends="init" name="set_jonas_properties">
    <jant:jonasProperties configfile="${jonas.log.configfile}"
      csiv2Propagation="${jonas.csiv2.propagation}"
      development="${jonas.development}" master="${jonas.master}"
      securityManager="${jonas.security.manager}"
      securityPropagation="${jonas.security.propagation}"
      services="${jonas.services}" transactionPropagation="${jonas.transaction.propagation}"/>
  </target>
  <target depends="init" name="set_lib">
    <jant:lib destDir="${jonas.base}" jonasRoot="${jonas.root}">
      <fileset dir="${user.home}/${drivers.dir}">
        <include name="${rajdbc.jdbcdriverjarfile}"/>
      </fileset>
    </jant:lib>
  </target>
  <target depends="init" name="set_web_container">
    <antcall target="set_web_container_tomcat7"/>
  </target>
  <target depends="init" if="tomcat7_selected" name="set_web_container_tomcat7">
    <jant:tomcat7
      ondemandenabled="${webcontainer.ondemandenabled}" ondemandredirectPort="${webcontainer.ondemanderedirectport}">
      <!-- @name is optionnal, if there is only a <tomcat> inner element, tomcat service will be choosed -->
      <!-- @port is optionnal, if set it will affect both jetty6.xml and tomcat6-server.xml.
           If not set, the (tomcat|jetty)/http[@port] value is used -->
      <connectors skipOptionalDeployablesCopy="false">
        <!-- Simply configure a HTTP/1.1 Connector : just set the port to use -->
        <http port="${http.port}"/>
        <!--
        <http port="${http.port}"
              redirectPort="9043"
              enableLookups="false"
              minSpareThreads="10"
              maxThreads="200"
              connectionTimeout="60000"
              acceptCount="256"
              maxKeepAliveRequest="100"
              compression="off"/>
        -->
        <!-- Simply configure a Director Connector : just set the port to use
        <director port="1234" />
        -->
        <!-- Simply configure a AJP/1.3 Connector : just set the port to use
        <ajp port="${ajp.port}"
             redirectPort="9043"
             enableLookups="false"
             minSpareThreads="10"
             maxThreads="200"
             connectionTimeout="60000"
             acceptCount="256"/>
        -->
        <!-- Simply configure a HTTPS Connector : just set the port to use, the keystore and its password
        <https port="${https.port}"
               redirectPort="9043"
               keystoreFile="/path/to/your/keystore"
               keystorePass="changeit"
               enableLookups="false"
               minSpareThreads="10"
               maxThreads="200"
               connectionTimeout="60000"
               acceptCount="256"
               maxKeepAliveRequest="100"
               compression="off"/>
        -->
      </connectors>
      <!-- Simply add a <Cluster> node into the <Host>. There are two algorithms for session replication: delta and
      backup (see the documentation http://tomcat.apache.org/tomcat-7.0-doc/cluster-howto.html for more informations).
      <sessionReplication listenPort="7777"
                           mcastAddr="222.222.222.222"
                           mcastPort="11111"
                           algorithm="delta"/>
      -->
      <!-- Simply configure the session manager in the tomcat7-context file
      <sessionManager maxActiveSessions="2500"/>
      -->
    </jant:tomcat7>
  </target>
  <target depends="init" name="set_smartclient">
    <jant:smartclient port="${smartclient.port}"/>
  </target>
  <target depends="init" name="set_carol">
    <jant:carol defaultPort="${carol.allport}"
      jrmpOptimization="${carol.jrmpopt}"
      localRegistry="${carol.localregistry}" protocols="${carol.protocol}"/>
  </target>
  <target depends="init" name="set_security">
    <jant:security>
      <admin name="jonas" password="SHA:NaLG+uYfgHeqth+qQBlyKr8FCTw="/>
      <user name="user1" password="notencoded" roles="role1"/>
      <!--<user name="user2" roles="role2" password="myPassword"/>-->
      <!--
      <jaasEntry name="">
        <jResourceLoginModule resourceName=""
                              serverName=""
                              certCallback=""
                              useUpperCaseUsername=""/>
      </jaasEntry>   -->
    </jant:security>
  </target>
</project>
