Added functionality to restart tomcat from the ui or reload Openbravo context from the ui
authorMartin Taal <martin.taal@openbravo.com>
Tue, 16 Dec 2008 14:32:57 +0000
changeset 2345 c1d06366f748
parent 2344 c423e8e59859
child 2346 c215e390856e
Added functionality to restart tomcat from the ui or reload Openbravo context from the ui
build.xml
src/org/openbravo/service/system/ReloadContext.java
src/org/openbravo/service/system/RestartTomcat.java
--- a/build.xml	Tue Dec 16 14:05:49 2008 +0000
+++ b/build.xml	Tue Dec 16 14:32:57 2008 +0000
@@ -69,502 +69,541 @@
 compare.database.structure: refer to compare.database.structure target of database.
 -->
 <project name="openbravo" default="compile.complete" basedir=".">
-  <property environment="env"/>
-  <property name="base.config" location="config"/>
-  <property file="${base.config}/Openbravo.properties"/>
+	<property environment="env" />
+	<property name="base.config" location="config" />
+	<property file="${base.config}/Openbravo.properties" />
 
-  <property name="base.src" location="src"/>
-  <property name="base.src.core" location="src-core"/>
-  <property name="base.src.db" location="src-db"/>
-  <property name="base.src.trl" location="src-trl"/>
-  <property name="base.src.wad" location="src-wad"/>
-  <property name="base.src.gen" location="src-gen"/>
-  <property name="base.client.src" location="srcClient"/>
-  <property name="base.db" location="src-db/database"/>
-  <property name="base.web" location="web"/>
-  <property name="base.context" location="WebContent"/>
-  <property name="base.design" location="${base.context}/src-loc"/>
-  <property name="base.lib" location="lib"/>
-  <property name="base.modules" location="modules"/>
-  <property name="build" location="build/classes"/>
-  <property name="build.AD" location="srcAD"/>
-  <property name="build.sqlc" location="build/javasqlc"/>
-  <property name="build.core.lib" location="src-core/lib"/>
-  <property name="build.trl.lib" location="src-trl/lib"/>
-  <property name="build.wad.lib" location="src-wad/lib"/>
-  <property name="build.docs" location="docs/api"/>
-  <property name="jakarta.home" location="${env.CATALINA_HOME}"/>
-  <property name="module" value="%"/>
-	<property name="apply.on.create" value="false"/>
-	<property name="obx.export.RD" value="false"/>
-	<property name="obx.export.DB" value="false"/>
-	<property name="obx.export.CS" value="false"/>
-	<property name="chekPerms" value="false"/>
-	
-	<available file=".svn/entries" property="is.svn"/>
+	<property name="base.src" location="src" />
+	<property name="base.src.core" location="src-core" />
+	<property name="base.src.db" location="src-db" />
+	<property name="base.src.trl" location="src-trl" />
+	<property name="base.src.wad" location="src-wad" />
+	<property name="base.src.gen" location="src-gen" />
+	<property name="base.client.src" location="srcClient" />
+	<property name="base.db" location="src-db/database" />
+	<property name="base.web" location="web" />
+	<property name="base.context" location="WebContent" />
+	<property name="base.design" location="${base.context}/src-loc" />
+	<property name="base.lib" location="lib" />
+	<property name="base.modules" location="modules" />
+	<property name="build" location="build/classes" />
+	<property name="build.AD" location="srcAD" />
+	<property name="build.sqlc" location="build/javasqlc" />
+	<property name="build.core.lib" location="src-core/lib" />
+	<property name="build.trl.lib" location="src-trl/lib" />
+	<property name="build.wad.lib" location="src-wad/lib" />
+	<property name="build.docs" location="docs/api" />
+	<property name="jakarta.home" location="${env.CATALINA_HOME}" />
+	<property name="module" value="%" />
+	<property name="apply.on.create" value="false" />
+	<property name="obx.export.RD" value="false" />
+	<property name="obx.export.DB" value="false" />
+	<property name="obx.export.CS" value="false" />
+	<property name="chekPerms" value="false" />
 
-	
+	<available file=".svn/entries" property="is.svn" />
+
+
 	<condition property="mode.war">
-	  <equals arg1="war" arg2="${deploy.mode}"/>
+		<equals arg1="war" arg2="${deploy.mode}" />
 	</condition>
-	
-	 <condition property="mode.class">
-	    <equals arg1="class" arg2="${deploy.mode}"/>
-	  </condition>
-		
+
+	<condition property="mode.class">
+		<equals arg1="class" arg2="${deploy.mode}" />
+	</condition>
+
 	<condition property="apply.modules.on.create">
 		<or>
-		  <equals arg1="yes" arg2="${apply.on.create}"/>
-			<equals arg1="true" arg2="${apply.on.create}"/>
+			<equals arg1="yes" arg2="${apply.on.create}" />
+			<equals arg1="true" arg2="${apply.on.create}" />
 		</or>
 	</condition>
-	
+
 	<condition property="obx.exp.DB">
 		<or>
-	    <equals arg1="yes" arg2="${obx.export.DB}"/>
-			<equals arg1="true" arg2="${obx.export.DB}"/>
+			<equals arg1="yes" arg2="${obx.export.DB}" />
+			<equals arg1="true" arg2="${obx.export.DB}" />
 		</or>
 	</condition>
-	
+
 	<condition property="obx.exp.CS">
 		<or>
-	    <equals arg1="yes" arg2="${obx.export.CS}"/>
-			<equals arg1="true" arg2="${obx.export.CS}"/>
+			<equals arg1="yes" arg2="${obx.export.CS}" />
+			<equals arg1="true" arg2="${obx.export.CS}" />
 		</or>
 	</condition>
