The Map Component

Search XAP 7.0
Searching XAP 7.0.X Documentation
Browse XAP 7.0
Offline Documentation

Download latest offline documentation in HTML format:
xap-7.0.2-documentation.zip (12.3MB)

                                                              

Summary: A Map component allows you to create an IMap (or JCache Cache) based on a Space component.

Overview

GigaSpaces allows applications to interact with the space using the Map API (JCache). Accessing the space via the Map API can be done using the Cache or IMap interfaces. The com.j_spaces.map.IMap is an extension of the com.j_spaces.javax.cache.Cache interface, and includes enhanced options such as transaction support, timeout operations (blocking read), and versioning.


OpenSpaces provides a simplified option to create an IMap or Cache implementation based on the Space component. Here is an example of how it can be configured:

Map/JCache API vs. Space API

Expand this...

Clustered Flag

When configuring a Space, an IJSpace instance is registered with Spring application context. When starting an embedded space with a cluster topology, or when looking up a remote space started with a cluster topology, a clustered proxy is returned. A clustered proxy is a smart proxy that performs operations against the whole cluster.

Many times, especially when working with a Processing Unit that starts an embedded space, operations against the space should be performed directly on the cluster member. This is a core concept of SBA and Processing Unit, where most if not all operations should be performed in-memory without leaving the Processing Unit boundaries, when a Processing Unit starts an embedded space.

The decision of working directly with a cluster member or against the whole cluster is done in the Map component level. The MapFactoryBean provides a clustered flag with the following logic as the default value: If the space is started in embedded mode (for example, /./space), the clustered flag is set to false. When the space is looked up in a remote protocol (Jini or RMI), the clustered flag is set to true. Naturally, the flag can be set explicitly. Here is an example of how the clustered flag can be configured:

The above example shows a typical scenario where the clustered flag is used. Within a Processing Unit, an application might need to access both the cluster member and the whole cluster directly.

Local Cache

A Map implementation can be constructed with Local Cache support.

Here is an example of how it can be configured:

Once the local cache support element/bean is provided, a Map with local cache support is constructed.

Working with Map Component

The following bean uses an IMap component for simple put and get operations:

public class SimpleMapUsage {

    private IMap map;

    public void setMap(IMap map) {
        this.map = map;
    }
    
    public void performPutAndGet() {
        map.put("key1", "value1");
        String value1 = (String) map.get("key1");
    }
}

Here is how it can be configured:

The Map component has an extremely simple API. The GigaMap simplifies it even more by wrapping it and providing declarative transaction support and other features.

IMPORTANT: This is an old version of GigaSpaces XAP. Click here for the latest version.

Labels

 
(None)