Package org.apache.ignite.resources
Annotation Type ServiceResource
-
@Documented @Retention(RUNTIME) @Target({METHOD,FIELD}) public @interface ServiceResource
Annotates a field or a setter method for injection of Ignite service(s) by specified service name. If more than one service is deployed on a server, then the first available instance will be returned.Here is how injection would typically happen:
public class MyGridJob implements ComputeJob { ... // Inject single instance of 'myService'. If there is // more than one, first deployed instance will be picked. @IgniteServiceResource(serviceName = "myService", proxyInterface = MyService.class) private MyService svc; ... }
or attach the same annotations to methods:public class MyGridJob implements ComputeJob { ... private MyService svc; ... // Inject all locally deployed instances of 'myService'. @IgniteServiceResource(serviceName = "myService") public void setMyService(MyService svc) { this.svc = svc; } ... }
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description String
serviceName
Service name.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description boolean
forwardCallerContext
Flag indicating that the service call context should be passed to the injected service.Class<?>
proxyInterface
In case if an instance of the service is not available locally, an instance of the service proxy for a remote service instance may be returned.boolean
proxySticky
Flag indicating if a sticky instance of a service proxy should be returned.
-
-
-
Element Detail
-
serviceName
String serviceName
Service name.- Returns:
- Name of the injected services.
-
-
-
proxyInterface
Class<?> proxyInterface
In case if an instance of the service is not available locally, an instance of the service proxy for a remote service instance may be returned. If you wish to return only locally deployed instance, then leave this property asnull
.For more information about service proxies, see
IgniteServices.serviceProxy(String, Class, boolean)
documentation.- Returns:
- Interface class for remote service proxy.
- Default:
- java.lang.Void.class
-
-
-
proxySticky
boolean proxySticky
Flag indicating if a sticky instance of a service proxy should be returned. This flag is only valid ifproxyInterface()
is notnull
.For information about sticky flag, see
IgniteServices.serviceProxy(String, Class, boolean)
documentation.- Returns:
True
if a sticky instance of a service proxy should be injected.
- Default:
- false
-
-