JMX_connection_pool_adapter.bin.generate-ra.sh Maven / Gradle / Ivy
#!/bin/bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# - JASMINe
# - Copyright (C) 2009 Bull S.A.S.
# - Contact: [email protected]
# -
# - 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
# -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# - $Id$
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
#
export JONAS_ROOT=${INSTALL_PATH}/jonas-root
export JONAS_BASE=${INSTALL_PATH}
JMXCONNEXIONPOOL_DIR=${INSTALL_PATH}/JMX_connection_pool_adapter
echo "#############################################################################################"
echo "#"
echo "#"
echo "# JMXConnection RA Building tool"
echo "#"
echo "#"
# Check if $JONAS_ROOT is set.
if [ ! -d "$JONAS_ROOT" ]; then
echo "# Please set the JONAS_ROOT variable."
echo "#"
echo "#############################################################################################"
exit
fi
# Check if $JONAS_BASE is set.
if [ ! -d "$JONAS_BASE" ]; then
JONAS_BASE=$JONAS_ROOT
fi
DEPLOYDIR=""
DEPLOY="false"
RACONFIG=""
JNDINAME="service:jmx:rmi:///jndi/rmi://localhost:1099/jrmpconnector_jasmine-monitoring"
FILEPROPERTY=$JMXCONNEXIONPOOL_DIR/jmxconnectionra.properties
INPUTFILE=""
OUTPUT_DIR=$JMXCONNEXIONPOOL_DIR/generated
OUTPUTFILE=$OUTPUT_DIR/JMXGeneratedRA.rar
LEGACY="false"
#Parse command line
while [ -n "$1" ]; do
if [ $1 == "-j" ]; then
shift
JNDINAME="$1"
shift
elif [ $1 == "-p" ]; then
shift
FILEPROPERTY="$1"
shift
elif [ $1 == "-o" ]; then
shift
OUTPUTFILE="$1".rar
shift
elif [ $1 == "-d" ]; then
DEPLOY="true"
shift
elif [ $1 == "-l" ]; then
LEGACY="true"
shift
elif [ $1 == "-h" ]; then
help
exit 3
else
help
exit 3
fi
done
# suffix the name of the generated resource adapter with the monitored server name
if [ "$OUTPUTFILE" = "$OUTPUT_DIR"/JMXGeneratedRA.rar ]; then
SUFFIX=`echo $JNDINAME| cut -d'_' -f 2`
OUTPUTFILE=$OUTPUT_DIR/JMXGeneratedRA-$SUFFIX.rar
fi
# create output directory if not exists
if [ ! -d "$OUTPUT_DIR" ]; then
mkdir -p $OUTPUT_DIR
fi
# Transform JNDI Name
JNDINAME=${JNDINAME//:/_}
JNDINAME=${JNDINAME//\//_}
#Set input file
if [ -f $JMXCONNEXIONPOOL_DIR/jmxadapter_for_jonas.rar ]; then
INPUTFILE=$JMXCONNEXIONPOOL_DIR/jmxadapter_for_jonas.rar
else
echo "#"
echo "# you need to compile the RA and deploy it first"
echo "#"
echo "#############################################################################################"
exit 1
fi
echo "#"
echo "# Use the following input file :"
echo "# ${INPUTFILE} "
echo "#"
#Set deploy directory and RAConfig path
if [ -d $JONAS_BASE/deploy ]; then
DEPLOYDIR=$JONAS_BASE/deploy
else
echo "#"
echo "# A problem occured when trying to get the deploy directory."
echo "# Check that JONAS_BASE is set"
echo "#"
echo "#############################################################################################"
exit 2
fi
if [ -f $JONAS_ROOT/bin/RAConfig ]; then
RACONFIG=$JONAS_ROOT/bin/RAConfig
else
echo "#"
echo "# A problem occured when trying to get the RAConfig script."
echo "# Check that JONAS_ROOT is set"
echo "#"
echo "#############################################################################################"
exit 2
fi
echo "#"
echo "# Generating RA ..."
echo "#"
if [ ${LEGACY} == "false" ]; then
${RACONFIG} -NEW -r JMXConnectionRA -jndiname ${JNDINAME} -p ${FILEPROPERTY} ${INPUTFILE} ${OUTPUTFILE}
else
mkdir -p tmp/jmxRA/META-INF/
touch tmp/jmxRA/META-INF/jonas-ra.xml
echo "
JMXConnectionRA
false
0
`grep "minconpool" ${FILEPROPERTY} | awk -F "=" '{print $2}'`
`grep "maxconpool" ${FILEPROPERTY} | awk -F "=" '{print $2}'`
`grep "connmaxage" ${FILEPROPERTY} | awk -F "=" '{print $2}'`
10
`grep "maxopentime" ${FILEPROPERTY} | awk -F "=" '{print $2}'`
`grep "maxwaiters" ${FILEPROPERTY} | awk -F "=" '{print $2}'`
`grep "maxwaittime" ${FILEPROPERTY} | awk -F "=" '{print $2}'`
30
0
org.ow2.jasmine.adapter.jmx.pool.outbound.ManagedConnectionFactoryImpl
$JNDINAME
" > tmp/jmxRA/META-INF/jonas-ra.xml
# Make the rar file
jar -cf ${OUTPUTFILE} -C tmp/jmxRA META-INF
rm -r tmp
fi
if [ $DEPLOY == "true" ]; then
# Move the RA in the deploy directory
mv ${OUTPUTFILE} ${DEPLOYDIR}
echo "#"
echo "# RA generated and moved into the deploy directory"
echo "#"
echo "# Summary :"
echo "# Property file used : $FILEPROPERTY"
echo "# RAConfig : $RACONFIG"
echo "# JNDIName : $JNDINAME"
echo "# Output file : $OUTPUTFILE"
echo "# Deploy dir : $DEPLOYDIR"
echo "#"
else
echo "#"
echo "# RA generated ..."
echo "#"
echo "# Summary :"
echo "# Property file used : $FILEPROPERTY"
echo "# RAConfig : $RACONFIG"
echo "# JNDIName : $JNDINAME"
echo "# Output file : $OUTPUTFILE"
echo "# Deploy dir : RA not deployed, $OUTPUTFILE is in the current directory"
echo "#"
fi
echo "#"
echo "#############################################################################################"
help(){
echo "# This script helps to generate new RA from the JMXConnectionRA. It uses RAConfig."
echo "#"
echo "# Options :"
echo "#"
echo "# -h Print this help message"
echo "# -l This option has to be set if running on JOnAS 4.8.6, 4.9.2, 5.0.3 or older versions."
echo "# -j Set the JMX URL of the server you want to connect
echo "# example :" service:jmx:rmi:///jndi/rmi://localhost:1099/jrmpconnector_jonas"
echo "#"
echo "# -p Specify a property file to build the RA. Default value "
echo "# is conf/jmxconnectionra.properties. This file is used"
echo "# to configure the RA pool."
echo "# -o Specify the output file name of the ra. default value is "
echo "# JMXGeneratedRA. The .rar extension is automatically set."
echo "# -d If this option is set, the generated RA will be moved into the JONAS_BASE "
echo "# deploy directory."
echo "#"
echo "#############################################################################################"
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy