Code Modules

A code module is Content Engine object that contains one or more Java action handlers and any supporting libraries. The easiest way to create a code module is with Administration Console for Content Platform Engine. You can, however, create CodeModule objects programmatically by using the Content Engine API.

For deploying an action handler in an enterprise production environment, it is more efficient to store the action handler as a CodeModule object than reference it in the class path of your application server. Code modules are automatically available when the Content Engine is deployed to multiple application server instances, or moving your content metadata from one system to another. If you reference action handlers in the JVM class path, you must manually distribute them to new systems.

Other code module characteristics are as follows:

  • A code module applies to a single object store; that is, it can only be referenced only by a Action subobject stored on the same object store as the code module. Therefore, if you want to use the same code module in multiple object stores, you need to create the code module for each object store. However, an action handler that is referenced in the JVM class path is available to all object stores running in the JVM, including newly created object stores.
  • A code module loads classes from itself first. If a supporting library is both contained in a code module and referenced in the class path, the code module uses the library that is contained in itself. If the supporting library is not contained in the code module, the code module uses the library that is referenced in the class path.
  • A library that is contained in a code module is not available to an action handler referenced in a class path. To be available to the action handler, the library must also be referenced in the class path.
  • Supporting libraries that are included in a CodeModule object are only visible to the classes contained in that CodeModule object; they are not visible to classes contained in other CodeModule objects. For example, the same library that is required by two separate CodeModule objects must be included separately in the two objects.
  • For maintenance purposes, it is easier to reference a common library in the class path rather than duplicate it in multiple CodeModule objects.
  • The code module class loader cannot load classes from nested jar files. Dependent jar files need to be added as separate content elements. To use multiple dependent jar files, you must place each jar file in a separate content element of the CodeModule object.