org.springframework.data.gemfire
Class RegionLookupFactoryBean<K,V>

java.lang.Object
  extended by org.springframework.data.gemfire.RegionLookupFactoryBean<K,V>
All Implemented Interfaces:
Aware, BeanNameAware, FactoryBean<com.gemstone.gemfire.cache.Region<K,V>>, InitializingBean
Direct Known Subclasses:
ClientRegionFactoryBean, RegionFactoryBean

public class RegionLookupFactoryBean<K,V>
extends Object
implements FactoryBean<com.gemstone.gemfire.cache.Region<K,V>>, InitializingBean, BeanNameAware

Simple FactoryBean for retrieving generic GemFire Regions. If the Region does not exist, an exception is thrown. For declaring and configuring new regions, see RegionFactoryBean.


Field Summary
protected  org.apache.commons.logging.Log log
           
 
Constructor Summary
RegionLookupFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
 Boolean getLookupEnabled()
           
 com.gemstone.gemfire.cache.Region<K,V> getObject()
           
 Class<?> getObjectType()
           
protected  com.gemstone.gemfire.cache.Region<?,?> getParent()
          Gets a reference to the parent Region if this FactoryBean represents a GemFire Cache Sub-Region.
protected  com.gemstone.gemfire.cache.Region<K,V> getRegion()
           
 boolean isSingleton()
           
protected  com.gemstone.gemfire.cache.Region<K,V> lookupFallback(com.gemstone.gemfire.cache.GemFireCache cache, String regionName)
          Fallback method in case the named Region does not exist.
 void setBeanName(String name)
          Sets the name of the Cache Region based on the bean 'id' attribute.
 void setCache(com.gemstone.gemfire.cache.GemFireCache cache)
          Sets a reference to the Cache used to create the Region.
 void setLookupEnabled(Boolean lookupEnabled)
           
 void setName(String name)
          Sets the name of the Cache Region based on the bean 'name' attribute.
 void setParent(com.gemstone.gemfire.cache.Region<?,?> parent)
          Sets a reference to the parent Region if this FactoryBean represents a GemFire Cache Sub-Region.
 void setRegionName(String regionName)
          Sets the name of the Cache Region as expected by GemFire.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log
Constructor Detail

RegionLookupFactoryBean

public RegionLookupFactoryBean()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

lookupFallback

protected com.gemstone.gemfire.cache.Region<K,V> lookupFallback(com.gemstone.gemfire.cache.GemFireCache cache,
                                                                String regionName)
                                                         throws Exception
Fallback method in case the named Region does not exist. By default, this implementation throws an exception.

Parameters:
cache - a reference to the GemFire Cache.
regionName - the name of the GemFire Cache Region.
Returns:
the Region in the GemFire Cache with the given name.
Throws:
Exception - if the lookup operation fails.

getObject

public com.gemstone.gemfire.cache.Region<K,V> getObject()
                                                 throws Exception
Specified by:
getObject in interface FactoryBean<com.gemstone.gemfire.cache.Region<K,V>>
Throws:
Exception

getObjectType

public Class<?> getObjectType()
Specified by:
getObjectType in interface FactoryBean<com.gemstone.gemfire.cache.Region<K,V>>

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface FactoryBean<com.gemstone.gemfire.cache.Region<K,V>>

setBeanName

public void setBeanName(String name)
Sets the name of the Cache Region based on the bean 'id' attribute. If no Region is found for the given name, a new one will be created.

Specified by:
setBeanName in interface BeanNameAware
Parameters:
name - the name of this bean (Region) in the application context (bean factory).
See Also:
BeanNameAware.setBeanName(String)

setCache

public void setCache(com.gemstone.gemfire.cache.GemFireCache cache)
Sets a reference to the Cache used to create the Region.

Parameters:
cache - a reference to the Cache.
See Also:
CacheFactoryBean, GemFireCache

setName

public void setName(String name)
Sets the name of the Cache Region based on the bean 'name' attribute. If no Region is found with the given name, a new one will be created. If no name is given, the value of the 'beanName' property will be used.

Parameters:
name - the region name
See Also:
setBeanName(String), Region.getFullPath()

setParent

public void setParent(com.gemstone.gemfire.cache.Region<?,?> parent)
Sets a reference to the parent Region if this FactoryBean represents a GemFire Cache Sub-Region.

Parameters:
parent - a reference to the parent Region if this Region is a Sub-Region.
See Also:
Region

getParent

protected com.gemstone.gemfire.cache.Region<?,?> getParent()
Gets a reference to the parent Region if this FactoryBean represents a GemFire Cache Sub-Region.

Returns:
a reference to the parent Region or null if this Region is not a Sub-Region.
See Also:
Region

setRegionName

public void setRegionName(String regionName)
Sets the name of the Cache Region as expected by GemFire. If no Region is found with the given name, a new one will be created. If no name is given, the value of the 'name' property will be used.

Parameters:
regionName - a String indicating the name of the Region in GemFire.
See Also:
setName(String), Region.getName()

getLookupEnabled

public Boolean getLookupEnabled()

setLookupEnabled

public void setLookupEnabled(Boolean lookupEnabled)

getRegion

protected com.gemstone.gemfire.cache.Region<K,V> getRegion()