org.apache.ignite.configuration

## Class IgniteReflectionFactory<T>

- java.lang.Object
- - org.apache.ignite.configuration.IgniteReflectionFactory<T>

- All Implemented Interfaces:
    Serializable, javax.cache.configuration.Factory<T>

      public class IgniteReflectionFactory<T>
      extends Object
      implements javax.cache.configuration.Factory<T>

  Factory implementation that use reflection to create instance of given class.

  There are 2 modes of factory: singleton and non-sigletton.

  Class that should be created by `IgniteReflectionFactory` (component class) have to be public java POJO with public setters for field for which property injection will be used (see `setProperties(Map)`).

  # Configuration

  ## Mandatory

  The following configuration parameters are mandatory:
  - Component class - class to be created (see `setComponentClass(Class)`. It have to be public java POJO class with default constructor and public setters to be used by properties injection (see `setProperties(Map)`)

  ## Optional

  The following configuration parameters are optional:
- Singleton mode (see `setSingleton(boolean)`)
- Properties map (see `setProperties(Map)`
- With method (see `setWithMethod(Object, String, Serializable)`

## Java Example

     Factory factory =
         new IgniteReflectionFactory(MyCacheStoreSessionListener.class);

     CacheConfiguration cc = new CacheConfiguration()
         .setCacheStoreSessionListenerFactories(factory);

     IgniteConfiguration cfg = new IgniteConfiguration()
         .setCacheConfiguration(cc);

     // Start grid.
     Ignition.start(cfg);

## Spring Example

TcpDiscoverySpi can be configured from Spring XML configuration file:

     <bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
         ...
         <property name="cacheConfiguration">
             <list>
                 <bean class="org.apache.ignite.configuration.CacheConfiguration">
                     ...
                     <property name="cacheStoreSessionListenerFactories">
                         <list>
                             <bean class="org.apache.ignite.configuration.IgniteReflectionFactory">
                                 <property name="componentClass" value="custom.project.MyCacheStoreSessionListener"/>
                             </bean>
                         </list>
                     </property>
                     ...
                 </bean>
             </list>
         </property>
         ...
     </bean>

For information about Spring framework visit www.springframework.org

See Also:
  `Factory`, Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `IgniteReflectionFactory()` Default constructor.
    `IgniteReflectionFactory(Class<? extends T> cls)` Creates non-singleton component factory.
    `IgniteReflectionFactory(Class<? extends T> cls, boolean singleton)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `T` | `create()`
    `Class<? extends T>` | `getComponentClass()`
    `Map<String,Serializable>` | `getProperties()` Gets a map of properties.
    `boolean` | `isSingleton()`
    `void` | `setComponentClass(Class<T> cls)`
    `void` | `setProperties(Map<String,Serializable> props)` Sets a map of properties.
    `void` | `setSingleton(boolean singleton)`

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

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

- - ### Constructor Detail

    - #### IgniteReflectionFactory

          public IgniteReflectionFactory()

      Default constructor.

    - #### IgniteReflectionFactory

          public IgniteReflectionFactory(Class<? extends T> cls,
                                         boolean singleton)

      Parameters:
        `cls` - Component class.
        `singleton` - Singleton flag.

    - #### IgniteReflectionFactory

          public IgniteReflectionFactory(Class<? extends T> cls)

      Creates non-singleton component factory.
      Parameters:
        `cls` - Component class.

  - ### Method Detail

    - #### isSingleton

          public boolean isSingleton()

      Returns:
        `True` if factory is singleton.

    - #### setSingleton

          public void setSingleton(boolean singleton)

      Parameters:
        `singleton` - Singleton flag.

    - #### getComponentClass

          public Class<? extends T> getComponentClass()

      Returns:
        Component class to create.

    - #### setComponentClass

          public void setComponentClass(Class<T> cls)

      Parameters:
        `cls` - Component class to create.

    - #### getProperties

          public Map<String,Serializable> getProperties()

      Gets a map of properties. Map contains entries of component class field name to value of the field which will be used as initial value.
      Returns:
        Properties.

    - #### setProperties

          public void setProperties(Map<String,Serializable> props)

      Sets a map of properties. Map contains entries of component class field name to a value of the field which will be used as initial value.
      Parameters:
        `props` - Properties.

    - #### create

          public T create()

      Specified by:
        `create` in interface `javax.cache.configuration.Factory<T>`

${current.year} Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.15.0
Release Date | : April 25 2023