-	
-  <condition property="jakarta.base" value="${env.CATALINA_BASE}" else="${jakarta.home}">
-    <and>
-      <isset property="env.CATALINA_BASE"/>
-    </and>
-  </condition>
-  <property name="log.path" location="${jakarta.base}/logs"/>
-  <property name="lib" location="${jakarta.home}/common"/>
-  <property name="jakarta.context" location="${jakarta.base}/webapps/${context.name}"/>
-  <property name="build.maxmemory" value="512M"/>
 
-  <condition property="no.java.home" value="true">
-    <not>
-      <isset property="env.JAVA_HOME"/>
-    </not>
-  </condition>
-	
+	<condition property="jakarta.base" value="${env.CATALINA_BASE}" else="${jakarta.home}">
+		<and>
+			<isset property="env.CATALINA_BASE" />
+		</and>
+	</condition>
+	<property name="log.path" location="${jakarta.base}/logs" />
+	<property name="lib" location="${jakarta.home}/common" />
+	<property name="jakarta.context" location="${jakarta.base}/webapps/${context.name}" />
+	<property name="build.maxmemory" value="512M" />
 
-  <path id="project.class.path">
-    <pathelement path="${build}"/>
-    <pathelement path="${base.src}" />
-    <fileset dir="${base.lib}">
-      <include name="**/*.jar"/>
-    </fileset>
-    <fileset dir="${build.core.lib}">
-      <include name="openbravo-core.jar"/>
-    </fileset>
-    <fileset dir="${build.trl.lib}">
-      <include name="openbravo-trl.jar"/>
-    </fileset>
-    <fileset dir="${build.wad.lib}">
-      <include name="openbravo-wad.jar"/>
-    </fileset>
-    <fileset dir="${base.lib}">
-      <include name="**/*.jar"/>
-    </fileset>
-    <fileset dir="${base.db}/lib/">
-      <include name="**/*.jar"/>
-    </fileset>
-    <fileset dir="${base.modules}">
-      <include name="*/lib/**"/>
-    </fileset>
-  </path>
-	
-	<taskdef resource="axis-tasks.properties" classpathref="project.class.path"/>
+	<condition property="no.java.home" value="true">
+		<not>
+			<isset property="env.JAVA_HOME" />
+		</not>
+	</condition>
 
-  <target name="init">
-    <fail if="no.java.home" message="The environment variable JAVA_HOME is not set."/>
-  </target>
+
+	<path id="project.class.path">
+		<pathelement path="${build}" />
+		<pathelement path="${base.src}" />
+		<fileset dir="${base.lib}">
+			<include name="**/*.jar" />
+		</fileset>
+		<fileset dir="${build.core.lib}">
+			<include name="openbravo-core.jar" />
+		</fileset>
+		<fileset dir="${build.trl.lib}">
+			<include name="openbravo-trl.jar" />
+		</fileset>
+		<fileset dir="${build.wad.lib}">
+			<include name="openbravo-wad.jar" />
+		</fileset>
+		<fileset dir="${base.lib}">
+			<include name="**/*.jar" />
+		</fileset>
+		<fileset dir="${base.db}/lib/">
+			<include name="**/*.jar" />
+		</fileset>
+		<fileset dir="${base.modules}">
+			<include name="*/lib/**" />
+		</fileset>
+	</path>
+
+	<taskdef resource="axis-tasks.properties" classpathref="project.class.path" />
+
+	<target name="init">
+		<fail if="no.java.home" message="The environment variable JAVA_HOME is not set." />
+	</target>
 
 	<target name="code.rev" depends="set.code.rev">
-		<condition property="code.revision" value="${svn.entries}" else ="0">
-		  <isset property="svn.entries" />
-    </condition>
-	</target>
-	
-  <target name="set.code.rev" if="is.svn">
-    <loadfile property="svn.entries" srcFile=".svn/entries" failonerror="false">
-      <filterchain>
-        <filterreader classname="org.apache.tools.ant.filters.HeadFilter">
-          <param name="skip" value="3"/>
-          <param name="lines" value="1"/>
-        </filterreader>
-      </filterchain>
-      <filterchain>
-        <filterreader classname="org.apache.tools.ant.filters.StripLineBreaks" />
-      </filterchain>
-    </loadfile>
+		<condition property="code.revision" value="${svn.entries}" else="0">
+			<isset property="svn.entries" />
+		</condition>
 	</target>
 
-  <target name="compile.complete" depends="init">
-    <ant dir="${base.src}" target="compile.complete" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="set.code.rev" if="is.svn">
+		<loadfile property="svn.entries" srcFile=".svn/entries" failonerror="false">
+			<filterchain>
+				<filterreader classname="org.apache.tools.ant.filters.HeadFilter">
+					<param name="skip" value="3" />
+					<param name="lines" value="1" />
+				</filterreader>
+			</filterchain>
+			<filterchain>
+				<filterreader classname="org.apache.tools.ant.filters.StripLineBreaks" />
+			</filterchain>
+		</loadfile>
+	</target>
 
-  <target name="compile" depends="init">
-    <ant dir="${base.src}" target="compile" inheritAll="true" inheritRefs="true"/>
-  </target>
-	
+	<target name="compile.complete" depends="init">
+		<ant dir="${base.src}" target="compile.complete" inheritAll="true" inheritRefs="true" />
+	</target>
+
+	<target name="compile" depends="init">
+		<ant dir="${base.src}" target="compile" inheritAll="true" inheritRefs="true" />
+	</target>
+
 	<target name="compile.complete.deploy">
