Package org.apache.ignite.resources
Annotation Type SpringResource
-
@Documented @Retention(RUNTIME) @Target({METHOD,FIELD}) public @interface SpringResource
Annotates a field or a setter method for injection of resource from SpringApplicationContext. 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 SpringApplicationContextor XML configuration.Note that Spring resources cannot be peer-class-loaded. They must be available in every
ApplicationContextor Spring XML configuration on every grid node. For this reason, if injected into aSerializableclass, they must be declared astransient.The lifecycle of Spring resources is controlled by Spring container.
Examples
Here is how injection would typically happen:public class MyGridJob implements ComputeJob { ... @SpringResource(resourceName = "bean-name") private transient MyUserBean rsrc; ... }orpublic class MyGridJob implements ComputeJob { ... private transient MyUserBean rsrc; ... @SpringResource(resourceName = "bean-name") public void setMyUserBean(MyUserBean rsrc) { this.rsrc = rsrc; } ... }and user resourceMyUserResourcepublic class MyUserResource { ... @SpringResource(resourceName = "bean-name") private MyUserBean rsrc; ... // Inject logger (or any other resource). @LoggerResource private IgniteLogger log; // Inject ignite instance (or any other resource). @IgniteInstanceResource private Ignite ignite; ... }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>
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description booleanrequiredDetermines whether the injection procedure should fail in case no beans with specified name or type are present in the Spring Context.Class<?>resourceClassResource bean class in providedApplicationContextto look up a Spring bean.StringresourceNameResource bean name in providedApplicationContextto look up a Spring bean.
-
-
-
Element Detail
-
resourceName
String resourceName
Resource bean name in providedApplicationContextto look up a Spring bean.- Returns:
- Resource bean name.
- Default:
- ""
-
-
-
resourceClass
Class<?> resourceClass
Resource bean class in providedApplicationContextto look up a Spring bean.- Returns:
- Resource bean class.
- Default:
- org.apache.ignite.resources.SpringResource.DEFAULT.class
-
-