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 .
The IlpClassManager interface provides five methods to manage a class hierarchy:
  • getRootClasses() Returns the root classes of the model in a collection of IlpClass instances. Root classes are classes that do not inherit from another class.
  • getClass(String name) Returns the class called name or null if this class does not exist.
  • getClasses() Returns the classes of the model as a collection.
  • hasClass(IlpClass aClass) Returns true if the given class belongs to this model.
  • hasClass(String name) Returns whether a class with the given name is registered in the manager.

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 initialize 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());
}