-	  <antcall target="compile.complete.development"/>
-	  <antcall target="compile.complete.war"/>
+		<antcall target="compile.complete.development" />
+		<antcall target="compile.complete.war" />
 	</target>
-	
-  <target name="compile.complete.development" depends="init" if="mode.class">
-    <ant dir="${base.src}" target="compile.complete.development" inheritAll="true" inheritRefs="true"/>
-  </target>
-	
+
+	<target name="compile.complete.development" depends="init" if="mode.class">
+		<ant dir="${base.src}" target="compile.complete.development" inheritAll="true" inheritRefs="true" />
+	</target>
+
 	<target name="compile.complete.war" depends="init" if="mode.war">
-	  <antcall target="compile.complete"/>
-		<antcall target="war"/>
+		<antcall target="compile.complete" />
+		<antcall target="war" />
 	</target>
 
 	<target name="compile.deploy">
-		<antcall target="compile.war"/>
-	  <antcall target="compile.development"/>
-	</target>
-	
-  <target name="compile.development" depends="init" if="mode.class">
-    <ant dir="${base.src}" target="compile.development" inheritAll="true" inheritRefs="true"/>
-  </target>
-	
-	<target name="compile.war" if="mode.war">
-		<antcall target="compile"/>
-		<antcall target="war"/>
+		<antcall target="compile.war" />
+		<antcall target="compile.development" />
 	</target>
 
-  <target name="compile.web" depends="init">
-    <ant dir="${base.src}" target="compile.web" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="compile.development" depends="init" if="mode.class">
+		<ant dir="${base.src}" target="compile.development" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="compile.web.development" depends="init">
-    <ant dir="${base.src}" target="compile.web.development" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="compile.war" if="mode.war">
+		<antcall target="compile" />
+		<antcall target="war" />
+	</target>
 
-  <target name="eclipse.compile" depends="init">
-    <ant dir="${base.src.core}" target="build.jar" inheritAll="true" inheritRefs="true"/>
-    <ant dir="${base.src.trl}" target="build.jar" inheritAll="true" inheritRefs="true"/>
-    <ant dir="${base.src.wad}" target="build.jar" inheritAll="true" inheritRefs="true"/>
-    <ant dir="${base.src}" target="eclipse.compile" inheritAll="true" inheritRefs="true"/>
-    <eclipse.refreshLocal resource="openbravo" depth="infinite"/>
-    <eclipse.incrementalBuild project="openbravo" kind="incremental"/>
-  </target>
+	<target name="compile.web" depends="init">
+		<ant dir="${base.src}" target="compile.web" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="eclipse.compile.complete" depends="init">
-    <ant dir="${base.src.core}" target="build.jar" inheritAll="true" inheritRefs="true"/>
-    <ant dir="${base.src.trl}" target="build.jar" inheritAll="true" inheritRefs="true"/>
-    <ant dir="${base.src.wad}" target="build.jar" inheritAll="true" inheritRefs="true"/>
-    <ant dir="${base.src}" target="eclipse.compile.complete" inheritAll="true" inheritRefs="true"/>
-    <eclipse.refreshLocal resource="openbravo" depth="infinite"/>
-    <eclipse.incrementalBuild project="openbravo" kind="full"/>
-  </target>
-  
-  <target name="compile.src.gen" depends="init">
-    <ant dir="${base.src}" target="compile.src.gen" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="compile.web.development" depends="init">
+		<ant dir="${base.src}" target="compile.web.development" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="generate.entities">
-    <ant dir="${base.src}" target="generate.entities" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="eclipse.compile" depends="init">
+		<ant dir="${base.src.core}" target="build.jar" inheritAll="true" inheritRefs="true" />
+		<ant dir="${base.src.trl}" target="build.jar" inheritAll="true" inheritRefs="true" />
+		<ant dir="${base.src.wad}" target="build.jar" inheritAll="true" inheritRefs="true" />
+		<ant dir="${base.src}" target="eclipse.compile" inheritAll="true" inheritRefs="true" />
+		<eclipse.refreshLocal resource="openbravo" depth="infinite" />
+		<eclipse.incrementalBuild project="openbravo" kind="incremental" />
+	</target>
 
-  <target name="export.sample.data">
-  	<ant dir="${base.src}" target="export.sample.data" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="eclipse.compile.complete" depends="init">
+		<ant dir="${base.src.core}" target="build.jar" inheritAll="true" inheritRefs="true" />
+		<ant dir="${base.src.trl}" target="build.jar" inheritAll="true" inheritRefs="true" />
+		<ant dir="${base.src.wad}" target="build.jar" inheritAll="true" inheritRefs="true" />
+		<ant dir="${base.src}" target="eclipse.compile.complete" inheritAll="true" inheritRefs="true" />
+		<eclipse.refreshLocal resource="openbravo" depth="infinite" />
+		<eclipse.incrementalBuild project="openbravo" kind="full" />
+	</target>
 
