Class AbstractSpaceFactoryBean
- All Implemented Interfaces:
InternalDumpProcessor,EventListener,MemberAliveIndicator,ServiceDetailsProvider,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,org.springframework.context.ApplicationContextAware,org.springframework.context.ApplicationListener
- Direct Known Subclasses:
DirectSpaceFactoryBean,EmbeddedSpaceFactoryBean,SpaceProxyFactoryBean,UrlSpaceFactoryBean
IJSpace
implementation.
Provides support for raising Spring application events: BeforeSpaceModeChangeEvent and
AfterSpaceModeChangeEvent alerting other beans of the current space mode
(primary/backup). Beans that wish to be notified of it should implement Spring ApplicationListener. Note that this space mode events might be
raised more than once for the same space mode, and beans that listen to it should take it into
account.
The space mode event will be raised regardless of the space "type" that is used. For embedded
spaces, an actual space mode event listener will be registered with the actual cluster member (if
not in cluster mode, the actual space). For remote space lookups (jini/rmi), no listener will be
registered and Space mode events will still be raised during context refresh with a
PRIMARY mode in order to allow beans to be written regardless of how the space is
looked up.
Derived classes should implement the doCreateSpace() to obtain the IJSpace.
- Author:
- kimchy
-
Field Summary
FieldsFields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddServiceDetails(ServiceDetailsProvider serviceDetailsProvider) voidInitializes the space by calling thedoCreateSpace().voidclose()Destroys the space and unregisters the internal space mode listener (if registered).voiddestroy()Destroys the space and unregisters the internal space mode listener (if registered).protected abstract IJSpaceResponsible for creating/finding the actualIJSpaceimplementation.protected voidSendsAfterSpaceModeChangeEventevents with space modeSpaceMode.BACKUPto all beans in the application context that implement theSpaceAfterBackupListenerinterface.protected voidSendsAfterSpaceModeChangeEventevents with space modeSpaceMode.PRIMARYto all beans in the application context that implement theSpaceAfterPrimaryListenerinterfaceprotected voidSendsBeforeSpaceModeChangeEventevents with space modeSpaceMode.BACKUPto all beans in the application context that implement theSpaceBeforeBackupListenerinterface.protected voidSendsBeforeSpaceModeChangeEventevents with space modeSpaceMode.PRIMARYto all beans in the application context that implement theSpaceBeforePrimaryListenerinterface.protected org.springframework.context.ApplicationContextgetName()Spring factory bean returning theIJSpacecreated during the bean initialization (afterPropertiesSet()).Returns the object type of the factory bean.protected SecurityConfigRetruns one or more service details that the service exposes.booleanisAlive()Returns if this space is alive or not by pinging the Space and if it is considered healthy.booleanShould this space be checked to see if it is alive or not.protected booleanReturns if the space should register for primary backup notifications.booleanReturnstruesince this factory is a singleton.voidonApplicationEvent(org.springframework.context.ApplicationEvent applicationEvent) IfContextRefreshedEventis raised will send two extra events:BeforeSpaceModeChangeEventandAfterSpaceModeChangeEventwith the current space mode.voidprocess(InternalDump dump) voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) Injected by Spring thanks toApplicationContextAware.voidsetBeanName(String name) voidsetCredentialsProvider(CredentialsProvider credentialsProvider) Sets the security configuration with the provided custom credentials provider.voidsetEnableMemberAliveIndicator(Boolean enableMemberAliveIndicator) Should this Space bean control if the cluster member is alive or not.voidsetPrimaryBackupListener(ISpaceModeListener primaryBackupListener) Sets a custom primary backup listenervoidsetRegisterForSpaceModeNotifications(boolean registerForSpaceMode) Sets if the space should register for primary backup (mode) notifications.voidsetSecurityConfig(SecurityConfig securityConfig) Sets security configuration for the Space.voidsetUserDetails(UserDetails userDetails) Sets the security configuration with the provided custom user details.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecutionMethods inherited from interface com.gigaspaces.internal.dump.InternalDumpProcessor
getDumpFileReportLocation, setDumpFileReportLocation
-
Field Details
-
logger
protected org.apache.commons.logging.Log logger
-
-
Constructor Details
-
AbstractSpaceFactoryBean
public AbstractSpaceFactoryBean()
-
-
Method Details
-
setRegisterForSpaceModeNotifications
public void setRegisterForSpaceModeNotifications(boolean registerForSpaceMode) Sets if the space should register for primary backup (mode) notifications. Default behavior (if the flag was not set) will register to primary backup notification if the space was found using an embedded protocol, and will not register for notification if the space was found usingrmiorjiniprotocols. -
setUserDetails
Sets the security configuration with the provided custom user details.- Parameters:
userDetails- a custom user details.
-
setCredentialsProvider
Sets the security configuration with the provided custom credentials provider.- Parameters:
credentialsProvider- a custom credentials provider.
-
setSecurityConfig
Sets security configuration for the Space. If not set, no security will be used. -
getSecurityConfig
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException Injected by Spring thanks toApplicationContextAware.- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
getApplicationContext
protected org.springframework.context.ApplicationContext getApplicationContext() -
setBeanName
- Specified by:
setBeanNamein interfaceorg.springframework.beans.factory.BeanNameAware
-
setPrimaryBackupListener
Sets a custom primary backup listener -
setEnableMemberAliveIndicator
Should this Space bean control if the cluster member is alive or not. Defaults totrueif the Space started is an embedded Space, andfalseif the it is connected to a remote Space. -
afterPropertiesSet
public void afterPropertiesSet() throws org.springframework.dao.DataAccessExceptionInitializes the space by calling thedoCreateSpace().Registers with the Space an internal space mode listener in order to be able to send Spring level
BeforeSpaceModeChangeEventandAfterSpaceModeChangeEventfor primary and backup handling of different beans within the context. The registration is based onisRegisterForSpaceModeNotifications().- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
org.springframework.dao.DataAccessException
-
destroy
Destroys the space and unregisters the internal space mode listener (if registered).- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean- Throws:
Exception
-
close
public void close()Destroys the space and unregisters the internal space mode listener (if registered). -
onApplicationEvent
public void onApplicationEvent(org.springframework.context.ApplicationEvent applicationEvent) IfContextRefreshedEventis raised will send two extra events:BeforeSpaceModeChangeEventandAfterSpaceModeChangeEventwith the current space mode. This is done since other beans that use this events might not catch them while the context is constructed.Note, this will mean that events with the same Space mode might be raised, one after the other, and Spring beans that listens for them should take it into account.
- Specified by:
onApplicationEventin interfaceorg.springframework.context.ApplicationListener
-
getObject
Spring factory bean returning theIJSpacecreated during the bean initialization (afterPropertiesSet()).- Specified by:
getObjectin interfaceorg.springframework.beans.factory.FactoryBean- Returns:
- The
IJSpaceimplementation
-
getObjectType
Returns the object type of the factory bean. Defaults to IJSpace class or the actualIJSpaceimplementation class.- Specified by:
getObjectTypein interfaceorg.springframework.beans.factory.FactoryBean
-
isSingleton
public boolean isSingleton()Returnstruesince this factory is a singleton.- Specified by:
isSingletonin interfaceorg.springframework.beans.factory.FactoryBean
-
isMemberAliveEnabled
public boolean isMemberAliveEnabled()Should this space be checked to see if it is alive or not.- Specified by:
isMemberAliveEnabledin interfaceMemberAliveIndicator
-
isAlive
Returns if this space is alive or not by pinging the Space and if it is considered healthy.- Specified by:
isAlivein interfaceMemberAliveIndicator- Throws:
Exception
-
doCreateSpace
Responsible for creating/finding the actualIJSpaceimplementation.- Returns:
- The IJSpace implementation used for the factory bean
- Throws:
org.springframework.dao.DataAccessException
-
isRegisterForSpaceModeNotifications
protected boolean isRegisterForSpaceModeNotifications()Returns if the space should register for primary backup notifications. IfsetRegisterForSpaceModeNotifications(boolean)was set, will return this flag. If not, will register to primary backup notification if the space was found using an embedded protocol, and will not register for notification if the space was found usingrmiorjiniprotocols. -
fireSpaceBeforeBackupEvent
protected void fireSpaceBeforeBackupEvent()SendsBeforeSpaceModeChangeEventevents with space modeSpaceMode.BACKUPto all beans in the application context that implement theSpaceBeforeBackupListenerinterface. -
fireSpaceAfterBackupEvent
protected void fireSpaceAfterBackupEvent()SendsAfterSpaceModeChangeEventevents with space modeSpaceMode.BACKUPto all beans in the application context that implement theSpaceAfterBackupListenerinterface. -
fireSpaceBeforePrimaryEvent
protected void fireSpaceBeforePrimaryEvent()SendsBeforeSpaceModeChangeEventevents with space modeSpaceMode.PRIMARYto all beans in the application context that implement theSpaceBeforePrimaryListenerinterface. -
fireSpaceAfterPrimaryEvent
protected void fireSpaceAfterPrimaryEvent()SendsAfterSpaceModeChangeEventevents with space modeSpaceMode.PRIMARYto all beans in the application context that implement theSpaceAfterPrimaryListenerinterface -
getServicesDetails
Description copied from interface:ServiceDetailsProviderRetruns one or more service details that the service exposes.- Specified by:
getServicesDetailsin interfaceServiceDetailsProvider
-
addServiceDetails
-
getName
- Specified by:
getNamein interfaceInternalDumpProcessor
-
process
- Specified by:
processin interfaceInternalDumpProcessor- Throws:
InternalDumpProcessorFailedException
-
toString
-