public class IgniteSpringBean extends Object implements Ignite, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.SmartInitializingSingleton, org.springframework.context.ApplicationContextAware, Externalizable
Ignition
methods.
In other words, this bean class allows to inject new grid instance from
Spring configuration file directly without invoking static
Ignition
methods. This class can be wired directly from
Spring and can be referenced from within other Spring beans.
By virtue of implementing DisposableBean
and SmartInitializingSingleton
interfaces, IgniteSpringBean
automatically starts and stops underlying
grid instance.
A note should be taken that Ignite instance is started after all other
Spring beans have been initialized and right before Spring context is refreshed.
That implies that it's not valid to reference IgniteSpringBean from
any kind of Spring bean init methods like PostConstruct
.
If it's required to reference IgniteSpringBean for other bean
initialization purposes, it should be done from a ContextRefreshedEvent
listener method declared in that bean.
<bean id="mySpringBean" class="org.apache.ignite.IgniteSpringBean"> <property name="configuration"> <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> <property name="igniteInstanceName" value="mySpringGrid"/> </bean> </property> </bean>Or use default configuration:
<bean id="mySpringBean" class="org.apache.ignite.IgniteSpringBean"/>
AbstractApplicationContext ctx = new FileSystemXmlApplicationContext("/path/to/spring/file"); // Register Spring hook to destroy bean automatically. ctx.registerShutdownHook(); Ignite ignite = (Ignite)ctx.getBean("mySpringBean");
Constructor and Description |
---|
IgniteSpringBean() |
public IgniteConfiguration configuration()
configuration
in interface Ignite
public IgniteConfiguration getConfiguration()
This method is required for proper Spring integration and is the same as
configuration()
.
See https://issues.apache.org/jira/browse/IGNITE-1102 for details.
NOTE:
SPIs obtains through this method should never be used directly. SPIs provide
internal view on the subsystem and is used internally by Ignite kernal. In rare use cases when
access to a specific implementation of this SPI is required - an instance of this SPI can be obtained
via this method to check its configuration properties or call other non-SPI
methods.
configuration()
public void setConfiguration(IgniteConfiguration cfg)
cfg
- Ignite configuration.public org.springframework.context.ApplicationContext getApplicationContext() throws org.springframework.beans.BeansException
org.springframework.beans.BeansException
public void setApplicationContext(org.springframework.context.ApplicationContext ctx) throws org.springframework.beans.BeansException
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
org.springframework.beans.BeansException
public void destroy() throws Exception
destroy
in interface org.springframework.beans.factory.DisposableBean
Exception
public void afterSingletonsInstantiated()
afterSingletonsInstantiated
in interface org.springframework.beans.factory.SmartInitializingSingleton
public IgniteLogger log()
public IgniteProductVersion version()
public IgniteCompute compute()
public IgniteServices services()
public IgniteMessaging message()
public IgniteEvents events()
public ExecutorService executorService()
executorService
in interface Ignite
public IgniteCluster cluster()
public IgniteCompute compute(ClusterGroup grp)
public IgniteMessaging message(ClusterGroup prj)
public IgniteEvents events(ClusterGroup grp)
public IgniteServices services(ClusterGroup grp)
public ExecutorService executorService(ClusterGroup grp)
executorService
in interface Ignite
public IgniteScheduler scheduler()
public void resetLostPartitions(Collection<String> cacheNames)
resetLostPartitions
in interface Ignite
public Collection<DataRegionMetrics> dataRegionMetrics()
dataRegionMetrics
in interface Ignite
@Nullable public DataRegionMetrics dataRegionMetrics(String memPlcName)
dataRegionMetrics
in interface Ignite
public DataStorageMetrics dataStorageMetrics()
dataStorageMetrics
in interface Ignite
public Collection<MemoryMetrics> memoryMetrics()
memoryMetrics
in interface Ignite
@Nullable public MemoryMetrics memoryMetrics(String memPlcName)
memoryMetrics
in interface Ignite
public PersistenceMetrics persistentStoreMetrics()
persistentStoreMetrics
in interface Ignite
public <K,V> IgniteCache<K,V> cache(@Nullable String name)
public Collection<String> cacheNames()
cacheNames
in interface Ignite
public <K,V> IgniteCache<K,V> createCache(CacheConfiguration<K,V> cacheCfg)
createCache
in interface Ignite
public <K,V> IgniteCache<K,V> getOrCreateCache(CacheConfiguration<K,V> cacheCfg)
getOrCreateCache
in interface Ignite
public <K,V> IgniteCache<K,V> createCache(CacheConfiguration<K,V> cacheCfg, NearCacheConfiguration<K,V> nearCfg)
createCache
in interface Ignite
public Collection<IgniteCache> createCaches(Collection<CacheConfiguration> cacheCfgs)
createCaches
in interface Ignite
public <K,V> IgniteCache<K,V> getOrCreateCache(CacheConfiguration<K,V> cacheCfg, NearCacheConfiguration<K,V> nearCfg)
getOrCreateCache
in interface Ignite
public <K,V> IgniteCache<K,V> createNearCache(String cacheName, NearCacheConfiguration<K,V> nearCfg)
createNearCache
in interface Ignite
public <K,V> IgniteCache<K,V> getOrCreateNearCache(@Nullable String cacheName, NearCacheConfiguration<K,V> nearCfg)
getOrCreateNearCache
in interface Ignite
public <K,V> IgniteCache<K,V> getOrCreateCache(String cacheName)
getOrCreateCache
in interface Ignite
public Collection<IgniteCache> getOrCreateCaches(Collection<CacheConfiguration> cacheCfgs)
getOrCreateCaches
in interface Ignite
public <K,V> IgniteCache<K,V> createCache(String cacheName)
createCache
in interface Ignite
public <K,V> void addCacheConfiguration(CacheConfiguration<K,V> cacheCfg)
addCacheConfiguration
in interface Ignite
public void destroyCache(String cacheName)
destroyCache
in interface Ignite
public void destroyCaches(Collection<String> cacheNames)
destroyCaches
in interface Ignite
public IgniteTransactions transactions()
transactions
in interface Ignite
public <K,V> IgniteDataStreamer<K,V> dataStreamer(@Nullable String cacheName)
dataStreamer
in interface Ignite
public IgniteFileSystem fileSystem(String name)
fileSystem
in interface Ignite
public Collection<IgniteFileSystem> fileSystems()
fileSystems
in interface Ignite
public <T extends IgnitePlugin> T plugin(String name) throws PluginNotFoundException
plugin
in interface Ignite
PluginNotFoundException
public IgniteBinary binary()
public void close() throws IgniteException
close
in interface AutoCloseable
close
in interface Ignite
IgniteException
@Nullable public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create)
atomicSequence
in interface Ignite
public IgniteAtomicSequence atomicSequence(String name, AtomicConfiguration cfg, long initVal, boolean create) throws IgniteException
atomicSequence
in interface Ignite
IgniteException
@Nullable public IgniteAtomicLong atomicLong(String name, long initVal, boolean create)
atomicLong
in interface Ignite
public IgniteAtomicLong atomicLong(String name, AtomicConfiguration cfg, long initVal, boolean create) throws IgniteException
atomicLong
in interface Ignite
IgniteException
@Nullable public <T> IgniteAtomicReference<T> atomicReference(String name, @Nullable T initVal, boolean create)
atomicReference
in interface Ignite
public <T> IgniteAtomicReference<T> atomicReference(String name, AtomicConfiguration cfg, @Nullable T initVal, boolean create) throws IgniteException
atomicReference
in interface Ignite
IgniteException
@Nullable public <T,S> IgniteAtomicStamped<T,S> atomicStamped(String name, @Nullable T initVal, @Nullable S initStamp, boolean create)
atomicStamped
in interface Ignite
public <T,S> IgniteAtomicStamped<T,S> atomicStamped(String name, AtomicConfiguration cfg, @Nullable T initVal, @Nullable S initStamp, boolean create) throws IgniteException
atomicStamped
in interface Ignite
IgniteException
@Nullable public IgniteCountDownLatch countDownLatch(String name, int cnt, boolean autoDel, boolean create)
countDownLatch
in interface Ignite
@Nullable public IgniteSemaphore semaphore(String name, int cnt, boolean failoverSafe, boolean create)
@Nullable public IgniteLock reentrantLock(String name, boolean failoverSafe, boolean fair, boolean create)
reentrantLock
in interface Ignite
@Nullable public <T> IgniteQueue<T> queue(String name, int cap, CollectionConfiguration cfg)
@Nullable public <T> IgniteSet<T> set(String name, CollectionConfiguration cfg)
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
protected void checkIgnite() throws IllegalStateException
IllegalStateException
- If bean is not valid, i.e. Ignite has already been stopped
or has not yet been started.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.7.0 Release Date : November 30 2018