-	  <target name="import.sample.data">
-	  	<ant dir="${base.src}" target="import.sample.data" inheritAll="true" inheritRefs="true"/>
-	  </target>
+	<target name="compile.src.gen" depends="init">
+		<ant dir="${base.src}" target="compile.src.gen" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="compile.src" depends="init">
-    <ant dir="${base.src}" target="compile.src" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="generate.entities">
+		<ant dir="${base.src}" target="generate.entities" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="war" depends="init">
-    <ant dir="${base.src}" target="build.war" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="export.sample.data">
+		<ant dir="${base.src}" target="export.sample.data" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="core.docs" depends="init">
-    <ant dir="${base.src.core}" target="doc" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="import.sample.data">
+		<ant dir="${base.src}" target="import.sample.data" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="core.lib" depends="init">
-    <ant dir="${base.src.core}" target="build" inheritAll="true" inheritRefs="true"/>
-    <copy file="${base.src.core}/lib/openbravo-core.jar" todir="${base.lib}/runtime" overwrite="true" failonerror="false"/>
-  </target>
+	<target name="compile.src" depends="init">
+		<ant dir="${base.src}" target="compile.src" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="eclipse.wad.lib" depends="init">
-    <ant dir="${base.src.wad}" target="sqlc" inheritAll="true" inheritRefs="true"/>
-    <eclipse.refreshLocal resource="OpenbravoWAD" depth="infinite"/>
-    <eclipse.incrementalBuild project="OpenbravoWAD" kind="full"/>
-  </target>
+	<target name="war" depends="init">
+		<ant dir="${base.src}" target="build.war" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="wad.docs" depends="init">
-    <ant dir="${base.src.wad}" target="doc" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="core.docs" depends="init">
+		<ant dir="${base.src.core}" target="doc" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="wad.lib" depends="init">
-    <ant dir="${base.src.wad}" target="build" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="core.lib" depends="init">
+		<ant dir="${base.src.core}" target="build" inheritAll="true" inheritRefs="true" />
+		<copy file="${base.src.core}/lib/openbravo-core.jar" todir="${base.lib}/runtime" overwrite="true" failonerror="false" />
+	</target>
 
-  <target name="eclipse.trl.lib" depends="init">
-    <ant dir="${base.src.trl}" target="sqlc" inheritAll="true" inheritRefs="true"/>
-    <eclipse.refreshLocal resource="OpenbravoTrl" depth="infinite"/>
-    <eclipse.incrementalBuild project="OpenbravoTrl" kind="full"/>
-  </target>
+	<target name="eclipse.wad.lib" depends="init">
+		<ant dir="${base.src.wad}" target="sqlc" inheritAll="true" inheritRefs="true" />
+		<eclipse.refreshLocal resource="OpenbravoWAD" depth="infinite" />
+		<eclipse.incrementalBuild project="OpenbravoWAD" kind="full" />
+	</target>
 
-  <target name="trl.docs" depends="init">
-    <ant dir="${base.src.trl}" target="doc" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="wad.docs" depends="init">
+		<ant dir="${base.src.wad}" target="doc" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="trl.lib" depends="init">
-    <ant dir="${base.src.trl}" target="build" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="wad.lib" depends="init">
+		<ant dir="${base.src.wad}" target="build" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="database.lib" depends="init">
-    <ant dir="${base.src.db}" target="jar" inheritAll="true" inheritRefs="true"/>
-    <copy file="${base.src.db}/build/lib/dbmanager.jar" todir="${base.db}/lib" overwrite="true" failonerror="false"/>
-  </target>
+	<target name="eclipse.trl.lib" depends="init">
+		<ant dir="${base.src.trl}" target="sqlc" inheritAll="true" inheritRefs="true" />
+		<eclipse.refreshLocal resource="OpenbravoTrl" depth="infinite" />
+		<eclipse.incrementalBuild project="OpenbravoTrl" kind="full" />
+	</target>
 
-  <target name="clean" depends="init">
-    <ant dir="${base.src}" target="clean" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="trl.docs" depends="init">
+		<ant dir="${base.src.trl}" target="doc" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="trl.clean" depends="init">
-    <ant dir="${base.src}" target="trl.clean" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="trl.lib" depends="init">
+		<ant dir="${base.src.trl}" target="build" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="translate" depends="init">
-    <ant dir="${base.src}" target="translate" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="database.lib" depends="init">
+		<ant dir="${base.src.db}" target="jar" inheritAll="true" inheritRefs="true" />
+		<copy file="${base.src.db}/build/lib/dbmanager.jar" todir="${base.db}/lib" overwrite="true" failonerror="false" />
+	</target>
 
-  <target name="installWebService" depends="init">
-    <ant dir="${base.src}" target="installWebService" inheritAll="true" inheritRefs="true">
-      <property name="wsdd" value="1"/>
-    </ant>
-  </target>
+	<target name="clean" depends="init">
+		<ant dir="${base.src}" target="clean" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="uninstallWebService" depends="init">
-    <ant dir="${base.src}" target="uninstallWebService" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="trl.clean" depends="init">
+		<ant dir="${base.src}" target="trl.clean" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="install.source" depends="init,code.rev">
-    <antcall target="database.lib"/>
-    <ant dir="${base.db}" antfile="build-create.xml" target="create.database" inheritAll="true" inheritRefs="true"/>
-    <antcall target="core.lib"/>
-    <antcall target="wad.lib"/>
-    <antcall target="trl.lib"/>
-    <antcall target="compile.complete.deploy"/>
-    <echo message="applying modules"/>
-    <taskdef name="applyModule"
-             classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
-      <classpath refid="project.class.path"/>
-    </taskdef>
-    <applyModule userId="0"
-                 propertiesFile="${base.config}/Openbravo.properties"/>
-    <!-- 
+	<target name="translate" depends="init">
+		<ant dir="${base.src}" target="translate" inheritAll="true" inheritRefs="true" />
+	</target>
+
+	<target name="installWebService" depends="init">
+		<ant dir="${base.src}" target="installWebService" inheritAll="true" inheritRefs="true">
+			<property name="wsdd" value="1" />
+		</ant>
+	</target>
+
+	<target name="uninstallWebService" depends="init">
+		<ant dir="${base.src}" target="uninstallWebService" inheritAll="true" inheritRefs="true" />
+	</target>
+
+	<target name="install.source" depends="init,code.rev">
+		<antcall target="database.lib" />
+		<ant dir="${base.db}" antfile="build-create.xml" target="create.database" inheritAll="true" inheritRefs="true" />
+		<antcall target="core.lib" />
+		<antcall target="wad.lib" />
+		<antcall target="trl.lib" />
+		<antcall target="compile.complete.deploy" />
+		<echo message="applying modules" />
+		<taskdef name="applyModule" classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
+			<classpath refid="project.class.path" />
+		</taskdef>
+		<applyModule userId="0" propertiesFile="${base.config}/Openbravo.properties" />
+		<!-- 
     	this antcall implements the previous method of importing data 
     	use that if the new method does not work for you: 
     -->
