In this post I will describe what is module storage and how to use it.
Module storage service enables storage and retrieval of the module instance’s runtime content. This storage service is designed only for module instances. Other components, such as module templates, should not use it.
Every module instance can use this service, when the lifecycle of the storage is handled by the service itself, so that module instances do not need to create or delete the storage. The storage is automatically created on the first request, and destroyed when the instance is deleted from the workspace (when a module is removed from a workspace, its storage is removed automatically). However, you can destroy the storage explicitly.
It provides significant benefits in terms of performance and maintenance, rather than PCD storage directly in the iView properties.
Today in enterprise workspaces, we use module storage in the TextPad, Link-List and Document List modules in order to save texts, links, etc.
Another benefit is that during workspace transport, the storage of each module is included in the transport package.
How is the content saved in module storage?
The content is saved as a stream.
Let’s look at the following link list module and check how the content is saved in module storage:
Now, let’s take a look at the public interfaces:
Provides storage for the runtime content of a module instance.
Enables storage and retrieval of the module instance’s runtime content.
As an example let’s take this piece of code which illustrates how to access and use module storage using the public interfaces mentioned above:
private void storeModuleRuntimeContent(IPortalComponentRequest request)
// Get module storage factory
IWorkspacesRuntime workspacesRuntime = RuntimeFactory.getWorkspacesRuntime();
IModuleStorageFactory storageFactory = (IModuleStorageFactory)
IModuleContext moduleContext = ModuleHelper.getModuleContext(request);
//Returns the storage for this module instance; if the storage does not exist, creates it
IModuleStorage storage = storageFactory.getStorage(moduleContext);
// Get string content
String value = storage.getProperty(“key”);
// Store string content
// Store binary property
byte myBinaryData = “myBinaryData”.getBytes();
storage.setBinaryProperty(“key”, new ByteArrayInputStream(myBinaryData));
Go back to: A Deep Dive into SAP NetWeaver Portal, Enterprise Workspaces (Main TOC blog)