Accessor SPI

The Accessor SPI provides typed access to the state document model. It allows the programmer to query and modify navigational state information. The Accessor SPI is part of the package com.ibm.portal.state.accessors.*.

The Accessor SPI is an abstract layer surrounding the access to particular nodes in the hierarchical document model; see Object Model for additional information about the hierarchical document model. For each state aspect such as, but not limited to, page selection, expansion states, and portlet states, the SPI offers an accessor factory that provides read-only and read-write accessor controls that are designed for the particular state aspect they refer to. The accessors read from or write to the respective positions in the state document model and perform required type conversions.

The navigational state information is located in the state document model and is available when the accessor factory is used. After the node is located, the accessor factory passes a node reference to the accessor or accessor controller during. The accessor and accessor controller are independent from the state document model structure; you can reuse accessors even if the information is moved to another node in the state document.

For example, the SelectionAccessorFactory offers the following interfaces:

SelectionAccessor getSelectionAccessor(StateHolder)

SelectionAccessorController getSelectionAccessorController(StateHolderController)

The flyweight pattern – the StateHolder or StateHolderController is used as an argument – is commonly used in the accessor factory interfaces. The navigational state the accessor operates on may not be the base state retrieved from the request URL; typically, it is the state clone created for a particular EngineURL. Call getState() on the EngineURL object to obtain the URL-specific state holder. The following example shows how to let a created EngineURL point to a certain portal page (for example, the “Stock Market” page) using the SelectionAccessorController:

final EngineURL url = ...;
final SelectionAccessorFactory selectionFct = ...;
 
final SelectionAccessorController selectionCtrl = 
    selectionFct.getSelectionAccessorController(url.getState());
 
try {
    selectionCtrl.setSelection(“wps.StockMarket”);
} catch (StateException e) {
    // include error handling here
} finally {
    selectionCtrl.dispose();
}


Use the SelectionAccessorController to create a page link

The base Accessor interface is derived from the com.ibm.portal.Disposable interface. Invoke the dispose() method to indicate when the accessor is no longer required. Using the dispose() method allows the accessor factory to store the accessors and accessor controllers in object pools to achieve better performance (due to less initialization and garbage collection overhead).

The Navigational State SPI offers the following accessor factories, each covering a certain state aspect:

SelectionAccessorFactory

PortletAccessorFactory

PortletTargetAccessorFactory

SoloAccessorFactory

ThemeTemplateAccessorFactory

LocaleAccessorFactory

ExpansionStatesAccessorFactory

ShowToolsAccessorFactory

StatePartitionAccessorFactory

EngineActionAccessorFactory


Parent

Navigational State SPI

 


+

Search Tips   |   Advanced Search