Publishing Engine Programmer's Guide > The Arbortext Publishing Engine Sub-Process > Writing Arbortext PE Applications in Java > Initialization
  
Initialization
When an Arbortext PE Application Context receives a request, it first determines that the request specifies f=java, then examines the class parameter to see if this is the first time the class has been invoked since the Arbortext PE sub-process started. If so, the Arbortext PE Application Context loads the Java class into the Arbortext PE sub-process's embedded Java Virtual Machine. In order for this to happen, the Arbortext PE Application class must be present in a custom\classes directory either as a .class file or as a member of a .jar file. After loading the application, the Arbortext PE Application Context calls its init method and passes a parameter specifying an instance of com.arbortext.e3.E3ApplicationConfig, allowing the Arbortext Publishing Engine application to access configuration information from e3config.xml. The configuration parameters include the global parameters plus any other parameters defined for the Arbortext PE sub-process pool, both defined in e3config.xml.
If initialization succeeds and the init method returns normally, then the Arbortext PE Application Context passes the request to the Java application's doGet or doPost method.
If any error is detected, the init should throw an exception. In that case, the Arbortext PE Application Context will return an error to the Arbortext PE Request Manager.
If a Java Arbortext PE Application initializes successfully, the Arbortext PE ApplicationContext will retain a reference to the application object. If the Arbortext PE Request Manager sends another request for the same application, the Arbortext PE Application Context will again invoke the doGet or doPost method. The Arbortext PE Application Context will not create another instance of the application object, nor will it call the application’s init method again.
If a Java application fails to initialize (meaning its init method throws an exception), the Arbortext PE Application Context will discard the application object. It will not call the object's destroy method. If the Arbortext PE Request Manager sends another request for the same application, the Arbortext PE Application Context will allocate another new object and call its init method. Depending on the condition which caused the first call to throw an exception, this attempt could succeed or throw another exception.