@Documented @Retention(value=RUNTIME) @Target(value={METHOD,FIELD}) public @interface SpringResource
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:
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.
public class MyGridJob implements ComputeJob { ... @SpringResource(resourceName = "bean-name") private transient MyUserBean rsrc; ... }or
public class MyGridJob implements ComputeJob { ... private transient MyUserBean rsrc; ... @SpringResource(resourceName = "bean-name") public void setMyUserBean(MyUserBean rsrc) { this.rsrc = rsrc; } ... }and user resource
MyUserResource
public 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>
Modifier and Type | Optional Element and Description |
---|---|
boolean |
required
Determines whether the injection procedure should fail in case no beans with specified name or type are present
in the Spring Context.
|
Class<?> |
resourceClass
Resource bean class in provided
ApplicationContext to look up
a Spring bean. |
String |
resourceName
Resource bean name in provided
ApplicationContext to look up
a Spring bean. |
public abstract String resourceName
ApplicationContext
to look up
a Spring bean.public abstract Class<?> resourceClass
ApplicationContext
to look up
a Spring bean.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.16.0 Release Date : December 15 2023