This page describes an older version of the product. The latest stable version is 16.3.
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. XAP 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:
XAP 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 Space, but the Space requires the filter injection). XAP 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: