org.apache.ignite.resources

## Annotation Type ServiceResource

    @Documented
     @Retention(value=RUNTIME)
     @Target(value={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
`String` `serviceName` Service name.

### Optional Element Summary

Optional Elements
`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

    public abstract String serviceName

Service name.

Returns:
  Name of the injected services.

#### proxyInterface

    public abstract 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 as `null`.

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

    public abstract boolean proxySticky

Flag indicating if a sticky instance of a service proxy should be returned. This flag is only valid if `proxyInterface()` is not `null`.

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

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.4.0
Release Date | : March 5 2018