Tynamo™-aJile Configuration

This document discusses how to configure Tynamo™ for aJile systems.

The server configuration is specified with system properties. Other configuration data, including that for Servlets and MIME types, are stored in Java resources. The sections below detail the steps necessary to properly configure all components of the server.

There is a sample JemBuilder project, called Tynamo.ajp, included in the distribution that can serve as a starting point for your own builds.

  1. Build Environment Paths
  2. System Properties
  3. Including Class.forName Information
  4. Configuring Servlets
  5. Configuring MIME Types
  6. Resources and Static Content

0. Build Environment Paths

Be sure to set up the correct paths in your build environment. Sometimes, absolute paths are used for configuration, and these must be changed for every environment on which your project will be built. For JemBuilder, configure:

  • Project.Output Files panel, Output Directory option
  • JVM0.Classpath panel (Note that "JVM0" may not be the correct name, depending on how each JVM was set up.)

The relative path segments for these paths in the sample project should be correct, therefore you only need to change the part that contains the root of your project. For example, /myprojects/tynamo/bin/tws_core.jar should still contain the bin/tws_core.jar part, while the first part must be changed to the root of your Tynamo project.

Note that the paths for the above two JemBuilder locations (and only those two locations) are constructed using path and file separators appropriate to a specific OS. For example, Windows users must use a backslash (\) as the file separator character, and a semicolon (;) as the path separater. UNIX-like users generally use a forward slash (/) as the file separator character, and a colon (:) as the path separator.

For example, this classpath for UNIX-based systems:

/tynamo/bin/tws_core.jar:/tynamo/examples/servlet_examples.jar:/tynamo/res

should look like this on Windows systems:

\tynamo\bin\tws_core.jar;\tynamo\examples\servlet_examples.jar;\tynamo\res

The Classpath and Resources

Some configuration parameters, such as the servlet mappings and the MIME types, and also any HTML pages and images, are stored in the build as resources. To have JemBuilder include these resources, their parent location must be one of the classpath entries. For example, the Tynamo distribution includes all resources inside a directory named res. Thus, one of the classpath entries must be <path_to_tynamo_distribution>/res.

To illustrate further, take the servlet configuration file, whose contents are stored in a resource named "/config/servlets.props". Since the file is stored as res/config/servlets.props, and since <path_to>/res is in the classpath, the resource will be found.

The section on resources has a further discussion on this topic.

[Top]


1. System Properties

The HTTP server and Servlet container are configured using system properties. Tables 1, 2, & 3 describe each recognized property. Table 4 describes some additional properties recognized by aJile systems. Finally, Table 5 details some properties that are recommended to get the 1-Wire library to work.

Server Configuration

Table 1 – Server configuration
Property Name Default Value Description
mail.host <none> Address of a mail server. This host is used with the "mailto" protocol. The HTTP logging code uses this, and so may any mail-related servlets. Use the four octet form for the address if the DNS resolver is not configured.
tynamo.server.bufferSize 512 Size, in bytes, of any input or output buffers.
tynamo.server.hostname <none> This is the default host name of the server. If this is specified and an absolute URL or "Host" header specify a different host, then a 400 Bad Request will be returned. If this property is not specified then the server will ignore the host part of the request. The servlet container, however, will make a "best guess" for the server name.
tynamo.server.maxHandlers 4 Maximum number of requests that the server will process at once.
tynamo.server.maxRequestURILength -1 Maximum size of of the Request-URI that the server will accept. The server will respond with 414 Request-URI Too Long for anything over this limit. A negative number means there is no limit.
tynamo.server.minGCInterval 30 Minimum number of seconds between server internal cleanup calls.
tynamo.server.port 80 The server listens for requests on this port.
tynamo.server.sendServerHeader false Indicates whether the "Server" header field will be sent with each response. The HTTP specification encourages that implementors make this a configurable option ("HTTP/1.1", RFC 2616, p. 141). This is a Boolean value.
tynamo.server.shutdownEnabled false The server can be shut down if a special password URL is requested. This property enables this feature. This is a Boolean value.
tynamo.server.shutdownPasswordAttribute <none> If this property is set then the special password URL is stored in the specified servlet container attribute. This property is only utilized if the shutdown feature is enabled with tynamo.server.shutdownEnabled. Note that if an attribute with the specified name already exists, then it will not be reset with the shutdown password.
tynamo.server.welcomeFile index.html Specifies the default welcome file name. The server will look for this file if a directory is specified in the Request-URI.

Servlet Container Configuration

Table 2 – Servlet container configuration
Property Name Default Value Description
tynamo.servlet.contextParams <none> Specifies the ServletContext initialization parameters, formatted as a comma-separated list of name=value pairs.
tynamo.servlet.sessionTimeout 300 Specifies the default session timeout, in seconds.

