#!/bin/sh
# JOnAS: Java(TM) Open Application Server
# Copyright (C) 1999 Bull S.A.
# Contact: jonas-team@objectweb.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): ____________________________________.
# Contributor(s): ______________________________________.
#

if [ ! -f $JONAS_ROOT/bin/unix/config_env ]
then
    echo "JONAS_ROOT must be set"
    exit 1
fi

. $JONAS_ROOT/bin/unix/config_env
CLASSES_DIR=$JONAS_ROOT/examples/classes

[ -d $CLASSES_DIR ] || mkdir $CLASSES_DIR

# Compiles the source files
javac -d $CLASSES_DIR ManacEC.java ManacLocal.java ManacLocalHome.java Manager.java ManagerHome.java ManagerSF.java Client.java

# Make the ejb-jar file
[ -d $CLASSES_DIR/META-INF ] || mkdir -p $CLASSES_DIR/META-INF
cp lb.xml $CLASSES_DIR/META-INF/ejb-jar.xml
cp jonas-lb.xml $CLASSES_DIR/META-INF/jonas-ejb-jar.xml
cd $CLASSES_DIR
jar cvf lb/lb.jar META-INF/ejb-jar.xml META-INF/jonas-ejb-jar.xml lb/ManacEC.class lb/ManacLocal.class lb/ManacLocalHome.class lb/Manager.class lb/ManagerHome.class lb/ManagerSF.class
rm -f META-INF/ejb-jar.xml META-INF/jonas-ejb-jar.xml

# Generates the interposition classes, compiles them and put them in the ejb-jar file
cd $JONAS_ROOT/examples/src/lb
GenIC -d $CLASSES_DIR -keepgenerated  $CLASSES_DIR/lb/lb.jar

# Install the ejb-jar file in $JONAS_ROOT/ejbjars directory
cp $CLASSES_DIR/lb/lb.jar $JONAS_ROOT/ejbjars/
