Publishing Engine Programmer's Guide > PTC Arbortext Publishing > Arbortext Publishing Engine Server Composer > Arbortext Publishing Engine Server Composer
  
Arbortext Publishing Engine Server Composer
The PE Server Composer is a Java object of a class implementing the interface com.arbortext.e3c.E3ServerComposer. A Server Composer object is instantiated the first time the Publishing Application processes a request with a composer-class parameter that specifies the Server Composer's class name. The Server Composer is essentially a filter intended to transform a JAR file of input data to a JAR file of output data.
The PE Client Composer code always specifies the Server Composer class name as com.arbortext.e3c.ServerComposer.
The Arbortext Publishing Engine Server Composer's primary method is:
File doCompose( File inputJar );
The inputJar parameter specifies a JAR file transmitted from the Arbortext Editor client. The return value is a File object naming a JAR file to be returned to the client.
A Server Composer also exports a default constructor and a destroy method, and neither takes any arguments. The distributed Server Composer allocates a working directory in its constructor and deletes the directory and its content in its destroy method.
In its doCompose method, the PE Server Composer begins by searching its input JAR file for an entry named index.xml, which it parses into a com.arbortext.e3c.E3ServerCompositionRequest object. Before continuing, it looks for the name of the PE Server Composition Extension it will call later (by retrieving the value of the parameter e3.serverCompositionExtension) and checks that the underlying object has been instantiated.
The PE Server Composer creates directories named source and target in the transaction directory allocated by the Arbortext PE Request Manager to handle the publishing request. Then PE Server Composer restores its input JAR archive to the source directory.
Next, the PE Server Composer creates an empty property map (see the AOM interface com.arbortext.epic.PropertyMap in the Programmer's Reference) and copies parameter names and values from the E3ServerCompositionRequest object to the property map. Each parameter has a type of either string, file, or entry. The Server Composer copies the value of string parameters. For file parameters, it checks whether the parameter value specifies the absolute path to an existing file, and fails with an error message if the file isn't found. For entry parameters, it checks to make sure that the JAR file entry specified by the parameter value has been restored to a file in the source directory. If so, it replaces the parameter value with the absolute path to the restored entry. If not, it issues an error message and fails.
Next, the PE Server Composer allocates an empty result object (see the Javadoc for the interface com.arbortext.e3c.E3ServerCompositionResult). Then it calls the Server Composition Extension specified by the client, which does the real publishing work.
When the Server Composition Extension returns, the PE Server Composer serializes the result object to the file result.xml in the output directory. Then it compresses the output directory into a JAR archive and writes the archive to the file that will be returned as the HTTP response body. The PE Server Composer then returns to its caller, which returns to the Arbortext PE Request Manager, which returns the response to the Client Composer on the client machine.
Note that the Server Composer does not need to delete its source and target directories. They are created in the transaction directory managed by the Arbortext PE Request Manager. After the Arbortext PE Request Manager returns the response to the client, it may be configured to save the transaction directory as a zip archive in the transaction archive and then delete the transaction directory, including the source and target directories. Consult the Configuration Guide for Arbortext Publishing Engine for information.