Logging Configuration

Table 3 – Logging configuration
Property Name Default Value Description
tynamo.server.log.logEnabled true Indicates that the server should enable logging. Note that this is a separate setting from tynamo.server.log.transferLogEnabled. Servlets may use this log for messages, and the server uses it to log exceptions and various system messages. Also note that this setting is ignored if both tynamo.server.log.mailTo and tynamo.server.log.printToConsole are disabled.
tynamo.server.log.mailFrom <none> This specifies where the emailed log files are 'from'. This should be an email address.
tynamo.server.log.mailTo <none> Email address to which log files are sent once they reach the maximum size given in the server.log.maxSize property. If both this property and tynamo.server.log.printToConsole are disabled then the server will not perform any logging, regardless of the settings of tynamo.server.log.logEnabled or tynamo.server.log.transferLogEnabled.
tynamo.server.log.maxSize 5000 The log files can reach this maximum size before being sent to the address specified in the server.log.mailTo property. If the log is not mailed, then it is truncated when it reaches this length.
tynamo.server.log.printToConsole false The server will print all log and transfer log messages to the console if this is set to true. If both this property and tynamo.server.log.mailTo are disabled then the server will not perform any logging, regardless of the settings of tynamo.server.log.logEnabled or tynamo.server.log.transferLogEnabled.
tynamo.server.log.stackTraceEnabled false Specifies that any logged exceptions will have their stack traces printed to the standard error stream.
tynamo.server.log.transferLogEnabled true Indicates that the server should log each request. Note that this setting is ignored if both tynamo.server.log.mailTo and tynamo.server.log.printToConsole are disabled.

aJile-Specific Configuration

The aJile platform has the ability to configure additional server-related features such as DNS resolution and socket timeouts. Table 3 describes these properties. Note that the DNS properties are required if the mailhost is not in the four octet form, and you wish to mail the logs.

Table 4 – aJile-specific additional configuration
Property Name Default Value Description
dns.resolver <none> The fully qualified classname of the DNS client. This class must implement the com.ajile.net.dns.ResolveIntfc interface (com.ajile.net.dns.DNSClient works). Please consult the com.ajile.net.dns package documentation for further details.
dns.server <none> Well-formed, four octect IP address of a DNS server. Please consult the com.ajile.net.dns package documentation for further details.
ethernet0.sockettimeout <unknown> Time, in milliseconds, the server will wait for input from a socket connection. A 408 Request Timeout will be sent after this time.
ethernet0.tcp.twomsl <unknown> Defines the time, in milliseconds, the TCP driver will wait before closing a connection. It is suggested that this property be set to a few seconds, otherwise sockets must wait a full 120 seconds (at least in the current release — 3.16.09) before they can be reused.
microedition.timezone <none> Used to set the timezone when setting the time (with SNTP, for example). The default will probably be "UTC".
sntp.server <none> Address of an SNTP server. The web server will consult the value of this property to set the time at startup.

Recommended 1-Wire Configuration

The 1-Wire API for J2ME Readme says to make sure the following properties are set for proper execution of the library.

Table 5 – 1-Wire configuration
Property Name Default Value Description
onewire.port.default <none> The default port is set to wherever the 1-Wire master resides. For example, "com1" or "com2" are valid values.
os.arch <none> The OS architecture. Can be "saJe" or "JStik", for example.
os.name <none> The OS name. Can be "cldc", for example.
os.version <none> The OS version. Can be "1", for example.

[Top]


2. Including Class.forName Information

Many classes are accessed via Class.forName. For instance, the Servlet container loads servlets this way, and the 1-Wire library searches for device containers using this mechanism. Even the basic protocol classes in the CLDC connection architecture are loaded this way. This section describes which classes need to retain this information, and also how to determine if any additional classes need to be included in this list.

The JVM0.Classpath (or the name of another JVM) panel is used to configure these classes.

Minimum List

These classes are generally needed all the time.

Table 6 – Minimum Class.forName list
Class Description
com.ajile.net.DNSClient Generally some sort of name resolution is desired. For example, it is needed if the mailhost is not specified in the four octet form.
com.qindesign.servlet.DefaultServlet This is required if you have not supplied your own default Servlet.
com.sun.cldc.io.j2me.datagram.Protocol This is required for name resolution and also for SNTP requests.
Note that this may already be included by default.
com.sun.cldc.io.j2me.serversocket.Protocol This is required for creating a server socket that listens for incoming requests.
Note that this may already be included by default.
com.sun.cldc.io.j2me.socket.Protocol This is required for making a conection inside the "mailto" protocol.
Note that this may already be included by default.
com.sun.cldc.io.j2me.mailto.Protocol The mail client code needs this. The HTTP logging code and possibly some servlets will use the "mailto" protocol.

