The JDAPI session is represented in the API by a class, oracle.forms.jdapi.Jdapi
,
which has a number of static methods for managing the session. The underlying
Forms API must be initialed before any work can be done in JDAPI. By default,
this happens by lazy initialization, that is, as soon as the first functional
API call is made.
There are two additional session modes which can be set at any time:
public static void setFailSubclassLoad(boolean val)
: whether
to ignore subclass load failures on module loadpublic static void setFailLibraryLoad(Boolean val)
: whether
to ignore attached library load failure on module loadPassing false
to either of these methods will cause the JDAPI to
ignore errors on module loading which occur as a result of failing to find subclassed
modules or attached PL/SQL libraries. Passing true
will restore
the default behavior, which is to throw exceptions when these conditions occur.
Note that it is safe to ignore these errors and save the form, since the missing
references will not be lost. However, in these situations you may not be working
with a complete representation of the Form application so you should use these
modes with caution. For example, it may not be possible to compile the Form.
There is a jdapi.shutdown()
method which will end the session and
free Forms resources without ending your process. This allows you to later restart
the session, for example, after default initialization has occurred, or simply
to temporarily free resources if processing Forms is only a part of your running
application.
You are free to shutdown and restart JDAPI as often as required but multiple concurrent sessions are not supported and the API is single-threaded. Also, calling shutdown destroys all the open JDAPI modules and objects.
The following code example illustrates how to start and shutdown a JDAPI session.
import oracle.forms.jdapi.*; /** * Basic example illustrating (lazy) initialization of a Jdapi session. * * Jdapi.startup() needs to be called only because we want to start * the Jdapi in a mode other than its default mode. */
public class JdapiSessionExample { public static void main(String[] args) {// suppress errors from missing subclassed modules
Jdapi.setFailSubclassLoad(false);// suppress errors from missing PLLs
Jdapi.setFailLibraryLoad(false);// This line will cause initialization
FormModule fmb = new FormModule("myform.fmb");// program code goes here
...// finally, free API resources
Jdapi.shutdown(); } }