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.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
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);
}
}
To acquire resources (like NamedCaches) from a session, they can be similarly
resolved (and injected).
@Configuration
public class ApplicationConfiguration
{
@Bean
public SpringBasedCoherenceSession session()
{
return new SpringBasedCoherenceSession("cache-config-file.xml);
}
@Bean
public NamedCache accounts()
{
return session.getCache("accounts");
}
}
Copyright (c) 2015-2015. All Rights Reserved. Oracle Corporation.Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
- Author:
- Brian Oliver
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs aSpringBasedCoherenceSessionthat will auto-detect the cache configuration.SpringBasedCoherenceSession(String cacheConfigURI) Constructs aSpringBasedCoherenceSessionusing the specified cache configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoiddestroy()com.tangosol.net.NamedCacheAcquire the specifiedNamedCache.com.tangosol.net.ExtensibleConfigurableCacheFactorycom.tangosol.util.ResourceRegistryObtain theResourceRegistryfor theSpringBasedCoherenceSession.com.tangosol.net.ServicegetService(String name) Acquire the specifiedService.voidvoidsetApplicationContext(ApplicationContext applicationContext) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecution
-
Constructor Details
-
SpringBasedCoherenceSession
public SpringBasedCoherenceSession()Constructs aSpringBasedCoherenceSessionthat will auto-detect the cache configuration. -
SpringBasedCoherenceSession
Constructs aSpringBasedCoherenceSessionusing the specified cache configuration.- Parameters:
cacheConfigURI- the URI of the cache configuration
-
-
Method Details
-
getCache
Acquire the specifiedNamedCache.- Parameters:
name- the name of the cache- Returns:
- a
NamedCache
-
getService
Acquire the specifiedService.- Parameters:
name- the name of theService- Returns:
- a
Service
-
getResourceRegistry
public com.tangosol.util.ResourceRegistry getResourceRegistry()Obtain theResourceRegistryfor theSpringBasedCoherenceSession.- Returns:
- the
ResourceRegistry
-
setApplicationContext
- Specified by:
setApplicationContextin interfaceApplicationContextAware- Throws:
BeansException
-
onApplicationEvent
- Specified by:
onApplicationEventin interfaceApplicationListener<ApplicationContextEvent>
-
getConfigurableCacheFactory
public com.tangosol.net.ExtensibleConfigurableCacheFactory getConfigurableCacheFactory() -
destroy
- Specified by:
destroyin interfaceDisposableBean- Throws:
Exception
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceInitializingBean- Throws:
Exception
-