-    	<!--<antcall target="import.database.sampledata"/>-->
-   <antcall target="import.sample.data"/>
-  </target>
+		<!--<antcall target="import.database.sampledata"/>-->
+		<antcall target="import.sample.data" />
+	</target>
 
-  <target name="eclipse.install.source" depends="init,code.rev">
-    <antcall target="database.lib"/>
-    <ant dir="${base.db}" antfile="build-create.xml" target="create.database" inheritAll="true" inheritRefs="true"/>
-    <eclipse.incrementalBuild project="OpenbravoCore" kind="full"/>
-    <antcall target="eclipse.wad.lib"/>
-    <antcall target="eclipse.trl.lib"/>
-    <antcall target="eclipse.compile.complete"/>
-    <echo message="applying modules"/>
-    <taskdef name="applyModule"
-             classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
-      <classpath refid="project.class.path"/>
-    </taskdef>
-    <applyModule userId="0"
-                 propertiesFile="${base.config}/Openbravo.properties"/>
-    <antcall target="import.database.sampledata"/>
-  </target>
+	<target name="eclipse.install.source" depends="init,code.rev">
+		<antcall target="database.lib" />
+		<ant dir="${base.db}" antfile="build-create.xml" target="create.database" inheritAll="true" inheritRefs="true" />
+		<eclipse.incrementalBuild project="OpenbravoCore" kind="full" />
+		<antcall target="eclipse.wad.lib" />
+		<antcall target="eclipse.trl.lib" />
+		<antcall target="eclipse.compile.complete" />
+		<echo message="applying modules" />
+		<taskdef name="applyModule" classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
+			<classpath refid="project.class.path" />
+		</taskdef>
+		<applyModule userId="0" propertiesFile="${base.config}/Openbravo.properties" />
+		<antcall target="import.database.sampledata" />
+	</target>
 
-  <target name="create.database" depends="init,code.rev">
-    <antcall target="database.lib"/>
-    <ant dir="${base.db}" antfile="build-create.xml" target="create.database" inheritAll="true" inheritRefs="true"/>
-    <antcall target="db.apply.modules.sampledata"/>
-  </target>
+	<target name="create.database" depends="init,code.rev">
+		<antcall target="database.lib" />
+		<ant dir="${base.db}" antfile="build-create.xml" target="create.database" inheritAll="true" inheritRefs="true" />
+		<antcall target="db.apply.modules.sampledata" />
+	</target>
 
-  <target name="update.database" depends="init,code.rev">
-    <antcall target="database.lib"/>
-    <ant dir="${base.db}" target="update.database" inheritAll="true" inheritRefs="true"/>
-  	<antcall target="db.apply.modules"/>
-  </target>
+	<target name="update.database" depends="init,code.rev">
+		<antcall target="database.lib" />
+		<ant dir="${base.db}" target="update.database" inheritAll="true" inheritRefs="true" />
+		<antcall target="db.apply.modules" />
+	</target>
 
-  <target name="update.database.mod" depends="init,code.rev">
-    <antcall target="database.lib"/>
-    <ant dir="${base.db}" target="update.database.mod" inheritAll="true" inheritRefs="true"/>
-  	<antcall target="db.apply.modules"/>
-  </target>
+	<target name="update.database.mod" depends="init,code.rev">
+		<antcall target="database.lib" />
+		<ant dir="${base.db}" target="update.database.mod" inheritAll="true" inheritRefs="true" />
+		<antcall target="db.apply.modules" />
+	</target>
 
