Skip to content

Commit 9d3cfdd

Browse files
authored
Merge pull request #20 from daveneiman/dev
Update build; update documentation
2 parents 799e227 + 4501710 commit 9d3cfdd

File tree

3 files changed

+68
-88
lines changed

3 files changed

+68
-88
lines changed

README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,17 @@ See <a href="#test-client">below</a> for a Java test client example.
4747

4848
## <a name="tomcat"></a>Deploying to Tomcat 7 and Tomcat 8
4949
### Add Entries to catalina.properties
50-
It’s necessary to add the location of the FITS directory to the file `$CATALINA_BASE/conf/catalina.properties` then add the FITS lib folder JAR files. (See example below.)
50+
It’s necessary to add the location of the FITS home directory to the file `$CATALINA_BASE/conf/catalina.properties` then add the location of the FITS lib folder JAR files. (See example below.)
5151
<br>1. Add the “fits.home” environment variable.
5252
<br>2. Add all “fits.home”/lib/ JAR files to the shared class loader classpath with a wildcard ‘*’ and the `${fits.home}` property substitution.
5353
**Note: Do NOT add any JAR files that are contained in any of the FITS lib/ subdirectories to this classpath entry. They are added programmatically at runtime by the application.**
5454
<br>3. (optional) Rather than using the default log4j.properties file located within the WAR file (which logs to a file within the Tomcat directory structure) it's possible to set up logging to point to an external log4j.properties file. Add a "log4j.configuration" property to catalina.properties pointing to this file. It can be either a full path or have the `file:` protocol at the beginning of the entry. This is managed by the class `edu.harvard.hul.ois.fits.service.listeners.LoggingConfigurator.java`.
5555
#### catalina.properties example
5656
Add the following to the bottom of the file:
57-
`fits.home=path/to/fits/home'` (note: no final slash in path)
58-
`shared.loader=${fits.home}/lib/*.jar
59-
log4j.configuration=/path/to/log4j.properties`
60-
or
61-
`log4j.configuration=file:/path/to/log4j.properties`
57+
- `fits.home=path/to/fits/home` (note: no final slash in path)
58+
- `shared.loader=${fits.home}/lib/*.jar`
59+
- `log4j.configuration=/path/to/log4j.properties` or `log4j.configuration=file:/path/to/log4j.properties` (optional -- to override using the default log4j.properties in the WEB-INF directory of the WAR file.)
60+
6261
#### Additional Information:
6362
**Class loading:** Within the WAR file’s META-INF directory is a Tomcat-specific file, context.xml. This file indicates to the Tomcat server to modify the Tomcat default class loader scheme for this application. The result is that, rather than load the WAR’s classes and JAR files first, classes on Tomcat’s shared classpath will be loaded first. This is critical given the nature of the custom class loaders used in FITS. (This file will be ignored if deploying to JBoss.)
6463

build.xml

+63-21
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" ?>
2-
<project name="FITServlet" default="war">
2+
<project name="FITS Service" default="war">
33

44
<!--
5-
Compile classpath depends on finding an external fits.jar from FITS project.
5+
Compile classpath depends on finding an external fits.jar from the FITS project.
66
The environment variable "fits_jar_location" can be set to point to the
7-
location containing fits.jar. Alternatively, set the value for property "fits.jar.fallback.location"
8-
in the following properties file.
7+
directory containing fits.jar (or some version JAR such as fits-1.0.0.jar).
8+
Alternatively, set the value for property "fits.jar.fallback.location" in the build.properties file.
99
-->
1010
<property file="build.properties" />
1111
<property environment="env"/> <!-- access to environment properties -->
@@ -28,28 +28,61 @@
2828
<property name="classes.dir" location="WebContent/WEB-INF/classes" />
2929
<property name="dist.dir" location="dist" />
3030

