[Bedework-commit] bwtzsvr r35 - in trunk: . build build/buildTools
build/platforms common common/src common/src/org
common/src/org/bedework common/src/org/bedework/timezones
common/src/org/bedework/timezones/common ear.meta resources
server server/src/org/bedework/timezones/server service
service/src service/src/org service/src/org/bedework
service/src/org/bedework/timezones
service/src/org/bedework/timezones/service
svnadmin at bedework.org
svnadmin at bedework.org
Thu Oct 21 22:07:21 EDT 2010
Author: douglm
Date: 2010-10-21 22:06:58 -0400 (Thu, 21 Oct 2010)
New Revision: 35
Added:
trunk/appjars.xml
trunk/build/buildTools/
trunk/build/buildTools/buildjar.xml
trunk/build/buildTools/getJar.xml
trunk/build/buildsh.xml
trunk/build/bw-deployutil-3.6.jar
trunk/build/deploy.xml
trunk/build/deployService.xml
trunk/build/deployTermination.xml
trunk/build/platforms/jboss.xml
trunk/build/platforms/jbossService.xml
trunk/common/
trunk/common/build.xml
trunk/common/src/
trunk/common/src/org/
trunk/common/src/org/bedework/
trunk/common/src/org/bedework/timezones/
trunk/common/src/org/bedework/timezones/common/
trunk/common/src/org/bedework/timezones/common/Stat.java
trunk/common/src/org/bedework/timezones/common/TzServerUtil.java
trunk/common/src/org/bedework/timezones/common/TzsvrConfig.java
trunk/common/src/org/bedework/timezones/common/TzsvrOptionsFactory.java
trunk/ear.meta/
trunk/ear.meta/jboss-service.xml
trunk/server/
trunk/server/src/org/bedework/timezones/server/GetMethod.java
trunk/service/
trunk/service/build.xml
trunk/service/resources/
trunk/service/src/
trunk/service/src/org/
trunk/service/src/org/bedework/
trunk/service/src/org/bedework/timezones/
trunk/service/src/org/bedework/timezones/service/
trunk/service/src/org/bedework/timezones/service/Tzsvc.java
trunk/service/src/org/bedework/timezones/service/TzsvcMBean.java
Removed:
trunk/build/buildjar.xml
trunk/server/src/org/bedework/timezones/server/GetMethod.java
trunk/server/src/org/bedework/timezones/server/TzServerUtil.java
Modified:
trunk/.classpath
trunk/build.properties
trunk/build.xml
trunk/build/buildfilters.xml
trunk/build/buildwar.xml
trunk/build/loadDeployConfig.xml
trunk/build/platforms/jbossWar.xml
trunk/resources/aliases.txt
trunk/server/build.xml
trunk/server/src/org/bedework/timezones/server/MethodBase.java
trunk/server/src/org/bedework/timezones/server/OptionsMethod.java
trunk/server/src/org/bedework/timezones/server/PostMethod.java
trunk/server/src/org/bedework/timezones/server/TzServer.java
Log:
Make timezones server build more like other projects.
Now builds as server + service, deployed as an ear file.
Modified: trunk/.classpath
===================================================================
--- trunk/.classpath 2010-10-22 02:01:10 UTC (rev 34)
+++ trunk/.classpath 2010-10-22 02:06:58 UTC (rev 35)
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="tzsvr/src"/>
+ <classpathentry kind="src" path="common/src"/>
+ <classpathentry kind="src" path="server/src"/>
+ <classpathentry kind="src" path="service/src"/>
<classpathentry kind="lib" path="lib/log4j-1.2.8.jar"/>
<classpathentry kind="lib" path="lib/servletapi-2.4.jar"/>
<classpathentry kind="lib" path="lib/commons-httpclient-3.0.jar"/>
@@ -8,7 +10,7 @@
<classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/>
<classpathentry kind="lib" path="lib/commons-lang-2.1.jar"/>
<classpathentry kind="lib" path="lib/ehcache-1.6.2.jar"/>
- <classpathentry kind="lib" path="lib/ical4j-head-dev.jar"/>
<classpathentry kind="lib" path="lib/rpiutil-3.6.jar"/>
+ <classpathentry kind="lib" path="lib/ical4j-1.0-rc3-SNAPSHOT.jar"/>
<classpathentry kind="output" path="bin/timezones/bwtzsvr/bwtzsvr"/>
</classpath>
Added: trunk/appjars.xml
===================================================================
--- trunk/appjars.xml (rev 0)
+++ trunk/appjars.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,93 @@
+<?xml version="1.0"?>
+
+<!-- ===================================================================
+ Fetch or define extra jars for this application
+ =================================================================== -->
+<project name="extraJars" basedir="." default="">
+ <macrodef name="getExtraJars">
+ <sequential>
+ <delete dir="${org.bedework.temp.extrajars.dir}" />
+ <mkdir dir="${org.bedework.temp.extrajars.dir}" />
+
+ <property name="bedework.home"
+ location="${project.home}/../bedework" />
+
+ <!-- Generated by this project -->
+
+ <getJar lib="${org.bedework.temp.extrajars.dir}"
+ libcache="${org.bedework.libcache.dir}"
+ name="bw-tzsvr-cmn" version="3.7"
+ projecthome="${project.home}" />
+
+ <getJar lib="${org.bedework.temp.extrajars.dir}"
+ libcache="${org.bedework.libcache.dir}"
+ name="bw-tzsvr" version="3.7"
+ projecthome="${project.home}" />
+
+ <getJar lib="${org.bedework.temp.extrajars.dir}"
+ libcache="${org.bedework.libcache.dir}"
+ name="bw-tzsvr-svc" version="3.7"
+ projecthome="${project.home}" />
+
+ <!-- Bedework jars -->
+
+ <getJar lib="${org.bedework.temp.extrajars.dir}"
+ libcache="${org.bedework.libcache.dir}"
+ name="rpiutil" version="3.6" project="rpiutil"
+ projecthome="${bedework.home}/projects/rpiutil" />
+
+ <getJar lib="${org.bedework.temp.extrajars.dir}"
+ libcache="${org.bedework.libcache.dir}"
+ name="bw-annotations" version="3.6" project="calendarapi"
+ projecthome="${project.home}/../bedework/projects/calendarapi"/>
+
+ <getJar lib="${org.bedework.temp.extrajars.dir}"
+ libcache="${org.bedework.libcache.dir}"
+ name="bw-calfacade" version="3.6" project="calendarapi"
+ projecthome="${project.home}/../bedework/projects/calendarapi" />
+
+ <!-- Other jars -->
+
+ <getJar lib="${org.bedework.temp.extrajars.dir}"
+ libcache="${org.bedework.libcache.dir}"
+ name="commons-codec" version="1.3"/>
+
+ <getJar lib="${org.bedework.temp.extrajars.dir}"
+ libcache="${org.bedework.libcache.dir}"
+ name="commons-httpclient" version="3.0"/>
+
+ <getJar lib="${org.bedework.temp.extrajars.dir}"
+ libcache="${org.bedework.libcache.dir}"
+ name="commons-lang" version="2.1"/>
+
+ <getJar lib="${org.bedework.temp.extrajars.dir}"
+ libcache="${org.bedework.libcache.dir}"
+ name="ehcache" version="1.6.2" />
+
+ <getJar lib="${org.bedework.temp.extrajars.dir}"
+ libcache="${org.bedework.libcache.dir}"
+ name="ical4j" version="1.0-rc3-SNAPSHOT"/>
+
+<!--
+ <getJar lib="${org.bedework.temp.extrajars.dir}"
+ libcache="${org.bedework.libcache.dir}"
+ name="jta" version="1.1" />
+
+ <getJar lib="${org.bedework.temp.extrajars.dir}"
+ libcache="${org.bedework.libcache.dir}"
+ name="commons-collections"/>
+
+ <getJar lib="${org.bedework.temp.extrajars.dir}"
+ libcache="${org.bedework.libcache.dir}"
+ name="commons-ssl" />
+ <getJar lib="${org.bedework.temp.extrajars.dir}"
+ libcache="${org.bedework.libcache.dir}"
+ name="exchangews" version="2010"/>
+
+ <getJar lib="${org.bedework.temp.extrajars.dir}"
+ libcache="${org.bedework.libcache.dir}"
+ name="commons-logging" />
+ -->
+ </sequential>
+ </macrodef>
+</project>
Added: trunk/build/buildTools/buildjar.xml
===================================================================
--- trunk/build/buildTools/buildjar.xml (rev 0)
+++ trunk/build/buildTools/buildjar.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,161 @@
+<!-- This file builds a single jar file. It just sets defaults for the java
+ compiler then invokes it.
+
+ This is the only place we compile files.
+
+ On entry we require:
+ build.jar.file Fully specified name of destination jar file.
+ base.name Defines the name of the source base.
+ base.java.sources Defines the java source files
+ base.class.patternset Defines the java class files
+ base.resource.files Defines extra resources to go in the jar
+
+ We will copy all files defined by base.java.patternset to a temporary
+ location and compile out of that into a temporary classes location.
+
+ We do that to avoid a problematic feature of the java compilers, the
+ tendency to recompile any referenced sources found on the source path.
+
+ So, if we have all our sources under the directory "src" and compile a
+ single package in that tree, all referenced classes will be compiled,
+ even if they exist in a jar file on the class path.
+
+ The other side-effect is that we might compile and include classes we
+ didn't realise we were compiling.
+
+ The downside is that we need to be very specific about the classes we
+ compile for a package and we might need to put classes in
+ base.java.sources which we don't want in the final jar file.
+
+ On exit we will have created classes in the directory
+ ${jar.temp.classes}
+ and a jar file
+ ${build.jar.file}
+
+ Authors: Mike Douglass douglm at rpi.edu
+-->
+
+<project name="buildjar" default="build" >
+ <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
+
+ <target name="init">
+ <!-- =================== Compilation Control Options ===============
+ These properties control option settings on the Javac compiler when it
+ is invoked using the <javac> task.
+
+ compile.debug Should compilation include the debug option?
+ compile.deprecation Should compilation include the deprecation option?
+ compile.optimize Should compilation include the optimize option?
+
+ Below are the defaults. They may already be set in the build properties.
+ -->
+
+ <property name="compile.debug" value="true"/>
+ <property name="compile.deprecation" value="false"/>
+ <property name="compile.optimize" value="true"/>
+ <property name="compile.verbose" value="false"/>
+ <property name="compile.listfiles" value="false"/>
+
+ <!-- default to empty -->
+ <fileset id="buildjar.resource.files" refid="empty.fileset" />
+ <fileset id="buildjar.generated.java.sources" refid="empty.fileset" />
+
+ <property name="jar.dest.dir" location="${dist.home}" />
+
+ <property name="jar.temp.sources"
+ location="${jar.dest.dir}/source" />
+ <property name="jar.temp.classes"
+ location="${jar.dest.dir}/classes" />
+ </target>
+
+ <target name="build" depends="init"
+ description="Compile Java sources">
+ <!-- ==============================================================
+ See if the jar is up to date. We recompile if any of the
+ source files or metainf files are newer. We also recompile if
+ any jars on the package classpath are newer.
+ ============================================================== -->
+
+ <echo message="build.jar.file=${build.jar.file}" />
+ <uptodate property="build.jar.uptodate"
+ targetfile="${build.jar.file}" >
+ <srcfiles refid="buildjar.java.sources" />
+ <srcfiles refid="buildjar.generated.java.sources" />
+ <srcfiles refid="buildjar.resource.files"/>
+ <!-- change this to a fileset
+ <srcfiles refid="compile.classpath" />
+ -->
+ </uptodate>
+
+ <if>
+ <isset property="build.jar.uptodate"/>
+ <then>
+ <echo message="**** ${build.jar.file} is up to date" />
+ </then>
+ </if>
+
+ <if>
+ <not>
+ <isset property="build.jar.uptodate"/>
+ </not>
+ <then>
+ <echo message="**** ${build.jar.file} needs rebuilding" />
+
+ <!-- Delete jar file -->
+ <delete file="${build.jar.file}"/>
+
+ <dirname property="build.jar.dir" file="${build.jar.file}"/>
+
+ <mkdir dir="${build.jar.dir}" />
+
+ <!-- ==========================================================
+ Build the classes
+ ========================================================== -->
+
+ <!-- First copy the sources we are going to compile into a temp
+ directory. -->
+ <mkdir dir="${jar.temp.sources}" />
+ <copy toDir="${jar.temp.sources}">
+ <fileset refid="buildjar.java.sources" />
+ <fileset refid="buildjar.generated.java.sources" />
+ <fileset refid="buildjar.resource.files"/>
+ </copy>
+
+ <mkdir dir="${jar.temp.classes}"/>
+ <echo message="About to build jar ${build.jar.file}"/>
+ <property name="cp" refid="compile.classpath" />
+ <echo message="***************cp: ${cp}"/>
+
+ <javac srcdir="${jar.temp.sources}"
+ destdir="${jar.temp.classes}"
+ debug="${compile.debug}"
+ verbose="${compile.verbose}"
+ listfiles="${compile.listfiles}"
+ deprecation="${compile.deprecation}"
+ optimize="${compile.optimize}">
+ <classpath refid="compile.classpath"/>
+ <include name="**/*.java"/>
+ <compilerarg value="-nowarn" compiler="jikes" />
+ </javac>
+
+ <!-- ==========================================================
+ Build jar file
+ ========================================================== -->
+
+ <jar jarfile="${build.jar.file}">
+ <fileset dir="${jar.temp.classes}">
+ <patternset refid="base.class.patternset"/>
+ </fileset>
+ <fileset refid="buildjar.resource.files"/>
+ </jar>
+
+ <!-- ==========================================================
+ Clean up
+ ========================================================== -->
+
+ <delete dir="${jar.temp.sources}" />
+ <delete dir="${jar.temp.classes}"/>
+ </then>
+ </if>
+ </target>
+</project>
Added: trunk/build/buildTools/getJar.xml
===================================================================
--- trunk/build/buildTools/getJar.xml (rev 0)
+++ trunk/build/buildTools/getJar.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,176 @@
+<?xml version="1.0"?>
+
+<!-- ===================================================================
+ Define a macro to fetch jars from the bedework repository or from
+ the generated library in the named project.
+
+ IF a project is named and we cannot locate the named file we try the
+ repository.
+
+ For jars fetched from the archive we have a two step process, first check
+ that a copy in a local cache is up to date, second copy from the local cache
+ into the final destination. This allows the caller to delete and recreate the
+ destination, ensuring that jar version changes don't result in multiple
+ copies of a jar.
+
+ @param name Name of the jar e.g. junit
+ @param version optional version for the jar
+ @param src optional url for the get task
+ @param lib optional destination for the get task
+ @param libcache optional location of the cache
+ @param property optional name of property to hold location of resulting jar
+ @param project optional project name for local fetch from generated quickstart.
+ =================================================================== -->
+<project name="getJar" basedir="." default="">
+ <macrodef name="getJar">
+ <attribute name="name"/>
+ <attribute name="version" default="" />
+ <attribute name="src" default="http://bedework.org/downloads/lib"/>
+ <attribute name="lib" default="${lib.dir}"/>
+ <attribute name="libcache" default="${org.bedework.libcache.dir}"/>
+ <attribute name="property" default="" />
+ <attribute name="project" default="" />
+ <attribute name="projectHome" default="" />
+ <sequential>
+ <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
+
+ <mkdir dir="@{libcache}" />
+
+ <!-- Names are of form
+ <name-part>-<version>.jar or
+ <name-part>.jar
+ -->
+
+ <if>
+ <equals arg1="@{version}" arg2="" />
+ <then>
+ <var name="org.bedework.getjar.jarname" value="@{name}.jar" />
+ </then>
+ <else>
+ <var name="org.bedework.getjar.jarname" value="@{name}-@{version}.jar" />
+ </else>
+ </if>
+
+ <!-- Ensure projectHome is set to something
+ -->
+
+ <if>
+ <equals arg1="@{projectHome}" arg2="" />
+ <then>
+ <var name="org.bedework.getjar.projecthome"
+ value="${project.home}/../@{project}" />
+ </then>
+ <else>
+ <var name="org.bedework.getjar.projecthome" value="@{projectHome}" />
+ </else>
+ </if>
+
+ <var name="org.bedework.getjar.dest"
+ value="@{lib}/${org.bedework.getjar.jarname}" />
+
+ <var name="org.bedework.getjar.finished" value="false" />
+
+ <!-- If a project or projecthome was specified try to get it from the
+ local file system
+ -->
+ <if>
+ <or>
+ <not>
+ <equals arg1="@{project}" arg2="" />
+ </not>
+ <not>
+ <equals arg1="@{projecthome}" arg2="" />
+ </not>
+ </or>
+ <then>
+ <var name="org.bedework.getjar.project.jar"
+ value="${org.bedework.getjar.projecthome}/dist/${org.bedework.getjar.jarname}" />
+ <echo message="check ${org.bedework.getjar.project.jar}" />
+
+ <if>
+ <available file="${org.bedework.getjar.project.jar}" />
+ <then>
+ <!-- Say we found the file -->
+ <var name="org.bedework.getjar.finished" value="true" />
+
+ <if>
+ <not>
+ <uptodate srcfile="${org.bedework.getjar.project.jar}"
+ targetfile="${org.bedework.getjar.dest}" />
+ </not>
+ <then>
+ <echo message="Fetch ${org.bedework.getjar.jarname} from project @{project}" />
+ <copy file="${org.bedework.getjar.project.jar}"
+ todir="@{lib}" overwrite="yes" />
+ </then>
+ </if>
+ </then>
+ </if>
+ </then>
+ </if>
+
+ <!-- if org.bedework.getjar.finished is true we found a local file,
+ otherwise we need to check the repository. -->
+
+ <if>
+ <equals arg1="${org.bedework.getjar.finished}" arg2="false" />
+ <then>
+ <if>
+ <equals arg1="${org.bedework.offline.build}" arg2="yes" />
+ <then>
+ <echo message="Offline: skip check for ${org.bedework.getjar.jarname}" />
+ </then>
+ <else>
+ <!-- Not offline - check repository -->
+ <echo message="Fetch ${org.bedework.getjar.jarname} from archive" />
+ <get src="@{src}/${org.bedework.getjar.jarname}"
+ dest="@{libcache}/${org.bedework.getjar.jarname}"
+ ignoreerrors="true"
+ verbose="true"
+ usetimestamp="true"/>
+ </else>
+ </if>
+
+ <if>
+ <not>
+ <available file="@{libcache}/${org.bedework.getjar.jarname}" />
+ </not>
+ <then>
+ <echo message="******************************************************" />
+ <echo message="File ${org.bedework.getjar.jarname} is not available" />
+ <echo message="******************************************************" />
+ </then>
+ <else>
+ <copy file="@{libcache}/${org.bedework.getjar.jarname}"
+ todir="@{lib}" overwrite="yes" />
+ </else>
+ </if>
+
+ </then>
+ </if>
+
+ <if>
+ <not>
+ <equals arg1="@{property}" arg2="" />
+ </not>
+ <then>
+ <echo message="set property @{property} to ${org.bedework.getjar.dest}" />
+ <property name="@{property}" location="${org.bedework.getjar.dest}" />
+ </then>
+ <elseif>
+ <isset property="org.bedework.getjar.property.prefix" />
+ <then>
+ <echo message="set property ${org.bedework.getjar.property.prefix}.@{name} to ${org.bedework.getjar.dest}" />
+ <property name="${org.bedework.getjar.property.prefix}.@{name}"
+ location="${org.bedework.getjar.dest}" />
+ </then>
+ </elseif>
+ <else>
+ <echo message="set property org.bedework.getjar.jarloc.@{name} to ${org.bedework.getjar.dest}" />
+ <property name="org.bedework.getjar.jarloc.@{name}"
+ location="${org.bedework.getjar.dest}" />
+ </else>
+ </if>
+ </sequential>
+ </macrodef>
+</project>
Modified: trunk/build/buildfilters.xml
===================================================================
--- trunk/build/buildfilters.xml 2010-10-22 02:01:10 UTC (rev 34)
+++ trunk/build/buildfilters.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -11,6 +11,9 @@
<filter token="QUICKSTART_DIR"
value="${quickstart.dir}"/>
+ <filter token="APPSERVER-DATA-DIR"
+ value="${org.bedework.data.dir}"/>
+
<filter token="BW-APP-NAME"
value="${org.bedework.deploy.name}"/>
@@ -50,6 +53,9 @@
<filter token="LIFERAY-COMPANY-ID"
value="${org.bedework.global.liferay.company-id}"/>
+ <filter token="JBOSS-CARDDB-DATASOURCE"
+ value="${org.bedework.global.jboss.carddb.datasource.jndiname}"/>
+
<!-- Application settings -->
<filter token="APP-DESCRIPTION"
@@ -95,6 +101,12 @@
<!-- ???????
<filter token="CALFILE-NAME"
value="${propval.app.calfile.name}" /> -->
+ <filter token="ADMIN-URI"
+ value="${org.bedework.global.public.admin.uri}" />
+ <filter token="PUBEVENTS-URI"
+ value="${org.bedework.global.public.calendar.uri}" />
+ <filter token="PERSONAL-URI"
+ value="${org.bedework.global.personal.calendar.uri}" />
<!-- Shell script settings -->
Deleted: trunk/build/buildjar.xml
===================================================================
--- trunk/build/buildjar.xml 2010-10-22 02:01:10 UTC (rev 34)
+++ trunk/build/buildjar.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -1,160 +0,0 @@
-<!-- This file builds a single jar file. It just sets defaults for the java
- compiler then invokes it.
-
- This is the only place we compile files.
-
- On entry we require:
- build.jar.file Fully specified name of destination jar file.
- base.name Defines the name of the source base.
- base.java.sources Defines the java source files
- base.class.patternset Defines the java class files
- base.resource.files Defines extra resources to go in the jar
-
- We will copy all files defined by base.java.patternset to a temporary
- location and compile out of that into a temporary classes location.
-
- We do that to avoid a problematic feature of the java compilers, the
- tendency to recompile any referenced sources found on the source path.
-
- So, if we have all our sources under the directory "src" and compile a
- single package in that tree, all referenced classes will be compiled,
- even if they exist in a jar file on the class path.
-
- The other side-effect is that we might compile and include classes we
- didn't realise we were compiling.
-
- The downside is that we need to be very specific about the classes we
- compile for a package and we might need to put classes in
- base.java.sources which we don't want in the final jar file.
-
- On exit we will have created classes in the directory
- ${jar.temp.classes}
- and a jar file
- ${build.jar.file}
-
- Authors: Mike Douglass douglm at rpi.edu
--->
-
-<project name="buildjar" default="build" >
- <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
-
- <target name="init">
- <!-- =================== Compilation Control Options ===============
- These properties control option settings on the Javac compiler when it
- is invoked using the <javac> task.
-
- compile.debug Should compilation include the debug option?
- compile.deprecation Should compilation include the deprecation option?
- compile.optimize Should compilation include the optimize option?
-
- Below are the defaults. They may already be set in the build properties.
- -->
-
- <property name="compile.debug" value="true"/>
- <property name="compile.deprecation" value="false"/>
- <property name="compile.optimize" value="true"/>
- <property name="compile.verbose" value="false"/>
- <property name="compile.listfiles" value="false"/>
-
- <!-- default to empty -->
- <fileset id="buildjar.resource.files" refid="empty.fileset" />
- <fileset id="buildjar.generated.java.sources" refid="empty.fileset" />
-
- <property name="jar.dest.dir" location="${dist.home}" />
-
- <property name="jar.temp.sources"
- location="${jar.dest.dir}/source" />
- <property name="jar.temp.classes"
- location="${jar.dest.dir}/classes" />
- </target>
-
- <target name="build" depends="init"
- description="Compile Java sources">
- <!-- ==============================================================
- See if the jar is up to date. We recompile if any of the
- source files or metainf files are newer. We also recompile if
- any jars on the package classpath are newer.
- ============================================================== -->
-
- <uptodate property="build.jar.uptodate"
- targetfile="${build.jar.file}" >
- <srcfiles refid="buildjar.java.sources" />
- <srcfiles refid="buildjar.generated.java.sources" />
- <srcfiles refid="buildjar.resource.files"/>
- <!-- change this to a fileset
- <srcfiles refid="compile.classpath" />
- -->
- </uptodate>
-
- <if>
- <isset property="build.jar.uptodate"/>
- <then>
- <echo message="**** ${build.jar.file} is up to date" />
- </then>
- </if>
-
- <if>
- <not>
- <isset property="build.jar.uptodate"/>
- </not>
- <then>
- <echo message="**** ${build.jar.file} needs rebuilding" />
-
- <!-- Delete jar file -->
- <delete file="${build.jar.file}"/>
-
- <dirname property="build.jar.dir" file="${build.jar.file}"/>
-
- <mkdir dir="${build.jar.dir}" />
-
- <!-- ==========================================================
- Build the classes
- ========================================================== -->
-
- <!-- First copy the sources we are going to compile into a temp
- directory. -->
- <mkdir dir="${jar.temp.sources}" />
- <copy toDir="${jar.temp.sources}">
- <fileset refid="buildjar.java.sources" />
- <fileset refid="buildjar.generated.java.sources" />
- <fileset refid="buildjar.resource.files"/>
- </copy>
-
- <mkdir dir="${jar.temp.classes}"/>
- <echo message="About to build jar ${build.jar.file}"/>
- <property name="cp" refid="compile.classpath" />
- <echo message="***************cp: ${cp}"/>
-
- <javac srcdir="${jar.temp.sources}"
- destdir="${jar.temp.classes}"
- debug="${compile.debug}"
- verbose="${compile.verbose}"
- listfiles="${compile.listfiles}"
- deprecation="${compile.deprecation}"
- optimize="${compile.optimize}">
- <classpath refid="compile.classpath"/>
- <include name="**/*.java"/>
- <compilerarg value="-nowarn" compiler="jikes" />
- </javac>
-
- <!-- ==========================================================
- Build jar file
- ========================================================== -->
-
- <jar jarfile="${build.jar.file}">
- <fileset dir="${jar.temp.classes}">
- <patternset refid="base.class.patternset"/>
- </fileset>
- <fileset refid="buildjar.resource.files"/>
- </jar>
-
- <!-- ==========================================================
- Clean up
- ========================================================== -->
-
- <delete dir="${jar.temp.sources}" />
- <delete dir="${jar.temp.classes}"/>
- </then>
- </if>
- </target>
-</project>
Added: trunk/build/buildsh.xml
===================================================================
--- trunk/build/buildsh.xml (rev 0)
+++ trunk/build/buildsh.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,140 @@
+<?xml version="1.0"?>
+
+<!-- ===================================================================
+ This file builds a runnable application wrapped up as a zip file.
+ Unpacking the zip should result in a directory containing a shell
+ script, a set of jars and any other resources needed.
+
+ Properties we need:
+ app.core.env.pname core properties source
+ app.run.shellscr location of the skeleton shell script.
+ app.run.jar.file application jar file
+ app.run.main.class main class for application.
+
+ Authors: Mike Douglass douglm at rpi.edu
+ =================================================================== -->
+
+<project name="bw.buildsh" default="build">
+ <import file="${build.dir}/buildfilters.xml" />
+
+ <import file="${build.dir}/platforms/${org.bedework.global.deploy.platform}Service.xml" />
+
+ <target name="init">
+ <!-- Destinations - where we build stuff -->
+ <property name="app.dest.home"
+ location="${org.bedework.temp.shellscr.home}/${propval.app.zip.name}" />
+ <property name="app.dest.lib"
+ location="${app.dest.home}/lib" />
+ <property name="app.dest.classes"
+ location="${app.dest.home}/classes" />
+ <property name="app.dest.properties"
+ location="${app.dest.classes}/${propval.app.properties.path}" />
+ <property name="app.dest.data"
+ location="${app.dest.home}/data" />
+
+ <property name="app.zip.file"
+ location="${dist.home}/${propval.app.zip.name}.zip" />
+ </target>
+
+ <!-- ================================================================
+ build target
+ ================================================================ -->
+
+ <target name="build" depends="init">
+ <delete dir="${app.dest.home}" />
+
+ <!-- Library stuff -->
+
+ <mkdir dir="${app.dest.lib}" />
+
+ <!-- Platform specific -->
+ <antcall target="addLibs" inheritRefs="true" />
+
+ <if>
+ <available file="${app.global.properties.dir}" type="dir" />
+ <then>
+ <copy todir="${app.dest.classes}">
+ <fileset dir="${app.global.properties.dir}"
+ excludes="*.sh,*.bat" />
+ <filterset refid="property.filters" />
+ </copy>
+
+ <!-- and again? -->
+ <copy todir="${app.dest.home}">
+ <fileset dir="${app.global.properties.dir}"
+ includes="*.sh,*.bat" />
+ <filterset refid="property.filters" />
+ </copy>
+ </then>
+ </if>
+
+ <!--
+ <copy todir="${app.dest.classes}">
+ <fileset dir="${org.bedework.project.calendarapi}/calCore/resources/hbms" />
+ <filterset refid="property.filters" />
+ </copy>
+
+ <copy tofile="${app.dest.classes}/sysevents.properties"
+ file="${org.bedework.config.sysevents.properties}" /> -->
+
+ <if>
+ <isreference refid="org.bedework.extra.resources" />
+ <then>
+ <copy todir="${app.dest.classes}" overwrite="yes" >
+ <fileset refid="org.bedework.extra.resources" />
+ <filterset refid="property.filters" />
+ </copy>
+ </then>
+ </if>
+
+ <!-- Platform specific hibernate properties -->
+ <antcall target="doHibProps" inheritRefs="true" />
+
+ <!-- Create the env.properties file -->
+ <mkdir dir="${app.dest.properties}" />
+
+ <copy tofile="${app.dest.properties}/options.xml"
+ file="${org,bedework.service.options.file}" />
+
+ <!-- ===============================================================
+ Add any resource files
+ =============================================================== -->
+
+ <!-- Platform specific -->
+ <antcall target="addResources" inheritRefs="true" />
+
+ <!-- ===============================================================
+ Add any data files
+ =============================================================== -->
+
+ <if>
+ <istrue value="${org.bedework.shellscr.copy.data}" />
+ <then>
+ <mkdir dir="${app.dest.data}" />
+
+ <copy todir="${app.dest.data}" overwrite="yes" >
+ <fileset refid="org.bedework.shellscr.data" />
+ <filterset refid="property.filters" />
+ </copy>
+ </then>
+ </if>
+
+ <!-- ===============================================================
+ Add any extra stuff
+ =============================================================== -->
+
+ <!-- Platform specific -->
+ <antcall target="addExtras" inheritRefs="true" />
+
+ <!-- ================================================================
+ Build the zip file
+ ================================================================ -->
+
+ <mkdir dir="${dist.home}" />
+ <delete file="${app.zip.file}" />
+
+ <zip destfile="${app.zip.file}" >
+ <zipfileset prefix="${propval.app.zip.name}" dir="${app.dest.home}" />
+ </zip>
+ </target>
+</project>
Modified: trunk/build/buildwar.xml
===================================================================
--- trunk/build/buildwar.xml 2010-10-22 02:01:10 UTC (rev 34)
+++ trunk/build/buildwar.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -1,197 +1,387 @@
-<?xml version="1.0"?>
-
-<!-- ===================================================================
- Build server web applications.
-
- It is assumed that no changes will be made to this file. It should be
- possible to make all changes needed by modifying the configuration
- properties or a bedework.build.proeprties file
-
- An unwrapped web application will be built in the temp directory
- and a war and ear file will be left in the dist directory.
-
- Properties which must be defined on entry,
-
- dist.home where we build distributable products
- lib.dir where the library jars are located
- libapi.dir where the generated library jars are located
- app.sou.dir Location of the application skeleton,
- propval.app.war.name Name of the application war file.
- propval.app.display.name Built into application war
- propval.app.tomcat.context.xml (Optional - points at your own context.xml file)
-
- It is possible to define any of the app.dest properties below to override
- the location of destination files.
-
- In the directory
- ${apps.sou.dir}
- we expect an application skeleton formatted like a web-application
- For the purposes of this build it should contain a
- structure like
- war - docs (contains jsp and html for this app)
- WEB-INF - struts-config.xml
- web.xml
- jboss-web.xml (for jboss only)
-
- Authors: Mike Douglass
- =================================================================== -->
-
-<project name="bedework.buildwar" default="build" >
- <import file="${build.dir}/buildfilters.xml" />
-
- <import file="${build.dir}/platforms/${org.bedework.global.deploy.platform}War.xml" />
-
- <target name="init">
- <property name="temp.home" location="${dist.home}/temp" />
-
- <mkdir dir="${temp.home}" />
-
- <!-- Destinations - where we build an unwrapped war -->
- <property name="app.dest.war"
- location="${temp.home}/wars/${propval.app.war.name}.war" />
- <property name="app.dest.docs"
- location="${app.dest.war}/docs" />
- <property name="app.dest.webinf"
- location="${app.dest.war}/WEB-INF" />
- <property name="app.dest.metainf"
- location="${app.dest.war}/META-INF" />
- <property name="app.dest.classes"
- location="${app.dest.webinf}/classes" />
- <property name="app.dest.properties"
- location="${app.dest.classes}" />
-
- <property name="app.dest.lib"
- location="${app.dest.webinf}/lib" />
-
- <!--temp web.xml location -->
- <property name="app.temp.web.xml"
- location="${app.dest.webinf}/tempweb.xml" />
-
- <!--final web.xml location -->
- <property name="app.dest.web.xml"
- location="${app.dest.webinf}/web.xml" />
-
- <property name="app.war.file"
- location="${dist.home}/${propval.app.war.name}.war" />
-
- <!-- default web.xml -->
- <property name="app.web.xml"
- location="${app.sou.dir}/war/WEB-INF/web.xml" />
-
- <property name="app.sou.properties"
- location="${temp.home}/properties" />
- </target>
-
- <target name="build" depends="init">
- <delete dir="${app.dest.war}" />
-
- <!-- Add modifed login pages -->
- <copy todir="${app.dest.docs}/login" failonerror="false" >
- <fileset dir="${org.bedework.common.resources}/login" />
- <filterset>
- <filter token="DISPLAY-NAME" value="${propval.app.display.name}"/>
- </filterset>
- </copy>
-
- <!-- ===============================================================
- We copy 3 sets of properties.
-
- First (for struts) are the servlet properties which ends up as
- classes/servlet.properties
- Next we copy in a set of generic property files and then with
- overwrite we copy in a set of base specific files.
-
- All are updated with new values.
- =============================================================== -->
-
- <available file="${app.sou.properties}" type="dir"
- property="org.bedework.properties.dir.exists" />
-
- <available file="${app.sou.dir}/war/docs" type="dir"
- property="org.bedework.war.docs.exists" />
-
- <antcall target="copy.properties" inheritRefs="true" />
- <antcall target="copy.war.docs" inheritRefs="true" />
-
- <!-- Make a temp copy of the web.xml file -->
- <copy tofile="${app.temp.web.xml}" file="${app.web.xml}"
- overwrite="yes" />
-
- <!-- Filter the temp copy of the web.xml file -->
- <copy tofile="${app.dest.web.xml}"
- file="${app.temp.web.xml}"
- overwrite="yes" >
- <filterset>
- <filter token="RPI-DEBUG" value="${app.debug.val}"/>
- </filterset>
- <!-- <filterset refid="property.filters" /> -->
- </copy>
-
- <delete file="${app.temp.web.xml}" />
-
- <if>
- <isset property="org.bedework.global.context.roots" />
- <then>
- <!-- Add the contex root to the file. Note that newline is required -->
- <echo file="${org.bedework.global.context.roots}" append="yes">
-${propval.app.war.name}.context=${propval.app.context.root}
- </echo>
- </then>
- </if>
-
- <!-- ===============================================================
- Any jar files required
- =============================================================== -->
-
- <copy todir="${app.dest.lib}" overwrite="yes">
- <fileset dir="${lib.dir}" excludes="servlet*.jar" />
- <fileset dir="${dist.home}">
- <include name="*.jar"/>
- </fileset>
- </copy>
-
- <!-- Platform specific -->
- <antcall target="doPlatform" inheritRefs="true" />
-
- <!-- build the war file -->
- <mkdir dir="${dist.home}" />
- <delete file="${app.war.file}" />
-
- <war warfile="${app.war.file}"
- webxml="${app.dest.web.xml}"
- basedir="${app.dest.war}"
- excludes="WEB-INF/web.xml" />
- </target>
-
- <target name="add.jdbcdriver" if="app.jdbcdriver.jar">
- <copy todir="${app.dest.lib}" file="${app.jdbcdriver.jar}"/>
- </target>
-
- <target name="copy.properties" if="org.bedework.properties.dir.exists">
- <!-- ===============================================================
- Any property files we need for configuration, other than the
- standard struts file, should be in the "${app.sou.dir}/properties
- directory. They will be copied into the appropriate place for the
- war and transformed by the above filter.
- =============================================================== -->
- <copy todir="${app.dest.properties}" overwrite="yes" >
- <fileset dir="${dist.home}/temp/properties"
- includes="*"/>
-<!-- <filterset refid="property.filters" /> -->
- </copy>
- </target>
-
- <target name="copy.servlet.properties">
- <copy todir="${app.dest.classes}">
- <fileset dir="${app.sou.properties}"
- includes="*"/>
- <!--<filterset refid="property.filters" />-->
- </copy>
- </target>
-
- <target name="copy.war.docs" if="org.bedework.war.docs.exists">
- <copy todir="${app.dest.docs}">
- <fileset dir="${app.sou.dir}/war/docs" />
- </copy>
- </target>
-</project>
+<?xml version="1.0"?>
+
+<!-- ===================================================================
+ This file is called by other build files to create web applications.
+
+ It is assumed that no changes will be made to this file. It should be
+ possible to make all changes needed by modifying the configuration
+ properties or a bedework.build.proeprties file
+
+ An unwrapped web application will be built in the temp directory
+ and a war and ear file will be left in the dist directory.
+
+ Properties which must be defined on entry, apart from those described
+ in the main build file are:
+ app.root.dir Location of the root directory for the apps
+ app.sou.dir Location of the application skeleton,
+ app.name Name of the application. This wil be used to determine
+ the name of the file containing the rest of the
+ application properties, the directory we build in
+ and the name of war and ear files.
+ These should be defined in the build properties for the application.
+
+ It is possible to define any of the app.dest properties below to override
+ the location of destination files.
+
+ In the directory
+ ${apps.sou.dir}
+ we expect an application skeleton formatted like a web-application
+ For the purposes of this build it should contain a
+ structure like
+ war - docs (contains jsp and html for this app)
+ WEB-INF - struts-config.xml
+ web.xml
+ jboss-web.xml (for jboss only)
+
+ Authors: Mike Douglass
+ =================================================================== -->
+
+<project name="bedework.buildwar" default="build" >
+ <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
+
+ <path id="build.cp">
+ <fileset dir="${build.dir}">
+ <include name="*.jar"/>
+ </fileset>
+ </path>
+
+ <taskdef name="resolveFile"
+ classname="org.bedework.deployment.ResolveFile">
+ <classpath refid="build.cp"/>
+ </taskdef>
+
+ <import file="${build.dir}/buildfilters.xml" />
+
+ <import file="${project.home}/appjars.xml" />
+
+ <if>
+ <isset property="org.bedework.global.portal.platform" />
+ <then>
+ <import file="${build.dir}/portals/${org.bedework.global.portal.platform}War.xml" />
+ </then>
+ </if>
+
+ <import file="${build.dir}/platforms/${org.bedework.global.deploy.platform}War.xml" />
+
+ <target name="init" depends="init.common">
+ <getExtraJars/>
+ <if>
+ <isset property="org.bedework.global.build.ear" />
+ <then>
+ <!-- Common library in ear file -->
+ <property name="app.dest.lib"
+ location="${org.bedework.ear.templib}" />
+
+ <!-- Properties all go into a single jar file at termination -->
+ <property name="app.dest.classes"
+ location="${org.bedework.ear.properties.dir}" />
+ </then>
+ <else>
+ <!-- Library in war file -->
+ <property name="app.dest.lib"
+ location="${app.dest.webinf}/lib" />
+
+ <!-- Properties in the war file -->
+ <property name="app.dest.classes"
+ location="${app.dest.webinf}/classes" />
+ </else>
+ </if>
+ <property name="app.dest.properties"
+ location="${app.dest.classes}/${propval.app.properties.path}" />
+ </target>
+
+ <target name="init.common">
+ <echo message="+_+_+_+_+_+_+_+_+_+_+_ org.bedework.temp.wars.home=${org.bedework.temp.wars.home}"/>
+
+ <!-- Destinations - where we build an unwrapped war -->
+ <property name="app.dest.war"
+ location="${org.bedework.temp.wars.home}/${propval.app.war.name}.war" />
+ <property name="app.dest.docs"
+ location="${app.dest.war}/docs" />
+ <property name="app.dest.webinf"
+ location="${app.dest.war}/WEB-INF" />
+ <property name="app.dest.metainf"
+ location="${app.dest.war}/META-INF" />
+
+ <!--temp web.xml location -->
+ <property name="app.temp.web.xml"
+ location="${app.dest.webinf}/tempweb.xml" />
+
+ <!--final web.xml location -->
+ <property name="app.dest.web.xml"
+ location="${app.dest.webinf}/web.xml" />
+
+ <property name="app.war.file"
+ location="${dist.home}/${propval.app.war.name}.war" />
+
+ <!-- default web.xml -->
+ <property name="propval.app.web.xml"
+ value="war/WEB-INF/web.xml" />
+
+ <!--
+ <property name="app.web.xml"
+ location="${propval.app.web.xml}" />
+ -->
+ <resolveFile name="app.web.xml"
+ file="${propval.app.web.xml}"
+ base="${app.sou.dir}"/>
+
+ <property name="app.sou.properties"
+ location="${app.sou.dir}/war/WEB-INF/classes/servlet.properties" />
+ </target>
+
+ <target name="build" depends="init">
+ <echo message="**************************************************" />
+ <echo message=" * Building war ${propval.app.war.name}"/>
+ <echo message="**************************************************" />
+
+ <delete dir="${app.dest.war}" />
+
+ <!-- Add modifed login pages -->
+ <copy todir="${app.dest.docs}/login" failonerror="false" >
+ <fileset dir="${org.bedework.common.resources}/login" />
+ <filterset>
+ <filter token="DISPLAY-NAME" value="${propval.app.display.name}"/>
+ </filterset>
+ </copy>
+
+ <!-- ===============================================================
+ We copy 3 sets of properties.
+
+ First (for struts) are the servlet properties which ends up as
+ classes/servlet.properties
+ Next we copy in a set of generic property files and then with
+ overwrite we copy in a set of base specific files.
+
+ All are updated with new values.
+ =============================================================== -->
+
+ <if>
+ <available file="${app.sou.dir}/war/docs" type="dir" />
+ <then>
+ <copy todir="${app.dest.docs}">
+ <fileset dir="${app.sou.dir}/war/docs" />
+ </copy>
+ </then>
+ </if>
+
+ <!-- ===============================================================
+ Any property files we need for configuration, other than the
+ standard struts file, should be in the "${app.sou.dir}/properties
+ directory. They will be copied into the appropriate place for the
+ war and transformed by the above filter.
+ =============================================================== -->
+
+ <!-- Create the runtime options file -->
+ <mkdir dir="${app.dest.properties}" />
+
+ <if>
+ <available file="${app.sou.dir}/properties" type="dir" />
+ <then>
+ <copy todir="${app.dest.properties}" overwrite="yes" >
+ <fileset dir="${app.sou.dir}/properties"
+ includes="*.properties"/>
+ <filterset refid="property.filters" />
+ </copy>
+ </then>
+ </if>
+
+ <copy tofile="${app.dest.properties}/options.xml"
+ file="${org.bedework.service.options.file}" >
+ <filterset>
+ <filter token="RPI-DEBUG" value="${app.debug.val}"/>
+ </filterset>
+ <filterset refid="property.filters" />
+ </copy>
+
+ <!--
+ <copy todir="${app.dest.classes}">
+ <fileset dir="${app.sou.dir}/war/WEB-INF/classes"
+ includes="*"/>
+ <filterset refid="property.filters" />
+ </copy>
+ -->
+
+ <!-- Make our own servlet.properties file for struts applications
+ <copy tofile="${app.dest.classes}/servlet.properties" file="${app.sou.properties}">
+ <filterset refid="property.filters" />
+ </copy>
+ -->
+
+ <copy tofile="${app.dest.classes}/sysevents.properties"
+ file="${org.bedework.config.sysevents.properties}" />
+
+ <!-- ===============================================================
+ Add hibernate jars and property files.
+ =============================================================== -->
+
+ <if>
+ <available file="${resources.dir}" type="dir" />
+ <then>
+ <copy todir="${app.dest.classes}">
+ <fileset dir="${resources.dir}" />
+ <filterset refid="property.filters" />
+ </copy>
+ </then>
+ </if>
+
+ <!-- NOT CALDAV
+ <copy todir="${app.dest.classes}">
+ <fileset dir="${org.bedework.project.calendarapi}/calCore/resources/properties" />
+ <filterset refid="property.filters" />
+ </copy>
+
+ <copy todir="${app.dest.classes}">
+ <fileset dir="${org.bedework.project.calendarapi}/calCore/resources/hbms" />
+ <filterset refid="property.filters" />
+ </copy>
+ -->
+
+ <!-- Make a temp copy of the web.xml file -->
+ <copy tofile="${app.temp.web.xml}" file="${app.web.xml}"
+ overwrite="yes" />
+
+ <antcall target="struts-stuff" inheritRefs="true" />
+
+ <!-- Filter the temp copy of the web.xml file -->
+ <copy tofile="${app.dest.web.xml}"
+ file="${app.temp.web.xml}"
+ overwrite="yes" >
+ <filterset>
+ <filter token="RPI-DEBUG" value="${app.debug.val}"/>
+ </filterset>
+ <filterset refid="property.filters" />
+ </copy>
+
+ <delete file="${app.temp.web.xml}" />
+
+ <!-- Add the contex root to the file. Note that newline is required -->
+ <echo file="${org.bedework.global.context.roots}" append="yes">
+${propval.app.war.name}.context=${propval.app.context.root}
+ </echo>
+
+ <!-- Add libraries: Platform specific -->
+ <antcall target="addLibs" inheritRefs="true" />
+
+ <!-- Platform specific -->
+ <antcall target="doPlatform" inheritRefs="true" />
+
+ <!-- build the war file -->
+ <mkdir dir="${dist.home}" />
+
+ <!-- may be there as a file or a directory -->
+ <delete file="${app.war.file}" />
+ <delete dir="${app.war.file}" />
+
+ <if>
+ <or>
+ <not>
+ <isset property="org.bedework.global.wars.zipped" />
+ </not>
+ <istrue value="${org.bedework.global.wars.zipped}"/>
+ </or>
+ <then>
+ <!-- Build a zipped war file -->
+ <war warfile="${app.war.file}"
+ webxml="${app.dest.web.xml}"
+ basedir="${app.dest.war}"
+ excludes="WEB-INF/web.xml" />
+ </then>
+ <else>
+ <!-- Unzipped war file -->
+ <copy todir="${app.war.file}">
+ <fileset dir="${app.dest.war}" includes="*"/>
+ <filterset refid="property.filters" />
+ </copy>
+ </else>
+ </if>
+ </target>
+
+ <target name="struts-stuff" if="org.bedework.strutsapp">
+ <!-- Make our own servlet.properties file for struts applications -->
+ <echo file="${app.dest.classes}/servlet.properties" ><![CDATA[#
+# ========================================================================
+# This file contains all properties for servlet applications.
+# It cannot be application specific as the jboss build creates a
+# single set of resources on the classpath.
+# ========================================================================
+#
+
+# ========================================================================
+# Properties for the xml/xslt based calendar web applications
+# ========================================================================
+#
+# author Mike Douglass douglm rpi.edu
+
+# This is only here because the jetspeed portal-struts bridge does not seem to be
+# passing across the servlet context.
+#org.bedework.svcicb.sessionAttrName=org.bedework.admin.svcicb.sessionattrname. at APP-NAME@
+
+# These are required by the Struts framework
+errors.header=<errors><ul>
+errors.footer=</ul></errors>
+
+messages.header=<messages><ul>
+messages.footer=</ul></messages>
+
+edu.rpi.sss.util.action.noactionerrors=yes
+
+applicationResources=<li>Cannot load application resources bundle {0}</li>
+
+# set the default content type - html for jsp, xml for xml/xslt.
+#edu.rpi.sss.util.action.contenttype=@DEFAULT-CONTENTTYPE@
+edu.rpi.sss.util.action.contenttype=text/xml
+
+edu.rpi.sss.util.error.exc=<li>Exception: {0}</li>
+
+# Turn nocache headers on. We don't use the standard struts directives
+# because we need to be able to turn nocache off for a single response.
+# This gets around an IE problem with delivery of files.
+edu.rpi.sss.util.action.nocache=yes
+
+org.bedework.security.prefix=@SECURITY-PREFIX@
+
+edu.rpi.sss.util.action.logprefix=@APP-NAME@
+
+# Roles we need to know about - init action uses these
+# (Not using roles in the current system)
+#org.bedework.role.admin=@SECURITY-PREFIX at .admin
+#org.bedework.role.contentadmin=@SECURITY-PREFIX at .contentadmin
+#org.bedework.role.alert=@SECURITY-PREFIX at .alerts
+#org.bedework.role.owner=@SECURITY-PREFIX at .owner
+]]></echo>
+
+ <!-- Replace the tokens -->
+ <replace file="${app.dest.classes}/servlet.properties">
+ <replacefilter token="@SECURITY-PREFIX@"
+ value="${propval.app.security.prefix}" />
+ <replacefilter token="@APP-NAME@"
+ value="${propval.app.name}" />
+ <replacefilter token="@DEFAULT-CONTENTTYPE@"
+ value="${propval.app.default.contenttype}" />
+ </replace>
+
+ <!-- Copy a dummy startup file into the war. -->
+ <copy todir="${app.dest.war}">
+ <fileset dir="${app.sou.dir}/war/" includes="setup.do" />
+ </copy>
+
+ <copy todir="${app.dest.webinf}"
+ file="${app.sou.dir}/war/WEB-INF/struts-config.xml"/>
+
+ <mkdir dir="${app.dest.webinf}/tlds"/>
+ <copy todir="${app.dest.webinf}/tlds" >
+ <fileset dir="${org.bedework.struts.tlds}">
+ <include name="*"/>
+ </fileset>
+ </copy>
+
+ <if>
+ <isset property="org.bedework.global.portal.platform" />
+ <then>
+ <antcall target="doPortal" inheritRefs="true" />
+ </then>
+ </if>
+
+ </target>
+</project>
Added: trunk/build/bw-deployutil-3.6.jar
===================================================================
(Binary files differ)
Property changes on: trunk/build/bw-deployutil-3.6.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/build/deploy.xml
===================================================================
--- trunk/build/deploy.xml (rev 0)
+++ trunk/build/deploy.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+
+<!-- ===================================================================
+ terminations task.
+ =================================================================== -->
+
+<project name="bwdeploy.ear" default="deployFiles" >
+ <import file="${build.dir}/platforms/${org.bedework.global.deploy.platform}War.xml" />
+
+ <import file="${build.dir}/buildfilters.xml" />
+
+ <dirname property="this.dir" file="${ant.file}"/>
+
+ <target name="init">
+ </target>
+
+ <target name="deployFiles" depends="init,build.configured" >
+ <!-- Deploy common resources
+ <ant antfile="${org.bedework.common.resources}/build.xml"
+ inheritrefs="true" target="deploy" />
+ -->
+ <if>
+ <isset property="org.bedework.global.build.ear" />
+ <then>
+ <!-- Platform specific -->
+ <antcall target="deployEar" inheritRefs="true" />
+ </then>
+ </if>
+ </target>
+
+ <target name="build.configured" depends="init" >
+ </target>
+</project>
Added: trunk/build/deployService.xml
===================================================================
--- trunk/build/deployService.xml (rev 0)
+++ trunk/build/deployService.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+
+<!-- ===================================================================
+ terminations task.
+ =================================================================== -->
+
+<project name="bwdeploy.dumpres" default="deploy" >
+ <import file="${build.dir}/platforms/${org.bedework.global.deploy.platform}Service.xml" />
+
+ <import file="${build.dir}/buildfilters.xml" />
+
+ <dirname property="this.dir" file="${ant.file}"/>
+
+ <target name="init">
+ </target>
+
+ <target name="deploy" depends="init,build.configured" >
+ <antcall target="deployService" inheritRefs="true" />
+ </target>
+
+ <target name="build.configured" depends="init" >
+ <!-- ===============================================================
+ Build the shell script
+ =============================================================== -->
+
+ <ant antfile="${buildsh}" inheritRefs="true" target="build" />
+ </target>
+</project>
Added: trunk/build/deployTermination.xml
===================================================================
--- trunk/build/deployTermination.xml (rev 0)
+++ trunk/build/deployTermination.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+
+<!-- ===================================================================
+ terminations task.
+ =================================================================== -->
+
+<project name="bwdeploy.termination" default="deployTerminate" >
+ <import file="${build.dir}/platforms/${org.bedework.global.deploy.platform}.xml" />
+
+ <dirname property="this.dir" file="${ant.file}"/>
+
+ <target name="init">
+ </target>
+
+ <target name="deployTerminate" depends="init" >
+ <!-- Platform specific -->
+ <antcall target="doPlatform" inheritRefs="true" />
+ </target>
+</project>
Modified: trunk/build/loadDeployConfig.xml
===================================================================
--- trunk/build/loadDeployConfig.xml 2010-10-22 02:01:10 UTC (rev 34)
+++ trunk/build/loadDeployConfig.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -22,9 +22,7 @@
location="${org.bedework.config.base}/configs/democal.properties" />
<property name="org.bedework.config.options"
location="${org.bedework.config.base}/configs/democal.options.xml" />
- <property name="org.bedework.carddav.options"
- location="${org.bedework.config.base}/configs/democal.options.xml" />
- -->
+ -->
<echo message="==========================================================" />
<echo message="Use config properties ${org.bedework.config.properties}" />
@@ -33,11 +31,11 @@
<!-- Load the run time options and define some properties based on some
of the values -->
+ <!-- Load the general bedework options -->
<xmlproperty file="${org.bedework.config.options}"/>
- <property file="${org.bedework.config.properties}" />
- <!-- Load the CardDAV options -->
- <xmlproperty file="${org.bedework.carddav.options}"/>
+ <!-- Load this service options -->
+ <xmlproperty file="${org.bedework.service.options.file}"/>
<if>
<isset property="bedework-options.org.bedework.global.portal.platform"/>
@@ -60,12 +58,15 @@
</else>
</if>
+ <!--
<if>
<isset property="org.bedework.global.build.ear"/>
<then>
+ <echo message="******************* load from ${org.bedework.configurations.home}/.platform/ear.properties" />
<property file="${org.bedework.configurations.home}/.platform/ear.properties" />
</then>
</if>
+ -->
<property name="org.bedework.global.version"
value="${bedework-options.org.bedework.global.version}" />
Added: trunk/build/platforms/jboss.xml
===================================================================
--- trunk/build/platforms/jboss.xml (rev 0)
+++ trunk/build/platforms/jboss.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+
+<!-- ===================================================================
+ This file is imported by termination/build.xml and adds the targets
+ which will be invoked by that file.
+ doPlatform - misc stuff
+ =================================================================== -->
+
+<project name="bedework.platformTermination" default="doPlatform" >
+ <target name="doPlatform" >
+ <!-- If requested copy in the db configuration. -->
+
+ <if>
+ <istrue value="${org.bedework.global.copy.bedeworkcardds.config}" />
+ <then>
+ <copy file="${org.bedework.config.home}/bedework-card-ds.xml"
+ tofile="${org.bedework.appserver.deploy.dir}/bedework-card-ds.xml"
+ overwrite="yes" />
+ </then>
+ </if>
+ </target>
+</project>
\ No newline at end of file
Added: trunk/build/platforms/jbossService.xml
===================================================================
--- trunk/build/platforms/jbossService.xml (rev 0)
+++ trunk/build/platforms/jbossService.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,151 @@
+<?xml version="1.0"?>
+
+<!-- ===================================================================
+ This file is imported by buildsh.xml and others and adds the targets:
+ doHibProps: builds a set of properties for the service
+ addLibs: add libraries for this platform
+ addResources: add anything we want in the resources directory
+ addExtras: add scripts for runnable versions and META-INF for
+ jboss services etc.
+ deployService: deploy the service
+ =================================================================== -->
+
+<project name="bedework.platformService" default="doHibProps" >
+ <target name="doHibProps" >
+ <if>
+ <istrue value="${propval.app.runnable}" />
+ <then>
+ <antcall target="runnableDoHibProps" inheritRefs="true" />
+ </then>
+ <else>
+ <mkdir dir="${app.dest.classes}"/>
+
+ <echo file="${app.dest.classes}/hibernate.properties">
+hibernate.dialect=${org.bedework.global.hibernate.dialect}
+
+hibernate.connection.datasource=java:${org.bedework.global.jboss.carddb.datasource.jndiname}
+
+hibernate.bytecode.use_reflection_optimizer=false
+hibernate.cache.use_second_level_cache=false
+#
+# Here for better debugging
+#
+hibernate.jdbc.batch_size=0
+ </echo>
+ </else>
+ </if>
+ </target>
+
+ <!-- ================================================================
+ Add libraries
+ ================================================================ -->
+
+ <target name="addLibs">
+ <if>
+ <istrue value="${propval.app.runnable}" />
+ <then>
+ <property name="app.dest.lib"
+ location="${app.dest.home}/lib" />
+ <antcall target="runnableAddLibs" inheritRefs="true" />
+ </then>
+ <else>
+ <!-- Library in sar file -->
+ <property name="app.dest.lib"
+ location="${app.dest.webinf}/lib" />
+ <antcall target="copyLibs" inheritRefs="true" />
+ </else>
+ </if>
+ </target>
+
+ <!-- ================================================================
+ Add resources
+ ================================================================ -->
+
+ <target name="addResources">
+ <if>
+ <istrue value="${propval.app.runnable}" />
+ <then>
+ <antcall target="runnableAddResources" inheritRefs="true" />
+ </then>
+ <else>
+ <!-- None for this platform -->
+ </else>
+ </if>
+ </target>
+
+ <!-- ================================================================
+ Add extras
+ ================================================================ -->
+
+ <target name="addExtras">
+ <if>
+ <istrue value="${propval.app.runnable}" />
+ <then>
+ <antcall target="runnableAddExtras" inheritRefs="true" />
+ </then>
+ <else>
+ <property name="metainf.dir"
+ location="${app.service.base}/resources/META-INF" />
+
+ <mkdir dir="${app.dest.home}/META-INF" />
+
+ <echo file="${app.dest.home}/META-INF/jboss-structure.xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<structure>
+ <context>
+ <path name=""/>
+ <metaDataPath>
+ <path name="META-INF"/>
+ </metaDataPath>
+ <classpath>
+ <path name="classes"/>
+ <path name="lib" suffixes=".jar" />
+ </classpath>
+ </context>
+</structure>
+]]></echo>
+
+ <copy todir="${app.dest.home}/META-INF">
+ <fileset dir="${metainf.dir}" />
+ <filterset refid="property.filters" />
+ </copy>
+ </else>
+ </if>
+ </target>
+
+ <target name="deployService">
+ <!-- copy the sar - at the moment copy the uncompressed. -->
+
+ <if>
+ <istrue value="${propval.app.runnable}" />
+ <then>
+ <antcall target="runnableDeployService" inheritRefs="true" />
+ </then>
+ <else>
+ <if>
+ <isset property="org.bedework.appserver.deploy.dir" />
+ <then>
+ <property name="app.dest.home"
+ location="${org.bedework.temp.shellscr.home}/${propval.app.zip.name}" />
+
+ <delete dir="${org.bedework.appserver.deploy.dir}/${propval.app.zip.name}.sar" />
+ <mkdir dir="${org.bedework.appserver.deploy.dir}/${propval.app.zip.name}.sar" />
+ <copy todir="${org.bedework.appserver.deploy.dir}/${propval.app.zip.name}.sar">
+ <fileset dir="${app.dest.home}"/>
+ </copy>
+ </then>
+ </if>
+ </else>
+ </if>
+ </target>
+
+ <!-- ================================================================
+ Private target to copy libraries
+ ================================================================ -->
+
+ <target name="copyLibs">
+ <!-- any extra files-->
+ <copy todir="${app.dest.lib}" >
+ <fileset dir="${org.bedework.temp.extrajars.dir}" />
+ </copy>
+ </target>
+</project>
\ No newline at end of file
Modified: trunk/build/platforms/jbossWar.xml
===================================================================
--- trunk/build/platforms/jbossWar.xml 2010-10-22 02:01:10 UTC (rev 34)
+++ trunk/build/platforms/jbossWar.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -8,7 +8,6 @@
<project name="bedework.platformWar" default="doPlatform" >
<target name="doPlatform" >
- <echo message="$$$$$$$$$$$$$$$ jbossWar.xml $$$$$$$$$$$$$$$$$$$$$$$" />
<!-- ===============================================================
We create an updated jboss-web.xml file (for jboss) and a ear
=============================================================== -->
@@ -33,4 +32,190 @@
</then>
</if>
</target>
+
+ <!-- ================================================================
+ Add libraries
+ ================================================================ -->
+
+ <target name="addLibs">
+ <if>
+ <not>
+ <isset property="org.bedework.global.build.ear" />
+ </not>
+ <then>
+ <!-- Library in war file -->
+ <property name="app.dest.lib"
+ location="${app.dest.webinf}/lib" />
+ <antcall target="copyLibs" inheritRefs="true" />
+ </then>
+ <else>
+ <!-- Preserve extra jars for later -->
+ <copy todir="${org.bedework.temp.ear.extrajars.dir}" >
+ <fileset dir="${org.bedework.temp.extrajars.dir}" />
+ </copy>
+ </else>
+ </if>
+ </target>
+
+ <!-- ================================================================
+ Deploy war
+ ================================================================ -->
+
+ <target name="deployWar">
+ <if>
+ <not>
+ <isset property="org.bedework.global.build.ear" />
+ </not>
+ <then>
+ <echo message="***************************************************************" />
+ <echo message="Deploying standalone app ${app.war.file} into ${org.bedework.appserver.dir}/${propval.app.deploy.dir}" />
+ <echo message="***************************************************************" />
+
+ <!-- copy the war file. -->
+ <copy todir="${org.bedework.appserver.dir}/${propval.app.deploy.dir}" file="${app.war.file}"
+ overwrite="yes" />
+
+ <!-- Delete expanded version -->
+ <delete dir="${org.bedework.appserver.dir}/${propval.app.deploy.dir}/${propval.app.war.name}" />
+ </then>
+ </if>
+ </target>
+
+ <!-- ================================================================
+ Deploy ear
+ ================================================================ -->
+
+ <target name="deployEar">
+ <!-- Common library in ear file -->
+ <property name="app.dest.lib"
+ location="${org.bedework.ear.dir}" />
+ <antcall target="copyLibs" inheritRefs="true" />
+
+ <!-- And the extra jars we preserved -->
+ <copy todir="${app.dest.lib}" >
+ <fileset dir="${org.bedework.temp.ear.extrajars.dir}" />
+ </copy>
+
+ <echo message="***************************************************************" />
+ <echo message="Building ear file for jboss deployment" />
+ <echo message="***************************************************************" />
+
+ <jar jarfile="${org.bedework.ear.properties.jar}">
+ <fileset dir="${org.bedework.ear.properties.dir}"/>
+ </jar>
+
+ <path id="app.xml.cp">
+ <pathelement location="${org.bedework.deployutil.jar}"/>
+ </path>
+
+ <taskdef name="applicationXml"
+ classname="org.bedework.deployment.ApplicationXmlTask">
+ <classpath refid="app.xml.cp"/>
+ </taskdef>
+
+ <echo message="outFile=${org.bedework.ear.dir}/META-INF/application.xml
+ warDir=${org.bedework.temp.dir}/wars
+ contexts=${org.bedework.global.context.roots}" />
+
+ <mkdir dir="${org.bedework.ear.dir}/META-INF" />
+
+ <applicationXml displayName="Bedework calendar suite"
+ outFile="${org.bedework.ear.dir}/META-INF/application.xml"
+ warDir="${org.bedework.temp.dir}/wars"
+ contexts="${org.bedework.global.context.roots}">
+ <fileset dir="${org.bedework.ear.dir}">
+ <include name="*.jar"/>
+ </fileset>
+ </applicationXml>
+
+ <echo file="${org.bedework.ear.dir}/META-INF/jboss-app.xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<jboss-app>
+ <loader-repository>
+ org.bedework:archive=@EAR_NAME@
+ <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
+ </loader-repository>
+</jboss-app>
+]]></echo>
+
+ <replace file="${org.bedework.ear.dir}/META-INF/jboss-app.xml"
+ token="@EAR_NAME@"
+ value="${app.ear.file.name}"/>
+
+ <if>
+ <available file="${ear.meta.dir}" type="dir" />
+ <then>
+ <copy todir="${org.bedework.ear.dir}/META-INF">
+ <fileset dir="${ear.meta.dir}" />
+ <filterset refid="property.filters" />
+ </copy>
+ </then>
+ </if>
+
+ <manifest file="${org.bedework.ear.dir}/META-INF/MANIFEST.MF" />
+
+ <if>
+ <equals arg1="${org.bedework.global.ear.wars.zipped}"
+ arg2="yes" />
+ <then>
+ <copy toDir="${org.bedework.ear.dir}">
+ <fileset dir="${dist.home}"
+ includes="*.war" />
+ </copy>
+ </then>
+ <else>
+ <copy toDir="${org.bedework.ear.dir}">
+ <fileset dir="${org.bedework.temp.wars.home}"/>
+ </copy>
+ </else>
+ </if>
+
+ <if>
+ <equals arg1="${org.bedework.global.ear.zipped}"
+ arg2="yes" />
+ <then>
+ <zip destfile="${org.bedework.ear.file}"
+ basedir="${org.bedework.ear.dir}"/>
+ </then>
+ </if>
+
+ <!-- copy the ear - at the moment copy the uncompressed. -->
+
+ <if>
+ <isset property="org.bedework.appserver.deploy.dir" />
+ <then>
+ <delete dir="${org.bedework.appserver.deploy.dir}/${app.ear.file.name}" />
+ <mkdir dir="${org.bedework.appserver.deploy.dir}/${app.ear.file.name}" />
+ <copy todir="${org.bedework.appserver.deploy.dir}/${app.ear.file.name}">
+ <fileset dir="${org.bedework.ear.dir}"/>
+ </copy>
+ </then>
+ </if>
+ </target>
+
+ <!-- ================================================================
+ Private target to copy libraries
+ ================================================================ -->
+
+ <target name="copyLibs">
+ <if>
+ <isset property="org.bedework.build.caldav.google" />
+ <then>
+ <copy todir="${app.dest.lib}">
+ <fileset dir="${google.dir}">
+ <include name="*.jar"/>
+ </fileset>
+ </copy>
+ </then>
+ </if>
+
+ <!-- ===============================================================
+ Any jar files required
+ =============================================================== -->
+
+ <!-- any extra files-->
+ <copy todir="${app.dest.lib}" >
+ <fileset dir="${org.bedework.temp.extrajars.dir}" />
+ </copy>
+
+ </target>
</project>
\ No newline at end of file
Modified: trunk/build.properties
===================================================================
--- trunk/build.properties 2010-10-22 02:01:10 UTC (rev 34)
+++ trunk/build.properties 2010-10-22 02:06:58 UTC (rev 35)
@@ -6,27 +6,16 @@
org.bedework.package.name=timezones package
# Version we are building
-org.bedework.version=3.6
+org.bedework.version=3.7
+# Name of generated common jar file
+org.bedework.module.common.jar=bw-tzsvr-cmn
+
# Name of generated jar file
-org.bedework.timezonessvr.jar=bw-timezonessvr
+org.bedework.module.server.jar=bw-tzsvr
-# =========================================================================
-# Following may be overridden elsewhere by the bedework system build
-# =========================================================================
+# Name of generated service jar file
+org.bedework.module.service.jar=bw-tzsvr-svc
-org.bedework.app.tzsvr.tzdata.url=http://localhost:8080/tzdata.zip
-
-# Property defining integer seconds refetch interval for data
-org.bedework.app.tzsvr.refetch.interval=6000
-
-# Property defining a key to allow POST
-org.bedework.app.tzsvr.post.id=12345abcde
-
-# =========================================================================
-# Caching information - most of this is in ehcache.xml
-# =========================================================================
-
-org.bedework.app.tzsvr.vtimezones.cache.name=vtz
-
-#propval.app.zoneinfo.cache.name=zoneinfo
\ No newline at end of file
+org.bedework.module.war.name=tzsvr
+org.bedework.module.context.root=tzsvr
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2010-10-22 02:01:10 UTC (rev 34)
+++ trunk/build.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -2,19 +2,21 @@
<!-- This is the ant build file for the timezones package.
- The target of interest is build which should leave a jar file
- in the dist directory..
-
- Authors: Mike Douglass douglm - rpi.edu
+ Authors: Mike Douglass douglm rpi.edu
-->
-<project name="timezones" default="build">
+<project name="tzsvr" default="deploy">
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
<property environment="env"/>
- <property name="base.name" value="timezones"/>
+ <!-- These may already be set from calling dir -->
+ <dirname property="org.bedework.project.tzsvr" file="${ant.file}"/>
<dirname property="project.home" file="${ant.file}"/>
+
<property file="${project.home}/build.properties" />
+
+ <property name="bedework.home"
+ location="${project.home}/../bedework" />
<property name="project.name" value="${org.bedework.package.name}"/>
<property name="project.version" value="${org.bedework.version}"/>
@@ -23,35 +25,57 @@
<property name="lib.dir" location="${project.home}/lib"/>
<property name="build.dir" location="${project.home}/build"/>
- <property name="buildjar" location="${build.dir}/buildjar.xml"/>
+ <property name="buildjar" location="${build.dir}/buildTools/buildjar.xml"/>
<property name="buildwar" location="${build.dir}/buildwar.xml"/>
+ <property name="buildsh" location="${build.dir}/buildsh.xml"/>
+ <property name="resources.dir" location="${project.home}/resources"/>
+
+ <property name="ear.meta.dir" location="${project.home}/ear.meta"/>
+
+ <property name="org.bedework.temp.dir"
+ location="${dist.home}/temp" />
+
+ <delete dir="${org.bedework.temp.dir}" />
+ <mkdir dir="${org.bedework.temp.dir}" />
+
<property name="org.bedework.libcache.dir"
location="${project.home}/libcache"/>
- <!-- Used to select our properties -->
- <property name="org.bedework.deploy.name" value="tzsvr" />
-
- <import file="${build.dir}/getJar.xml"/>
+ <import file="${build.dir}/buildTools/getJar.xml"/>
<import file="${build.dir}/loadDeployConfig.xml"/>
+ <property name="org.bedework.deployutil.jar"
+ location="${build.dir}/bw-deployutil-3.6.jar" />
+
<!-- =================================================================
init:
================================================================= -->
- <target name="init" >
+ <target name="init">
<property name="org.bedework.project.bedework"
location="${project.home}/../bedework" />
<loadDeployConfig />
- <propertyset id="deploy-app-properties">
- <propertyref prefix="org.bedework.app.${org.bedework.deploy.name}"/>
- <globmapper from="org.bedework.app.${org.bedework.deploy.name}.*" to="propval.app.*"/>
- </propertyset>
-
- <!-- echo message="*** Options file: ${org.bedework.carddav.options}" / -->
+ <property name="org.bedework.temp.wars.home"
+ location="${dist.home}/temp/wars" />
+
+ <if>
+ <not>
+ <isset property="org.bedework.global.context.roots" />
+ </not>
+ <then>
+ <tempfile property="org.bedework.global.context.roots"
+ destdir="${org.bedework.temp.dir}"
+ prefix="context-roots" suffix=".properties" />
+ </then>
+ </if>
+ <property name="org.bedework.service.options.file"
+ value="${org.bedework.config.options}" />
+ <echo message="*** Options file: ${org.bedework.service.options.file}" />
+
<delete dir="${lib.dir}" />
<mkdir dir="${lib.dir}" />
@@ -62,27 +86,22 @@
<getJar name="commons-httpclient" version="3.0" />
<getJar name="commons-lang" version="2.1" />
<getJar name="ehcache" version="1.6.2" />
- <getJar name="ical4j" version="head-dev" />
+ <getJar name="ical4j" version="1.0-rc3-SNAPSHOT" />
<getJar name="log4j" version="1.2.8" />
<getJar name="servletapi" version="2.4" />
- <getJar name="bw-deployutil" version="3.6" />
+ <getJar name="rpiutil" version="3.6" project="rpiutil"
+ projecthome="${project.home}/../bedework/projects/rpiutil" />
- <path id="app.xml.cp">
- <pathelement location="${org.bedework.appjar.bw-deployutil}"/>
- </path>
+ <property name="org.bedework.module.common.base"
+ location="${project.home}/common" />
- <taskdef name="resolveFile"
- classname="org.bedework.deployment.ResolveFile">
- <classpath refid="app.xml.cp"/>
- </taskdef>
+ <property name="org.bedework.module.server.base"
+ location="${project.home}/server" />
- <getJar name="rpiutil" version="3.6" project="rpiutil"
- projecthome="${project.home}/../bedework/projects/rpiutil" />
+ <property name="org.bedework.module.service.base"
+ location="${project.home}/service" />
- <property name="org.bedework.tzsvr.base"
- location="${project.home}/tzsvr" />
-
<mkdir dir="${dist.home}" />
<property name="test.data.dir"
@@ -94,30 +113,100 @@
<fileset id="empty.fileset" dir="${edu.rpi.cmt.empty.dir}"
excludes="*" />
+
<!-- default to empty -->
- <fileset id="base.resource.files" refid="empty.fileset" />
+ <fileset id="buildjar.resource.files" refid="empty.fileset" />
+ <fileset id="buildjar.generated.java.sources" refid="empty.fileset" />
- <property name="tzsvr.jar"
- location="${dist.home}/${org.bedework.timezonessvr.jar}-${project.version}.jar" />
+ <property name="common.jar"
+ location="${dist.home}/${org.bedework.module.common.jar}-${project.version}.jar" />
- <!-- Name of our war file -->
- <property name="propval.app.war.name" value="tzsvr" />
+ <property name="server.jar"
+ location="${dist.home}/${org.bedework.module.server.jar}-${project.version}.jar" />
+ <property name="service.jar"
+ location="${dist.home}/${org.bedework.module.service.jar}-${project.version}.jar" />
+
<!-- ==================== Compilation Classpath ==================== -->
<path id="compile.classpath">
<fileset dir="${lib.dir}">
- <include name="*.jar"/>
+ <include name="**/*.jar"/>
</fileset>
<fileset dir="${dist.home}">
<include name="*.jar"/>
</fileset>
- <fileset dir="${java.home}">
- <include name="lib/tools.jar"/>
- </fileset>
</path>
</target>
+ <target name="deploy-init" depends="init">
+
+ <!-- ========= Stuff in main bedework deployment build file ========= -->
+ <!-- Where we put ear stuff -->
+ <if>
+ <isset property="org.bedework.global.build.ear" />
+ <then>
+ <property name="app.ear.file.name"
+ value="${org.bedework.global.ear.name}-${ant.project.name}.ear" />
+
+ <property name="service.app.zip.name"
+ value="${org.bedework.global.ear.name}-${ant.project.name}svc" />
+
+ <if>
+ <equals arg1="${org.bedework.global.ear.zipped}"
+ arg2="yes" />
+ <then>
+ <property name="org.bedework.ear.dir"
+ location="${dist.home}/${org.bedework.global.ear.name}-${ant.project.name}" />
+ <property name="org.bedework.ear.file"
+ location="${dist.home}/${org.bedework.global.ear.name}-${ant.project.name}.ear" />
+ </then>
+ <else>
+ <property name="org.bedework.ear.dir"
+ location="${dist.home}/${org.bedework.global.ear.name}-${ant.project.name}.ear" />
+ </else>
+ </if>
+
+ <property name="org.bedework.ear.templib"
+ location="${org.bedework.temp.dir}/earlib" />
+
+ <property name="org.bedework.ear.properties.dir"
+ location="${org.bedework.temp.dir}/ear-properties" />
+
+ <property name="org.bedework.ear.properties.jar"
+ location="${org.bedework.ear.dir}/bw-ear-properties.jar"/>
+
+ <delete dir="${org.bedework.ear.dir}" />
+ <mkdir dir="${org.bedework.ear.dir}" />
+
+ <delete dir="${org.bedework.ear.templib}" />
+ <mkdir dir="${org.bedework.ear.templib}" />
+
+ <delete dir="${org.bedework.ear.properties.dir}" />
+ <mkdir dir="${org.bedework.ear.properties.dir}" />
+ </then>
+ </if>
+
+ <property name="org.bedework.temp.shellscr.home"
+ location="${org.bedework.temp.dir}/shellscr" />
+
+ <property name="org.bedework.temp.extrajars.dir"
+ location="${org.bedework.temp.dir}/extrajars" />
+
+ <!-- Preserve extra jars for ear builds -->
+ <property name="org.bedework.temp.ear.extrajars.dir"
+ location="${org.bedework.temp.dir}/earextrajars" />
+
+ <property name="org.bedework.global.context.roots"
+ location="${org.bedework.temp.dir}/context-roots.properties" />
+
+ <!-- ===== End of stuff in main bedework deployment build file ====== -->
+
+ <!-- Clean up before we start -->
+ <delete dir="${org.bedework.temp.wars.home}" />
+ <mkdir dir="${org.bedework.temp.wars.home}" />
+ </target>
+
<!-- =================================================================
Clean out all library files from other projects and all generated
files in preparation for a complete rebuild.
@@ -134,7 +223,6 @@
================================================================= -->
<target name="clean">
<delete dir="${dist.home}" />
- <delete dir="${libapi.dir}" />
</target>
<!-- =================================================================
@@ -150,93 +238,53 @@
================================================================= -->
<target name="clean-build" depends="clean,build"
- description="Clean and compile timezone classes"/>
+ description="Clean and compile classes"/>
- <target name="clean-build-all" depends="clean,build-all"
- description="Clean and compile timezone classes"/>
+ <target name="clean-build-all" depends="clean,build"
+ description="Clean and compile classes"/>
- <target name="build" depends="init,build-source,build-war,cleanup"
- description="Compile timezone classes"/>
+ <target name="build" depends="init,build-source,cleanup"
+ description="Compile classes"/>
- <target name="build-all" depends="build"
- description="Compile timezone classes"/>
-
- <!-- ===================== build.source Target ===============================
+ <!-- ===================== build.all Target ===============================
This target builds jar files ready for the deploy target.
=================================================================== -->
- <target name="build-source" depends="init,bld.tzsvr" />
-
- <!-- ===================== build.war Target ===============================
- This target builds war files ready for the deploy target.
- =================================================================== -->
-
- <target name="build-war" depends="build-source" >
- <!-- Create a servlet.properties file -->
-
- <mkdir dir="${dist.home}/temp/properties"/>
-
- <echo file="${dist.home}/temp/properties/tzsvr.properties">
-# ========================================================================
-# Properties file for the timezone server
-# ========================================================================
-#
-# Generated by the build process
-
-# Property defining location of the registry
-tzsvc.tzdata.url=${org.bedework.app.tzsvr.tzdata.url}
-
-# Property defining integer seconds refetch interval for data
-tzsvc.refetch.interval=${org.bedework.app.tzsvr.refetch.interval}
-
-# Property defining a key to allow POST
-tzsvc.post.id=${org.bedework.app.tzsvr.post.id}
-
-# =========================================================================
-# Caching information - most of this is in ehcache.xml
-# =========================================================================
-
-tzsvc.vtimezones.cache.name=${org.bedework.app.tzsvr.vtimezones.cache.name}
-
-#tzsvc.zoneinfo.cache.name=${}
-
- </echo>
-
- <copy todir="${dist.home}/temp/properties">
- <fileset dir="${project.home}/resources/properties"
- includes="*" />
- </copy>
-
- <ant antfile="${build.dir}/buildwar.xml" inheritrefs="true"
- target="build" >
- <propertyset refid="deploy-app-properties" />
- <property name="app.sou.dir" location="${org.bedework.tzsvr.base}" />
- <property name="propval.app.display.name"
- value="Timezones service" />
- </ant>
- </target>
-
+ <target name="build-source"
+ depends="init,bld.common,bld.service,bld.server" />
+
<!-- ===================== deploy Target ===============================
- This target deploys a war file to our app server.
+ Deploy if an application server is defined.
=================================================================== -->
- <target name="deploy" depends="build-war" >
- <if>
- <isset property="org.bedework.appserver.deploy.dir"/>
- <then>
- <delete dir="${org.bedework.appserver.deploy.dir}/${propval.app.war.name}" />
- <delete dir="${org.bedework.appserver.deploy.dir}/${propval.app.war.name}.war" />
+ <target name="deploy" depends="deploy-init,build"
+ description="Deploy generated files">
+ <ant antfile="${build.dir}/deploy.xml" target="deployFiles" inheritRefs="true" />
+
+ <!-- Service defined in ear file.
+ <ant antfile="${build.dir}/deployService.xml" target="deploy" inheritRefs="true" >
+ <property name="propval.app.zip.name"
+ value="${service.app.zip.name}" />
+ <property name="propval.app.options.path"
+ value="properties/exsynch" />
+ <property name="app.service.base"
+ location="${org.bedework.module.service.base}" />
+ <property name="app.global.properties.dir"
+ location="${resources.dir}" />
+ </ant>
+ -->
- <copy todir="${org.bedework.appserver.deploy.dir}">
- <fileset dir="${dist.home}">
- <include name="*.war" />
- </fileset>
- </copy>
- </then>
- <else>
- <echo message="********* No deploy directory defined" />
- </else>
- </if>
+ <getJar lib="${org.bedework.temp.extrajars.dir}"
+ libcache="${org.bedework.libcache.dir}"
+ name="bw-davio" version="3.6"
+ projecthome="${bedework.home}/projects/davutil" />
+
+ <getJar lib="${org.bedework.temp.extrajars.dir}"
+ libcache="${org.bedework.libcache.dir}"
+ name="log4j" version="1.2.8"/>
+
+ <ant antfile="${build.dir}/deployTermination.xml"
+ target="deployTerminate" inheritRefs="true" />
</target>
<!-- ==================== Javadoc Target ===============================
@@ -251,7 +299,7 @@
<property name="destdir" location="${dist.home}/docs/api"/>
<mkdir dir="${destdir}"/>
- <javadoc sourcepath="${org.bedework.tzsvr.base}/src:"
+ <javadoc sourcepath="${org.bedework.module.common.base}/src:${org.bedework.module.service.base}/src:${org.bedework.module.server.base}/src:"
classpathref="compile.classpath"
destdir="${destdir}"
overview="${project.home}/overview.html"
@@ -268,13 +316,48 @@
</javadoc>
</target>
- <!-- ======================== component build targets =======================
+ <!-- ===================== internal build targets ====================
================================================================= -->
- <target name="bld.tzsvr" >
- <ant antfile="${org.bedework.tzsvr.base}/build.xml" inheritrefs="true"
+ <target name="bld.common">
+ <ant antfile="${org.bedework.module.common.base}/build.xml" inheritrefs="true"
+ target="build" >
+ <property name="build.jar.file" location="${common.jar}" />
+ </ant>
+ </target>
+
+ <target name="bld.server">
+ <ant antfile="${org.bedework.module.server.base}/build.xml" inheritrefs="true"
target="build" >
- <property name="build.jar.file" location="${tzsvr.jar}" />
+ <property name="build.jar.file" location="${server.jar}" />
</ant>
+
+ <!-- ===============================================================
+ Build the war
+ =============================================================== -->
+
+ <property name="app.sou.dir"
+ location="${org.bedework.module.server.base}" />
+
+ <ant antfile="${buildwar}" inheritRefs="true" target="build" >
+ <property name="propval.app.context.root"
+ value="${org.bedework.module.context.root}" />
+ <property name="propval.app.properties.path"
+ value="properties/${ant.project.name}" />
+ <property name="propval.app.war.name"
+ value="${org.bedework.module.war.name}" />
+ <property name="propval.app.web.xml"
+ location="${app.sou.dir}/war/WEB-INF/web.xml" />
+
+ <property name="org.bedework.deploy.name"
+ value="${ant.project.name}" />
+ </ant>
</target>
+
+ <target name="bld.service">
+ <ant antfile="${org.bedework.module.service.base}/build.xml" inheritrefs="true"
+ target="build" >
+ <property name="build.jar.file" location="${service.jar}" />
+ </ant>
+ </target>
</project>
Added: trunk/common/build.xml
===================================================================
--- trunk/common/build.xml (rev 0)
+++ trunk/common/build.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+
+<!-- This is the ant build file for the Exchange synch service classes.
+
+ This file will probably need no modification as it is assumed that the
+ core of the calendar will be largely site and application independent.
+
+ The target of interest is build which should leave some jar files
+ in the temp jar directory..
+
+ These files will be needed for subsequent application or module builds.
+
+ This build file depends upon properties set by the master build file one
+ level up in the directory tree.
+
+ Authors: Mike Douglass douglm at rpi.edu
+-->
+
+<project name="compile" default="build">
+ <dirname property="module.home" file="${ant.file}"/>
+
+ <property name="source.home" location="${module.home}/src"/>
+ <property name="base.name" value="common"/>
+
+ <target name="init">
+ <dirname property="this.dir" file="${ant.file}"/>
+ </target>
+
+ <!-- ========================== Base build Targets ===================
+ Here we have one target building the classes and interfaces
+ ================================================================= -->
+
+ <target name="build" depends="init"
+ description="Compile classes">
+ <!-- ==================== Sources and classes ====================== -->
+
+ <fileset id="buildjar.java.sources" dir="${source.home}" >
+ <include name="org/bedework/**/*.java"/>
+ </fileset>
+
+ <patternset id="base.class.patternset">
+ <include name="org/bedework/**/*.class"/>
+ </patternset>
+
+ <!-- ==================== Build Target ============================= -->
+
+ <ant antfile="${buildjar}" inheritRefs="true" target="build" />
+ </target>
+</project>
Added: trunk/common/src/org/bedework/timezones/common/Stat.java
===================================================================
--- trunk/common/src/org/bedework/timezones/common/Stat.java (rev 0)
+++ trunk/common/src/org/bedework/timezones/common/Stat.java 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,100 @@
+/* **********************************************************************
+ Copyright 2009 Rensselaer Polytechnic Institute. All worldwide rights reserved.
+
+ Redistribution and use of this distribution in source and binary forms,
+ with or without modification, are permitted provided that:
+ The above copyright notice and this permission notice appear in all
+ copies and supporting documentation;
+
+ The name, identifiers, and trademarks of Rensselaer Polytechnic
+ Institute are not used in advertising or publicity without the
+ express prior written permission of Rensselaer Polytechnic Institute;
+
+ DISCLAIMER: The software is distributed" AS IS" without any express or
+ implied warranty, including but not limited to, any implied warranties
+ of merchantability or fitness for a particular purpose or any warrant)'
+ of non-infringement of any current or pending patent rights. The authors
+ of the software make no representations about the suitability of this
+ software for any particular purpose. The entire risk as to the quality
+ and performance of the software is with the user. Should the software
+ prove defective, the user assumes the cost of all necessary servicing,
+ repair or correction. In particular, neither Rensselaer Polytechnic
+ Institute, nor the authors of the software are liable for any indirect,
+ special, consequential, or incidental damages related to the software,
+ to the maximum extent the law permits.
+*/
+package org.bedework.timezones.common;
+
+import java.io.Serializable;
+
+/** Provide a way to get named values.
+ *
+ * @author douglm
+ */
+public class Stat implements Serializable {
+ private String name;
+ private String value1;
+ private String value2;
+
+ /**
+ * @param name
+ * @param value
+ */
+ public Stat(final String name,
+ final String value) {
+ this.name = name;
+ value1 = value;
+ }
+
+ /**
+ * @param name
+ * @param value1
+ * @param value2
+ */
+ public Stat(final String name,
+ final String value1,
+ final String value2) {
+ this.name = name;
+ this.value1 = value1;
+ this.value2 = value2;
+ }
+
+ /**
+ * @return name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return value
+ */
+ public String getValue1() {
+ return value1;
+ }
+
+ /**
+ * @return value
+ */
+ public String getValue2() {
+ return value2;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append(getName());
+ sb.append(" = ");
+ sb.append(getValue1());
+
+ if (getValue2() != null) {
+ sb.append(", ");
+ sb.append(getValue2());
+ }
+
+ sb.append("\n");
+
+ return sb.toString();
+ }
+}
Copied: trunk/common/src/org/bedework/timezones/common/TzServerUtil.java (from rev 30, trunk/tzsvr/src/org/bedework/timezones/server/TzServerUtil.java)
===================================================================
--- trunk/common/src/org/bedework/timezones/common/TzServerUtil.java (rev 0)
+++ trunk/common/src/org/bedework/timezones/common/TzServerUtil.java 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,783 @@
+/* **********************************************************************
+ Copyright 2009 Rensselaer Polytechnic Institute. All worldwide rights reserved.
+
+ Redistribution and use of this distribution in source and binary forms,
+ with or without modification, are permitted provided that:
+ The above copyright notice and this permission notice appear in all
+ copies and supporting documentation;
+
+ The name, identifiers, and trademarks of Rensselaer Polytechnic
+ Institute are not used in advertising or publicity without the
+ express prior written permission of Rensselaer Polytechnic Institute;
+
+ DISCLAIMER: The software is distributed" AS IS" without any express or
+ implied warranty, including but not limited to, any implied warranties
+ of merchantability or fitness for a particular purpose or any warrant)'
+ of non-infringement of any current or pending patent rights. The authors
+ of the software make no representations about the suitability of this
+ software for any particular purpose. The entire risk as to the quality
+ and performance of the software is with the user. Should the software
+ prove defective, the user assumes the cost of all necessary servicing,
+ repair or correction. In particular, neither Rensselaer Polytechnic
+ Institute, nor the authors of the software are liable for any indirect,
+ special, consequential, or incidental damages related to the software,
+ to the maximum extent the law permits.
+*/
+package org.bedework.timezones.common;
+
+import net.fortuna.ical4j.data.CalendarBuilder;
+import net.fortuna.ical4j.data.UnfoldingReader;
+import net.fortuna.ical4j.model.Component;
+import net.fortuna.ical4j.model.TimeZone;
+import net.fortuna.ical4j.model.component.VTimeZone;
+import net.fortuna.ical4j.util.TimeZones;
+import net.sf.ehcache.Cache;
+import net.sf.ehcache.CacheManager;
+import net.sf.ehcache.Element;
+
+import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.params.HttpMethodParams;
+import org.apache.log4j.Logger;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URL;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import javax.servlet.ServletException;
+
+import edu.rpi.sss.util.DateTimeUtil;
+import edu.rpi.sss.util.OptionsException;
+import edu.rpi.sss.util.OptionsI;
+
+/** Common code for the timezone service.
+ *
+ * @author Mike Douglass
+ */
+public class TzServerUtil {
+ private static String appname = "tzsvr";
+
+ private TzsvrConfig config;
+
+ private static TzServerUtil instance;
+
+ /* ======================= property names ======================= */
+
+ /** Property defining location of the zipped data */
+ public static final String pnameTzdataURL = "tzsvc.tzdata.url";
+
+ /** Property defining integer seconds refetch of data
+ */
+ public static final String pnameRefetchInterval = "tzsvc.refetch.interval";
+
+ /** Property defining a key to allow POST */
+ public static final String pnamePostId = "tzsvc.post.id";
+
+ /** name of vtimezone cache
+ */
+ public static final String pnameVtzCache = "tzsvc.vtimezones.cache.name";
+
+ /** name of zoneinfo cache
+ */
+ public static final String pnameZoneInfoCache = "tzsvc.zoneinfo.cache.name";
+
+ /* ======================= Error codes ======================= */
+
+ /** Unable to retrieve the data */
+ public static final String errorNodata = "org.tserver.no.data";
+
+ /* ======================= Caching ======================= */
+
+ private static CacheManager manager;
+ static {
+ URL u = TzServerUtil.class.getResource("/tzsvrEhcache.xml");
+
+ manager = CacheManager.create(u);
+ }
+
+ private static Cache vtzCache;
+
+ private static SortedSet<String> nameList;
+
+ /** Time we last fetched the data */
+ public static long lastDataFetch;
+
+ static String etagValue;
+
+ /* ======================= TimeZone objects ======================= */
+
+ private Map<String, TimeZone> tzs = new HashMap<String, TimeZone>();
+
+ private String aliases;
+
+ private Collection<String> tzinfo;
+
+ private ZipFile tzDefsZipFile;
+
+ private File tzDefsFile;
+
+ private static Object zipLock = new Object();
+
+ volatile boolean refreshNow;
+
+ /* ======================= Stats ======================= */
+
+ static long gets;
+ static long cacheHits;
+ static long reads;
+ static long nameLists;
+ static long aliasReads;
+ static long conversions;
+ static long conversionsMillis;
+ static long tzfetches;
+ static long tzbuilds;
+ static long tzbuildsMillis;
+
+ /**
+ * @return a singleton instance
+ * @throws ServletException
+ */
+ public static TzServerUtil getInstance() throws ServletException {
+ if (instance != null) {
+ return instance;
+ }
+
+ synchronized (zipLock) {
+ if (instance != null) {
+ return instance;
+ }
+
+ instance = new TzServerUtil();
+ }
+
+ return instance;
+ }
+
+ /** Set before calling getInstance
+ *
+ * @param val
+ */
+ public static void setAppname(final String val) {
+ appname = val;
+ }
+
+ /**
+ * @return appname
+ */
+ public static String getAppname() {
+ return appname;
+ }
+
+ /**
+ * @throws ServletException
+ */
+ private TzServerUtil() throws ServletException {
+ /* Note that the options factory returns a static object and we should
+ * initialise the config once only
+ */
+ OptionsI opts;
+ try {
+ opts = TzsvrOptionsFactory.getOptions(false);
+ config = (TzsvrConfig)opts.getAppProperty(appname);
+ if (config == null) {
+ config = new TzsvrConfig();
+ }
+ } catch (OptionsException e) {
+ throw new ServletException(e);
+ }
+
+ cacheInit();
+ }
+
+ /** Cause a refresh of the data
+ */
+ public void fireRefresh() {
+ refreshNow = true;
+ }
+
+ /**
+ * @return an etag based on when we refreshed data
+ * @throws ServletException
+ */
+ public String getEtag() throws ServletException {
+ if (etagValue == null) {
+ Collection<String> info = tzinfo;
+
+ if (info == null) {
+ info = getInfo();
+ }
+
+ if (info != null) {
+ for (String s: info) {
+ if (s.startsWith("buildTime=")) {
+ etagValue = s.substring("buildTime=".length());
+ break;
+ }
+ }
+ }
+
+ if (etagValue == null) {
+ etagValue = String.valueOf(lastDataFetch);
+ }
+ }
+
+ StringBuilder val = new StringBuilder();
+
+ val.append("\"");
+ val.append(etagValue);
+ val.append("\"");
+
+ return val.toString();
+ }
+
+ /**
+ * @return config
+ */
+ public TzsvrConfig getConfig() {
+ return config;
+ }
+
+ /**
+ * @return stats for the service
+ * @throws ServletException
+ */
+ public static List<Stat> getStats() throws ServletException {
+ List<Stat> stats = new ArrayList<Stat>();
+
+ stats.add(new Stat("Gets", String.valueOf(gets)));
+ stats.add(new Stat("Hits", String.valueOf(cacheHits)));
+ stats.add(new Stat("Name lists", String.valueOf(nameLists)));
+ stats.add(new Stat("Reads", String.valueOf(reads)));
+ stats.add(new Stat("conversions",
+ String.valueOf(conversions),
+ String.valueOf(conversionsMillis)));
+ stats.add(new Stat("tzfetches", String.valueOf(tzfetches)));
+ stats.add(new Stat("tzbuilds",
+ String.valueOf(tzbuilds),
+ String.valueOf(tzbuildsMillis)));
+
+ return stats;
+ }
+
+ /** Retrieve the data and store in a temp file. Return the file object.
+ *
+ * @return File
+ * @throws ServletException
+ */
+ public File getdata() throws ServletException {
+ try {
+ String dataUrl = config.getTzdataUrl();
+ if (dataUrl == null) {
+ throw new ServletException("No data url defined");
+ }
+
+ /* Fetch the data */
+ HttpClient client = new HttpClient();
+
+ HttpMethod get = new GetMethod(dataUrl);
+
+ client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
+ new DefaultHttpMethodRetryHandler());
+
+ client.executeMethod(get);
+
+ InputStream is = get.getResponseBodyAsStream();
+
+ File f = File.createTempFile("bwtzserver", "zip");
+
+ FileOutputStream fos = new FileOutputStream(f);
+
+ byte[] buff = new byte[4096];
+
+ for (;;) {
+ int num = is.read(buff);
+
+ if (num < 0) {
+ break;
+ }
+
+ if (num > 0) {
+ fos.write(buff, 0, num);
+ }
+ }
+
+ fos.close();
+ is.close();
+
+ get.releaseConnection();
+
+ logIt("Data (re)fetched");
+
+ return f;
+ } catch (Throwable t) {
+ throw new ServletException(t);
+ }
+ }
+
+ /**
+ * @return names fromthe zip file.
+ * @throws ServletException
+ */
+ public SortedSet<String> getNames() throws ServletException {
+ nameLists++;
+
+ /* Do this the right way round we don't need to synch */
+ SortedSet<String> nl = nameList;
+
+ if (nl != null) {
+ return nl;
+ }
+
+ try {
+ nl = new TreeSet<String>();
+
+ Enumeration<? extends ZipEntry> zes = tzDefsZipFile.entries();
+
+ while (zes.hasMoreElements()) {
+ ZipEntry ze = zes.nextElement();
+
+ if (!ze.isDirectory()) {
+ String n = ze.getName();
+
+ if (n.startsWith("zoneinfo/") && n.endsWith(".ics")) {
+ nl.add(n.substring(9, n.length() - 4));
+ }
+ }
+ }
+
+ nameList = nl;
+
+ return nl;
+ } catch (Throwable t) {
+ throw new ServletException(t);
+ }
+ }
+
+ /**
+ * @param name
+ * @return spec
+ * @throws ServletException
+ */
+ public String getTz(final String name) throws ServletException {
+ String s = getCachedVtz(name);
+ if (s != null) {
+ cacheHits++;
+ return s;
+ }
+
+ try {
+ reads++;
+ ZipEntry ze = tzDefsZipFile.getEntry("zoneinfo/" + name + ".ics");
+
+ if (ze == null) {
+ return null;
+ }
+
+ s = entryToString(ze);
+
+ putCachedVtz(name, s);
+
+ return s;
+ } catch (Throwable t) {
+ throw new ServletException(t);
+ }
+ }
+
+ /**
+ * @return aliases
+ * @throws ServletException
+ */
+ public String getAliases() throws ServletException {
+ try {
+ /* Do this the right way round we don't need to synch */
+ String a = aliases;
+
+ if (a != null) {
+ return a;
+ }
+
+ aliasReads++;
+ ZipEntry ze = tzDefsZipFile.getEntry("aliases.txt");
+
+ if (ze == null) {
+ return null;
+ }
+
+ a = entryToString(ze);
+ aliases = a;
+
+ return a;
+ } catch (Throwable t) {
+ throw new ServletException(t);
+ }
+ }
+
+ /**
+ * @return info
+ * @throws ServletException
+ */
+ public Collection<String> getInfo() throws ServletException {
+ try {
+ /* Do this the right way round we don't need to synch */
+ Collection<String> a = tzinfo;
+
+ if (a != null) {
+ return a;
+ }
+
+ ZipEntry ze = tzDefsZipFile.getEntry("info.txt");
+
+ if (ze == null) {
+ return null;
+ }
+
+ String info = entryToString(ze);
+
+ String[] infoLines = info.split("\n");
+ a = new ArrayList<String>();
+
+ for (String s: infoLines) {
+ a.add(s);
+ }
+
+ tzinfo = a;
+
+ return a;
+ } catch (Throwable t) {
+ throw new ServletException(t);
+ }
+ }
+
+ /**
+ * @param time
+ * @param tzid
+ * @return String utc date
+ * @throws Throwable
+ */
+ public String getUtc(final String time,
+ final String tzid) throws Throwable {
+ if (DateTimeUtil.isISODateTimeUTC(time)) {
+ // Already UTC
+ return time;
+ }
+
+ if (!DateTimeUtil.isISODateTime(time)) {
+ return null; // Bad datetime
+ }
+
+ conversions++;
+ long smillis = System.currentTimeMillis();
+
+ TimeZone tz = fetchTimeZone(tzid);
+
+ DateFormat formatTd = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
+ formatTd.setTimeZone(tz);
+
+ Date date = formatTd.parse(time);
+ String utc;
+
+ synchronized (cal) {
+ cal.clear();
+ cal.setTime(date);
+
+ //formatTd.setTimeZone(utctz);
+ //trace("formatTd with utc: " + formatTd.format(date));
+
+ StringBuilder sb = new StringBuilder();
+ digit4(sb, cal.get(Calendar.YEAR));
+ digit2(sb, cal.get(Calendar.MONTH) + 1); // Month starts at 0
+ digit2(sb, cal.get(Calendar.DAY_OF_MONTH));
+ sb.append('T');
+ digit2(sb, cal.get(Calendar.HOUR_OF_DAY));
+ digit2(sb, cal.get(Calendar.MINUTE));
+ digit2(sb, cal.get(Calendar.SECOND));
+ sb.append('Z');
+
+ utc = sb.toString();
+ }
+
+ conversionsMillis += System.currentTimeMillis() - smillis;
+
+ return utc;
+ }
+
+ /** Convert from local time in fromTzid to local time in toTzid. If dateTime is
+ * already an iso utc date time fromTzid may be null.
+ *
+ * @param dateTime
+ * @param fromTzid
+ * @param toTzid
+ * @return String time in given timezone
+ * @throws Throwable
+ */
+ public String convertDateTime(final String dateTime, final String fromTzid,
+ final String toTzid) throws Throwable {
+ String UTCdt = null;
+ if (DateTimeUtil.isISODateTimeUTC(dateTime)) {
+ // Already UTC
+ UTCdt = dateTime;
+ } else if (!DateTimeUtil.isISODateTime(dateTime)) {
+ return null; // Bad datetime
+ } else if (toTzid == null) {
+ return null; // Bad toTzid
+ } else {
+ UTCdt = getUtc(dateTime, fromTzid);
+ conversions--; // avoid double inc
+ }
+
+ conversions++;
+ long smillis = System.currentTimeMillis();
+
+ // Convert to time in toTzid
+
+ Date dt = DateTimeUtil.fromISODateTimeUTC(UTCdt);
+
+ TimeZone tz = fetchTimeZone(toTzid);
+ if (tz == null) {
+ return null;
+ }
+
+ String cdt = DateTimeUtil.isoDateTime(dt, tz);
+ conversionsMillis += System.currentTimeMillis() - smillis;
+
+ return cdt;
+ }
+
+ /** Get a timezone object from the server given the id.
+ *
+ * @param tzid
+ * @return TimeZone with id or null
+ * @throws Throwable
+ */
+ public TimeZone fetchTimeZone(final String tzid) throws Throwable {
+ tzfetches++;
+
+ TimeZone tz = tzs.get(tzid);
+ if (tz != null) {
+ return tz;
+ }
+
+ String tzdef = getTz(tzid);
+
+ if (tzdef == null) {
+ return null;
+ }
+
+ tzbuilds++;
+ long smillis = System.currentTimeMillis();
+
+ CalendarBuilder cb = new CalendarBuilder();
+
+ UnfoldingReader ufrdr = new UnfoldingReader(new StringReader(tzdef), true);
+
+ net.fortuna.ical4j.model.Calendar cal = cb.build(ufrdr);
+ VTimeZone vtz = (VTimeZone)cal.getComponents().getComponent(Component.VTIMEZONE);
+ if (vtz == null) {
+ throw new Exception("Incorrectly stored timezone");
+ }
+
+ tz = new TimeZone(vtz);
+ tzs.put(tzid, tz);
+
+ tzbuildsMillis += System.currentTimeMillis() - smillis;
+
+ return tz;
+ }
+
+ /**
+ * @throws ServletException
+ */
+ public void refresh() throws ServletException {
+ synchronized (zipLock) {
+ if ((tzDefsFile != null) && !refreshNow) {
+ if ((System.currentTimeMillis() - TzServerUtil.lastDataFetch) / 1000 < config.getRefetchInterval()) {
+ // No fetch needed
+ return;
+ }
+ }
+
+ try {
+ File f = getdata();
+
+ ZipFile zf = new ZipFile(f);
+
+ if (tzDefsZipFile != null) {
+ try {
+ tzDefsZipFile.close();
+ } catch (Throwable t) {
+ }
+ }
+
+ if (tzDefsFile != null) {
+ try {
+ tzDefsFile.delete();
+ } catch (Throwable t) {
+ }
+ }
+
+ tzDefsFile = f;
+ tzDefsZipFile = zf;
+
+ TzServerUtil.lastDataFetch = System.currentTimeMillis();
+ refreshNow = false;
+ } catch (ServletException se) {
+ throw se;
+ } catch (Throwable t) {
+ throw new ServletException(t);
+ }
+ }
+ }
+
+ /* ====================================================================
+ * Caching
+ * ==================================================================== */
+
+ private void cacheInit() throws ServletException {
+ vtzCache = manager.getCache(config.getCacheName());
+ }
+
+ private void cacheRefresh() throws ServletException {
+ cacheRefresh(vtzCache);
+ tzs.clear();
+ aliases = null;
+ nameList = null;
+ }
+
+ static String getCachedVtz(final String name) throws ServletException {
+ Element el = vtzCache.get(name);
+
+ if (el == null) {
+ return null;
+ }
+
+ return (String)el.getValue();
+ }
+
+ static void putCachedVtz(final String name, final String vtz) throws ServletException {
+ Element el = new Element(name, vtz);
+
+ vtzCache.put(el);
+ }
+
+ /* ====================================================================
+ * Private methods
+ * ==================================================================== */
+
+ private String entryToString(final ZipEntry ze) throws Throwable {
+ InputStreamReader is = new InputStreamReader(tzDefsZipFile.getInputStream(ze),
+ "UTF-8");
+
+ StringWriter sw = new StringWriter();
+
+ char[] buff = new char[4096];
+
+ for (;;) {
+ int num = is.read(buff);
+
+ if (num < 0) {
+ break;
+ }
+
+ if (num > 0) {
+ sw.write(buff, 0, num);
+ }
+ }
+
+ is.close();
+
+ return sw.toString();
+ }
+
+ private static Calendar cal = Calendar.getInstance();
+ private static java.util.TimeZone utctz;
+
+ static {
+ try {
+ utctz = TimeZone.getTimeZone(TimeZones.UTC_ID);
+ } catch (Throwable t) {
+ throw new RuntimeException("Unable to initialise UTC timezone");
+ }
+ cal.setTimeZone(utctz);
+ }
+
+ private static void cacheRefresh(final Cache cache) throws ServletException {
+ if (cache != null) {
+ cache.flush();
+ }
+ }
+
+ /**
+ * @return Logger
+ */
+ static Logger getLogger() {
+ return Logger.getLogger(TzServerUtil.class);
+ }
+
+ /** Debug
+ *
+ * @param msg
+ */
+ static void debugMsg(final String msg) {
+ getLogger().debug(msg);
+ }
+
+ /** Info messages
+ *
+ * @param msg
+ */
+ static void logIt(final String msg) {
+ getLogger().info(msg);
+ }
+
+ static void error(final String msg) {
+ getLogger().error(msg);
+ }
+
+ static void error(final Throwable t) {
+ getLogger().error(TzServerUtil.class, t);
+ }
+
+ private static void digit2(final StringBuilder sb, final int val) throws Throwable {
+ if (val > 99) {
+ throw new Exception("Bad date");
+ }
+ if (val < 10) {
+ sb.append("0");
+ }
+ sb.append(val);
+ }
+
+ private static void digit4(final StringBuilder sb, final int val) throws Throwable {
+ if (val > 9999) {
+ throw new Exception("Bad date");
+ }
+ if (val < 10) {
+ sb.append("000");
+ } else if (val < 100) {
+ sb.append("00");
+ } else if (val < 1000) {
+ sb.append("0");
+ }
+ sb.append(val);
+ }
+}
Added: trunk/common/src/org/bedework/timezones/common/TzsvrConfig.java
===================================================================
--- trunk/common/src/org/bedework/timezones/common/TzsvrConfig.java (rev 0)
+++ trunk/common/src/org/bedework/timezones/common/TzsvrConfig.java 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,115 @@
+/* **********************************************************************
+ Copyright 2007 Rensselaer Polytechnic Institute. All worldwide rights reserved.
+
+ Redistribution and use of this distribution in source and binary forms,
+ with or without modification, are permitted provided that:
+ The above copyright notice and this permission notice appear in all
+ copies and supporting documentation;
+
+ The name, identifiers, and trademarks of Rensselaer Polytechnic
+ Institute are not used in advertising or publicity without the
+ express prior written permission of Rensselaer Polytechnic Institute;
+
+ DISCLAIMER: The software is distributed" AS IS" without any express or
+ implied warranty, including but not limited to, any implied warranties
+ of merchantability or fitness for a particular purpose or any warrant)'
+ of non-infringement of any current or pending patent rights. The authors
+ of the software make no representations about the suitability of this
+ software for any particular purpose. The entire risk as to the quality
+ and performance of the software is with the user. Should the software
+ prove defective, the user assumes the cost of all necessary servicing,
+ repair or correction. In particular, neither Rensselaer Polytechnic
+ Institute, nor the authors of the software are liable for any indirect,
+ special, consequential, or incidental damages related to the software,
+ to the maximum extent the law permits.
+*/
+package org.bedework.timezones.common;
+
+import java.io.Serializable;
+
+/** This class defines the various properties we need for an Exchange synch
+ *
+ * @author Mike Douglass
+ */
+public class TzsvrConfig implements Serializable {
+ /* From bedework build */
+ private String appType;
+
+ private String tzdataUrl;
+
+ private int refetchInterval;
+
+ private String cacheName;
+
+ private String postId;
+
+ /**
+ * @param val
+ */
+ public void setAppType(final String val) {
+ appType = val;
+ }
+
+ /**
+ * @return String
+ */
+ public String getAppType() {
+ return appType;
+ }
+
+ /**
+ * @param val String
+ */
+ public void setTzdataUrl(final String val) {
+ tzdataUrl = val;
+ }
+
+ /**
+ * @return String
+ */
+ public String getTzdataUrl() {
+ return tzdataUrl;
+ }
+
+ /**
+ * @param val int
+ */
+ public void setRefetchInterval(final int val) {
+ refetchInterval = val;
+ }
+
+ /**
+ * @return int
+ */
+ public int getRefetchInterval() {
+ return refetchInterval;
+ }
+
+ /**
+ * @param val String
+ */
+ public void setCacheName(final String val) {
+ cacheName = val;
+ }
+
+ /**
+ * @return String
+ */
+ public String getCacheName() {
+ return cacheName;
+ }
+
+ /**
+ * @param val String
+ */
+ public void setPostId(final String val) {
+ postId = val;
+ }
+
+ /**
+ * @return String
+ */
+ public String getPostId() {
+ return postId;
+ }
+}
Added: trunk/common/src/org/bedework/timezones/common/TzsvrOptionsFactory.java
===================================================================
--- trunk/common/src/org/bedework/timezones/common/TzsvrOptionsFactory.java (rev 0)
+++ trunk/common/src/org/bedework/timezones/common/TzsvrOptionsFactory.java 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,66 @@
+/* **********************************************************************
+ Copyright 2010 Rensselaer Polytechnic Institute. All worldwide rights reserved.
+
+ Redistribution and use of this distribution in source and binary forms,
+ with or without modification, are permitted provided that:
+ The above copyright notice and this permission notice appear in all
+ copies and supporting documentation;
+
+ The name, identifiers, and trademarks of Rensselaer Polytechnic
+ Institute are not used in advertising or publicity without the
+ express prior written permission of Rensselaer Polytechnic Institute;
+
+ DISCLAIMER: The software is distributed" AS IS" without any express or
+ implied warranty, including but not limited to, any implied warranties
+ of merchantability or fitness for a particular purpose or any warrant)'
+ of non-infringement of any current or pending patent rights. The authors
+ of the software make no representations about the suitability of this
+ software for any particular purpose. The entire risk as to the quality
+ and performance of the software is with the user. Should the software
+ prove defective, the user assumes the cost of all necessary servicing,
+ repair or correction. In particular, neither Rensselaer Polytechnic
+ Institute, nor the authors of the software are liable for any indirect,
+ special, consequential, or incidental damages related to the software,
+ to the maximum extent the law permits.
+*/
+package org.bedework.timezones.common;
+
+import edu.rpi.sss.util.OptionsException;
+import edu.rpi.sss.util.OptionsFactory;
+import edu.rpi.sss.util.OptionsI;
+
+/** Obtain an options object.
+ *
+ */
+public class TzsvrOptionsFactory extends OptionsFactory {
+ /* Options class if we've already been called */
+ private static volatile OptionsI opts;
+
+ /** Location of the options file */
+ private static final String optionsFile = "/properties/tzsvr/options.xml";
+
+ private static final String outerTag = "bedework-options";
+
+ /** Global properties have this prefix.
+ */
+ public static final String globalPrefix = "org.bedework.global.";
+
+ /** App properties have this prefix.
+ */
+ public static final String appPrefix = "org.bedework.app.";
+
+ /** Obtain and initialise an options object.
+ *
+ * @param debug
+ * @return OptionsI
+ * @throws OptionsException
+ */
+ public static OptionsI getOptions(final boolean debug) throws OptionsException {
+ if (opts != null) {
+ return opts;
+ }
+
+ opts = getOptions(globalPrefix, appPrefix, optionsFile, outerTag, debug);
+ return opts;
+ }
+}
Added: trunk/ear.meta/jboss-service.xml
===================================================================
--- trunk/ear.meta/jboss-service.xml (rev 0)
+++ trunk/ear.meta/jboss-service.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+ <mbean code="org.bedework.timezones.service.Tzsvc"
+ name="org.bedework:service=Tzsvr">
+ <attribute name="Appname">tzsvr</attribute>
+
+ <!-- We need activemq
+ <depends>jboss.jca:service=ConnectionFactoryBinding,name=activemq/QueueConnectionFactory</depends>
+ -->
+ </mbean>
+</server>
Modified: trunk/resources/aliases.txt
===================================================================
--- trunk/resources/aliases.txt 2010-10-22 02:01:10 UTC (rev 34)
+++ trunk/resources/aliases.txt 2010-10-22 02:06:58 UTC (rev 35)
@@ -6,8 +6,9 @@
# Add any extra aliases below here...
+# ==============================================================================
# Here we have the Exchange timezones (or so I believe).
-# As far as I can tell they can occur with the "." in the time pr the ":"
+# As far as I can tell they can occur with the "." in the time or the ":"
#(UTC)\ Universal\ Coordinated\ Time
(GMT)\ Casablanca,\ Monrovia=Africa/Casablanca
@@ -165,6 +166,13 @@
(GMT-11.00)\ Midway\ Island,\ Samoa=Pacific/Pago_Pago
(GMT-12.00)\ Eniwetok,\ Kwajalein,\ Dateline\ Time=Pacific/Kwajalein
+# ==============================================================================
+# Events exported from Outlook appear to have their own names for events they
+# are fetching from Exchange
+
+Eastern\ Standard\ Time=America/New_York
+
+# ==============================================================================
# The following is a copy of the ical4j tz.alias file
Pacific/Samoa=Pacific/Pago_Pago
Copied: trunk/server (from rev 30, trunk/tzsvr)
Modified: trunk/server/build.xml
===================================================================
--- trunk/tzsvr/build.xml 2010-01-05 16:21:51 UTC (rev 30)
+++ trunk/server/build.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -1,32 +1,47 @@
<?xml version="1.0"?>
-<!-- This is the build for the bedework timezones server component.
+<!-- This is a fairly generic ant build file for java classes.
- Authors: Mike Douglass douglm at rpi.edu
+ This file will probably need no modification as it is assumed that the
+ core of the calendar will be largely site and application independent.
+
+ The target of interest is build which should leave some jar files
+ in the temp jar directory..
+
+ These files will be needed for subsequent application or module builds.
+
+ This build file depends upon properties set by the master build file one
+ level up in the directory tree.
+
+ Authors: Mike Douglass douglm rpi.edu
-->
-<project name="tzsvr.compile" default="build" >
+<project name="compile" default="build" >
+ <dirname property="module.home" file="${ant.file}"/>
+
+ <property name="source.home" location="${module.home}/src"/>
<property name="base.name" value="tzsvr"/>
<target name="init">
- <echo message="*********************${this.dir}" />
<dirname property="this.dir" file="${ant.file}"/>
- <property name="source.home" location="${this.dir}/src"/>
</target>
+ <!-- ========================== Base build Targets ===================
+ Here we have one target building the classes and interfaces
+ ================================================================= -->
+
<target name="build" depends="init"
- description="Compile bedework service api Java sources and create build file">
+ description="Compile classes">
<!-- ==================== Sources and classes ====================== -->
- <echo message="*********************${source.home}" />
<fileset id="buildjar.java.sources" dir="${source.home}" >
- <include name="org/bedework/timezones/server/**/*.java"/>
+ <include name="org/bedework/**/*.java"/>
</fileset>
<patternset id="base.class.patternset">
- <include name="org/bedework/timezones/server/**/*.class"/>
+ <include name="org/bedework/**/*.class"/>
</patternset>
- <ant antfile="${project.home}/build/buildjar.xml" inheritRefs="true" target="build" />
+ <ant antfile="${buildjar}" inheritRefs="true" target="build" />
</target>
</project>
Deleted: trunk/server/src/org/bedework/timezones/server/GetMethod.java
===================================================================
--- trunk/tzsvr/src/org/bedework/timezones/server/GetMethod.java 2010-01-05 16:21:51 UTC (rev 30)
+++ trunk/server/src/org/bedework/timezones/server/GetMethod.java 2010-10-22 02:06:58 UTC (rev 35)
@@ -1,363 +0,0 @@
-/* **********************************************************************
- Copyright 2006 Rensselaer Polytechnic Institute. All worldwide rights reserved.
-
- Redistribution and use of this distribution in source and binary forms,
- with or without modification, are permitted provided that:
- The above copyright notice and this permission notice appear in all
- copies and supporting documentation;
-
- The name, identifiers, and trademarks of Rensselaer Polytechnic
- Institute are not used in advertising or publicity without the
- express prior written permission of Rensselaer Polytechnic Institute;
-
- DISCLAIMER: The software is distributed" AS IS" without any express or
- implied warranty, including but not limited to, any implied warranties
- of merchantability or fitness for a particular purpose or any warrant)'
- of non-infringement of any current or pending patent rights. The authors
- of the software make no representations about the suitability of this
- software for any particular purpose. The entire risk as to the quality
- and performance of the software is with the user. Should the software
- prove defective, the user assumes the cost of all necessary servicing,
- repair or correction. In particular, neither Rensselaer Polytechnic
- Institute, nor the authors of the software are liable for any indirect,
- special, consequential, or incidental damages related to the software,
- to the maximum extent the law permits.
-*/
-
-package org.bedework.timezones.server;
-
-import java.io.Writer;
-import java.util.Collection;
-import java.util.Properties;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/** Class called to handle GET.
- *
- * @author Mike Douglass
- */
-public class GetMethod extends MethodBase {
- /**
- * @param debug
- */
- public GetMethod(final boolean debug) {
- super(debug);
- }
-
- private static final String tzspath = "/timezones";
-
- /* (non-Javadoc)
- * @see org.bedework.timezones.server.MethodBase#doMethod(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.util.Properties)
- */
- @Override
- public void doMethod(final HttpServletRequest req,
- final HttpServletResponse resp,
- final Properties props) throws ServletException {
- String path = getResourceUri(req);
-
- if (debug) {
- trace("GetMethod: doMethod path=" + path);
- }
-
- if (path == null) {
- path = "";
- }
-
- if (req.getParameter("names") != null) {
- if (ifNoneMatchTest(req, resp)) {
- return;
- }
-
- doNames(resp);
- } else if (req.getParameter("stats") != null) {
- doStats(resp);
- } else if (req.getParameter("info") != null) {
- doInfo(resp);
- } else if (req.getParameter("aliases") != null) {
- if (ifNoneMatchTest(req, resp)) {
- return;
- }
-
- doAliases(resp);
- } else if (req.getParameter("convert") != null) {
- doConvert(resp, req.getParameter("dt"),
- req.getParameter("fromtzid"),
- req.getParameter("totzid"));
- } else if (req.getParameter("utc") != null) {
- doToUtc(resp, req.getParameter("dt"),
- req.getParameter("fromtzid"));
- } else if (path.equals(tzspath) ||
- path.equals(tzspath + "/")) {
- doNames(resp);
- } else if (path.startsWith(tzspath + "/")) {
- String[] ids = {
- path.substring(tzspath.length() + 1)
- };
- doTzids(resp, ids);
- } else {
- doTzids(resp, req.getParameterValues("tzid"));
- }
- }
-
- private void doNames(final HttpServletResponse resp) throws ServletException {
- try {
- resp.setHeader("ETag", TzServerUtil.getEtag());
-
- Writer wtr = resp.getWriter();
-
- for (String s: TzServerUtil.getNames(TzServer.tzDefsZipFile)) {
- wtr.write(s);
- wtr.write("\n");
- }
- } catch (ServletException se) {
- throw se;
- } catch (Throwable t) {
- throw new ServletException(t);
- }
- }
-
- private void doStats(final HttpServletResponse resp) throws ServletException {
- try {
- Writer wtr = resp.getWriter();
-
- wtr.write("<html>\r\n");
- wtr.write(" <head>\r\n");
-
- /* Need some styles I guess */
-
- wtr.write(" <title>Timezone server statistics</title>\r\n");
-
- wtr.write("</head>\r\n");
- wtr.write("<body>\r\n");
-
- wtr.write(" <h1>Timezone server statistics</title></h1>\r\n");
-
- wtr.write(" <hr/>\r\n");
-
- wtr.write(" <table width=\"30%\" " +
- "cellspacing=\"0\"" +
- " cellpadding=\"4\">\r\n");
-
- statLine(wtr, "Gets", TzServerUtil.gets, 0);
- statLine(wtr, "Hits", TzServerUtil.cacheHits, 0);
- statLine(wtr, "Name lists", TzServerUtil.nameLists, 0);
- statLine(wtr, "Reads", TzServerUtil.reads, 0);
- statLine(wtr, "conversions",
- TzServerUtil.conversions,
- TzServerUtil.conversionsMillis);
- statLine(wtr, "tzfetches", TzServerUtil.tzfetches, 0);
- statLine(wtr, "tzbuilds",
- TzServerUtil.tzbuilds,
- TzServerUtil.tzbuildsMillis);
-
- wtr.write("</table>\r\n");
-
- /* Could use a footer */
- wtr.write("</body>\r\n");
- wtr.write("</html>\r\n");
- } catch (ServletException se) {
- throw se;
- } catch (Throwable t) {
- throw new ServletException(t);
- }
- }
-
- private void doAliases(final HttpServletResponse resp) throws ServletException {
- try {
- resp.setHeader("ETag", TzServerUtil.getEtag());
-
- Writer wtr = resp.getWriter();
-
- wtr.write(TzServerUtil.getAliases(TzServer.tzDefsZipFile));
- } catch (ServletException se) {
- throw se;
- } catch (Throwable t) {
- throw new ServletException(t);
- }
- }
-
- private void doInfo(final HttpServletResponse resp) throws ServletException {
- try {
- resp.setHeader("ETag", TzServerUtil.getEtag());
-
- Writer wtr = resp.getWriter();
-
- Collection<String> info = TzServerUtil.getInfo(TzServer.tzDefsZipFile);
-
- wtr.write("<html>\r\n");
- wtr.write(" <head>\r\n");
-
- /* Need some styles I guess */
-
- wtr.write(" <title>Timezone server information</title>\r\n");
-
- wtr.write("</head>\r\n");
- wtr.write("<body>\r\n");
-
- wtr.write(" <h1>Timezone server information</title></h1>\r\n");
-
- wtr.write(" <hr/>\r\n");
-
- wtr.write(" <table width=\"30%\" " +
- "cellspacing=\"0\"" +
- " cellpadding=\"4\">\r\n");
-
- for (String s: info) {
- String[] nameVal = s.split("=");
- infoLine(wtr, nameVal[0], nameVal[1]);
- }
-
- wtr.write("</table>\r\n");
-
- /* Could use a footer */
- wtr.write("</body>\r\n");
- wtr.write("</html>\r\n");
- } catch (ServletException se) {
- throw se;
- } catch (Throwable t) {
- throw new ServletException(t);
- }
- }
-
- private void infoLine(final Writer wtr,
- final String name,
- final String val) throws Throwable {
- wtr.write("<tr>\r\n");
-
- wtr.write(" <td align=\"right\">");
- wtr.write(name);
- wtr.write("</td>");
-
- wtr.write(" <td align=\"right\">");
- wtr.write(val);
- wtr.write("</td>");
-
- wtr.write("</tr>\r\n");
- }
-
- private void statLine(final Writer wtr,
- final String name, final long val,
- final long millis) throws Throwable {
- wtr.write("<tr>\r\n");
-
- wtr.write(" <td align=\"right\">");
- wtr.write(name);
- wtr.write("</td>");
-
- wtr.write(" <td align=\"right\">");
- wtr.write(String.valueOf(val));
- wtr.write("</td>");
-
- wtr.write("<td>");
- if (millis == 0) {
- wtr.write(" ");
- } else {
- String s = String.valueOf(millis);
- while (s.length() < 4) {
- s = "0" + s;
- }
-
- wtr.write(s.substring(0, s.length() - 3));
- wtr.write(".");
- wtr.write(s.substring(s.length() - 3));
- wtr.write(" seconds");
- }
- wtr.write("</td>");
-
- wtr.write("</td>\r\n");
-
- wtr.write("</tr>\r\n");
- }
-
- private void doConvert(final HttpServletResponse resp,
- final String dateTime,
- final String fromTzid,
- final String toTzid) throws ServletException {
- try {
- Writer wtr = resp.getWriter();
-
- String cnvDdateTime = TzServerUtil.convertDateTime(dateTime,
- fromTzid,
- toTzid);
-
- if (cnvDdateTime != null) {
- wtr.write(cnvDdateTime);
- } else {
- resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
- }
- } catch (ServletException se) {
- throw se;
- } catch (Throwable t) {
- throw new ServletException(t);
- }
- }
-
- private void doToUtc(final HttpServletResponse resp,
- final String dateTime,
- final String fromTzid) throws ServletException {
- try {
- Writer wtr = resp.getWriter();
-
- String cnvDdateTime = TzServerUtil.getUtc(dateTime, fromTzid);
-
- if (cnvDdateTime != null) {
- wtr.write(cnvDdateTime);
- } else {
- resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
- }
- } catch (ServletException se) {
- throw se;
- } catch (Throwable t) {
- throw new ServletException(t);
- }
- }
-
- private void doTzids(final HttpServletResponse resp,
- final String[] tzids) throws ServletException {
- if ((tzids == null) || (tzids.length == 0)) {
- return;
- }
-
- try {
- Writer wtr = resp.getWriter();
-
- boolean found = false;
-
- for (String tzid: tzids) {
- String tz = TzServerUtil.getTz(tzid, TzServer.tzDefsZipFile);
-
- if (tz != null) {
- found = true;
- wtr.write(tz);
- }
- }
-
- if (!found) {
- resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
- }
- } catch (ServletException se) {
- throw se;
- } catch (Throwable t) {
- throw new ServletException(t);
- }
- }
-
- /* Return true if data unchanged - status is set */
- private boolean ifNoneMatchTest(final HttpServletRequest req,
- final HttpServletResponse resp) throws ServletException {
- String inEtag = req.getHeader("If-None-Match");
-
- if (inEtag == null) {
- return false;
- }
-
- if (!inEtag.equals(TzServerUtil.getEtag())) {
- return false;
- }
-
- resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
- return true;
- }
-}
Copied: trunk/server/src/org/bedework/timezones/server/GetMethod.java (from rev 33, trunk/tzsvr/src/org/bedework/timezones/server/GetMethod.java)
===================================================================
--- trunk/server/src/org/bedework/timezones/server/GetMethod.java (rev 0)
+++ trunk/server/src/org/bedework/timezones/server/GetMethod.java 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,362 @@
+/* **********************************************************************
+ Copyright 2006 Rensselaer Polytechnic Institute. All worldwide rights reserved.
+
+ Redistribution and use of this distribution in source and binary forms,
+ with or without modification, are permitted provided that:
+ The above copyright notice and this permission notice appear in all
+ copies and supporting documentation;
+
+ The name, identifiers, and trademarks of Rensselaer Polytechnic
+ Institute are not used in advertising or publicity without the
+ express prior written permission of Rensselaer Polytechnic Institute;
+
+ DISCLAIMER: The software is distributed" AS IS" without any express or
+ implied warranty, including but not limited to, any implied warranties
+ of merchantability or fitness for a particular purpose or any warrant)'
+ of non-infringement of any current or pending patent rights. The authors
+ of the software make no representations about the suitability of this
+ software for any particular purpose. The entire risk as to the quality
+ and performance of the software is with the user. Should the software
+ prove defective, the user assumes the cost of all necessary servicing,
+ repair or correction. In particular, neither Rensselaer Polytechnic
+ Institute, nor the authors of the software are liable for any indirect,
+ special, consequential, or incidental damages related to the software,
+ to the maximum extent the law permits.
+*/
+
+package org.bedework.timezones.server;
+
+import org.bedework.timezones.common.Stat;
+import org.bedework.timezones.common.TzServerUtil;
+
+import java.io.Writer;
+import java.util.Collection;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/** Class called to handle GET.
+ *
+ * @author Mike Douglass
+ */
+public class GetMethod extends MethodBase {
+ /**
+ * @param debug
+ * @throws ServletException
+ */
+ public GetMethod(final boolean debug) throws ServletException {
+ super(debug);
+ }
+
+ private static final String tzspath = "/timezones";
+
+ /* (non-Javadoc)
+ * @see org.bedework.timezones.server.MethodBase#doMethod(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+ */
+ @Override
+ public void doMethod(final HttpServletRequest req,
+ final HttpServletResponse resp) throws ServletException {
+ String path = getResourceUri(req);
+
+ if (debug) {
+ trace("GetMethod: doMethod path=" + path);
+ }
+
+ if (path == null) {
+ path = "";
+ }
+
+ if (req.getParameter("names") != null) {
+ if (ifNoneMatchTest(req, resp)) {
+ return;
+ }
+
+ doNames(resp);
+ } else if (req.getParameter("stats") != null) {
+ doStats(resp);
+ } else if (req.getParameter("info") != null) {
+ doInfo(resp);
+ } else if (req.getParameter("aliases") != null) {
+ if (ifNoneMatchTest(req, resp)) {
+ return;
+ }
+
+ doAliases(resp);
+ } else if (req.getParameter("convert") != null) {
+ doConvert(resp, req.getParameter("dt"),
+ req.getParameter("fromtzid"),
+ req.getParameter("totzid"));
+ } else if (req.getParameter("utc") != null) {
+ doToUtc(resp, req.getParameter("dt"),
+ req.getParameter("fromtzid"));
+ } else if (path.equals(tzspath) ||
+ path.equals(tzspath + "/")) {
+ doNames(resp);
+ } else if (path.startsWith(tzspath + "/")) {
+ String[] ids = {
+ path.substring(tzspath.length() + 1)
+ };
+ doTzids(resp, ids);
+ } else {
+ doTzids(resp, req.getParameterValues("tzid"));
+ }
+ }
+
+ private void doNames(final HttpServletResponse resp) throws ServletException {
+ try {
+ resp.setContentType("text/plain");
+ resp.setHeader("ETag", util.getEtag());
+
+ Writer wtr = resp.getWriter();
+
+ for (String s: util.getNames()) {
+ wtr.write(s);
+ wtr.write("\n");
+ }
+ } catch (ServletException se) {
+ throw se;
+ } catch (Throwable t) {
+ throw new ServletException(t);
+ }
+ }
+
+ private void doStats(final HttpServletResponse resp) throws ServletException {
+ try {
+ resp.setContentType("text/html");
+ Writer wtr = resp.getWriter();
+
+ wtr.write("<html>\r\n");
+ wtr.write(" <head>\r\n");
+
+ /* Need some styles I guess */
+
+ wtr.write(" <title>Timezone server statistics</title>\r\n");
+
+ wtr.write("</head>\r\n");
+ wtr.write("<body>\r\n");
+
+ wtr.write(" <h1>Timezone server statistics</title></h1>\r\n");
+
+ wtr.write(" <hr/>\r\n");
+
+ wtr.write(" <table width=\"30%\" " +
+ "cellspacing=\"0\"" +
+ " cellpadding=\"4\">\r\n");
+
+ for (Stat s: TzServerUtil.getStats()) {
+ statLine(wtr, s.getName(), s.getValue1(), s.getValue2());
+ }
+
+ wtr.write("</table>\r\n");
+
+ /* Could use a footer */
+ wtr.write("</body>\r\n");
+ wtr.write("</html>\r\n");
+ } catch (ServletException se) {
+ throw se;
+ } catch (Throwable t) {
+ throw new ServletException(t);
+ }
+ }
+
+ private void doAliases(final HttpServletResponse resp) throws ServletException {
+ try {
+ resp.setHeader("ETag", util.getEtag());
+ resp.setContentType("text/plain");
+
+ Writer wtr = resp.getWriter();
+
+ wtr.write(util.getAliases());
+ } catch (ServletException se) {
+ throw se;
+ } catch (Throwable t) {
+ throw new ServletException(t);
+ }
+ }
+
+ private void doInfo(final HttpServletResponse resp) throws ServletException {
+ try {
+ resp.setHeader("ETag", util.getEtag());
+ resp.setContentType("text/html");
+
+ Writer wtr = resp.getWriter();
+
+ Collection<String> info = util.getInfo();
+
+ wtr.write("<html>\r\n");
+ wtr.write(" <head>\r\n");
+
+ /* Need some styles I guess */
+
+ wtr.write(" <title>Timezone server information</title>\r\n");
+
+ wtr.write("</head>\r\n");
+ wtr.write("<body>\r\n");
+
+ wtr.write(" <h1>Timezone server information</title></h1>\r\n");
+
+ wtr.write(" <hr/>\r\n");
+
+ wtr.write(" <table width=\"30%\" " +
+ "cellspacing=\"0\"" +
+ " cellpadding=\"4\">\r\n");
+
+ for (String s: info) {
+ String[] nameVal = s.split("=");
+ infoLine(wtr, nameVal[0], nameVal[1]);
+ }
+
+ wtr.write("</table>\r\n");
+
+ /* Could use a footer */
+ wtr.write("</body>\r\n");
+ wtr.write("</html>\r\n");
+ } catch (ServletException se) {
+ throw se;
+ } catch (Throwable t) {
+ throw new ServletException(t);
+ }
+ }
+
+ private void infoLine(final Writer wtr,
+ final String name,
+ final String val) throws Throwable {
+ wtr.write("<tr>\r\n");
+
+ wtr.write(" <td align=\"right\">");
+ wtr.write(name);
+ wtr.write("</td>");
+
+ wtr.write(" <td align=\"right\">");
+ wtr.write(val);
+ wtr.write("</td>");
+
+ wtr.write("</tr>\r\n");
+ }
+
+ private void statLine(final Writer wtr,
+ final String name, final String val,
+ final String millis) throws Throwable {
+ wtr.write("<tr>\r\n");
+
+ wtr.write(" <td align=\"right\">");
+ wtr.write(name);
+ wtr.write("</td>");
+
+ wtr.write(" <td align=\"right\">");
+ wtr.write(String.valueOf(val));
+ wtr.write("</td>");
+
+ wtr.write("<td>");
+ if (millis == null) {
+ wtr.write(" ");
+ } else {
+ String s = millis;
+ while (s.length() < 4) {
+ s = "0" + s;
+ }
+
+ wtr.write(s.substring(0, s.length() - 3));
+ wtr.write(".");
+ wtr.write(s.substring(s.length() - 3));
+ wtr.write(" seconds");
+ }
+
+ wtr.write("</td>");
+
+ wtr.write("</td>\r\n");
+
+ wtr.write("</tr>\r\n");
+ }
+
+ private void doConvert(final HttpServletResponse resp,
+ final String dateTime,
+ final String fromTzid,
+ final String toTzid) throws ServletException {
+ try {
+ Writer wtr = resp.getWriter();
+
+ String cnvDdateTime = util.convertDateTime(dateTime,
+ fromTzid,
+ toTzid);
+
+ if (cnvDdateTime != null) {
+ wtr.write(cnvDdateTime);
+ } else {
+ resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
+ }
+ } catch (ServletException se) {
+ throw se;
+ } catch (Throwable t) {
+ throw new ServletException(t);
+ }
+ }
+
+ private void doToUtc(final HttpServletResponse resp,
+ final String dateTime,
+ final String fromTzid) throws ServletException {
+ try {
+ Writer wtr = resp.getWriter();
+
+ String cnvDdateTime = util.getUtc(dateTime, fromTzid);
+
+ if (cnvDdateTime != null) {
+ wtr.write(cnvDdateTime);
+ } else {
+ resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
+ }
+ } catch (ServletException se) {
+ throw se;
+ } catch (Throwable t) {
+ throw new ServletException(t);
+ }
+ }
+
+ private void doTzids(final HttpServletResponse resp,
+ final String[] tzids) throws ServletException {
+ if ((tzids == null) || (tzids.length == 0)) {
+ return;
+ }
+
+ try {
+ Writer wtr = resp.getWriter();
+
+ boolean found = false;
+
+ for (String tzid: tzids) {
+ String tz = util.getTz(tzid);
+
+ if (tz != null) {
+ found = true;
+ wtr.write(tz);
+ }
+ }
+
+ if (!found) {
+ resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
+ }
+ } catch (ServletException se) {
+ throw se;
+ } catch (Throwable t) {
+ throw new ServletException(t);
+ }
+ }
+
+ /* Return true if data unchanged - status is set */
+ private boolean ifNoneMatchTest(final HttpServletRequest req,
+ final HttpServletResponse resp) throws ServletException {
+ String inEtag = req.getHeader("If-None-Match");
+
+ if (inEtag == null) {
+ return false;
+ }
+
+ if (!inEtag.equals(util.getEtag())) {
+ return false;
+ }
+
+ resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+ return true;
+ }
+}
Modified: trunk/server/src/org/bedework/timezones/server/MethodBase.java
===================================================================
--- trunk/tzsvr/src/org/bedework/timezones/server/MethodBase.java 2010-01-05 16:21:51 UTC (rev 30)
+++ trunk/server/src/org/bedework/timezones/server/MethodBase.java 2010-10-22 02:06:58 UTC (rev 35)
@@ -26,11 +26,12 @@
package org.bedework.timezones.server;
+import org.bedework.timezones.common.TzServerUtil;
+
import org.apache.log4j.Logger;
import java.net.URLDecoder;
import java.util.ArrayList;
-import java.util.Properties;
import java.util.StringTokenizer;
import javax.servlet.ServletException;
@@ -46,22 +47,25 @@
protected transient Logger log;
+ protected TzServerUtil util;
+
/**
* @param debug
+ * @throws ServletException
*/
- public MethodBase(boolean debug) {
+ public MethodBase(boolean debug) throws ServletException {
this.debug = debug;
+
+ util = TzServerUtil.getInstance();
}
/**
* @param req
* @param resp
- * @param props
* @throws ServletException
*/
public abstract void doMethod(HttpServletRequest req,
- HttpServletResponse resp,
- Properties props)
+ HttpServletResponse resp)
throws ServletException;
/** Get the decoded and fixed resource URI
Modified: trunk/server/src/org/bedework/timezones/server/OptionsMethod.java
===================================================================
--- trunk/tzsvr/src/org/bedework/timezones/server/OptionsMethod.java 2010-01-05 16:21:51 UTC (rev 30)
+++ trunk/server/src/org/bedework/timezones/server/OptionsMethod.java 2010-10-22 02:06:58 UTC (rev 35)
@@ -26,8 +26,6 @@
package org.bedework.timezones.server;
-import java.util.Properties;
-
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -41,14 +39,15 @@
public class OptionsMethod extends MethodBase {
/**
* @param debug
+ * @throws ServletException
*/
- public OptionsMethod(boolean debug) {
+ public OptionsMethod(boolean debug) throws ServletException {
super(debug);
}
+ @Override
public void doMethod(HttpServletRequest req,
- HttpServletResponse resp,
- Properties props) throws ServletException {
+ HttpServletResponse resp) throws ServletException {
if (debug) {
trace("OptionsMethod: doMethod");
}
Modified: trunk/server/src/org/bedework/timezones/server/PostMethod.java
===================================================================
--- trunk/tzsvr/src/org/bedework/timezones/server/PostMethod.java 2010-01-05 16:21:51 UTC (rev 30)
+++ trunk/server/src/org/bedework/timezones/server/PostMethod.java 2010-10-22 02:06:58 UTC (rev 35)
@@ -26,7 +26,7 @@
package org.bedework.timezones.server;
-import java.util.Properties;
+import org.bedework.timezones.common.TzServerUtil;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -43,14 +43,15 @@
public class PostMethod extends MethodBase {
/**
* @param debug
+ * @throws ServletException
*/
- public PostMethod(boolean debug) {
+ public PostMethod(boolean debug) throws ServletException {
super(debug);
}
+ @Override
public void doMethod(HttpServletRequest req,
- HttpServletResponse resp,
- Properties props) throws ServletException {
+ HttpServletResponse resp) throws ServletException {
if (debug) {
trace("PostMethod: doMethod");
}
@@ -66,7 +67,7 @@
resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
}
- TzServer.refreshNow = true;
+ util.fireRefresh();
} catch (Throwable t) {
throw new ServletException(t);
}
Modified: trunk/server/src/org/bedework/timezones/server/TzServer.java
===================================================================
--- trunk/tzsvr/src/org/bedework/timezones/server/TzServer.java 2010-01-05 16:21:51 UTC (rev 30)
+++ trunk/server/src/org/bedework/timezones/server/TzServer.java 2010-10-22 02:06:58 UTC (rev 35)
@@ -26,13 +26,12 @@
package org.bedework.timezones.server;
+import org.bedework.timezones.common.TzServerUtil;
+
import org.apache.log4j.Logger;
-import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
-import java.util.Properties;
-import java.util.zip.ZipFile;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -59,22 +58,17 @@
protected boolean dumpContent;
- /** Global resources for the servlet - not to be modified.
- */
- private static Properties props;
-
- static ZipFile tzDefsZipFile;
-
- static File tzDefsFile;
-
- volatile static boolean refreshNow;
-
protected transient Logger log;
+ private TzServerUtil util;
+
+ @Override
public void init(ServletConfig config) throws ServletException {
try {
super.init(config);
+ util = TzServerUtil.getInstance();
+
String debugStr = getInitParameter("debug");
if (debugStr != null) {
debug = !"0".equals(debugStr);
@@ -82,16 +76,8 @@
dumpContent = "true".equals(config.getInitParameter("dumpContent"));
- props = TzServerUtil.getResources(this, config);
+ //Properties props = TzServerUtil.getResources(this, config);
- Long propLong = TzServerUtil.longProp(props,
- TzServerUtil.pnameRefetchInterval);
- if (propLong == null) {
- propLong = 10L * 60; // default to 10 mins
- }
-
- propLong *= 1000;
- props.put(TzServerUtil.pnameRefetchInterval, propLong);
} catch (ServletException se) {
throw se;
} catch (Throwable t) {
@@ -99,6 +85,7 @@
}
}
+ @Override
protected void service(HttpServletRequest req,
HttpServletResponse resp) throws ServletException, IOException {
try {
@@ -110,12 +97,12 @@
}
if (methodName.equals("OPTIONS")) {
- new OptionsMethod(debug).doMethod(req, resp, props);
+ new OptionsMethod(debug).doMethod(req, resp);
} else if (methodName.equals("GET")) {
- refresh();
- new GetMethod(debug).doMethod(req, resp, props);
+ util.refresh();
+ new GetMethod(debug).doMethod(req, resp);
} else if (methodName.equals("POST")) {
- new PostMethod(debug).doMethod(req, resp, props);
+ new PostMethod(debug).doMethod(req, resp);
} else {
}
@@ -224,44 +211,4 @@
*/
public void sessionDestroyed(HttpSessionEvent se) {
}
-
- private synchronized void refresh() throws ServletException {
- if ((tzDefsFile != null) && !refreshNow) {
- Long regRefetchInterval = (Long)props.get(TzServerUtil.pnameRefetchInterval);
- if ((System.currentTimeMillis() - TzServerUtil.lastDataFetch) / 1000 < regRefetchInterval) {
- // No fetch needed
- return;
- }
- }
-
- try {
- File f = TzServerUtil.getdata(props);
-
- ZipFile zf = new ZipFile(f);
-
- if (tzDefsZipFile != null) {
- try {
- tzDefsZipFile.close();
- } catch (Throwable t) {
- }
- }
-
- if (tzDefsFile != null) {
- try {
- tzDefsFile.delete();
- } catch (Throwable t) {
- }
- }
-
- tzDefsFile = f;
- tzDefsZipFile = zf;
-
- TzServerUtil.lastDataFetch = System.currentTimeMillis();
- refreshNow = false;
- } catch (ServletException se) {
- throw se;
- } catch (Throwable t) {
- throw new ServletException(t);
- }
- }
}
Deleted: trunk/server/src/org/bedework/timezones/server/TzServerUtil.java
===================================================================
--- trunk/tzsvr/src/org/bedework/timezones/server/TzServerUtil.java 2010-01-05 16:21:51 UTC (rev 30)
+++ trunk/server/src/org/bedework/timezones/server/TzServerUtil.java 2010-10-22 02:06:58 UTC (rev 35)
@@ -1,675 +0,0 @@
-/* **********************************************************************
- Copyright 2009 Rensselaer Polytechnic Institute. All worldwide rights reserved.
-
- Redistribution and use of this distribution in source and binary forms,
- with or without modification, are permitted provided that:
- The above copyright notice and this permission notice appear in all
- copies and supporting documentation;
-
- The name, identifiers, and trademarks of Rensselaer Polytechnic
- Institute are not used in advertising or publicity without the
- express prior written permission of Rensselaer Polytechnic Institute;
-
- DISCLAIMER: The software is distributed" AS IS" without any express or
- implied warranty, including but not limited to, any implied warranties
- of merchantability or fitness for a particular purpose or any warrant)'
- of non-infringement of any current or pending patent rights. The authors
- of the software make no representations about the suitability of this
- software for any particular purpose. The entire risk as to the quality
- and performance of the software is with the user. Should the software
- prove defective, the user assumes the cost of all necessary servicing,
- repair or correction. In particular, neither Rensselaer Polytechnic
- Institute, nor the authors of the software are liable for any indirect,
- special, consequential, or incidental damages related to the software,
- to the maximum extent the law permits.
-*/
-package org.bedework.timezones.server;
-
-import edu.rpi.sss.util.DateTimeUtil;
-
-import net.fortuna.ical4j.data.CalendarBuilder;
-import net.fortuna.ical4j.data.UnfoldingReader;
-import net.fortuna.ical4j.model.Component;
-import net.fortuna.ical4j.model.TimeZone;
-import net.fortuna.ical4j.model.component.VTimeZone;
-import net.fortuna.ical4j.util.TimeZones;
-
-import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.params.HttpMethodParams;
-import org.apache.log4j.Logger;
-
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.CacheManager;
-import net.sf.ehcache.Element;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.net.URL;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-
-/** Some utility methods.
- *
- * @author Mike Douglass
- */
-public class TzServerUtil {
- /* ======================= property names ======================= */
-
- /** Property defining location of the zipped data */
- public static final String pnameTzdataURL = "tzsvc.tzdata.url";
-
- /** Property defining integer seconds refetch of data
- */
- public static final String pnameRefetchInterval = "tzsvc.refetch.interval";
-
- /** Property defining a key to allow POST */
- public static final String pnamePostId = "tzsvc.post.id";
-
- /** name of vtimezone cache
- */
- public static final String pnameVtzCache = "tzsvc.vtimezones.cache.name";
-
- /** name of zoneinfo cache
- */
- public static final String pnameZoneInfoCache = "tzsvc.zoneinfo.cache.name";
-
- /* ======================= Error codes ======================= */
-
- /** Unable to retrieve the data */
- public static final String errorNodata = "org.tserver.no.data";
-
- /* ======================= Caching ======================= */
-
- private static CacheManager manager;
- static {
- URL u = TzServerUtil.class.getResource("/tzsvrEhcache.xml");
-
- manager = CacheManager.create(u);
- }
-
- private static Cache vtzCache;
-
- private static SortedSet<String> nameList;
-
- /** Time we last fetched the data */
- static long lastDataFetch;
-
- static String etagValue;
-
- /* ======================= TimeZone objects ======================= */
-
- private static Map<String, TimeZone> tzs = new HashMap<String, TimeZone>();
-
- private static String aliases;
-
- private static Collection<String> tzinfo;
-
- /* ======================= Stats ======================= */
-
- static long gets;
- static long cacheHits;
- static long reads;
- static long nameLists;
- static long aliasReads;
- static long conversions;
- static long conversionsMillis;
- static long tzfetches;
- static long tzbuilds;
- static long tzbuildsMillis;
-
- /**
- * @return an etag based on when we refreshed data
- * @throws ServletException
- */
- public static String getEtag() throws ServletException {
- if (etagValue == null) {
- Collection<String> info = tzinfo;
-
- if (info == null) {
- info = getInfo(TzServer.tzDefsZipFile);
- }
-
- if (info != null) {
- for (String s: info) {
- if (s.startsWith("buildTime=")) {
- etagValue = s.substring("buildTime=".length());
- break;
- }
- }
- }
-
- if (etagValue == null) {
- etagValue = String.valueOf(lastDataFetch);
- }
- }
-
- StringBuilder val = new StringBuilder();
-
- val.append("\"");
- val.append(etagValue);
- val.append("\"");
-
- return val.toString();
- }
-
- /** Set up a Properties from the resources
- *
- * @param servlet
- * @param config
- * @return Properties
- * @throws ServletException
- */
- static Properties getResources(final HttpServlet servlet,
- final ServletConfig config) throws ServletException {
- String resname = config.getInitParameter("application");
-
- Properties props = new Properties();
-
- if (resname != null) {
- InputStream is;
-
- ClassLoader classLoader =
- Thread.currentThread().getContextClassLoader();
- if (classLoader == null) {
- classLoader = servlet.getClass().getClassLoader();
- }
- is = classLoader.getResourceAsStream(resname + ".properties");
-
- try {
- props.load(is);
- } catch (IOException ie) {
- throw new ServletException(ie);
- }
- }
-
- cacheInit(props);
-
- return props;
- }
-
- /** Retrieve the data and store in a temp file. Return the file object.
- *
- * @param props
- * @return File
- * @throws ServletException
- */
- static File getdata(final Properties props) throws ServletException {
- try {
- String dataUrl = props.getProperty(pnameTzdataURL);
- if (dataUrl == null) {
- throw new ServletException("No data url defined");
- }
-
- /* Fetch the data */
- HttpClient client = new HttpClient();
-
- HttpMethod get = new GetMethod(dataUrl);
-
- client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
- new DefaultHttpMethodRetryHandler());
-
- client.executeMethod(get);
-
- InputStream is = get.getResponseBodyAsStream();
-
- File f = File.createTempFile("bwtzserver", "zip");
-
- FileOutputStream fos = new FileOutputStream(f);
-
- byte[] buff = new byte[4096];
-
- for (;;) {
- int num = is.read(buff);
-
- if (num < 0) {
- break;
- }
-
- if (num > 0) {
- fos.write(buff, 0, num);
- }
- }
-
- fos.close();
- is.close();
-
- get.releaseConnection();
-
- logIt("Data (re)fetched");
-
- return f;
- } catch (Throwable t) {
- throw new ServletException(t);
- }
- }
-
- static SortedSet<String> getNames(final ZipFile zf) throws ServletException {
- nameLists++;
-
- /* Do this the right way round we don't need to synch */
- SortedSet<String> nl = nameList;
-
- if (nl != null) {
- return nl;
- }
-
- try {
- nl = new TreeSet<String>();
-
- Enumeration<? extends ZipEntry> zes = zf.entries();
-
- while (zes.hasMoreElements()) {
- ZipEntry ze = zes.nextElement();
-
- if (!ze.isDirectory()) {
- String n = ze.getName();
-
- if (n.startsWith("zoneinfo/") && n.endsWith(".ics")) {
- nl.add(n.substring(9, n.length() - 4));
- }
- }
- }
-
- nameList = nl;
-
- return nl;
- } catch (Throwable t) {
- throw new ServletException(t);
- }
- }
-
- static String getTz(final String name, final ZipFile zf) throws ServletException {
- String s = getCachedVtz(name);
- if (s != null) {
- cacheHits++;
- return s;
- }
-
- try {
- reads++;
- ZipEntry ze = zf.getEntry("zoneinfo/" + name + ".ics");
-
- if (ze == null) {
- return null;
- }
-
- s = entryToString(zf, ze);
-
- putCachedVtz(name, s);
-
- return s;
- } catch (Throwable t) {
- throw new ServletException(t);
- }
- }
-
- static String getAliases(final ZipFile zf) throws ServletException {
- try {
- /* Do this the right way round we don't need to synch */
- String a = aliases;
-
- if (a != null) {
- return a;
- }
-
- aliasReads++;
- ZipEntry ze = zf.getEntry("aliases.txt");
-
- if (ze == null) {
- return null;
- }
-
- a = entryToString(zf, ze);
- aliases = a;
-
- return a;
- } catch (Throwable t) {
- throw new ServletException(t);
- }
- }
-
- static Collection<String> getInfo(final ZipFile zf) throws ServletException {
- try {
- /* Do this the right way round we don't need to synch */
- Collection<String> a = tzinfo;
-
- if (a != null) {
- return a;
- }
-
- ZipEntry ze = zf.getEntry("info.txt");
-
- if (ze == null) {
- return null;
- }
-
- String info = entryToString(zf, ze);
-
- String[] infoLines = info.split("\n");
- a = new ArrayList<String>();
-
- for (String s: infoLines) {
- a.add(s);
- }
-
- tzinfo = a;
-
- return a;
- } catch (Throwable t) {
- throw new ServletException(t);
- }
- }
-
- private static String entryToString(final ZipFile zf,
- final ZipEntry ze) throws Throwable {
- InputStreamReader is = new InputStreamReader(zf.getInputStream(ze),
- "UTF-8");
-
- StringWriter sw = new StringWriter();
-
- char[] buff = new char[4096];
-
- for (;;) {
- int num = is.read(buff);
-
- if (num < 0) {
- break;
- }
-
- if (num > 0) {
- sw.write(buff, 0, num);
- }
- }
-
- is.close();
-
- return sw.toString();
- }
-
- private static Calendar cal = Calendar.getInstance();
- private static java.util.TimeZone utctz;
-
- static {
- try {
- utctz = TimeZone.getTimeZone(TimeZones.UTC_ID);
- } catch (Throwable t) {
- throw new RuntimeException("Unable to initialise UTC timezone");
- }
- cal.setTimeZone(utctz);
- }
-
- /**
- * @param time
- * @param tzid
- * @return String utc date
- * @throws Throwable
- */
- public static String getUtc(final String time,
- final String tzid) throws Throwable {
- if (DateTimeUtil.isISODateTimeUTC(time)) {
- // Already UTC
- return time;
- }
-
- if (!DateTimeUtil.isISODateTime(time)) {
- return null; // Bad datetime
- }
-
- conversions++;
- long smillis = System.currentTimeMillis();
-
- TimeZone tz = fetchTimeZone(tzid);
-
- DateFormat formatTd = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
- formatTd.setTimeZone(tz);
-
- Date date = formatTd.parse(time);
- String utc;
-
- synchronized (cal) {
- cal.clear();
- cal.setTime(date);
-
- //formatTd.setTimeZone(utctz);
- //trace("formatTd with utc: " + formatTd.format(date));
-
- StringBuilder sb = new StringBuilder();
- digit4(sb, cal.get(Calendar.YEAR));
- digit2(sb, cal.get(Calendar.MONTH) + 1); // Month starts at 0
- digit2(sb, cal.get(Calendar.DAY_OF_MONTH));
- sb.append('T');
- digit2(sb, cal.get(Calendar.HOUR_OF_DAY));
- digit2(sb, cal.get(Calendar.MINUTE));
- digit2(sb, cal.get(Calendar.SECOND));
- sb.append('Z');
-
- utc = sb.toString();
- }
-
- conversionsMillis += System.currentTimeMillis() - smillis;
-
- return utc;
- }
-
- /** Convert from local time in fromTzid to local time in toTzid. If dateTime is
- * already an iso utc date time fromTzid may be null.
- *
- * @param dateTime
- * @param fromTzid
- * @param toTzid
- * @return String time in given timezone
- * @throws Throwable
- */
- public static String convertDateTime(final String dateTime, final String fromTzid,
- final String toTzid) throws Throwable {
- String UTCdt = null;
- if (DateTimeUtil.isISODateTimeUTC(dateTime)) {
- // Already UTC
- UTCdt = dateTime;
- } else if (!DateTimeUtil.isISODateTime(dateTime)) {
- return null; // Bad datetime
- } else if (toTzid == null) {
- return null; // Bad toTzid
- } else {
- UTCdt = getUtc(dateTime, fromTzid);
- conversions--; // avoid double inc
- }
-
- conversions++;
- long smillis = System.currentTimeMillis();
-
- // Convert to time in toTzid
-
- Date dt = DateTimeUtil.fromISODateTimeUTC(UTCdt);
-
- TimeZone tz = fetchTimeZone(toTzid);
- if (tz == null) {
- return null;
- }
-
- String cdt = DateTimeUtil.isoDateTime(dt, tz);
- conversionsMillis += System.currentTimeMillis() - smillis;
-
- return cdt;
- }
-
- /** Get a timezone object from the server given the id.
- *
- * @param tzid
- * @return TimeZone with id or null
- * @throws Throwable
- */
- public static TimeZone fetchTimeZone(final String tzid) throws Throwable {
- tzfetches++;
-
- TimeZone tz = tzs.get(tzid);
- if (tz != null) {
- return tz;
- }
-
- String tzdef = getTz(tzid, TzServer.tzDefsZipFile);
-
- if (tzdef == null) {
- return null;
- }
-
- tzbuilds++;
- long smillis = System.currentTimeMillis();
-
- CalendarBuilder cb = new CalendarBuilder();
-
- UnfoldingReader ufrdr = new UnfoldingReader(new StringReader(tzdef), true);
-
- net.fortuna.ical4j.model.Calendar cal = cb.build(ufrdr);
- VTimeZone vtz = (VTimeZone)cal.getComponents().getComponent(Component.VTIMEZONE);
- if (vtz == null) {
- throw new Exception("Incorrectly stored timezone");
- }
-
- tz = new TimeZone(vtz);
- tzs.put(tzid, tz);
-
- tzbuildsMillis += System.currentTimeMillis() - smillis;
-
- return tz;
- }
-
- /* ====================================================================
- * Caching
- * ==================================================================== */
-
- static void cacheInit(final Properties props) throws ServletException {
-
- vtzCache = manager.getCache(props.getProperty(pnameVtzCache));
- }
-
- static void cacheRefresh() throws ServletException {
- cacheRefresh(vtzCache);
- tzs.clear();
- aliases = null;
- nameList = null;
- }
-
- static String getCachedVtz(final String name) throws ServletException {
- Element el = vtzCache.get(name);
-
- if (el == null) {
- return null;
- }
-
- return (String)el.getValue();
- }
-
- static void putCachedVtz(final String name, final String vtz) throws ServletException {
- Element el = new Element(name, vtz);
-
- vtzCache.put(el);
- }
-
- /* ====================================================================
- * Private methods
- * ==================================================================== */
-
- private static void cacheRefresh(final Cache cache) throws ServletException {
- if (cache != null) {
- cache.flush();
- }
- }
-
- static Long longProp(final Properties props, final String name) throws Throwable {
- String propVal = props.getProperty(name);
- if (propVal == null) {
- return null;
- }
-
- return Long.valueOf(propVal);
- }
-
- static boolean boolProp(final Properties props, final String name) throws Throwable {
- String propVal = props.getProperty(name);
- if (propVal == null) {
- return false;
- }
-
- return Boolean.valueOf(propVal);
- }
-
- /**
- * @return Logger
- */
- static Logger getLogger() {
- return Logger.getLogger(TzServerUtil.class);
- }
-
- /** Debug
- *
- * @param msg
- */
- static void debugMsg(final String msg) {
- getLogger().debug(msg);
- }
-
- /** Info messages
- *
- * @param msg
- */
- static void logIt(final String msg) {
- getLogger().info(msg);
- }
-
- static void error(final String msg) {
- getLogger().error(msg);
- }
-
- static void error(final Throwable t) {
- getLogger().error(TzServerUtil.class, t);
- }
-
- private static void digit2(final StringBuilder sb, final int val) throws Throwable {
- if (val > 99) {
- throw new Exception("Bad date");
- }
- if (val < 10) {
- sb.append("0");
- }
- sb.append(val);
- }
-
- private static void digit4(final StringBuilder sb, final int val) throws Throwable {
- if (val > 9999) {
- throw new Exception("Bad date");
- }
- if (val < 10) {
- sb.append("000");
- } else if (val < 100) {
- sb.append("00");
- } else if (val < 1000) {
- sb.append("0");
- }
- sb.append(val);
- }
-}
Added: trunk/service/build.xml
===================================================================
--- trunk/service/build.xml (rev 0)
+++ trunk/service/build.xml 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+
+<!-- This is the ant build file for the Exchange synch service classes.
+
+ This file will probably need no modification as it is assumed that the
+ core of the calendar will be largely site and application independent.
+
+ The target of interest is build which should leave some jar files
+ in the temp jar directory..
+
+ These files will be needed for subsequent application or module builds.
+
+ This build file depends upon properties set by the master build file one
+ level up in the directory tree.
+
+ Authors: Mike Douglass douglm at rpi.edu
+-->
+
+<project name="compile" default="build">
+ <dirname property="module.home" file="${ant.file}"/>
+
+ <property name="source.home" location="${module.home}/src"/>
+ <property name="base.name" value="exsynchsvc"/>
+
+ <target name="init">
+ <dirname property="this.dir" file="${ant.file}"/>
+ </target>
+
+ <!-- ========================== Base build Targets ===================
+ Here we have one target building the classes and interfaces.
+ ================================================================= -->
+
+ <target name="build" depends="init"
+ description="Compile classes">
+ <!-- ==================== Sources and classes ====================== -->
+
+ <fileset id="buildjar.java.sources" dir="${source.home}" >
+ <include name="org/bedework/**/*.java"/>
+ </fileset>
+
+ <patternset id="base.class.patternset">
+ <include name="org/bedework/**/*.class"/>
+ </patternset>
+
+ <!-- ==================== Build Target ============================= -->
+
+ <ant antfile="${buildjar}" inheritRefs="true" target="build" />
+ </target>
+</project>
Added: trunk/service/src/org/bedework/timezones/service/Tzsvc.java
===================================================================
--- trunk/service/src/org/bedework/timezones/service/Tzsvc.java (rev 0)
+++ trunk/service/src/org/bedework/timezones/service/Tzsvc.java 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,173 @@
+/* **********************************************************************
+ Copyright 2010 Rensselaer Polytechnic Institute. All worldwide rights reserved.
+
+ Redistribution and use of this distribution in source and binary forms,
+ with or without modification, are permitted provided that:
+ The above copyright notice and this permission notice appear in all
+ copies and supporting documentation;
+
+ The name, identifiers, and trademarks of Rensselaer Polytechnic
+ Institute are not used in advertising or publicity without the
+ express prior written permission of Rensselaer Polytechnic Institute;
+
+ DISCLAIMER: The software is distributed" AS IS" without any express or
+ implied warranty, including but not limited to, any implied warranties
+ of merchantability or fitness for a particular purpose or any warrant)'
+ of non-infringement of any current or pending patent rights. The authors
+ of the software make no representations about the suitability of this
+ software for any particular purpose. The entire risk as to the quality
+ and performance of the software is with the user. Should the software
+ prove defective, the user assumes the cost of all necessary servicing,
+ repair or correction. In particular, neither Rensselaer Polytechnic
+ Institute, nor the authors of the software are liable for any indirect,
+ special, consequential, or incidental damages related to the software,
+ to the maximum extent the law permits.
+*/
+package org.bedework.timezones.service;
+
+import org.bedework.timezones.common.Stat;
+import org.bedework.timezones.common.TzServerUtil;
+
+import org.apache.log4j.Logger;
+
+import java.util.List;
+
+/**
+ * @author douglm
+ *
+ */
+public class Tzsvc implements TzsvcMBean {
+ private transient Logger log;
+
+ private boolean running;
+
+ private TzServerUtil util;
+
+ /* ========================================================================
+ * Attributes
+ * ======================================================================== */
+
+ /* (non-Javadoc)
+ * @see org.bedework.dumprestore.BwDumpRestoreMBean#getName()
+ */
+ public String getName() {
+ /* This apparently must be the same as the name attribute in the
+ * jboss service definition
+ */
+ return "org.bedework:service=Tzsvr";
+ }
+
+ public void setAppname(final String val) {
+ TzServerUtil.setAppname(val);
+ }
+
+ public String getAppname() {
+ return TzServerUtil.getAppname();
+ }
+
+ /* ========================================================================
+ * Operations
+ * ======================================================================== */
+
+ public List<Stat> getStats() {
+ try {
+ return TzServerUtil.getStats();
+ } catch (Throwable t) {
+ error("Error getting stats");
+ error(t);
+ return null;
+ }
+ }
+
+ /* an example say's we need this - we should probably implement some system
+ * independent jmx support which will build this using introspection and/or lists
+ public MBeanInfo getMBeanInfo() throws Exception {
+ InitialContext ic = new InitialContext();
+ RMIAdaptor server = (RMIAdaptor) ic.lookup("jmx/rmi/RMIAdaptor");
+
+ ObjectName name = new ObjectName(MBEAN_OBJ_NAME);
+
+ // Get the MBeanInfo for this MBean
+ MBeanInfo info = server.getMBeanInfo(name);
+ return info;
+ }
+ */
+
+ /* ========================================================================
+ * Lifecycle
+ * ======================================================================== */
+
+ /* (non-Javadoc)
+ * @see org.bedework.dumprestore.BwDumpRestoreMBean#create()
+ */
+ public void create() {
+ // An opportunity to initialise
+ }
+
+ /* (non-Javadoc)
+ * @see org.bedework.indexer.BwIndexerMBean#start()
+ */
+ public void start() {
+ try {
+ util = TzServerUtil.getInstance();
+ running = true;
+ } catch (Throwable t) {
+ error("Error getting instance");
+ error(t);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.bedework.indexer.BwIndexerMBean#stop()
+ */
+ public void stop() {
+ running = false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.bedework.indexer.BwIndexerMBean#isStarted()
+ */
+ public boolean isStarted() {
+ return running;
+ }
+
+ /* (non-Javadoc)
+ * @see org.bedework.dumprestore.BwDumpRestoreMBean#destroy()
+ */
+ public void destroy() {
+ }
+
+ /* ====================================================================
+ * Private methods
+ * ==================================================================== */
+
+ /* ====================================================================
+ * Protected methods
+ * ==================================================================== */
+
+ protected void info(final String msg) {
+ getLogger().info(msg);
+ }
+
+ protected void trace(final String msg) {
+ getLogger().debug(msg);
+ }
+
+ protected void error(final Throwable t) {
+ getLogger().error(this, t);
+ }
+
+ protected void error(final String msg) {
+ getLogger().error(msg);
+ }
+
+ /* Get a logger for messages
+ */
+ protected Logger getLogger() {
+ if (log == null) {
+ log = Logger.getLogger(this.getClass());
+ }
+
+ return log;
+ }
+}
Added: trunk/service/src/org/bedework/timezones/service/TzsvcMBean.java
===================================================================
--- trunk/service/src/org/bedework/timezones/service/TzsvcMBean.java (rev 0)
+++ trunk/service/src/org/bedework/timezones/service/TzsvcMBean.java 2010-10-22 02:06:58 UTC (rev 35)
@@ -0,0 +1,94 @@
+/* **********************************************************************
+ Copyright 2010 Rensselaer Polytechnic Institute. All worldwide rights reserved.
+
+ Redistribution and use of this distribution in source and binary forms,
+ with or without modification, are permitted provided that:
+ The above copyright notice and this permission notice appear in all
+ copies and supporting documentation;
+
+ The name, identifiers, and trademarks of Rensselaer Polytechnic
+ Institute are not used in advertising or publicity without the
+ express prior written permission of Rensselaer Polytechnic Institute;
+
+ DISCLAIMER: The software is distributed" AS IS" without any express or
+ implied warranty, including but not limited to, any implied warranties
+ of merchantability or fitness for a particular purpose or any warrant)'
+ of non-infringement of any current or pending patent rights. The authors
+ of the software make no representations about the suitability of this
+ software for any particular purpose. The entire risk as to the quality
+ and performance of the software is with the user. Should the software
+ prove defective, the user assumes the cost of all necessary servicing,
+ repair or correction. In particular, neither Rensselaer Polytechnic
+ Institute, nor the authors of the software are liable for any indirect,
+ special, consequential, or incidental damages related to the software,
+ to the maximum extent the law permits.
+*/
+package org.bedework.timezones.service;
+
+import org.bedework.timezones.common.Stat;
+
+import java.util.List;
+
+/** Run the timezones service
+ *
+ * @author douglm
+ */
+public interface TzsvcMBean {
+ /* ========================================================================
+ * Attributes
+ * ======================================================================== */
+
+ /** Name apparently must be the same as the name attribute in the
+ * jboss service definition
+ *
+ * @return Name
+ */
+ public String getName();
+
+ /** Application name - for config info
+ *
+ * @param val
+ */
+ public void setAppname(String val);
+
+ /**
+ * @return String application namee
+ */
+ public String getAppname();
+
+ /** Get the current stats
+ *
+ * @return List of Stat
+ */
+ public List<Stat> getStats();
+
+ /* ========================================================================
+ * Lifecycle
+ * ======================================================================== */
+
+ /** Lifecycle
+ *
+ */
+ public void create();
+
+ /** Lifecycle
+ *
+ */
+ public void start();
+
+ /** Lifecycle
+ *
+ */
+ public void stop();
+
+ /** Lifecycle
+ *
+ * @return true if started
+ */
+ public boolean isStarted();
+
+ /** Lifecycle
+ *
+ */
+ public void destroy();
+}
More information about the Bedework-commit
mailing list