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.
Annotation
//There can be more than one GigaSpace instance definedpublicclassMyService{@GigaSpaceContext(name="directGigaSpace")privateGigaSpace directGigaSpace;@GigaSpaceContext(name="clusteredGigaSpace")privateGigaSpace 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:
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 Space, 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.
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: