org.apache.ignite.internal.processors.platform.services

## Class PlatformAbstractService

- java.lang.Object
- - org.apache.ignite.internal.processors.platform.services.PlatformAbstractService

All Implemented Interfaces:
  Externalizable, Serializable, PlatformService, Service

Direct Known Subclasses:
  PlatformDotNetServiceImpl

    public abstract class PlatformAbstractService
    extends Object
    implements PlatformService, Externalizable

Base platform service implementation.

See Also:
  Serialized Form

### Field Summary

Fields
`protected PlatformContext` `platformCtx` Context.
`protected long` `ptr` Pointer to deployed service.
`protected boolean` `srvKeepBinary` Whether to keep objects binary on server if possible.
`protected Object` `svc` .Net binary service.

### Constructor Summary

Constructors
Constructor and Description
`PlatformAbstractService()` Default constructor for serialization.
`PlatformAbstractService(Object svc, PlatformContext ctx, boolean srvKeepBinary)` Constructor.

### Method Summary

Methods
`void` `cancel(ServiceContext ctx)` Cancels this service.
`void` `execute(ServiceContext ctx)` Starts execution of this service.
`void` `init(ServiceContext ctx)` Pre-initializes service before execution.
`Object` `invokeMethod(String mthdName, boolean srvKeepBinary, Object[] args)` Invokes native service method.
`long` `pointer()` Gets native pointer.
`void` `readExternal(ObjectInput in)`
`void` `setIgniteInstance(Ignite ignite)`
`void` `writeExternal(ObjectOutput out)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### svc

    protected Object svc

.Net binary service.

#### srvKeepBinary

    protected boolean srvKeepBinary

Whether to keep objects binary on server if possible.

#### ptr

    protected transient long ptr

Pointer to deployed service.

#### platformCtx

    protected transient PlatformContext platformCtx

Context.

### Constructor Detail

#### PlatformAbstractService

    public PlatformAbstractService()

Default constructor for serialization.

#### PlatformAbstractService

    public PlatformAbstractService(Object svc,
                           PlatformContext ctx,
                           boolean srvKeepBinary)

Constructor.

Parameters:
  `svc` - Service.
  `ctx` - Context.
  `srvKeepBinary` - Whether to keep objects binary on server if possible.

### Method Detail

#### init

    public void init(ServiceContext ctx)
              throws Exception

Pre-initializes service before execution. This method is guaranteed to be called before service deployment is complete (this guarantees that this method will be called before method `Service.execute(ServiceContext)` is called).

Specified by:
  `init` in interface `Service`
Parameters:
  `ctx` - Service execution context.
Throws:
  `Exception` - If service initialization failed.

#### execute

    public void execute(ServiceContext ctx)
                 throws Exception

Starts execution of this service. This method is automatically invoked whenever an instance of the service is deployed on a grid node. Note that service is considered deployed even after it exits the `execute` method and can be cancelled (or undeployed) only by calling any of the `cancel` methods on `IgniteServices` API. Also note that service is not required to exit from `execute` method until `Service.cancel(ServiceContext)` method was called.

Specified by:
  `execute` in interface `Service`
Parameters:
  `ctx` - Service execution context.
Throws:
  `Exception` - If service execution failed. Not that service will still remain deployed, until `IgniteServices.cancel(String)` method will be called.

#### cancel

    public void cancel(ServiceContext ctx)

Cancels this service. Ignite will automatically call this method whenever any of the `cancel` methods on `IgniteServices` API are called.

Note that Ignite cannot guarantee that the service exits from `Service.execute(ServiceContext)` method whenever `cancel(ServiceContext)` method is called. It is up to the user to make sure that the service code properly reacts to cancellations.

Specified by:
  `cancel` in interface `Service`
Parameters:
  `ctx` - Service execution context.

#### pointer

    public long pointer()

Gets native pointer.

Specified by:
  `pointer` in interface `PlatformService`
Returns:
  Native pointer.

#### invokeMethod

    public Object invokeMethod(String mthdName,
                      boolean srvKeepBinary,
                      Object[] args)
                        throws IgniteCheckedException

Invokes native service method.

Specified by:
  `invokeMethod` in interface `PlatformService`
Parameters:
  `mthdName` - Method name.
  `srvKeepBinary` - Server keep binary flag.
  `args` - Arguments.
Returns:
  Resulting data.
Throws:
  `IgniteCheckedException` - If failed.

#### setIgniteInstance

    @IgniteInstanceResource
    public void setIgniteInstance(Ignite ignite)

Parameters:
  `ignite` - Ignite instance.

#### readExternal

    public void readExternal(ObjectInput in)
                      throws IOException,
                             ClassNotFoundException

Specified by:
  `readExternal` in interface `Externalizable`
Throws:
  `IOException`
  `ClassNotFoundException`

#### writeExternal

    public void writeExternal(ObjectOutput out)
                       throws IOException

Specified by:
  `writeExternal` in interface `Externalizable`
Throws:
  `IOException`

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.1.0
Release Date | : July 20 2017