org.apache.storm.cassandra.context

## Class WorkerCtx

- java.lang.Object
- - org.apache.storm.cassandra.context.WorkerCtx

- All Implemented Interfaces:
    Serializable
  Direct Known Subclasses:
    CassandraContext

      public class WorkerCtx
      extends Object
      implements Serializable

  Simple class used to register singletons within a storm worker.

  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `WorkerCtx()` Creates a new `WorkerCtx` instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected <T> BeanFactory<T>` | `getBeanfactory(Class<T> clazz)` Return an instance provider of the specified type.
    `<T,K,V> T` | `getWorkerBean(Class<T> clazz, Map<K,V> topoConf)` Return an instance, which is shared (within a Worker), of the specified type.
    `<T,K,V> T` | `getWorkerBean(Class<T> clazz, Map<K,V> topoConf, boolean force)` Return an instance, which is shared (within a Worker), of the specified type.
    `<T> void` | `register(Class<T> clazz, BeanFactory<T> provider)` Register a bean provider for a specified type.

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

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

- - ### Constructor Detail

    - #### WorkerCtx

          public WorkerCtx()

      Creates a new `WorkerCtx` instance.

  - ### Method Detail

    - #### register

          public <T> void register(Class<T> clazz,
                                   BeanFactory<T> provider)

      Register a bean provider for a specified type.

    - #### getBeanfactory

          protected <T> BeanFactory<T> getBeanfactory(Class<T> clazz)

      Return an instance provider of the specified type.

      Throws:
        `RuntimeException` - if no bean provider can be resolve for the given class

    - #### getWorkerBean

          public <T,K,V> T getWorkerBean(Class<T> clazz,
                                         Map<K,V> topoConf)

      Return an instance, which is shared (within a Worker), of the specified type.

    - #### getWorkerBean

          public <T,K,V> T getWorkerBean(Class<T> clazz,
                                         Map<K,V> topoConf,
                                         boolean force)

      Return an instance, which is shared (within a Worker), of the specified type.

      Parameters:
        `clazz` - the class of the bean.
        `topoConf` - the storm configuration
        `force` - if `true`= create a new instance even if one already exist.
      Returns:
        a instance of type `T`.

Copyright © 2019 The Apache Software Foundation. All rights reserved.