Class GigaSpaceFactoryBean
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.FactoryBean,org.springframework.beans.factory.InitializingBean
A factory bean creating GigaSpace implementation. The
implementation created is DefaultGigaSpace which
allows for pluggable IJSpace, TransactionProvider, and ExceptionTranslator.
The factory requires an IJSpace which can be either directly
acquired or build using one of the several space factory beans provided in
org.openspaces.core.space.
The factory accepts an optional TransactionProvider which defaults to DefaultTransactionProvider. The transactional context used is based on setTransactionManager(org.springframework.transaction.PlatformTransactionManager) and if no
transaction manager is provided, will use the space as the context.
When using org.openspaces.core.transaction.manager.LocalJiniTransactionManager there
is no need to pass the transaction manager to this factory, since both by default will use the
space as the transactional context. When working with LookupJiniTransactionManager
(which probably means Mahalo and support for more than one space as transaction resources) the
transaction manager should be provided to this class.
The factory accepts an optional ExceptionTranslator which defaults to DefaultExceptionTranslator.
A clustered flag allows to control if this GigaSpace instance will work against a clustered
view of the space or directly against a clustered member. This flag has no affect when not
working in a clustered mode (partitioned or primary/backup). By default if this flag is not set
it will be set automatically by this factory. It will be set to true if the space is
an embedded one AND the space is not a local cache proxy. It will be set to false
otherwise (i.e. the space is not an embedded space OR the space is a local cache proxy). A local
cache proxy is an IJSpace that is injected using setSpace(com.j_spaces.core.IJSpace) and was created using either LocalViewSpaceFactoryBean or LocalCacheSpaceFactoryBean.
The factory allows to set the default read/take timeout and write lease when using the same operations without the relevant parameters.
The factory also allows to set the default isolation level for read operations that will be
performed by GigaSpace API. The isolation level can be set either
using setDefaultIsolationLevel(int) or setDefaultIsolationLevelName(String).
Note, this setting will apply when not working under Spring declarative transactions or when
using Spring declarative transaction with the default isolation level (TransactionDefinition.ISOLATION_DEFAULT).
- Author:
- kimchy
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringPrefix for the isolation constants defined in TransactionDefinitionFields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidConstructs theGigaSpaceinstance using theDefaultGigaSpaceimplementation.voiddestroy()ReturnGigaSpaceimplementation constructed in theafterPropertiesSet()phase.booleanReturnstrueas this is a singleton.voidsetBeanName(String beanName) voidsetClustered(boolean clustered) Sets the cluster flag controlling if thisGigaSpacewill work with a clustered view of the space or directly with a cluster member.voidsetDefaultChangeModifiers(ChangeModifiers[] defaultChangeModifiers) Set the defaultChangeModifiersto be used for change operations on theGigaSpaceinstance.voidsetDefaultClearModifiers(ClearModifiers[] defaultClearModifiers) Set the defaultClearModifiersto be used for clear operations on theGigaSpaceinstance.voidsetDefaultCountModifiers(CountModifiers[] defaultCountModifiers) Set the defaultCountModifiersto be used for count operations on theGigaSpaceinstance.voidsetDefaultIsolationLevel(int defaultIsolationLevel) Set the default isolation level.final voidsetDefaultIsolationLevelName(String constantName) Set the default isolation level by the name of the corresponding constant in TransactionDefinition, e.g.voidsetDefaultReadModifiers(ReadModifiers[] defaultReadModifiers) Set the defaultReadModifiersto be used for read operations on theGigaSpaceinstance.voidsetDefaultReadTimeout(long defaultReadTimeout) Sets the default read timeout forGigaSpace.read(Object)andGigaSpace.readIfExists(Object)operations.voidsetDefaultTakeModifiers(TakeModifiers[] defaultTakeModifiers) Set the defaultTakeModifiersto be used for take operations on theGigaSpaceinstance.voidsetDefaultTakeTimeout(long defaultTakeTimeout) Sets the default take timeout forGigaSpace.take(Object)andGigaSpace.takeIfExists(Object)operations.voidsetDefaultWriteLease(long defaultWriteLease) Sets the default write lease forGigaSpace.write(Object)operation.voidsetDefaultWriteModifiers(WriteModifiers[] defaultWriteModifiers) Set the defaultWriteModifiersto be used for write operations on theGigaSpaceinstance.voidsetExTranslator(ExceptionTranslator exTranslator) Sets the exception translator that will be used by the createdGigaSpace.voidSets the space that will be used by the createdGigaSpace.voidsetTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager) Set the transaction manager to enable transactional operations.voidsetTxProvider(TransactionProvider txProvider) Sets the transaction provider that will be used by the createdGigaSpace.
-
Field Details
-
PREFIX_ISOLATION
Prefix for the isolation constants defined in TransactionDefinition- See Also:
-
-
Constructor Details
-
GigaSpaceFactoryBean
public GigaSpaceFactoryBean()
-
-
Method Details
-
setSpace
Sets the space that will be used by the created
GigaSpace. This is a required parameter to the factory.- Parameters:
space- The space used
-
setTxProvider
Sets the transaction provider that will be used by the created
GigaSpace. This is an optional parameter and defaults toDefaultTransactionProvider.- Parameters:
txProvider- The transaction provider to use
-
setExTranslator
Sets the exception translator that will be used by the created
GigaSpace. This is an optional parameter and defaults toDefaultExceptionTranslator.- Parameters:
exTranslator- The exception translator to use
-
setClustered
public void setClustered(boolean clustered) Sets the cluster flag controlling if this
GigaSpacewill work with a clustered view of the space or directly with a cluster member. By default if this flag is not set it will be set automatically by this factory. It will be set tofalseif the space is an embedded one AND the space is not a local cache proxy. It will be set totrueotherwise (i.e. the space is not an embedded space OR the space is a local cache proxy).- Parameters:
clustered- If theGigaSpaceis going to work with a clustered view of the space or directly with a cluster member
-
setDefaultReadTimeout
public void setDefaultReadTimeout(long defaultReadTimeout) Sets the default read timeout for
GigaSpace.read(Object)andGigaSpace.readIfExists(Object)operations. Default to 0. -
setDefaultTakeTimeout
public void setDefaultTakeTimeout(long defaultTakeTimeout) Sets the default take timeout for
GigaSpace.take(Object)andGigaSpace.takeIfExists(Object)operations. Default to 0. -
setDefaultWriteLease
public void setDefaultWriteLease(long defaultWriteLease) Sets the default write lease for
GigaSpace.write(Object)operation. Default toLease.FOREVER. -
setDefaultIsolationLevelName
Set the default isolation level by the name of the corresponding constant in TransactionDefinition, e.g. "ISOLATION_DEFAULT".- Parameters:
constantName- name of the constant- Throws:
IllegalArgumentException- if the supplied value is not resolvable to one of theISOLATION_constants or isnull- See Also:
-
setDefaultIsolationLevel(int)TransactionDefinition.ISOLATION_DEFAULT
-
setDefaultIsolationLevel
public void setDefaultIsolationLevel(int defaultIsolationLevel) Set the default isolation level. Must be one of the isolation constants in the TransactionDefinition interface. Default is ISOLATION_DEFAULT.- Throws:
IllegalArgumentException- if the supplied value is not one of theISOLATION_constants- See Also:
-
TransactionDefinition.ISOLATION_DEFAULT
-
setDefaultWriteModifiers
Set the defaultWriteModifiersto be used for write operations on theGigaSpaceinstance. Defaults toWriteModifiers.UPDATE_OR_WRITE- Parameters:
defaultWriteModifiers- The default write modifiers.- See Also:
-
setDefaultReadModifiers
Set the defaultReadModifiersto be used for read operations on theGigaSpaceinstance. Defaults toReadModifiers.READ_COMMITTED- Parameters:
defaultReadModifiers- The default read modifiers.- See Also:
-
setDefaultTakeModifiers
Set the defaultTakeModifiersto be used for take operations on theGigaSpaceinstance. Defaults toTakeModifiers.NONE- Parameters:
defaultTakeModifiers- The default take modifiers.- See Also:
-
setDefaultCountModifiers
Set the defaultCountModifiersto be used for count operations on theGigaSpaceinstance. Defaults toCountModifiers.NONE- Parameters:
defaultCountModifiers- The default count modifiers.- See Also:
-
setDefaultClearModifiers
Set the defaultClearModifiersto be used for clear operations on theGigaSpaceinstance. Defaults toClearModifiers.NONE- Parameters:
defaultClearModifiers- The default clear modifiers.- See Also:
-
setDefaultChangeModifiers
Set the defaultChangeModifiersto be used for change operations on theGigaSpaceinstance. Defaults toChangeModifiers.NONE- Parameters:
defaultChangeModifiers- The default change modifiers.- See Also:
-
setTransactionManager
public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager) Set the transaction manager to enable transactional operations. Can be
nullif transactional support is not required or the default space is used as a transactional context. -
setBeanName
- Specified by:
setBeanNamein interfaceorg.springframework.beans.factory.BeanNameAware
-
afterPropertiesSet
public void afterPropertiesSet()Constructs theGigaSpaceinstance using theDefaultGigaSpaceimplementation. Uses the clustered flag to get a cluster member directly (if set tofalse) and applies the different defaults).- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
getObject
ReturnGigaSpaceimplementation constructed in theafterPropertiesSet()phase.- Specified by:
getObjectin interfaceorg.springframework.beans.factory.FactoryBean
-
getObjectType
- Specified by:
getObjectTypein interfaceorg.springframework.beans.factory.FactoryBean
-
isSingleton
public boolean isSingleton()Returnstrueas this is a singleton.- Specified by:
isSingletonin interfaceorg.springframework.beans.factory.FactoryBean
-
destroy
- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean- Throws:
Exception
-