#!/bin/ksh

# Copyright  2005 Sun Microsystems, Inc. All rights reserved. 
# 
# Sun Microsystems, Inc. has intellectual property rights relating to
# technology embodied in the product that is described in this document.
# In particular, and without limitation, these intellectual property rights
# may include one or more of the U.S. patents listed at
# http://www.sun.com/patents and one or more additional patents or pending
# patent applications in the U.S. and in other countries.
# 
# U.S. Government Rights - Commercial software. Government users are subject
# to the Sun Microsystems, Inc. standard license agreement and applicable
# provisions of the FAR and its supplements.
# 
# Use is subject to license terms. 
# 
# This distribution may include materials developed by third parties. Sun,
# Sun Microsystems, the Sun logo, Java and Sun[tm] ONE are trademarks or
# registered trademarks of Sun Microsystems, Inc. in the U.S. and other
# countries. 
# 
# Copyright  2005 Sun Microsystems, Inc. Tous droits rservs. Sun
# Microsystems, Inc. dtient les droits de proprit intellectuels relatifs
#  la technologie incorpore dans le produit qui est dcrit dans ce document.
# En particulier, et ce sans limitation, ces droits de proprit
# intellectuelle peuvent inclure un ou plus des brevets amricains lists
#  l'adresse http://www.sun.com/patents et un ou les brevets supplmentaires
# ou les applications de brevet en attente aux Etats - Unis et dans les
# autres pays.
# 
# L'utilisation est soumise aux termes du contrat de licence.
# 
# Cette distribution peut comprendre des composants dvelopps par des
# tierces parties.
# 
# Sun, Sun Microsystems, le logo Sun, Java et Sun[tm] ONE sont des marques
# de fabrique ou des marques dposes de Sun Microsystems, Inc. aux
# Etats-Unis et dans d'autres pays.


AM_HOME=IS_INSTALL_BASEDIR/IS_PRODNAME
JAVA_HOME=JAVADIR
JDK14=true
LOCAL_LOGGING=true

JAXP_HOME=${AM_HOME}/lib
JAXB_HOME=${AM_HOME}/lib
SEC_HOME=${AM_HOME}/lib

JSS_JAR_PATH=TAG_JSS_JAR_PATH
JSS_SO_PATH=TAG_JSS_SO_PATH
NSPR_SO_PATH=TAG_NSPR_SO_PATH
NSS_SO_PATH=TAG_NSS_SO_PATH

JSS_JAR=${JSS_JAR_PATH}/jss4.jar

OS_ARCH=`/bin/uname -s`
SDK_JARS=${AM_HOME}/lib/am_sdk.jar:${AM_HOME}/lib/ldapjdk.jar:${AM_HOME}/lib/am_services.jar:${AM_HOME}/lib/jaas.jar
AM_DIRS=${AM_HOME}/lib:${AM_HOME}/locale:IS_INSTALL_ETCDIR/IS_PRODNAME/config
JAXP_JARS=${JAXP_HOME}/jaxp-api.jar:${JAXP_HOME}/xalan.jar:${JAXP_HOME}/xercesImpl.jar:${JAXP_HOME}/sax.jar:${JAXP_HOME}/dom.jar
SERVLET_JARS=${AM_HOME}/lib/servlet.jar:${AM_HOME}/lib/preference_servlet.jar
LOGGING_JARS=${AM_HOME}/lib/am_logging.jar
LDAPJDK_JAR=${AM_HOME}/lib/ldapjdk.jar

SEC_JARS=${SEC_HOME}/jce1_2_1.jar:${SEC_HOME}/sunjce_provider.jar:${SEC_HOME}/US_export_policy.jar:${SEC_HOME}/local_policy.jar:${SEC_HOME}/jakarta-log4j-1.2.6.jar:${SEC_HOME}/xmlsec.jar:${JAVA_HOME}/jre/lib/sunrsasign.jar

JAXB_JARS=${JAXB_HOME}/jaxb-api.jar:${JAXB_HOME}/jaxb-impl.jar:${JAXB_HOME}/jaxb-xjc.jar:${JAXB_HOME}/jaxb-libs.jr:${JAXB_HOME}/relaxngDatatype.jar:${JAXB_HOME}/namespace.jar:${JAXB_HOME}/jax-qname.jar:${JAXB_HOME}/xsdlib.jar

AM_CLASSPATH=.:${AM_DIRS}:${SDK_JARS}:${JSS_JAR}:${SERVLET_JARS}:${LOGGING_JARS}:${JAXP_JARS}:${JAXB_JARS}:${SEC_JARS}:${AM_HOME}/lib/mail.jar:${AM_HOME}/lib/activation.jar:${AM_HOME}/lib/commons-logging.jar

# Setup proper LD_LIBRARY_PATH if not already set
if [ -z "$LD_LIBRARY_PATH" ] ; then
    if [ $OS_ARCH = "Linux" ] ; then
        LD_LIBRARY_PATH="${JSS_SO_PATH}:${NSS_SO_PATH}:${NSPR_SO_PATH}:$JAVA_HOME/jre/lib/i386/native_threads"
    else
        LD_LIBRARY_PATH="${JSS_SO_PATH}:${NSS_SO_PATH}:${NSPR_SO_PATH}"
    fi
else
    if [ $OS_ARCH = "Linux" ] ; then
        LD_LIBRARY_PATH="${JSS_SO_PATH}:${NSS_SO_PATH}:${NSPR_SO_PATH}":$JAVA_HOME/jre/lib/i386/native_threads:$LD_LIBRARY_PATH
    else
        LD_LIBRARY_PATH="${JSS_SO_PATH}:${NSS_SO_PATH}:${NSPR_SO_PATH}":$LD_LIBRARY_PATH
    fi
fi

export LD_LIBRARY_PATH

if [ -z "$CLASSPATH" ]
then
  CLASSPATH="${AM_CLASSPATH}:${JAVA_HOME}/lib/lib.zip"
else
  CLASSPATH="${AM_CLASSPATH}:$CLASSPATH"
fi

#
#  add JDBC driver(s) when DB logging is in use
#
#CLASSPATH="${CLASSPATH}:/xxx/Oracle_8.1.7/classes12.zip:/xxx/Mysql/mysql-connector-java-3.0.6-stable-bin.jar"

if [ "$JDK14" = "true" ]; then
  BOOTCLASSPATHOPTION=""
else
  BOOTCLASSPATHOPTION="-Xbootclasspath:${AM_HOME}/lib/jdk_logging.jar:${JAVA_HOME}/lib/tools.jar:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/jre/lib/i18n.jar"
fi

if [ "$LOCAL_LOGGING" = "true" ]; then
  CONFIGOPTION="java.util.logging.config.class=com.sun.identity.log.s1is.LogConfigReader"
else
  CONFIGOPTION="java.util.logging.config.file=${AM_HOME}/lib/LogConfig.properties"
fi

${JAVA_HOME}/bin/java  -Xms64m -Xmx256m ${BOOTCLASSPATHOPTION}  -classpath ${CLASSPATH} -D"max_conn_pool=10" -D"min_conn_pool=1" -D"java.protocol.handler.pkgs=com.iplanet.services.comm" -D"java.util.logging.manager=com.sun.identity.log.LogManager" -D${CONFIGOPTION} LogReaderSample "$@"
