Package 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 (seesetProperties(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 (seesetProperties(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 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 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)
-
-
-
Method Detail
-
isSingleton
public boolean isSingleton()
- Returns:
True
if factory is singleton.
-
setSingleton
public void setSingleton(boolean singleton)
- Parameters:
singleton
- Singleton flag.
-
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.
-
-