Publishing Engine Programmer's Guide > The Arbortext Publishing Engine Request Manager > Predefined Dynamic Components > Predefined Cache Managers > The Publishing Configuration Cache, Initializer, and Application
  
The Publishing Configuration Cache, Initializer, and Application
The publishing configuration cache contains information about the publishing-related files installed on the Arbortext PE server. The cache stores an XML document listing the document types, stylesheets, and related configuration information retrieved during initialization. It also stores an HTML version of the XML document, a second XML document containing more detail (which is retrieved by Arbortext Editor when performing a publishing configuration comparison with the Arbortext PE server), and a text log file of the scan process by which the information was discovered. The documents are intended for debugging, and three of them can be retrieved from the Arbortext Publishing Engine Index page.
Support for the cache is implemented in three parts.
1. the cache itself, which stores the documents so that they can be returned quickly.
2. the initializer, which generates the information in the cache when the Arbortext PE Request Manager initializes by obtaining an Arbortext PE sub-process and running the next component.
3. a Java Arbortext PE Application, com.arbortext.e3ci.Application, which is running in the Arbortext PE sub-process.
These components provide useful functionality and offer an example of how to implement a cache manager for other purposes. The publishing configuration cache is implemented by the com.arbortext.e3.CompConfigCache class. It takes one parameter, query-function-prefix, that has a default value of f.
When the Arbortext PE Request Manager calls the cache's init method, the cache initializes itself to an empty state, and obtains and remembers the value of its query-function-prefix parameter (if any).
When the Arbortext PE Request Manager calls the cache's search method, the cache manager examines the HTTP request being processed.
If the request has an HTTP parameter named bypass-cache with a value of yes (not case sensitive), then search returns not cacheable.
If the request has a parameter whose name is equal to the value of the query-function-prefix parameter and with the value java, a parameter named class with the value com.arbortext.e3ci.Application, and a parameter named type with a value of xml, html, or log, then search returns either in cache or cacheable, depending upon whether the requested document has been placed in the cache yet.
Otherwise search returns not cacheable.
When the Arbortext PE Request Manager calls the cache's search method and receives a cacheable response, it calls the cache method to store the associated response as the XML, detailed XML, HTML, or log document, which will be return for future calls to the search method.
The publishing configuration initializer is implemented by the com.arbortext.e3.CompConfigInit class. It runs as a deferred initializer so that the rather lengthy publishing configuration scan will not unduly slow the launch of the Arbortext PE Request Manager. When its init method is called by the Arbortext PE Request Manager, it uses services provided by the Arbortext Publishing Engine Request Context to create and run the dummy HTTP requests. These requests generate the XML, detailed XML, HTML, and text log forms of the publishing configuration document. The three requests are:
f=java&class=com.arbortext.e3ci.Application&type=xml
f=java&class=com.arbortext.e3ci.Application&type=html
f=java&class=com.arbortext.e3ci.Application&
type=log&trace-level=2
Each request is processed by the Arbortext Publishing Engine Request Handler as if it were received from the network. The Arbortext Publishing Engine Request Handler will follow its normal request handling procedure, which will result in each request being passed to:
the publishing configuration cache manager (which will return cacheable)
the predefined request handler (explained in Predefined Request Handlers) which will recognize each request as a request for an Arbortext PE Application and allocate an Arbortext PE sub-process to do the work
the publishing configuration cache manager (using the cache method) to store each response in the cache.
The publishing configuration initializer takes one parameter, debug. If the debug parameter has any value other than true, the initializer adds the HTTP query parameter console-log=no to the type=log request. The console-log=no suppresses writing the publishing configuration scan to the Arbortext Diagnostics window.
The Java Arbortext PE Applicationcom.arbortext.e3ci.Application is an Arbortext PE Application that scans the Arbortext Publishing Engine install tree for publishing information and returns a report in an XML, HTML, or log file as requested. If the application is subsequently invoked (for example, once for an XML document, then for an HTML document, and again for a log file), it does not repeat its scan, because it caches the information it discovers the first time and simply reformats it on subsequent requests.
There are a couple of potential race conditions in the operation of the publishing configuration cache, initializer, and application.
a client might request any of the three documents before the initializer has time to complete, which can result in two copies of the application running simultaneously in separate Arbortext PE sub-processes.
the Arbortext PE Request Manager cannot guarantee that all three of the requests generated by the initializer will be allocated to the same Arbortext PE sub-process. If each request runs in a different Arbortext PE sub-process, the application's ability to cache the results of a prior scan won't come into play, and the scan will be repeated several times, once in each Arbortext PE sub-process.
Both possibilities will result in slowing the Arbortext PE server startup but have no otherwise harmful effects.