GigaSpaces XAP 7.0 API

org.openspaces.core
Class GigaSpaceFactoryBean

java.lang.Object
  extended by org.openspaces.core.GigaSpaceFactoryBean
All Implemented Interfaces:
BeanNameAware, FactoryBean, InitializingBean

public class GigaSpaceFactoryBean
extends Object
implements InitializingBean, FactoryBean, 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 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:
GigaSpace, DefaultGigaSpace, TransactionProvider, ExceptionTranslator, AbstractJiniTransactionManager

Field Summary
static String PREFIX_ISOLATION
          Prefix for the isolation constants defined in TransactionDefinition
 
Constructor Summary
GigaSpaceFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
          Constructs the GigaSpace instance using the DefaultGigaSpace implementation.
 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 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 setDefaultReadTimeout(long defaultReadTimeout)
          Sets the default read timeout for GigaSpace.read(Object) and GigaSpace.readIfExists(Object) operations.
 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 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(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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREFIX_ISOLATION

public static final String PREFIX_ISOLATION
Prefix for the isolation constants defined in TransactionDefinition

See Also:
Constant Field Values
Constructor Detail

GigaSpaceFactoryBean

public GigaSpaceFactoryBean()
Method Detail

setSpace

public void setSpace(IJSpace space)

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

public 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.

Parameters:
txProvider - The transaction provider to use

setExTranslator

public 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.

Parameters:
exTranslator - The exception translator to use

setClustered

public 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 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).

Parameters:
clustered - If the GigaSpace is 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) and GigaSpace.readIfExists(Object) operations. Default to JavaSpace.NO_WAIT.


setDefaultTakeTimeout

public void setDefaultTakeTimeout(long defaultTakeTimeout)

Sets the default take timeout for GigaSpace.take(Object) and GigaSpace.takeIfExists(Object) operations. Default to JavaSpace.NO_WAIT.


setDefaultWriteLease

public void setDefaultWriteLease(long defaultWriteLease)

Sets the default write lease for GigaSpace.write(Object) operation. Default to Lease.FOREVER.


setDefaultIsolationLevelName

public final void setDefaultIsolationLevelName(String constantName)
                                        throws IllegalArgumentException
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 the ISOLATION_ constants or is null
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 the ISOLATION_ constants
See Also:
TransactionDefinition.ISOLATION_DEFAULT

setTransactionManager

public void setTransactionManager(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.


setBeanName

public void setBeanName(String beanName)
Specified by:
setBeanName in interface BeanNameAware

afterPropertiesSet

public void afterPropertiesSet()
Constructs the 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).

Specified by:
afterPropertiesSet in interface InitializingBean

getObject

public Object getObject()
Return GigaSpace implementation constructed in the afterPropertiesSet() phase.

Specified by:
getObject in interface FactoryBean

getObjectType

public Class<? extends GigaSpace> getObjectType()
Specified by:
getObjectType in interface FactoryBean

isSingleton

public boolean isSingleton()
Returns true as this is a singleton.

Specified by:
isSingleton in interface FactoryBean

GigaSpaces XAP 7.0 API

Copyright © GigaSpaces.