@Echo off

Rem   ---------------------------------------------------------------------------
Rem   JASMINe
Rem   Copyright (C) 2009 Bull S.A.S.
Rem   Contact: jasmine@ow2.org
Rem
Rem   This library is free software; you can redistribute it and/or
Rem   modify it under the terms of the GNU Lesser General Public
Rem   License as published by the Free Software Foundation; either
Rem   version 2.1 of the License, or any later version.
Rem
Rem   This library is distributed in the hope that it will be useful,
Rem   but WITHOUT ANY WARRANTY; without even the implied warranty of
Rem   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Rem   Lesser General Public License for more details.
Rem
Rem   You should have received a copy of the GNU Lesser General Public
Rem   License along with this library; if not, write to the Free Software
Rem   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
Rem   USA
Rem   ---------------------------------------------------------------------------
Rem   $Id: startjm.bat 4896 2009-08-13 08:31:27Z jlegrand $
Rem   ---------------------------------------------------------------------------

Rem Test JONAS_ROOT and JONAS_BASE

if ["%JONAS_ROOT%"]==[""] goto set_jonas_root
if ["%JONAS_BASE%"]==[""] goto set_jonas_base
set PATH=%JONAS_ROOT%\bin;%PATH%
goto :args

:set_jonas_root
  echo Check that JONAS_ROOT is set
goto :EOF

:set_jonas_base
set JONAS_BASE=%JONAS_ROOT%

Rem ---------------------------------------------
Rem Get args
Rem ---------------------------------------------
:args
if [%1]==[]   goto no_arg
set ARGS=
:loop_on_args
set VALUE=%~1
if [%1]==[start]     goto start_arg
if [%1]==[stop]      goto stop_arg
set ARGS=%ARGS% %1
goto next_arg

Rem First arguments : start, stop, admin, version, check

:start_arg

del %JONAS_BASE%\deploy\zz_jasmine-monitoring.xml

start /B jonas start -clean -Djonas.felix.configuration.file=config.properties

sleep 25

echo
echo Deploying JASMINe Monitoring ...

copy %JONAS_BASE%\repositories\url-internal\zz_jasmine-monitoring.xml %JONAS_BASE%\deploy
goto :EOF

:stop_arg
start /B jonas stop
goto :EOF

:no_arg
echo No arguments specified.
goto usage

:usage
echo jasmine start | stop