-  <target name="update.customized.database" depends="init,code.rev">
-    <antcall target="database.lib"/>
-    <ant dir="${base.db}" target="update.customized.database" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="update.customized.database" depends="init,code.rev">
+		<antcall target="database.lib" />
+		<ant dir="${base.db}" target="update.customized.database" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="create.database.structure" depends="init">
-    <ant dir="${base.db}" target="create.database.structure" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="create.database.structure" depends="init">
+		<ant dir="${base.db}" target="create.database.structure" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="update.database.structure" depends="init">
-    <ant dir="${base.db}" target="update.database.structure" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="update.database.structure" depends="init">
+		<ant dir="${base.db}" target="update.database.structure" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="create.database.script" depends="init">
-    <ant dir="${base.db}" target="create.database.script" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="create.database.script" depends="init">
+		<ant dir="${base.db}" target="create.database.script" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="update.database.script" depends="init">
-    <ant dir="${base.db}" target="update.database.script" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="update.database.script" depends="init">
+		<ant dir="${base.db}" target="update.database.script" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="export.database" depends="init,code.rev">
-    <antcall target="database.lib"/>
-    <ant dir="${base.db}" target="export.database.structure" inheritAll="true" inheritRefs="true"/>
-    <ant dir="${base.db}" target="export.database.data" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="export.database" depends="init,code.rev">
+		<antcall target="database.lib" />
+		<ant dir="${base.db}" target="export.database.structure" inheritAll="true" inheritRefs="true" />
+		<ant dir="${base.db}" target="export.database.data" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="export.database.structure" depends="init,code.rev">
-    <ant dir="${base.db}" target="export.database.structure" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="export.database.structure" depends="init,code.rev">
+		<ant dir="${base.db}" target="export.database.structure" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="export.config.script" depends="init,code.rev">
-    <ant dir="${base.db}" target="export.config.script" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="export.config.script" depends="init,code.rev">
+		<ant dir="${base.db}" target="export.config.script" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="export.database.data" depends="init,code.rev">
-    <ant dir="${base.db}" target="export.database.data" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="export.database.data" depends="init,code.rev">
+		<ant dir="${base.db}" target="export.database.data" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="import.database.data" depends="init,code.rev">
-    <ant dir="${base.db}" target="import.database.data" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="import.database.data" depends="init,code.rev">
+		<ant dir="${base.db}" target="import.database.data" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="export.database.sampledata" depends="init,code.rev">
-    <ant dir="${base.db}" target="export.database.sampledata" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="export.database.sampledata" depends="init,code.rev">
+		<ant dir="${base.db}" target="export.database.sampledata" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="import.database.sampledata" depends="init,code.rev">
-  	<!--<ant dir="${base.src}" target="import.reference.data" inheritAll="true" inheritRefs="true"/>-->
-    <ant dir="${base.db}" target="import.database.sampledata" inheritAll="true" inheritRefs="true"/> 
-  </target>
+	<target name="import.database.sampledata" depends="init,code.rev">
+		<!--<ant dir="${base.src}" target="import.reference.data" inheritAll="true" inheritRefs="true"/>-->
+		<ant dir="${base.db}" target="import.database.sampledata" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="export.database.masterdata" depends="init,code.rev">
-    <ant dir="${base.db}" target="export.database.masterdata" inheritAll="true" inheritRefs="true"/>
-  </target>
+	<target name="export.database.masterdata" depends="init,code.rev">
+		<ant dir="${base.db}" target="export.database.masterdata" inheritAll="true" inheritRefs="true" />
+	</target>
 
-  <target name="import.database.masterdata" depends="init,code.rev">
-    <ant dir="${base.db}" target="import.database.masterdata" inheritAll="true" inheritRefs="true"/>
-  </target>
-  
-  <target name="db.apply.modules" if="apply.modules.on.create">
-    <echo message="applying modules"/>
-    <taskdef name="applyModule"
-             classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
-      <classpath refid="project.class.path"/>
-    </taskdef>
-    <applyModule userId="0"
-                 propertiesFile="${base.config}/Openbravo.properties"/>
-  </target>
-  
-  <target name="db.apply.modules.sampledata" if="apply.modules.on.create">
-    <echo message="applying modules"/>
-    <taskdef name="applyModule"
-             classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
-      <classpath refid="project.class.path"/>
-    </taskdef>
-    <applyModule userId="0"
-                 propertiesFile="${base.config}/Openbravo.properties"/>
-    <antcall target="import.database.sampledata"/>
-  </target>
-		
+	<target name="import.database.masterdata" depends="init,code.rev">
+		<ant dir="${base.db}" target="import.database.masterdata" inheritAll="true" inheritRefs="true" />
+	</target>
+
+	<target name="db.apply.modules" if="apply.modules.on.create">
+		<echo message="applying modules" />
+		<taskdef name="applyModule" classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
+			<classpath refid="project.class.path" />
+		</taskdef>
+		<applyModule userId="0" propertiesFile="${base.config}/Openbravo.properties" />
+	</target>
+
+	<target name="db.apply.modules.sampledata" if="apply.modules.on.create">
+		<echo message="applying modules" />
+		<taskdef name="applyModule" classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
+			<classpath refid="project.class.path" />
+		</taskdef>
+		<applyModule userId="0" propertiesFile="${base.config}/Openbravo.properties" />
+		<antcall target="import.database.sampledata" />
+	</target>
+
 	<target name="apply.modules">
-	  <echo>Applying ${module} modules...</echo>
-    <taskdef name="applyModule"
-             classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
-      <classpath refid="project.class.path"/>
-    </taskdef>
-    <antcall target="update.database.mod"/>
-    <applyModule userId="0"
-                 propertiesFile="${base.config}/Openbravo.properties"
-    			reinitializemodel="true"/>
-		<antcall target="compile.deploy"/>
+		<echo>Applying ${module} modules...</echo>
+		<taskdef name="applyModule" classname="org.openbravo.erpCommon.modules.ApplyModuleTask">
+			<classpath refid="project.class.path" />
+		</taskdef>
+		<antcall target="update.database.mod" />
+		<applyModule userId="0" propertiesFile="${base.config}/Openbravo.properties" reinitializemodel="true" />
+		<antcall target="compile.deploy" />
 		<!--antcall target="deploy.context"/-->
 	</target>
