Initializing and preparing the Java API
Before you begin configuring document specifications and
generating documents, you must initialize the Java™ API and select a logging method.
Procedure
- Required: Select a method for initializing
the API:
- Automatically: The RPE_HOME environment variable is used to identify the path to the config and source directories in the Rational® Publishing Engine installation.
- Programmatically: Set the path to the config and source directories in the Rational Publishing Engine installation by using AppUtils.setProductHome(path).
Tip: Initializing the API programmatically is the recommended method. When you initialize the API programmatically, the application is shipped with config and source directories rather than relying on the directories in the Rational Publishing Engine installation. - Optional: Select a method for logging:
- Configure Rational Publishing Engine to
use the logger in your application:
- Create an instance of the org.apache.commons.logging.Log class for logging.
- If your application does not use common logging, you can provide Rational Publishing Engine with an instance of a class implementing the IRPELogger interface. This class transforms Rational Publishing Engine logging calls into calls to the logging for your application.
- Configure the Rational Publishing Engine logger
in your application:
- Use the Rational Publishing Engine logger
in your application. Example:
AppUtils.getLogger().info( "Starting RPE"); - Configure the Log4j logger before using any Rational Publishing Engine function:
- If the log4j.properties file is in the root
folder of your project, initialize the Log4j logger by:
PropertyConfigurator.configure( this.class.getClassLoader().getResource("./log4j.properties")); - If the log4j.properties file is not in the
root folder of your project, initialize the Log4j logger by:
PropertyConfigurator.configure( new File( AppUtils.getConfigFilePath(), "log4j.properties").getAbsolutePath());
- If the log4j.properties file is in the root
folder of your project, initialize the Log4j logger by:
- Use the Rational Publishing Engine logger
in your application. Example:
- Configure Rational Publishing Engine to
use the logger in your application:
- Optional: Connect to progress notifications. The report generators can be sent notification messages through RPEListener. These messages are the same messages that the Launcher application displays in the progress window while a document is generating.
Related tasks:
Feedback