org.apache.ignite.internal.processors.resource

## Class GridResourceProcessor

- java.lang.Object
- - org.apache.ignite.internal.processors.GridProcessorAdapter
  - - org.apache.ignite.internal.processors.resource.GridResourceProcessor

All Implemented Interfaces:
  GridComponent, GridProcessor

    public class GridResourceProcessor
    extends GridProcessorAdapter

Processor for all Ignite and task/job resources.

### 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
`GridResourceProcessor(GridKernalContext ctx)` Creates resources processor.

### Method Summary

Methods
`void` `cleanup(IgniteSpi spi)` Cleans up resources from given SPI implementation.
`void` `cleanup(LifecycleBean lifecycleBean)` Cleans up resources from given lifecycle beans.
`void` `cleanup(Service svc)` Cleans up resources from given service.
`void` `cleanupGeneric(Object obj)`
`Collection<Method>` `getMethodsWithAnnotation(GridDeployment dep, Class<?> rsrcCls, Class<? extends Annotation> annCls)` Gets list of methods in specified class annotated with specified annotation.
`void` `inject(GridDeployment dep, Class<?> taskCls, ComputeJob job, ComputeTaskSession ses, GridJobContextImpl jobCtx)` Injects held resources into given `job`.
`void` `inject(GridDeployment dep, Class<?> depCls, Object target)` Injects resources into generic class.
`void` `inject(GridDeployment dep, ComputeTask<?,?> task, GridTaskSessionImpl ses, ComputeLoadBalancer balancer, ComputeTaskContinuousMapper mapper)` Injects held resources into given grid task.
`void` `inject(IgniteSpi spi)` Injects held resources into given SPI implementation.
`void` `inject(LifecycleBean lifecycleBean)` Injects held resources into given lifecycle bean.
`void` `inject(Service svc)` Injects resources into service.
`void` `injectBasicResource(Object target, Class<? extends Annotation> annCls, Object rsrc)` This method is declared public as it is used from tests as well.
`void` `injectBasicResource(Object target, Class<? extends Annotation> annCls, Object rsrc, GridDeployment dep, Class<?> depCls)` This method is declared public as it is used from tests as well.
`void` `injectCacheName(Object obj, String cacheName)` Injects cache name into given object.
`void` `injectGeneric(Object obj)`
`boolean` `injectStoreSession(Object obj, CacheStoreSession ses)` Injects cache store session into given object.
`void` `invokeAnnotated(GridDeployment dep, Object target, Class<? extends Annotation> annCls)`
`boolean` `isAnnotationPresent(GridDeployment dep, Object target, Class<? extends Annotation> annCls)` Checks if annotation presents in specified object.
`void` `onUndeployed(GridDeployment dep)` Callback to be called when class loader is undeployed.
`void` `printMemoryStats()` Prints memory statistics (sizes of internal structures, etc.).
`void` `setSpringContext(GridSpringResourceContext rsrcCtx)` Sets Spring resource context.
`void` `start()` Starts grid component.
`void` `stop(boolean cancel)` Stops grid component.

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

`addAttributes, assertParameter, collectDiscoveryData, discoveryDataType, onDiscoveryDataReceived, onKernalStart, onKernalStop, toString, validateNode`

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

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

### Constructor Detail

#### GridResourceProcessor

    public GridResourceProcessor(GridKernalContext ctx)

Creates resources processor.

Parameters:
  `ctx` - Kernal context.

### Method Detail

#### start

    public void start()
               throws IgniteCheckedException

Starts grid component.

Specified by:
  `start` in interface `GridComponent`
Overrides:
  `start` in class `GridProcessorAdapter`
Throws:
  `IgniteCheckedException` - Throws in case of any errors.

#### stop

    public void stop(boolean cancel)

Stops grid component.

Specified by:
  `stop` in interface `GridComponent`
Overrides:
  `stop` in class `GridProcessorAdapter`
Parameters:
  `cancel` - If `true`, then all ongoing tasks or jobs for relevant components need to be cancelled.

#### setSpringContext

    public void setSpringContext(@Nullable
                        GridSpringResourceContext rsrcCtx)

Sets Spring resource context.

Parameters:
  `rsrcCtx` - Spring resource context.

#### onUndeployed

    public void onUndeployed(GridDeployment dep)

Callback to be called when class loader is undeployed.

Parameters:
  `dep` - Deployment to release resources for.

#### invokeAnnotated

    public void invokeAnnotated(GridDeployment dep,
                       Object target,
                       Class<? extends Annotation> annCls)
                         throws IgniteCheckedException

Parameters:
  `dep` - Deployment.
  `target` - Target object.
  `annCls` - Annotation class.
Throws:
  `IgniteCheckedException` - If failed to execute annotated methods.

#### inject

    public void inject(GridDeployment dep,
              Class<?> depCls,
              Object target)
                throws IgniteCheckedException

Injects resources into generic class.

Parameters:
  `dep` - Deployment.
  `depCls` - Deployed class.
  `target` - Target instance to inject into.
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### injectCacheName

    public void injectCacheName(Object obj,
                       String cacheName)
                         throws IgniteCheckedException

Injects cache name into given object.

Parameters:
  `obj` - Object.
  `cacheName` - Cache name to inject.
Throws:
  `IgniteCheckedException` - If failed to inject.

