public class GigaSpaceFactoryBean extends Object implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.BeanNameAware
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
).
GigaSpace
,
DefaultGigaSpace
,
TransactionProvider
,
ExceptionTranslator
,
AbstractJiniTransactionManager
Modifier and Type | Field and Description |
---|---|
static String |
PREFIX_ISOLATION
Prefix for the isolation constants defined in TransactionDefinition
|
Constructor and Description |
---|
GigaSpaceFactoryBean() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Constructs the
GigaSpace instance using the DefaultGigaSpace implementation. |
void |
destroy() |
Object |
getObject()
Return
GigaSpace implementation constructed in the afterPropertiesSet() phase. |
Class<? extends GigaSpace> |
getObjectType() |
boolean |
isSingleton()
Returns
true as this is a singleton. |
void |
setBeanName(String beanName) |
void |
setClustered(boolean clustered)
Sets the cluster flag controlling if this
GigaSpace will work
with a clustered view of the space or directly with a cluster member. |
void |
setDefaultChangeModifiers(ChangeModifiers[] defaultChangeModifiers)
Set the default
ChangeModifiers to be used for change operations on the GigaSpace instance. |
void |
setDefaultClearModifiers(ClearModifiers[] defaultClearModifiers)
Set the default
ClearModifiers to be used for clear operations on the GigaSpace instance. |
void |
setDefaultCountModifiers(CountModifiers[] defaultCountModifiers)
Set the default
CountModifiers to be used for count operations on the GigaSpace instance. |
void |
setDefaultIsolationLevel(int defaultIsolationLevel)
Set the default isolation level.
|
void |
setDefaultIsolationLevelName(String constantName)
Set the default isolation level by the name of the corresponding constant in
TransactionDefinition, e.g.
|
void |
setDefaultReadModifiers(ReadModifiers[] defaultReadModifiers)
Set the default
ReadModifiers to be used for read operations on the GigaSpace
instance. |
void |
setDefaultReadTimeout(long defaultReadTimeout)
Sets the default read timeout for
GigaSpace.read(Object) and
GigaSpace.readIfExists(Object) operations. |
void |
setDefaultTakeModifiers(TakeModifiers[] defaultTakeModifiers)
Set the default
TakeModifiers to be used for take operations on the GigaSpace
instance. |
void |
setDefaultTakeTimeout(long defaultTakeTimeout)
Sets the default take timeout for
GigaSpace.take(Object) and
GigaSpace.takeIfExists(Object) operations. |
void |
setDefaultWriteLease(long defaultWriteLease)
Sets the default write lease for
GigaSpace.write(Object)
operation. |
void |
setDefaultWriteModifiers(WriteModifiers[] defaultWriteModifiers)
Set the default
WriteModifiers to be used for write operations on the GigaSpace instance. |
void |
setExTranslator(ExceptionTranslator exTranslator)
Sets the exception translator that will be used by the created
GigaSpace . |
void |
setSpace(IJSpace space)
Sets the space that will be used by the created
GigaSpace . |
void |
setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
Set the transaction manager to enable transactional operations.
|
void |
setTxProvider(TransactionProvider txProvider)
Sets the transaction provider that will be used by the created
GigaSpace . |
public static final String PREFIX_ISOLATION
public void setSpace(IJSpace space)
Sets the space that will be used by the created GigaSpace
.
This is a required parameter to the factory.
space
- The space usedpublic void setTxProvider(TransactionProvider txProvider)
Sets the transaction provider that will be used by the created GigaSpace
. This is an optional parameter and defaults to DefaultTransactionProvider
.
txProvider
- The transaction provider to usepublic void setExTranslator(ExceptionTranslator exTranslator)
Sets the exception translator that will be used by the created GigaSpace
. This is an optional parameter and defaults to DefaultExceptionTranslator
.
exTranslator
- The exception translator to usepublic void setClustered(boolean clustered)
Sets the cluster flag controlling if this GigaSpace
will 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 to false
if the space is an embedded one AND the space is not a local cache proxy. It will be set to
true
otherwise (i.e. the space is not an embedded space OR the space is a local
cache proxy).
clustered
- If the GigaSpace
is going to work with a
clustered view of the space or directly with a cluster memberpublic void setDefaultReadTimeout(long defaultReadTimeout)
Sets the default read timeout for GigaSpace.read(Object)
and
GigaSpace.readIfExists(Object)
operations. Default to 0.
public void setDefaultTakeTimeout(long defaultTakeTimeout)
Sets the default take timeout for GigaSpace.take(Object)
and
GigaSpace.takeIfExists(Object)
operations. Default to 0.
public void setDefaultWriteLease(long defaultWriteLease)
Sets the default write lease for GigaSpace.write(Object)
operation. Default to Lease.FOREVER
.
public final void setDefaultIsolationLevelName(String constantName) throws IllegalArgumentException
constantName
- name of the constantIllegalArgumentException
- if the supplied value is not resolvable to one of the
ISOLATION_
constants or is null
setDefaultIsolationLevel(int)
,
TransactionDefinition.ISOLATION_DEFAULT
public void setDefaultIsolationLevel(int defaultIsolationLevel)
IllegalArgumentException
- if the supplied value is not one of the ISOLATION_
constantsTransactionDefinition.ISOLATION_DEFAULT
public void setDefaultWriteModifiers(WriteModifiers[] defaultWriteModifiers)
WriteModifiers
to be used for write operations on the GigaSpace
instance. Defaults to WriteModifiers.UPDATE_OR_WRITE
defaultWriteModifiers
- The default write modifiers.WriteModifiers
public void setDefaultReadModifiers(ReadModifiers[] defaultReadModifiers)
ReadModifiers
to be used for read operations on the GigaSpace
instance. Defaults to ReadModifiers.READ_COMMITTED
defaultReadModifiers
- The default read modifiers.ReadModifiers
public void setDefaultTakeModifiers(TakeModifiers[] defaultTakeModifiers)
TakeModifiers
to be used for take operations on the GigaSpace
instance. Defaults to TakeModifiers.NONE
defaultTakeModifiers
- The default take modifiers.TakeModifiers
public void setDefaultCountModifiers(CountModifiers[] defaultCountModifiers)
CountModifiers
to be used for count operations on the GigaSpace
instance. Defaults to CountModifiers.NONE
defaultCountModifiers
- The default count modifiers.CountModifiers
public void setDefaultClearModifiers(ClearModifiers[] defaultClearModifiers)
ClearModifiers
to be used for clear operations on the GigaSpace
instance. Defaults to ClearModifiers.NONE
defaultClearModifiers
- The default clear modifiers.ClearModifiers
public void setDefaultChangeModifiers(ChangeModifiers[] defaultChangeModifiers)
ChangeModifiers
to be used for change operations on the GigaSpace
instance. Defaults to ChangeModifiers.NONE
defaultChangeModifiers
- The default change modifiers.ChangeModifiers
public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
Set the transaction manager to enable transactional operations. Can be null
if transactional support is not required or the default space is used as a transactional
context.
public void setBeanName(String beanName)
setBeanName
in interface org.springframework.beans.factory.BeanNameAware
public void afterPropertiesSet()
GigaSpace
instance using the DefaultGigaSpace
implementation. Uses the clustered flag to get a
cluster member directly (if set to false
) and applies the different defaults).afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
public Object getObject()
GigaSpace
implementation constructed in the afterPropertiesSet()
phase.getObject
in interface org.springframework.beans.factory.FactoryBean
public Class<? extends GigaSpace> getObjectType()
getObjectType
in interface org.springframework.beans.factory.FactoryBean
public boolean isSingleton()
true
as this is a singleton.isSingleton
in interface org.springframework.beans.factory.FactoryBean
Copyright © GigaSpaces.