|
GridGain 2.1.0
Java API Specification |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||||
@Documented
@Retention(value=RUNTIME)
@Target(value={METHOD,FIELD})
@Apache20LicenseCompatible
public @interface GridUserResourceAnnotates a field or a setter method for any custom resources injection. It can be injected into grid tasks and grid jobs. Use it when you would like, for example, to inject something like JDBC connection pool into tasks or jobs - this way your connection pool will be instantiated only once per task and reused for all executions of this task.
You can inject other resources into your user resource. The following grid resources can be injected:
GridLoggerResourceGridLocalNodeIdResourceGridHomeResourceGridMBeanServerResourceGridExecutorServiceResourceGridMarshallerResourceGridSpringApplicationContextResourceGridSpringResourceGridInstanceResource
GridUserResource.resourceClass() value. If
If resourceClass is not specified, then field type or setter parameter
type will be used to infer the class type of the resource. Set GridUserResource.resourceClass()
to a specific value if the class of resource cannot be inferred from field or setter
declaration (for example, if field is an interface).
GridUserResourceOnDeployed and GridUserResourceOnUndeployed
annotation for resource deployment and undeployment callbacks). For this
reason resources should not be sent to remote nodes and should
always be declared as transient just in case.
Note that an instance of user resource will be created for every deployed task.
In case if you need a singleton resource instances on grid nodes (not per-task),
you can use GridSpringApplicationContextResource for injecting per-VM
singleton resources configured in Spring.
public class MyGridJob implements GridJob {
...
@GridUserResource
private transient MyUserResource rsrc;
...
}
or
public class MyGridJob implements GridJob {
...
private transient MyUserResource rsrc = null;
...
@GridUserResource
public void setMyUserResource(MyUserResource rsrc) {
this.rsrc = rsrc;
}
...
}
where resource class can look like this:
public class MyUserResource {
...
// Inject logger (or any other resource).
@GridLoggerResource
private GridLogger log = null;
// Inject grid instance (or any other resource).
@GridInstanceResource
private Grid grid = null;
// Deployment callback.
@GridUserResourceOnDeployed
public void deploy() {
// Some initialization logic.
...
}
// Undeployment callback.
@GridUserResourceOnUndeployed
public void undeploy() {
// Some clean up logic.
...
}
}
Documentation
Email Support
Online Forums
Issue Tracking
Author: 2005-2008 Copyright © GridGain Systems. All Rights Reserved. ver. 2.1.0

| Optional Element Summary | |
|---|---|
Class<?> |
resourceClass
Optional resource class. |
public abstract Class<?> resourceClass
|
GridGain 2.1.0
Java API Specification |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||||
|
GridGain - Grid Computing Made Simple, ver. 2.1.0.19122008
2005-2008 Copyright © GridGain Systems. All Rights Reserved. |
|
|