Context and Deployment Descriptor > The Context Services > Class Manager

The class manager is defined by the interface IlpClassManager. It handles a hierarchy of business classes. Some of the classes stored in the class manager can be loaded dynamically from a file where they are defined. For details, see Business Class Manager API in the Business Objects and Data Sources documentation.

The IlpClassManager interface provides five methods to manage a class hierarchy:

How to Retrieve Information About Business Class IltNetworkElement

The following code extract shows how to retrieve information about the business class IltNetworkElement:

IlpContext context = IltSystem.GetDefaultContext();
IlpClassManager classMgr = context.getClassManager();
IlpClass bclass = classMgr.getClass("ilog.tgo.model.IltNetworkElement");

By default, the class manager service is implemented by the class IltDefaultClassManager. This default implementation stores dynamic classes, makes it possible to load classes from XML files and creates dynamic classes to represent JavaBean classes using introspection.

The default class manager service can be customized through the deployment descriptor file using the tag <classManager>.

All the files listed in the classManager scope are loaded in the default class manager implementation, and are therefore recognized as business classes within the application context.

How to Customize the Default Class Manager Through the Deployment Descriptor

The following example is an extract of <installdir>/samples/table/customClasses/deploy.xml and illustrates how you can customize your class manager in the deployment descriptor file:

<classManager>
    <!-- Register custom classes -->
    <file>customClasses.xml</file>
</classManager>

where <file> is the business class file that will be loaded in the class manager at initialization time.

How to Initialize the Class Manager service Through the API

The following code extract shows how to intialize the Class Manager service through the API:

IlpDefaultContext context = ...;
// Create a new class manager instance
IltDefaultClassManager classMgr = new IltDefaultClassManager();
 
// Set the new service in the context
context.addService(IlpClassManager.class, classMgr);
How to Customize the Class Manager service Through the API

The following code extract shows how to customize the Class Manager service through the API:

// Load a model file in the class manager. To do this, the class manager
// needs to use two services: type converter, URL access service - which can
// be retrieved from the context
try {
  classMgr.parse("model.xml", context.getTypeConverter(),
      context.getURLAccessService());
}