1-Wire Classes

The 1-Wire library needs some classes to be added, according to the 1-Wire J2ME Readme.

Table 7 – Minimum 1-Wire Class.forName list
Class Description
com.dalsemi.onewire.adapter.USerialAdapter Class that communicates with the 1-Wire master. Often this will talk to a DS2480.
com.dalsemi.onewire.container.OneWireContainer The base class for all 1-Wire device containers.

Determining Additional Classes

There will generally be two sets of classes that will need to be added to the Class.forName list. These are Servlet classes, and 1-Wire container classes. There is a third set of classes: those which your own Servlets call using this mechanism, either directly or via the use of additional connection protocols.

Any servlets with a valid mapping need to be added to the list. For example, these are necessary for including the example servlets in your build:

  • com.qindesign.servlet.example.AuthExampleServlet — Authentication example.
  • com.qindesign.servlet.example.DeviceInfoServlet — Device information example.
  • com.qindesign.servlet.example.RequestInfoServlet — Your request information.
  • com.qindesign.servlet.example.OneWireServlet — 1-Wire explorer.
  • com.qindesign.servlet.example.FamilyCode20Include — Used by OneWireServlet for accessing an A/D converter device.
  • com.qindesign.servlet.example.PotentiometerInclude — Used by OneWireServlet for accessing a potentiometer device.
  • com.qindesign.servlet.example.SwitchInclude — Used by OneWireServlet for accessing a switch device.
  • com.qindesign.servlet.example.TemperatureInclude — Used by OneWireServlet for accessing a temperature device.

Any 1-Wire containers that need to be recognized should be included. For example, these are used by some of the above servlets:

  • com.dalsemi.onewire.container.OneWireContainer10 — Temperature container.
  • com.dalsemi.onewire.container.OneWireContainer12 — Switch container.
  • com.dalsemi.onewire.container.OneWireContainer20 — A/D converter container.
  • com.dalsemi.onewire.container.OneWireContainer2C — Potentiometer container.

Lastly, any additional protocol classes used by a call to Connector.open should be added as well.

[Top]


3. Configuring Servlets

The server looks for a resource named "/config/servlets.props" to find the servlet configuration. The distribution stores this as the file res/config/servlets.props. Please consult the Servlet Configuration document for a detailed description this file.

A more detailed discussion about adding resources to your build is in another section on the classpath and resources, but briefly:

To include this resource in your build, create a file named servlets.props inside a directory named config. Add the parent of config to your build classpath, and add the resource "config/servlets.props" to the Resources panel in JemBuilder. Note that there is no leading '/' character.

[Top]


4. Configuring MIME Types

A resource named "/config/mimeTypes.props" is accessed to read the MIME Type configuration. Please consult the MIME Types Configuration document for a description of this file.

A more detailed discussion about adding resources to your build is in another section on the classpath and resources, but briefly:

To include this resource in your build, create a file named mimeTypes.props inside a directory named config. Add the parent of config to your build classpath, and add the resource "config/mimeTypes.props" to the Resources panel in JemBuilder. Note that there is no leading '/' character.

[Top]


5. Resources and Static Content

The default default-Servlet provided with this distribution is able to access any Request-URI with a matching resource. This means that you can include any files and binary content you need by attaching them as resources. The following guide for including these in your build is based on JemBuilder from aJile.

The procedure of including a resource in your build is best described by an example. Say you want the file /images/tree.gif to be accessible to a browser.

  1. First, specify a location for your resources. Let's use the res/http-root/ directory provided with this distribution.
  2. Second, create a directory called images inside the res/http-root/ directory.
  3. Third, place tree.gif inside the new "images/" directory.
  4. Lastly, add http-root/images/tree.gif to the resources list, and also add the full path to "res/" (the parent of http-root/) to the project's classpath.

There are several noteworthy things to point out. First, there should not be a leading '/' character in any of the resources in your resources list. Each resource is accessed as if it already had a '/'. Second, all HTTP-accessible resources should begin with "http-root/". The reason for this is that the server divides the resources into two namespaces: "config" and "http-root". All resources beginning with "config/" are potentially configuration information, and all resources beginning with "http-root/" are candidates for being accessed by an HTTP request.

Lastly, forward slashes, and not backslashes, are always used, as this is how Java accesses resources.

Provided Files

A few files were provided to help get you started with your own content. These are found in the res/http-root directory. The set includes an index.html, the default welcome file.

[Top]