The JCALibrary class is the entry point for all JCA enabled application.
There is only one instance available within a JVM (Java Virtual
Machine) which can be accessed with the static method getInstance().
The two main purposes of the JCALibrary is to provide a centralized
configuration tool for other JCA objects and to act as a Context
factory.
The JCALibrary as a configuration tool.
The JCALibrary holds a set of read-only Properties. These Properties
are loaded at initialization time from different sources.
- Sitewide properties: <jre.home>/lib/JCALibrary.properties
- User's properties: <user.home>/.JCALibrary/JCALibrary.properties
- Command line properties: specified on the command line with
the -D switch.
The properties specified on the command line take precedence over
the user's properties which take precedence over the sitewide properties.
What these properties represent and are going to be used for really
depends on the Objetcs that need them.
Some core JCA objects, like JNI_THREAD_SAFE and JNI_SINGLE_THREADED
contexts, use them to get their default configuration, ie default
communication ports, default thread priorities, etc...
The JCALibrary as a Context factory
The JCA package has been design in such a way that the role of
each JCA component has been dissociated from the real implementation.
This design allows the JCA to evolve without breaking it's contract
with the applications using it.
The JCALibrary offers two methods to create Contexts with very few
knowledge of the specific underlying implementation.
- createContext(String fqn):
This method take a String representing the fully qualified name
of the Context class to instantiate. The class should provide
a public no argument constructor. This is up to the class implementation
to configure itself with sensible default values.
- createContext(Configuration conf):
This method take a Configuration object to create and configure
the context. The fully qualified class name must be specified
as an attribute called "class". The Context instance
will be created using its default no arguments constructor and
the complete Confiuration object will be passed to the Context
if it implements the Configurable interface.
|