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 Modifier and Type Field Description protected ObjectinterceptorsService call interceptors.protected PlatformContextplatformCtxContext.protected longptrPointer to deployed service.protected booleansrvKeepBinaryWhether to keep objects binary on server if possible.protected Objectsvc.Net binary service.
-
Constructor Summary
Constructors Constructor Description PlatformAbstractService()Default constructor for serialization.PlatformAbstractService(Object svc, PlatformContext ctx, boolean srvKeepBinary, @Nullable Object interceptors)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()Cancels this service.voidexecute()Starts execution of this service.voidinit()Pre-initializes service before execution.ObjectinvokeMethod(String mthdName, boolean srvKeepBinary, boolean deserializeResult, @Nullable Object[] args, @Nullable Map<String,Object> callAttrs)Invokes native service method.longpointer()Gets native pointer.voidreadExternal(ObjectInput in)voidsetIgniteInstance(Ignite ignite)voidwriteExternal(ObjectOutput out)
-
-
-
Field Detail
-
svc
protected Object svc
.Net binary service.
-
interceptors
protected Object interceptors
Service call interceptors.
-
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, @Nullable @Nullable Object interceptors)
Constructor.- Parameters:
svc- Service.ctx- Context.srvKeepBinary- Whether to keep objects binary on server if possible.interceptors- Service call interceptors.
-
-
Method Detail
-
init
public void init() throws ExceptionPre-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 methodService.execute()is called).- Specified by:
initin interfaceService- Throws:
Exception- If service initialization failed.- See Also:
ServiceContextResource
-
execute
public void execute() throws ExceptionStarts 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 theexecutemethod and can be cancelled (or undeployed) only by calling any of thecancelmethods onIgniteServicesAPI. Also note that service is not required to exit fromexecutemethod untilService.cancel()method was called.- Specified by:
executein interfaceService- Throws:
Exception- If service execution failed. Not that service will still remain deployed, untilIgniteServices.cancel(String)method will be called.- See Also:
ServiceContextResource
-
cancel
public void cancel()
Cancels this service. Ignite will automatically call this method whenever any of thecancelmethods onIgniteServicesAPI are called.Note that Ignite cannot guarantee that the service exits from
Service.execute()method whenevercancel()method is called. It is up to the user to make sure that the service code properly reacts to cancellations.- Specified by:
cancelin interfaceService- See Also:
ServiceContextResource
-
pointer
public long pointer()
Gets native pointer.- Specified by:
pointerin interfacePlatformService- Returns:
- Native pointer.
-
invokeMethod
public Object invokeMethod(String mthdName, boolean srvKeepBinary, boolean deserializeResult, @Nullable @Nullable Object[] args, @Nullable @Nullable Map<String,Object> callAttrs) throws IgniteCheckedException
Invokes native service method.- Specified by:
invokeMethodin interfacePlatformService- Parameters:
mthdName- Method name.srvKeepBinary- Server keep binary flag.deserializeResult- Iftrue, call service in cross-platform compatible manner.args- Arguments.callAttrs- Service call context attributes.- 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:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
-