Package com.oracle.coherence.spring
Class SpringBasedCoherenceSession
- java.lang.Object
-
- com.oracle.coherence.spring.SpringBasedCoherenceSession
-
- All Implemented Interfaces:
EventListener
,Aware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,ApplicationListener<ApplicationContextEvent>
public class SpringBasedCoherenceSession extends Object implements ApplicationContextAware, ApplicationListener<ApplicationContextEvent>, DisposableBean, InitializingBean
Provides the ability to acquire Coherence-based resources in the Spring Framework.Spring-based Applications will typically use this to access resources (NamedCaches) provided by Coherence. Using this class allows Spring to both inject values into Coherence and Coherence to request Beans from Spring, all without requiring the use of static member variables or methods.
Typically developers will instantiate an instance of a session to share across their application from with in their application configuration class. ie: the class(es) annotated with @Configuration
For Example:
@Configuration public class ApplicationConfiguration { @Bean public SpringBasedCoherenceSession session() { return new SpringBasedCoherenceSession("cache-config-file.xml); } }
@Configuration public class ApplicationConfiguration { @Bean public SpringBasedCoherenceSession session() { return new SpringBasedCoherenceSession("cache-config-file.xml); } @Bean public NamedCache accounts() { return session.getCache("accounts"); } }
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.- Author:
- Brian Oliver
-
-
Constructor Summary
Constructors Constructor Description SpringBasedCoherenceSession()
Constructs aSpringBasedCoherenceSession
that will auto-detect the cache configuration.SpringBasedCoherenceSession(String cacheConfigURI)
Constructs aSpringBasedCoherenceSession
using the specified cache configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
void
destroy()
com.tangosol.net.NamedCache
getCache(String name)
Acquire the specifiedNamedCache
.com.tangosol.net.ExtensibleConfigurableCacheFactory
getConfigurableCacheFactory()
com.tangosol.util.ResourceRegistry
getResourceRegistry()
Obtain theResourceRegistry
for theSpringBasedCoherenceSession
.com.tangosol.net.Service
getService(String name)
Acquire the specifiedService
.void
onApplicationEvent(ApplicationContextEvent event)
void
setApplicationContext(ApplicationContext applicationContext)
-
-
-
Constructor Detail
-
SpringBasedCoherenceSession
public SpringBasedCoherenceSession()
Constructs aSpringBasedCoherenceSession
that will auto-detect the cache configuration.
-
SpringBasedCoherenceSession
public SpringBasedCoherenceSession(String cacheConfigURI)
Constructs aSpringBasedCoherenceSession
using the specified cache configuration.- Parameters:
cacheConfigURI
- the URI of the cache configuration
-
-
Method Detail
-
getCache
public com.tangosol.net.NamedCache getCache(String name)
Acquire the specifiedNamedCache
.- Parameters:
name
- the name of the cache- Returns:
- a
NamedCache
-
getService
public com.tangosol.net.Service getService(String name)
Acquire the specifiedService
.- Parameters:
name
- the name of theService
- Returns:
- a
Service
-
getResourceRegistry
public com.tangosol.util.ResourceRegistry getResourceRegistry()
Obtain theResourceRegistry
for theSpringBasedCoherenceSession
.- Returns:
- the
ResourceRegistry
-
setApplicationContext
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Throws:
BeansException
-
onApplicationEvent
public void onApplicationEvent(ApplicationContextEvent event)
- Specified by:
onApplicationEvent
in interfaceApplicationListener<ApplicationContextEvent>
-
getConfigurableCacheFactory
public com.tangosol.net.ExtensibleConfigurableCacheFactory getConfigurableCacheFactory()
-
destroy
public void destroy() throws Exception
- Specified by:
destroy
in interfaceDisposableBean
- Throws:
Exception
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- Throws:
Exception
-
-