| Introduction | How to use | ClassLoader | Serialization | Reflection | Attributes | Mechanism |
Through the build in Metainformation of ACDK classes can be loacated
and loaded by name.
To load a class via name at runtime, the class has to be compiled
with meta info.
See also: man acdkmc.
With the method
static acdk::lang::Class::forName(IN(RString) className);
a class can be located.
With the method
RObject acdk::lang::Class::newInstance(); a new Instance
of this object can be created as long there is a public default constructor or the
class implements the method
static RObject create_instance().
Classes of one branch in the namespace are organized in a package
and compiled in to one shared library / DLL can be found and loaded at runtime.
The standard acdk::lang::ClassLoader of ACDK try to locate the shared library
in the ACDKHOME/bin directory.
For instance you can load a Class this way:
Class::forName look if class already loaded. In this case returns the Class.
If not try to find a
If not found this library then try to find
acdk_security.dll/.so can be found in
$ACDKHOME/bin the library
will be loaded. At load time all ACDK classes are registered into
the local ACDK class registry.
The Class can be returned.
RClass digestclass = Class::forName("acdk/security/SHAMessageDigest");
With the Class instance a new object instance can be created,
and can be casted to a known interface (here MessageDigest).
RMessageDigest digest = (RMessageDigest)digestclass->newInstance();
Sometime the name of a shared library doesn't reflect the class name.
For example the class org::w3c::dom::Node cannot be found in a shared
library named like org_w3c*, but in the shared library org_xml*.
Therefore aliases can be defined in the
$ACDKHOME/cfg) as a map
# define an alias for a given namespace to a library name
# used by the classloader to find the shared library for
# a given class. This sample load the libary org_xml if searching
# for mapped org.w3c.*