You may want to add additional features to the web server with your own
servlets. This
document discusses how to do this.
The build process relies on the Ant
build tool from The Jakarta Project.
A build.xml file is included, and the only file you need to modify
for your own configuration is the build.properties file.
Subject Menu
Including Your Own Source
The build process allows you to include your own source. You will need
to modify these build properties:
src.paths ,
src.files , and possibly
target.jar and
dependency.classpath .
Place the location of the source files in src.paths , and a
list of files in src.files . If your code depends on further
libraries, you may need to modify dependency.classpath as
well. See the build configuration section
for more details.
[Top]
Including Your Own Classes
There are no extra steps required to include your own libraries. They
need to be copied to the SNAP and then added to the classpath when
executing the server, but that's it.
[Top]
Build Configuration — The
build.properties File
The build.properties file is the only place you are required to
manage your build configuration. The syntax requrements are only that a
forward slash (/) for the file separator, and a colon (:) for the path
separator, are used. Also, any non-required properties may be left
unspecified.
Note: If you choose to use backslashes
(\) for your paths, say, in Windows, then you must use pairs (eg.
snap.path=C:\\Java\\snap1.0.6).
This is because in properties files, backslashes are treated
specially. They act to change the meaning of the following character.
Please consult the Java documentation for more information.
snap.path
This points to the location of the SNAP distribution. For example:
snap.path=C:/Java/snap1.0.6
This property is required.
preverify.exe
This points to the location of the preverify.exe program
included in your SNAP distribution. For example:
preverify.exe=C:/Java/snap1.0.6/bin/preverify.exe
This program is used to preprocess and check your classes before
archiving them into a JAR. It is not necessary to preverify your classes,
so it is okay to leave this property undefined.
src.paths
This points to the location(s) of your source files. For example:
src.paths=mysrc:myservlets/src
A path separator is used between different paths.
src.files
A comma- or space-separated list of source files. This may be specified
using Ant-style wildcard
patterns. For example:
src.files=com/mycompany/util/*.java,com/theircompany/**/*.java
It is not a good idea to specify **/*.java since that may
include unwanted source files. Instead, be more specific with the package
structure, as in the above example.
dependency.classpath
This specifies a CLASSPATH-like list of paths and archives containing
classes needed for the build. Any SNAP-related library, such as the
1-Wire library, is automatically included in the SNAP classes, and does
not need to be specified here. For example:
dependency.classpath=mymodules.jar
target.jar
This names the JAR file that will be created from any compiled source
code that was specified with src.files . If not
specified, then the default will be "myclasses.jar".
This should not contain extra path information. For example:
target.jar=mylib.jar
These are incorrect: target.jar=path/mylib.jar
or target.jar=/root/path/mylib.jar.
This file will be included by the deploy script.
One additional step you must do is prepend this file to the
'-classpath' setting inside the WebServer script in the
snap/bin/ directory. This will enable the virtual machine to
find your classes.
[Top]
Other Build-Related Files
This section discusses the other files needed in the build process.
The build.xml file
The build.xml file is the Ant build script. Its default task
will automatically compile any source files you have specified, and
then archive them into a JAR in the snap/bin/ directory.
By default, all compiled classes will be written to a directory named
classes/. This can be changed by changing the
javac.destination property to something else.
[Top]
|