Entering content frame

Function documentation Class Loader References Locate the document in its SAP Library structure

Use

Class loaders in SAP J2EE Engine use the reference model. This delegation model extends the default “delegate-to-parent” to comply with the application environment. Thus we can easily state dependencies between components and applications that are equal in rights.

With references, the constraint that one class loader can only load classes from its direct parents is omitted. When there is a reference from loader A to loader B (A ® B), this means that after loader A has unsuccessfully delegated the loading of a class to its parents, A tries to load the class through B. If the class is residing in B, it will be loaded and returned to A.

The references are registered in the ClassLoader Manager. Each loader has a unique name. The naming convention for component’s loader name is followed from the Service Manager while the application’s loader is named from the Deploy Service.

There is no limit for the number of references each loader can register. From a class loading point of view, each reference has equal weight.

The following reference types are available – notify, weak, hard, and strong. These types are used by the Service Manager only to manage the component’s startup order and their integrity. For the class loader itself, every reference has only one meaning – an attempt to load classes through the referee class loader.

The reference model is not transitive. Even if you have A ® B and B ® C references, A cannot directly load classes from C. If A depends on C, it will have to explicitly state the reference A ® C.

The circularity of references is allowed, but only for services, libraries, and interfaces. If you have the A ® B and B ® A references, the Service Manager creates a single class loader which serves as class loader for both A and B components. Its name is “common:A;B”. When you have a loader name that starts with “common:” this means that between the loaders that follow this prefix, there is a circularity dependency. In such cases, the common loader gets all references and resources of the cycle participants.

Recommendation

Even it is allowed, it is not recommended to use cycles between server components (services, libraries and interfaces). It is better for those server components that are mutually dependent to be one component.

 

Caution

Applications cannot participate in cycles. Every reference to an application is deprecated and strongly prohibited.

 

For more information about working with class loader references, see Class Loading System in the Administration Manual.

 

Leaving content frame