org.apache.ignite.internal.processors.cacheobject

## Class IgniteCacheObjectProcessorImpl

- java.lang.Object
- - org.apache.ignite.internal.processors.GridProcessorAdapter
  - - org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessorImpl

All Implemented Interfaces:
  GridComponent, IgniteCacheObjectProcessor, GridProcessor

    public class IgniteCacheObjectProcessorImpl
    extends GridProcessorAdapter
    implements IgniteCacheObjectProcessor

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.ignite.internal.GridComponent

`GridComponent.DiscoveryDataExchangeType`

### Field Summary

### Fields inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter

`ctx, log`

### Constructor Summary

Constructors
Constructor and Description
`IgniteCacheObjectProcessorImpl(GridKernalContext ctx)`

### Method Summary

Methods
`CacheObjectContext` `contextForCache(ClusterNode node, String cacheName)`
`Object` `field(Object obj, String fieldName)`
`boolean` `hasField(Object obj, String fieldName)` Checks whether field is set in the object.
`boolean` `immutable(Object obj)`
`boolean` `isPortableObject(Object obj)` Checks whether object is portable object.
`boolean` `keepPortableInStore(String cacheName)`
`byte[]` `marshal(CacheObjectContext ctx, Object val)`
`void` `onCacheProcessorStarted()`
`CacheObject` `prepareForCache(CacheObject obj, GridCacheContext cctx)` Prepares cache object for cache (e.g. copies user-provided object if needed).
`KeyCacheObject` `toCacheKeyObject(CacheObjectContext ctx, Object obj, boolean userObj)`
`protected KeyCacheObject` `toCacheKeyObject0(Object obj, boolean userObj)`
`CacheObject` `toCacheObject(CacheObjectContext ctx, byte type, byte[] bytes)`
`CacheObject` `toCacheObject(CacheObjectContext ctx, Object obj, boolean userObj)`
`CacheObject` `toCacheObject(GridCacheContext ctx, long valPtr, boolean tmp)`
`protected CacheObject` `toCacheObject0(Object obj, boolean userObj)`
`int` `typeId(Object obj)`
`int` `typeId(String typeName)`
`Object` `unmarshal(CacheObjectContext ctx, byte[] bytes, ClassLoader clsLdr)`
`Object` `unwrapTemporary(GridCacheContext ctx, Object obj)` Converts temporary off-heap object to heap-based.

### Methods inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter

`assertParameter, collectDiscoveryData, discoveryDataType, onDiscoveryDataReceived, onKernalStart, onKernalStop, printMemoryStats, start, stop, toString, validateNode`

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

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

### Methods inherited from interface org.apache.ignite.internal.GridComponent

`collectDiscoveryData, discoveryDataType, onDiscoveryDataReceived, onKernalStart, onKernalStop, printMemoryStats, start, stop, validateNode`

### Constructor Detail

#### IgniteCacheObjectProcessorImpl

    public IgniteCacheObjectProcessorImpl(GridKernalContext ctx)

Parameters:
  `ctx` - Context.

### Method Detail

#### prepareForCache

    @Nullable
    public CacheObject prepareForCache(@Nullable
                                       CacheObject obj,
                                       GridCacheContext cctx)

Prepares cache object for cache (e.g. copies user-provided object if needed).

Specified by:
  `prepareForCache` in interface `IgniteCacheObjectProcessor`
Parameters:
  `obj` - Cache object.
  `cctx` - Cache context.
Returns:
  Object to be store in cache.

#### marshal

    public byte[] marshal(CacheObjectContext ctx,
                 Object val)
                   throws IgniteCheckedException

Specified by:
  `marshal` in interface `IgniteCacheObjectProcessor`
Parameters:
  `ctx` - Cache object context.
  `val` - Value.
Returns:
  Value bytes.
Throws:
  `IgniteCheckedException` - If failed.

#### unmarshal

    public Object unmarshal(CacheObjectContext ctx,
                   byte[] bytes,
                   ClassLoader clsLdr)
                     throws IgniteCheckedException

Specified by:
  `unmarshal` in interface `IgniteCacheObjectProcessor`
Parameters:
  `ctx` - Context.
  `bytes` - Bytes.
  `clsLdr` - Class loader.
Returns:
  Unmarshalled object.
Throws:
  `IgniteCheckedException` - If failed.

#### toCacheKeyObject

    @Nullable
    public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx,
                                           Object obj,
                                           boolean userObj)

Specified by:
  `toCacheKeyObject` in interface `IgniteCacheObjectProcessor`
Parameters:
  `ctx` - Cache context.
  `obj` - Key value.
  `userObj` - If `true` then given object is object provided by user and should be copied before stored in cache.
Returns:
  Cache key object.

