Package org.openspaces.core.bean
Class DefaultBeanServer<T extends Bean>
java.lang.Object
org.openspaces.core.bean.DefaultBeanServer<T>
- All Implemented Interfaces:
BeanConfigPropertiesManager,BeanServer<T>
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultBeanServer(Admin admin) DefaultBeanServer(BeanFactory<T> beanFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()voidDisable all currently enabled beans.voiddisableAllBeansAssignableTo(Class<?> interfaceClass) Disables all beans that implement the specified interface.voiddisableBean(String beanClassName) Disables a bean.voidenableBean(String beanClassName) Disables a bean.getBeanConfig(String beanClassName) Get the bean configuration.String[]Lists the class names of configured beans.getEnabledBean(String beanClassName) getEnabledBeansAssignableTo(Class<?>[] interfaceClasses) String[]Lists the class names of enabled beans.getEnabledBeansClassNamesAssignableTo(Class<?>[] interfaceClasses) booleanisBeanEnabled(String beanClassName) booleanremoveBeanConfig(String beanClassName) Removes a bean configuration.booleanreplaceBeanAssignableTo(Class<?>[] interfaceClasses, String newBeanClassName, Map<String, String> newBeanProperties) Assuming there is at most one enabled bean that implements one of the specified interfaces, puts the specified configuration and enables a new bean in its place.voidsetBeanConfig(String beanClassName, Map<String, String> properties) Defines a configuration for the specified bean.
-
Constructor Details
-
DefaultBeanServer
-
DefaultBeanServer
-
-
Method Details
-
setBeanConfig
public void setBeanConfig(String beanClassName, Map<String, String> properties) throws EnabledBeanConfigCannotBeChangedExceptionDescription copied from interface:BeanConfigPropertiesManagerDefines a configuration for the specified bean. Overrides all previously set properties for that bean.An exception is raised if the bean is enabled.
- Specified by:
setBeanConfigin interfaceBeanConfigPropertiesManager- Parameters:
beanClassName- the bean class nameproperties- the String key-value pairs used to configure this bean.- Throws:
EnabledBeanConfigCannotBeChangedException- The bean is enabled. Disable it first.
-
enableBean
public void enableBean(String beanClassName) throws BeanConfigNotFoundException, BeanConfigurationException, BeanInitializationException Description copied from interface:BeanConfigPropertiesManagerDisables a bean. The bean object is discarded but it's configuration remains. The bean can be enabled at a later time.If the bean is already disabled, the request is silently ignored.
- Specified by:
enableBeanin interfaceBeanConfigPropertiesManager- Parameters:
beanClassName- the bean class name- Throws:
BeanConfigNotFoundException- bean configuration cannot be found.BeanConfigurationException- in the event of misconfiguration (such as failure to set an essential property).BeanInitializationException- if bean initialization fails.
-
disableBean
Description copied from interface:BeanConfigPropertiesManagerDisables a bean. The bean object is discarded but it's configuration remains. The bean can be enabled at a later time.If the bean is already disabled, the request is silently ignored.
- Specified by:
disableBeanin interfaceBeanConfigPropertiesManager- Parameters:
beanClassName- the bean class name- Throws:
BeanConfigNotFoundException- bean configuration cannot be found.
-
removeBeanConfig
Description copied from interface:BeanConfigPropertiesManagerRemoves a bean configuration.An exception is raised if the bean is enabled.
- Specified by:
removeBeanConfigin interfaceBeanConfigPropertiesManager- Parameters:
beanClassName- the bean class name- Returns:
trueif removed ,falseif it did not exist in the first place.- Throws:
BeanConfigNotFoundException- bean configuration cannot be found.
-
isBeanEnabled
- Specified by:
isBeanEnabledin interfaceBeanConfigPropertiesManager- Parameters:
beanClassName- the bean class name- Returns:
trueif the bean is enabled,falseif the bean is disabled.
-
getBeanConfig
Description copied from interface:BeanConfigPropertiesManagerGet the bean configuration.- Specified by:
getBeanConfigin interfaceBeanConfigPropertiesManager- Parameters:
beanClassName- the bean class name- Returns:
- the String key-value pairs configuration properties.
- Throws:
BeanConfigNotFoundException- bean configuration cannot be found. Put the configuration first.
-
getBeansClassNames
Description copied from interface:BeanConfigPropertiesManagerLists the class names of configured beans.- Specified by:
getBeansClassNamesin interfaceBeanConfigPropertiesManager- Returns:
- an array of bean class names that have been configured bean. If no bean configuration exists, a zero length array is returned.
-
getEnabledBeansClassNames
Description copied from interface:BeanConfigPropertiesManagerLists the class names of enabled beans.- Specified by:
getEnabledBeansClassNamesin interfaceBeanConfigPropertiesManager- Returns:
- an array of enabled beans. If no beans are enabled, a zero length array is returned.
- See Also:
-
disableAllBeans
public void disableAllBeans()Description copied from interface:BeanConfigPropertiesManagerDisable all currently enabled beans.- Specified by:
disableAllBeansin interfaceBeanConfigPropertiesManager- See Also:
-
getEnabledBean
- Specified by:
getEnabledBeanin interfaceBeanServer<T extends Bean>- Returns:
- the bean instance of the specified class name, or null if not enabled.
-
disableAllBeansAssignableTo
Description copied from interface:BeanServerDisables all beans that implement the specified interface.- Specified by:
disableAllBeansAssignableToin interfaceBeanServer<T extends Bean>
-
replaceBeanAssignableTo
public boolean replaceBeanAssignableTo(Class<?>[] interfaceClasses, String newBeanClassName, Map<String, String> newBeanProperties) throws BeanInitializationExceptionDescription copied from interface:BeanServerAssuming there is at most one enabled bean that implements one of the specified interfaces, puts the specified configuration and enables a new bean in its place.- Specified by:
replaceBeanAssignableToin interfaceBeanServer<T extends Bean>- Parameters:
interfaceClasses- - the interface that the new and old bean need to implementnewBeanClassName- - the class name of the beannewBeanProperties- - the new bean configuration that is to replace the existing specified interface implementation.- Returns:
- true -if bean reaplaced, false if no configuration change detected.
- Throws:
BeanInitializationException
-
getEnabledBeansClassNamesAssignableTo
public List<String> getEnabledBeansClassNamesAssignableTo(Class<?>[] interfaceClasses) throws ClassNotFoundException - Specified by:
getEnabledBeansClassNamesAssignableToin interfaceBeanServer<T extends Bean>- Parameters:
interfaceClasses- - the interface that the bean we are looking for needs to implement- Returns:
- the enabled bean class names that implements any one of the specified interfaces.
- Throws:
ClassNotFoundException
-
destroy
public void destroy()- Specified by:
destroyin interfaceBeanServer<T extends Bean>
-
getEnabledBeansAssignableTo
- Specified by:
getEnabledBeansAssignableToin interfaceBeanServer<T extends Bean>- Parameters:
interfaceClasses- - the interface that the bean we are looking for needs to implement- Returns:
- the enabled bean that implements any one of the specified interfaces.
-