foxy.config

The classes in the foxy.config package have all been automatically created by Sun's Java Architecture for XML Binding (JAXB). JAXB creates Java-source-files out of an XML Schema description. The generated Java classes represent the structure of the Schema definition. This not only eases the reading and writing of XML-data, it also ensures that the data is compliant to a certain Schema.

The foxy.config package consists of three sub-packages: rules, patterns and server - each one responsible for the configuration-data of the same name. The classes in the root of these sub-packages are more or less a ''Java-representation'' of the elements described in the corresponding Schema-file. From outside the package, we only have deal with these objects (named after their underlying XML-elements) and do not need to parse the configuration-files by our own.

Figure 2.5 shows an example for reading in the server's (HTTP-request-)patterns configuration file:

Figure 2.5: Reading an XML-file compliant to the W3C XML Schema of the patterns-configuration file-format
\begin{figure}
\begin{small}
\begin{verbatim}
JAXBContext jc =
JAXBContext....
...ew FileInputStream(patternFile));\end{verbatim}
\end{small}
\end{figure}
After ''importing'' the patterns-file into Java (a process called unmarshalling), all data from the XML-file is accessible through the Patterns-structure returned by the Unmarshaller. The Pattern-object has only one public accessible function, getPattern(), which returns an instance of the java.util.List-class that contains a list of Pattern-objects. This procedure is similar to the synchronization of the rules-configuration data. Although we could use these objects directly, we decided to wrap the data into more appropriate data-structures to facilitate the proxy server's runtime-performance. In figure 2.6 we create a Hashtable of PatternMatcher-objects (see section 2.3.2) at runtime after the unmarshalling of the Patterns-element.
Figure 2.6: Example: Wrapping JAXB-created Pattern-objects into FOXY's PatternMatcher class
\begin{figure}
\begin{small}
\begin{verbatim}
...
(foxy.config.patterns...
...ns.put(pm.getHostName(), pm);
}\end{verbatim}
\end{small}
\end{figure}

A more detailed description of structure and usage of the configuration-files can be found in section 2.4.

root 2006-05-22