XAP

Grid Metadata

GigaSpaceContext

Attribute Annotation @GigaSpaceContext
Description In previous Spring releases, Spring only allowed you to inject the GigaSpace instance using setter injection or constructor injection. GigaSpaces extended this injection mechanism by allowing you to use annotations to inject a GigaSpace instance. As of Spring 2.5, this is no longer required since Spring support annotation based injection using the @Resource or @Autowired annotations.

//There can be more than one GigaSpace instance defined

public class MyService {

    @GigaSpaceContext(name="directGigaSpace")
    private GigaSpace directGigaSpace;

    @GigaSpaceContext(name="clusteredGigaSpace")
    private GigaSpace clusteredGigaSpace;
}

There is no need to have a setter for the GigaSpace instance, and by annotating it with GigaSpaceContext, a GigaSpace instance is automatically injected. In order to enable this feature, the following element needs to be configured in the Spring application context:


 <os-core:giga-space-context/>

 <os-core:embedded-space id="space" space-name="mySpace"/>

 <os-core:giga-space id="directGigaSpace" space="space"/>

 <os-core:giga-space id="clusteredGigaSpace" space="space" clustered="true"/>

 <bean id="myService" class="eg.MyService" />

 <bean id="gigaSpaceContext" class="org.openspaces.core.context.GigaSpaceContextBeanPostProcessor" />

 <bean id="space" class="org.openspaces.core.space.EmbeddedSpaceFactoryBean">
     <property name="name" value="space" />
 </bean>

 <bean id="directGigaSpace" class="org.openspaces.core.GigaSpaceFactoryBean">
    <property name="space" ref="space" />
 </bean>

 <bean id="clusteredGigaSpace" class="org.openspaces.core.GigaSpaceFactoryBean">
    <property name="space" ref="space" />
    <proeprty name="clustered" value="true" />
 </bean>

 <bean id="myService" class="eg.MyService" />

GigaSpaceLateContext

Class Annotation
Attribute Annotation @GigaSpaceLateContext
Description GigaSpaces allows you to define beans (such as filters), that are later injected to the actual space. If such beans require access to the GigaSpace instance, a cyclic dependency occurs (GigaSpace requires the SpaceClosed Where GigaSpaces data is stored. It is the logical cache that holds data objects in memory and might also hold them in layered in tiering. Data is hosted from multiple SoRs, consolidated as a unified data model., but the Space requires the filter injection). GigaSpaces allows you to use the same annotation-based injection mechanism in order to inject the GigaSpace instance at a different lifecycle stage.
public class MyService {

    @GigaSpaceLateContext
    private GigaSpace gigaSpace;

}

There is no need to have a setter for the GigaSpace instance, and by annotating it with GigaSpaceLateContext, a GigaSpace instance is automatically injected. In order to enable this feature, the following element needs to be configured in the Spring application context:


<os-core:giga-space-late-context/>

<os-core:embedded-space id="space" space-name="mySpace"/>

<os-core:giga-space id="gigaSpace" space="space"/>

<bean id="myService" class="eg.MyService" />

<bean id="gigaSpaceContext" class="org.openspaces.core.context.GigaSpaceLateContextBeanPostProcessor" />

<bean id="space" class="org.openspaces.core.space.EmbeddedSpaceFactoryBean">
    <property name="name" value="space" />
</bean>

<bean id="gigaSpace" class="org.openspaces.core.GigaSpaceFactoryBean">
    <property name="space" ref="space" />
</bean>

<bean id="myService" class="eg.MyService" />

ClusterInfoContext

Attribute Annotation @ClusterInfoContext
Description This annotation injects cluster information into the class.
public class Process {

    @ClusterInfoContext
    ClusterInfo  clusterInfo;

    Integer instanceId = clusterInfo.getInstanceId();
}