#### injectStoreSession

    public boolean injectStoreSession(Object obj,
                             CacheStoreSession ses)
                               throws IgniteCheckedException

Injects cache store session into given object.

Parameters:
  `obj` - Object.
  `ses` - Session to inject.
Returns:
  `True` if session was injected.
Throws:
  `IgniteCheckedException` - If failed to inject.

#### injectGeneric

    public void injectGeneric(Object obj)
                       throws IgniteCheckedException

Parameters:
  `obj` - Object to inject.
Throws:
  `IgniteCheckedException` - If failed to inject.

#### cleanupGeneric

    public void cleanupGeneric(Object obj)
                        throws IgniteCheckedException

Parameters:
  `obj` - Object.
Throws:
  `IgniteCheckedException` - If failed.

#### inject

    public void inject(GridDeployment dep,
              Class<?> taskCls,
              ComputeJob job,
              ComputeTaskSession ses,
              GridJobContextImpl jobCtx)
                throws IgniteCheckedException

Injects held resources into given `job`.

Parameters:
  `dep` - Deployment.
  `taskCls` - Task class.
  `job` - Grid job to inject resources to.
  `ses` - Current task session.
  `jobCtx` - Job context.
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### inject

    public void inject(GridDeployment dep,
              ComputeTask<?,?> task,
              GridTaskSessionImpl ses,
              ComputeLoadBalancer balancer,
              ComputeTaskContinuousMapper mapper)
                throws IgniteCheckedException

Injects held resources into given grid task.

Parameters:
  `dep` - Deployed class.
  `task` - Grid task.
  `ses` - Grid task session.
  `balancer` - Load balancer.
  `mapper` - Continuous task mapper.
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### isAnnotationPresent

    public boolean isAnnotationPresent(GridDeployment dep,
                              Object target,
                              Class<? extends Annotation> annCls)

Checks if annotation presents in specified object.

Parameters:
  `dep` - Class deployment.
  `target` - Object to check.
  `annCls` - Annotation to find.
Returns:
  `true` if annotation is presented, `false` otherwise.

#### inject

    public void inject(IgniteSpi spi)
                throws IgniteCheckedException

Injects held resources into given SPI implementation.

Parameters:
  `spi` - SPI implementation.
Throws:
  `IgniteCheckedException` - Throw in case of any errors.

#### cleanup

    public void cleanup(IgniteSpi spi)
                 throws IgniteCheckedException

Cleans up resources from given SPI implementation. Essentially, this method injects `null`s into SPI implementation.

Parameters:
  `spi` - SPI implementation.
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### inject

    public void inject(LifecycleBean lifecycleBean)
                throws IgniteCheckedException

Injects held resources into given lifecycle bean.

Parameters:
  `lifecycleBean` - Lifecycle bean.
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### cleanup

    public void cleanup(LifecycleBean lifecycleBean)
                 throws IgniteCheckedException

Cleans up resources from given lifecycle beans. Essentially, this method injects `null`s into lifecycle bean.

Parameters:
  `lifecycleBean` - Lifecycle bean.
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### inject

    public void inject(Service svc)
                throws IgniteCheckedException

Injects resources into service.

Parameters:
  `svc` - Service to inject.
Throws:
  `IgniteCheckedException` - If failed.

#### cleanup

    public void cleanup(Service svc)
                 throws IgniteCheckedException

Cleans up resources from given service. Essentially, this method injects `null`s into service bean.

Parameters:
  `svc` - Service.
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### injectBasicResource

    public void injectBasicResource(Object target,
                           Class<? extends Annotation> annCls,
                           Object rsrc,
                           GridDeployment dep,
                           Class<?> depCls)
                             throws IgniteCheckedException

This method is declared public as it is used from tests as well. Note, that this method can be used only with unwrapped objects (see `unwrapTarget(Object)`).

Parameters:
  `target` - Target object.
  `annCls` - Setter annotation.
  `rsrc` - Resource to inject.
  `dep` - Deployment.
  `depCls` - Deployed class.
Throws:
  `IgniteCheckedException` - If injection failed.

#### injectBasicResource

    public void injectBasicResource(Object target,
                           Class<? extends Annotation> annCls,
                           Object rsrc)
                             throws IgniteCheckedException

This method is declared public as it is used from tests as well. Note, that this method can be used only with unwrapped objects (see `unwrapTarget(Object)`).

Parameters:
  `target` - Target object.
  `annCls` - Setter annotation.
  `rsrc` - Resource to inject.
Throws:
  `IgniteCheckedException` - If injection failed.

#### getMethodsWithAnnotation

    @Nullable
    public Collection<Method> getMethodsWithAnnotation(GridDeployment dep,
                                                       Class<?> rsrcCls,
                                                       Class<? extends Annotation> annCls)

Gets list of methods in specified class annotated with specified annotation.

Parameters:
  `dep` - Class deployment.
  `rsrcCls` - Class to find methods in.
  `annCls` - Annotation to find annotated methods with.
Returns:
  List of annotated methods.

#### printMemoryStats

    public void printMemoryStats()

Prints memory statistics (sizes of internal structures, etc.). NOTE: this method is for testing and profiling purposes only.

Specified by:
  `printMemoryStats` in interface `GridComponent`
Overrides:
  `printMemoryStats` in class `GridProcessorAdapter`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC1
Release Date | : February 17 2015