31-
<target name="init" depends="clean">
32-
33-
<!-- Location of possible FITS JAR file as set by environment variable. -->
34-
<fileset dir="${fits.jar.environment.location}" includes="*.jar" id="fits.jar.environment">
31+
<target name="set-fits-jar-env-directory-exists">
32+
<!-- Set property if the fits.jar fallback directory exists (before checking for JAR file). -->
33+
<condition property="fits.jar.environment.location.exists">
34+
<available file="${env.fits_jar_location}" type="dir"/>
35+
</condition>
36+
</target>
37+
38+
<target name="set-fits-jar-location-by-env" if="fits.jar.environment.location.exists"
39+
depends="set-fits-jar-env-directory-exists">
40+
<!--
41+
Sets the count of fits JAR files found in (a possibly set) environment variable pointing to directory where file resides.
42+
(There should only be a single fits JAR file if this location exists.)
43+
-->
44+
<fileset dir="${fits.jar.environment.location}" includes="*.jar" id="fits.jar.environment">
3545
<filename regex="fits.*\.jar" /> <!-- regex takes into account version number in JAR file. -->
36-
</fileset>
37-
<!-- Set property indicating number of FITS JAR files at environment variable location. -->
38-
<resourcecount refid="fits.jar.environment" property="environ.fits.jar.count" />
39-
40-
<!-- Location of possible FITS JAR file as set by fallback location as set in properties file. -->
46+
</fileset>
47+
<!-- The following can only be called if the refid has a valid 'dir' attribute value. Thus, the 'if' on this target. -->
48+
<resourcecount refid="fits.jar.environment" property="environ.fits.jar.count" />
49+
</target>
50+
51+
<target name="set-fits-jar-fallback-directory-exists">
52+
<!-- Set property if the fits.jar fallback directory exists (before checking for JAR file). -->
53+
<condition property="fits.jar.fallback.location.exists">
54+
<available file="${fits.jar.fallback.location}" type="dir"/>
55+
</condition>
56+
</target>
57+
58+
<target name="set-fits-jar-location-by-fallback" if="fits.jar.fallback.location.exists" unless="fits.jar.environment.location.exists"
59+
depends="set-fits-jar-fallback-directory-exists">
60+
<!--
61+
Directory of possible FITS JAR file as set by fallback location as set in build.properties file.
62+
Only called if environment variable for fir JAR directory not set. Thus, the 'unless' on this target.
63+
(There should only be a single fits JAR file if this location exists.)
64+
-->
4165
<fileset dir="${fits.jar.fallback.location}" includes="*.jar" id="fits.jar.fallback">
4266
<filename regex="fits.*\.jar" /> <!-- regex takes into account version number in JAR file. -->
4367
</fileset>
4468
<!-- Set property indicating number of FITS JAR files at fallback location. -->
4569
<resourcecount refid="fits.jar.fallback" property="fallback.fits.jar.count" />
70+
</target>
71+
72+
<target name="init" depends="clean, set-fits-jar-location-by-env, set-fits-jar-location-by-fallback">
73+
74+
<!-- Location of possible FITS JAR file as set by environment variable. -->
75+
<fileset dir="${fits.jar.environment.location}" includes="*.jar" id="fits.jar.environment">
76+
<filename regex="fits.*\.jar" /> <!-- regex takes into account version number in JAR file. -->
77+
</fileset>
4678

47-
<!-- uncomment for property debugging information
79+
<!-- Property values for FITS JAR file dependency. -->
4880
<echo message="fits.jar.environment.location: ${env.fits_jar_location}" />
49-
<echo message="fits.jar.fallback.location: ${fits.jar.fallback.location}" />
81+
<echo message="fits.jar.environment.location.exists: ${fits.jar.environment.location.exists}" />
5082
<echo message="fits JAR files in environment variable location: ${environ.fits.jar.count}" />
83+
<echo message="fits.jar.fallback.location: ${fits.jar.fallback.location}" />
84+
<echo message="fits.jar.fallback.location.exists: ${fits.jar.fallback.location.exists}" />
5185
<echo message="fits JAR files in fallback location: ${fallback.fits.jar.count}" />
52-
-->
5386

5487
<fail message="*** Either missing FITS JAR file or more than one is present. There should be one and only one FITS JAR file. Cannot build! ***">
5588
<condition>
@@ -61,7 +94,16 @@
6194
</not>
6295
</condition>
6396
</fail>
64-
97+
98+
<!-- Set fits JAR file for use in comilation. -->
99+
<condition property="fits.jar.file.dir" value="${fits.jar.environment.location}">
100+
<equals arg1="${environ.fits.jar.count}" arg2="1" />
101+
</condition>
102+
<!-- Property cant be set a second time if set in the above condition. -->
103+
<condition property="fits.jar.file.dir" value="${fits.jar.fallback.location}">
104+
<equals arg1="${fallback.fits.jar.count}" arg2="1" />
105+
</condition>
106+
65107
<!-- Verify existance of version properties file containing the expected property. -->
66108
<fail message="Cannot find file: ${build.version.file}">
67109
<condition>
@@ -85,7 +127,7 @@
85127
</target>
86128

87129
<target name="compile" depends="init" description="Compile all source code">
88-
<javac destdir="${classes.dir}" debug="true" srcdir="${src.dirs}:${test.dirs}" includeantruntime="false" source="1.8" target="1.8">
130+
<javac destdir="${classes.dir}" debug="true" srcdir="${src.dirs}:${test.dirs}" includeantruntime="false" source="1.7" target="1.7">
89131
<classpath>
90132
<fileset dir="WebContent/WEB-INF/lib">
91133
<include name="*.jar" />
@@ -94,9 +136,9 @@
94136
<fileset dir="lib">
95137
<include name="*.jar" />
96138
</fileset>
97-
<!-- Already determined that FITS JAR file will be in only one of the following two locations. -->
98-
<fileset refid="fits.jar.fallback" />
99-
<fileset refid="fits.jar.environment" />
139+
<fileset dir="${fits.jar.file.dir}">
140+
<include name="*.jar"/>
141+
</fileset>
100142
</classpath>
101143
</javac>
102144
</target>

tests.log4j.properties

-61
This file was deleted.

0 commit comments

Comments
 (0)