GridGain™ 3.6.0e
Enterprise Edition

org.gridgain.grid.resources
Annotation Type GridSpringResource


@Documented
@Retention(value=RUNTIME)
@Target(value={METHOD,FIELD})
public @interface GridSpringResource

Annotates a field or a setter method for injection of resource from Spring ApplicationContext. Use it whenever you would like to inject resources specified in Spring application context of XML configuration.

Logger can be injected into instances of following classes:

Resource Name

This is a mandatory parameter. Resource name will be used to access Spring resources from Spring ApplicationContext or XML configuration.

Note that Spring resources cannot be peer-class-loaded. They must be available in every ApplicationContext or Spring XML configuration on every grid node. For this reason, if injected into a Serializable class, they must be declared as transient.

The lifecycle of Spring resources is controlled by Spring container.

Examples

Here is how injection would typically happen:
 public class MyGridJob implements GridJob {
      ...
      @GridSpringResource(resourceName = "bean-name")
      private transient MyUserBean rsrc;
      ...
      @GridUserResource
      private transient MyUserResource rsrc;
      ...
  }
 
or
 public class MyGridJob implements GridJob {
     ...
     private transient MyUserBean rsrc;
     ...
     @GridSpringResource(resourceName = "bean-name")
     public void setMyUserBean(MyUserBean rsrc) {
          this.rsrc = rsrc;
     }
     ...
 }
 
and user resource MyUserResource
 public class MyUserResource {
     ...
     @GridSpringResource(resourceName = "bean-name")
     private MyUserBean rsrc;
     ...
     // Inject logger (or any other resource).
     @GridLoggerResource
     private GridLogger log;

     // Inject grid instance (or any other resource).
     @GridInstanceResource
     private Grid grid;
     ...
 }
 
where spring bean resource class can look like this:
 public class MyUserBean {
     ...
 }
 
and Spring file
 <bean id="bean-name" class="my.foo.MyUserBean" singleton="true">
         ...
 </bean>
 

Wiki & Forum:


Wiki
Forum

 

Required Element Summary
 String resourceName
          Resource bean name in provided ApplicationContext to look up a Spring bean.
 

Element Detail

resourceName

public abstract String resourceName
Resource bean name in provided ApplicationContext to look up a Spring bean.

Returns:
Resource bean name.

GridGain™ 3.6.0e
Enterprise Edition

GridGain - Real Time Big Data
Enterprise Edition, ver. 3.6.0e.13012012
2012 Copyright © GridGain Systems
Follow us:   Follow GridGain on Github Follow GridGain on Facebook Join GridGain User Group Follow GridGain on Twitter Follow GridGain on YouTube