-  
+
+	<!-- 
+		apparently this does not overwrite the default catalina_opts, only
+		if it is not set will it be set to the value below 
+	-->
+	<property name="env.CATALINA_OPTS" value="-XX:MaxPermSize=128M" />
+
+	<!-- 
+		This task is called from the Openbravo ui, it spawns a java call which again
+		calls the restart.tomcat.do task as a spawned task.
+	-->
+	<target name="tomcat.restart" description="Restart the tomcat server process">
+		<echo message="${env.CATALINA_OPTS}"/>
+		<java classname="org.openbravo.service.system.RestartTomcat" jvm="${env.JAVA_HOME}/bin/java" spawn="true" fork="true" maxmemory="${build.maxmemory}">
+			<arg line="${base.src}" />
+			<classpath refid="project.class.path" />
+		</java>
+	</target>
+
+	<!--
+		Is called by the org.openbravo.service.system.RestartTomcat class.
+	-->
+	<target name="tomcat.restart.do" description="Restart the tomcat server process">
+		<echo message="Restarting Tomcat at ${env.CATALINA_HOME}" />
+		<java jar="${env.CATALINA_HOME}/bin/bootstrap.jar" fork="true">
+			<jvmarg value="-Dcatalina.home=${env.CATALINA_HOME}" />
+			<arg line="stop" />
+		</java>
+		<sleep description="Wait to give tomcat time to stop" seconds="10" />
+		<java jar="${env.CATALINA_HOME}/bin/bootstrap.jar" fork="true">
+			<classpath path="${env.CATALINA_HOME}/bin/bootstrap.jar:${env.CATALINA_HOME}/bin/commons-logging-api.jar" />
+			<jvmarg value="${env.CATALINA_OPTS}" />
+			<jvmarg value="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" />
+			<jvmarg value="-Djava.util.logging.config.file=${env.CATALINA_HOME}/conf/logging.properties" />
+			<jvmarg value="-Djava.endorsed.dirs=${env.CATALINA_HOME}/endorsed" />
+			<jvmarg value="-Dcatalina.base=${env.CATALINA_HOME}" />
+			<jvmarg value="-Dcatalina.home=${env.CATALINA_HOME}" />
+			<jvmarg value="-Djava.io.tmpdir=${env.CATALINA_HOME}/temp" />
+		</java>
+	</target>
+
+	<!-- 
+		This task is called from the Openbravo ui, it spawns a java call which again
+		calls the tomcat.reload.do task as a spawned task.
+	-->
+	<target name="tomcat.reload" description="Reload the Openbravo context">
+		<echo message="${env.CATALINA_OPTS}"/>
+		<java classname="org.openbravo.service.system.ReloadContext" jvm="${env.JAVA_HOME}/bin/java" maxmemory="${build.maxmemory}">
+			<arg line="${base.src}" />
+			<classpath refid="project.class.path" />
+		</java>
+	</target>
+
+	<target name="tomcat.reload.do">
+		<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
+			<classpath refid="project.class.path" />
+		</taskdef>
+		<reload url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${context.name}"/>
+	</target>
 	
 	<target name="tomcat.list">
-		<taskdef name="list"  classname="org.apache.catalina.ant.ListTask">
-		  <classpath refid="project.class.path"/>
+		<taskdef name="list" classname="org.apache.catalina.ant.ListTask">
+			<classpath refid="project.class.path" />
 		</taskdef>
-		<list url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}"/>
-	</target>
-	
-	<target name="deploy.context">
-		<taskdef name="undeploy"  classname="org.apache.catalina.ant.UndeployTask">
-		  <classpath refid="project.class.path"/>
-	  </taskdef>
-		<taskdef name="deploy.tomcat" classname="org.apache.catalina.ant.DeployTask">
-		  <classpath refid="project.class.path"/>
-		</taskdef>
-		<taskdef name="start"    classname="org.apache.catalina.ant.StartTask">
-		  <classpath refid="project.class.path"/>
-		</taskdef>
-		
-		<undeploy url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}"
-      path="/${context.name}" failonerror="false"/>
-    <deploy.tomcat url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}"
-                path="/${context.name}" war="file:${base.lib}/${context.name}.war"/>
-		<start url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}"
-		          path="/${context.name}"/>
-	</target>
-	
-	
-  <target name="generate-wsdd">
-            <ant dir="${base.src}" target="generate-wsdd" inheritAll="true" inheritRefs="true"/>
-    </target>
-	
-	<target name="obx.export.database" if="obx.exp.DB">
-	  <antcall target="export.database"/>
-	</target>
-	  
-  <target name="obx.export.config.script" if="obx.exp.CS">
-    <antcall target="export.config.script"/>
-  </target>
-	
-	<target name="extract.module">
-  	<taskdef name="extractModule"
-  	           classname="org.openbravo.erpCommon.modules.ExtractModuleTask">
-  	    <classpath refid="project.class.path"/>
-	  </taskdef>
-		
-    <antcall target="obx.export.database"/>
-    <antcall target="obx.export.config.script"/>
-
-		<extractModule moduleName="${module}"
-			  userId="0"
-			  propertiesFile="${base.config}/Openbravo.properties"
-			  exportRD="${obx.export.RD}"/>
+		<list url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" />
 	</target>
 
-	 <target name="diagnostic">
-	 	  <ant dir="src-diagnostics" antfile="build-create.xml" target="build"/>
-	    <ant dir="src-diagnostics" target="check.all"/>
-	  </target>
-	
+	<target name="deploy.context">
+		<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask">
+			<classpath refid="project.class.path" />
+		</taskdef>
+		<taskdef name="deploy.tomcat" classname="org.apache.catalina.ant.DeployTask">
+			<classpath refid="project.class.path" />
+		</taskdef>
+		<taskdef name="start" classname="org.apache.catalina.ant.StartTask">
+			<classpath refid="project.class.path" />
+		</taskdef>
+
+		<undeploy url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${context.name}" failonerror="false" />
+		<deploy.tomcat url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${context.name}" war="file:${base.lib}/${context.name}.war" />
+		<start url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${context.name}" />
+	</target>
+
+	<target name="generate-wsdd">
+		<ant dir="${base.src}" target="generate-wsdd" inheritAll="true" inheritRefs="true" />
+	</target>
+
+	<target name="obx.export.database" if="obx.exp.DB">
+		<antcall target="export.database" />
+	</target>
+
+	<target name="obx.export.config.script" if="obx.exp.CS">
+		<antcall target="export.config.script" />
+	</target>
+
+	<target name="extract.module">
+		<taskdef name="extractModule" classname="org.openbravo.erpCommon.modules.ExtractModuleTask">
+			<classpath refid="project.class.path" />
+		</taskdef>
+
+		<antcall target="obx.export.database" />
+		<antcall target="obx.export.config.script" />
+
+		<extractModule moduleName="${module}" userId="0" propertiesFile="${base.config}/Openbravo.properties" exportRD="${obx.export.RD}" />
+	</target>
+
+	<target name="diagnostic">
+		<ant dir="src-diagnostics" antfile="build-create.xml" target="build" />
+		<ant dir="src-diagnostics" target="check.all" />
+	</target>
+
 	<target name="test">
-		  <echo message="testing..."/>
-  </target>
+		<echo message="testing..." />
+	</target>
 </project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/service/system/ReloadContext.java	Tue Dec 16 14:32:57 2008 +0000
@@ -0,0 +1,57 @@
+package org.openbravo.service.system;
+
+import java.io.File;
+
+import org.apache.log4j.Logger;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.base.session.OBPropertiesProvider;
+import org.openbravo.erpCommon.utility.AntExecutor;
+
+/**
+ * Reloads the tomcat using the tomcat reload ant task.
+ * 
+ * @author mtaal
+ */
+public class ReloadContext {
+    private static final Logger log = Logger.getLogger(ReloadContext.class);
+
+    /**
+     * Method is called from the tomcat.reload tasks, this method again starts
+     * the tomcat.reload.do task.
+     * 
+     * @param args
+     *            arg[0] contains the source path
+     * @throws Exception
+     */
+    public static void main(String[] args) throws Exception {
+        final String srcPath = args[0];
+        final File srcDir = new File(srcPath);
+        final File baseDir = srcDir.getParentFile();
+        try {
+            log.debug("Reloading context with basedir " + baseDir);
+            final AntExecutor antExecutor = new AntExecutor(baseDir
+                    .getAbsolutePath());
+            antExecutor.runTask("tomcat.reload.do");
+        } catch (final Exception e) {
+            e.printStackTrace(System.err);
+            throw new OBException(e);
+        }
+    }
+
+    /**
+     * Restarts the tomcat server. Assumes the the Openbravo.properties are
+     * available through the {@link OBPropertiesProvider}.
+     */
+    public static void reload() {
+        final String baseDirPath = OBPropertiesProvider.getInstance()
+                .getOpenbravoProperties().getProperty("source.path");
+        try {
+            log.debug("Reloading context with basedir " + baseDirPath);
+            final AntExecutor antExecutor = new AntExecutor(baseDirPath);
+            antExecutor.runTask("tomcat.reload");
+        } catch (final Exception e) {
+            e.printStackTrace(System.err);
+            throw new OBException(e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/service/system/RestartTomcat.java	Tue Dec 16 14:32:57 2008 +0000
@@ -0,0 +1,62 @@
+package org.openbravo.service.system;
+
+import java.io.File;
+
+import org.apache.log4j.Logger;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.base.session.OBPropertiesProvider;
+import org.openbravo.erpCommon.utility.AntExecutor;
+
+/**
+ * Restarts the tomcat using the direct java bootstrap class/jar. The restart is
+ * an ant task which itself calls another ant task. The reason that the first
+ * ant task is required because the ant task needs to be spawned and only a java
+ * or exec task can be spawned. The stop and restart action are two java tasks
+ * which should be done in one step. Therefore these two actions have to be
+ * combined into one task which is called by the first (spawned) java task.
+ * 
+ * @author mtaal
+ */
+public class RestartTomcat {
+    private static final Logger log = Logger.getLogger(RestartTomcat.class);
+
+    /**
+     * Method is called from the tomcat.restart tasks, this method again starts
+     * the tomcat.restart.do task.
+     * 
+     * @param args
+     *            arg[0] contains the source path
+     * @throws Exception
+     */
+    public static void main(String[] args) throws Exception {
+        final String srcPath = args[0];
+        final File srcDir = new File(srcPath);
+        final File baseDir = srcDir.getParentFile();
+        try {
+            log.debug("Restarting tomcat with basedir " + baseDir);
+            final AntExecutor antExecutor = new AntExecutor(baseDir
+                    .getAbsolutePath());
+            antExecutor.runTask("tomcat.restart.do");
+        } catch (final Exception e) {
+            e.printStackTrace(System.err);
+            throw new OBException(e);
+        }
+    }
+
+    /**
+     * Restarts the tomcat server. Assumes the the Openbravo.properties are
+     * available through the {@link OBPropertiesProvider}.
+     */
+    public static void restart() {
+        final String baseDirPath = OBPropertiesProvider.getInstance()
+                .getOpenbravoProperties().getProperty("source.path");
+        try {
+            log.debug("Restarting tomcat with basedir " + baseDirPath);
+            final AntExecutor antExecutor = new AntExecutor(baseDirPath);
+            antExecutor.runTask("tomcat.restart");
+        } catch (final Exception e) {
+            e.printStackTrace(System.err);
+            throw new OBException(e);
+        }
+    }
+}