+

Search Tips   |   Advanced Search

Making modifications using the Controller SPI


The Controller SPI allows us to modify portal resources, the topology of the portal, and properties.

The following topics describe how we use the Controller SPI for different types of modifications. Some topics provide example code snippets. For these snippets to work, they need to be completed with preceding and subsequent code. Examples are shown in the following.

Preceding code: Each snippet must be preceded at least by the following code:

ContentModelController cmController= null;
final Context ctx = new InitialContext();
final ContentModelControllerHome home = (ContentModelControllerHome)        ctx.lookup(ContentModelControllerHome.CONTENT_MODEL_CONTROLLER_JNDI_NAME);
if (homeĀ != null) {
      cmController = home.getContentModelControllerProvider().
           createContentModelController(aContentModel);
}
Depending on the modification to make, we might require additional preceding code statements. For more details refer to Obtaining a controller for working with resources.

Subsequent code: After you have completed the modifications, you commit the controller so that the modification take effect. Aftethat we cannot use or commit the controller any more, but you dispose it. To commit the modifications and dispose the controller, add the following statements to the code:

// commit the controller
try {
    controller.commit();
} finally {
    controller.dispose();
}
For more details about this refer to Committing and persisting the modifications.


Parent: Controller SPI
Related:
Packages of the Controller SPI
Work with controllers
Confirming modifications
Tips for using the Controller SPI
Related:
Obtaining a controller for working with resources
Committing and persisting the modifications