#### toCacheKeyObject0

    protected KeyCacheObject toCacheKeyObject0(Object obj,
                                   boolean userObj)

Parameters:
  `obj` - Object.
  `userObj` - If `true` then given object is object provided by user and should be copied before stored in cache.
Returns:
  Key cache object.

#### toCacheObject

    public CacheObject toCacheObject(GridCacheContext ctx,
                            long valPtr,
                            boolean tmp)
                              throws IgniteCheckedException

Specified by:
  `toCacheObject` in interface `IgniteCacheObjectProcessor`
Parameters:
  `ctx` - Context.
  `valPtr` - Value pointer.
  `tmp` - If `true` can return temporary instance which is valid while entry lock is held.
Returns:
  Cache object.
Throws:
  `IgniteCheckedException` - If failed.

#### toCacheObject

    public CacheObject toCacheObject(CacheObjectContext ctx,
                            byte type,
                            byte[] bytes)

Specified by:
  `toCacheObject` in interface `IgniteCacheObjectProcessor`
Parameters:
  `ctx` - Cache context.
  `type` - Object type.
  `bytes` - Object bytes.
Returns:
  Cache object.

#### toCacheObject

    @Nullable
    public CacheObject toCacheObject(CacheObjectContext ctx,
                                     @Nullable
                                     Object obj,
                                     boolean userObj)

Specified by:
  `toCacheObject` in interface `IgniteCacheObjectProcessor`
Parameters:
  `ctx` - Cache context.
  `obj` - Object.
  `userObj` - If `true` then given object is object provided by user and should be copied before stored in cache.
Returns:
  Cache object.

#### toCacheObject0

    protected CacheObject toCacheObject0(@Nullable
                             Object obj,
                             boolean userObj)

Parameters:
  `obj` - Object.
  `userObj` - If `true` then given object is object provided by user and should be copied before stored in cache.
Returns:
  Cache object.

#### contextForCache

    public CacheObjectContext contextForCache(ClusterNode node,
                                     @Nullable
                                     String cacheName)

Specified by:
  `contextForCache` in interface `IgniteCacheObjectProcessor`
Parameters:
  `node` - Node.
  `cacheName` - Cache name.
Returns:
  Cache object context.

#### immutable

    public boolean immutable(Object obj)

Specified by:
  `immutable` in interface `IgniteCacheObjectProcessor`
Parameters:
  `obj` - Value.
Returns:
  `True` if object is of known immutable type of it is marked with `IgniteImmutable` annotation.

#### keepPortableInStore

    public boolean keepPortableInStore(@Nullable
                              String cacheName)

Specified by:
  `keepPortableInStore` in interface `IgniteCacheObjectProcessor`
Parameters:
  `cacheName` - Cache name.
Returns:
  `True` if portable format should be preserved when passing values to cache store.

#### onCacheProcessorStarted

    public void onCacheProcessorStarted()

Specified by:
  `onCacheProcessorStarted` in interface `IgniteCacheObjectProcessor`

#### typeId

    public int typeId(String typeName)

Specified by:
  `typeId` in interface `IgniteCacheObjectProcessor`
Parameters:
  `typeName` - Type name.
Returns:
  Type ID.

#### unwrapTemporary

    public Object unwrapTemporary(GridCacheContext ctx,
                         Object obj)
                           throws IgniteException

Converts temporary off-heap object to heap-based.

Specified by:
  `unwrapTemporary` in interface `IgniteCacheObjectProcessor`
Parameters:
  `ctx` - Context.
  `obj` - Object.
Returns:
  Heap-based object.
Throws:
  `IgniteException` - In case of error.

#### isPortableObject

    public boolean isPortableObject(Object obj)

Checks whether object is portable object.

Specified by:
  `isPortableObject` in interface `IgniteCacheObjectProcessor`
Parameters:
  `obj` - Object to check.
Returns:
  `True` if object is already a portable object, `false` otherwise.

#### typeId

    public int typeId(Object obj)

Specified by:
  `typeId` in interface `IgniteCacheObjectProcessor`
Parameters:
  `obj` - Object to get type ID for.
Returns:
  Type ID.

#### field

    public Object field(Object obj,
               String fieldName)

Specified by:
  `field` in interface `IgniteCacheObjectProcessor`
Parameters:
  `obj` - Portable object to get field from.
  `fieldName` - Field name.
Returns:
  Field value.

#### hasField

    public boolean hasField(Object obj,
                   String fieldName)

Checks whether field is set in the object.

Specified by:
  `hasField` in interface `IgniteCacheObjectProcessor`
Parameters:
  `obj` - Object.
  `fieldName` - Field name.
Returns:
  `true` if field is set.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC3
Release Date | : March 24 2015