#
# Script to run benchmark
# Run this under JBossCahe dir
#

#!/bin/sh

if [ "$1" == "debug" ]; then
    MODE="debug"
    shift
fi 

if [ "$1" == "profile" ]; then
    MODE="profile"
    shift
fi
    
CACHE_HOME=`dirname $0`
CACHE_LIB=$CACHE_HOME/lib
CACHE_OUTPUT=$CACHE_HOME/output

#PATH=$PATH:"C:\Program Files\jprofiler4\bin\windows"
CLASSPATH=$CLASSPATH:$CACHE_LIB/junit.jar:$CACHE_OUTPUT/classes:$CACHE_OUTPUT/test-classes:$CACHE_LIB/commons-logging.jar:$CACHE_LIB/bsh-2.0b4.jar:$CACHE_LIB/jboss-aop.jar:$CACHE_LIB/jboss-j2ee.jar:$CACHE_LIB/jgroups.jar:$CACHE_LIB/jboss-jmx.jar:$CACHE_LIB/trove.jar:$CACHE_LIB/javassist.jar:$CACHE_LIB/jboss-minimal.jar:$CACHE_LIB/jboss-common.jar:$CACHE_LIB/jboss-system.jar:$CACHE_LIB/log4j.jar:$CACHE_LIB/concurrent.jar:$CACHE_LIB/je.jar:$CACHE_LIB/jboss-remoting.jar:$CACHE_LIB/jboss-serialization.jar


CLASSPATH=$CLASSPATH:$CACHE_OUTPUT/etc:$CACHE_OUTPUT/build

AOP_PATH=$CACHE_OUTPUT/etc

LOG4J=$CACHE_OUTPUT/etc/log4j.xml

# OS specific support (must be 'true' or 'false').
cygwin=false;
case "`uname`" in
    CYGWIN*)
        cygwin=true
        ;;
esac

if [ $cygwin = "true" ]; then
   CP=`cygpath -wp $CLASSPATH`
   L4J=`cygpath -wp $LOG4J`
else
   CP=$CLASSPATH
   L4J=$LOG4J
fi

if [ "$MODE" == "debug" ]; then
JAVA_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=n"
fi

# Use aopc now instead of load-time mode
#sh build.sh aopcWithAnnoc
ARGS="-Dlog4j.configuration=file:$L4J"
#ARGS="-Dbind.address=${MYTESTIP_1} -Dlog4j.configuration=file:$L4J"

if [ "$MODE" == "profile" ]; then
 JAVA_OPTS="-agentlib:jprofilerti=port=8849  -Xbootclasspath/a:C:\Program Files\jprofiler4\bin\agent.jar"
JAVA_OPTS="$JAVA_OPTS -Xmx128m"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote"
fi

java -cp "$CP" $ARGS $JAVA_OPTS -Djboss.aop.aoppath=$AOP_PATH  org.jboss.cache.Server $@
#java -cp "$CP" $ARGS $JAVA_OPTS org.jboss.cache.Server $@

