GigaSpaces XAP 9.7.2 API

org.openspaces.core.bean
Class DefaultBeanServer<T extends Bean>

java.lang.Object
  extended by org.openspaces.core.bean.DefaultBeanServer<T>
All Implemented Interfaces:
BeanConfigPropertiesManager, BeanServer<T>

public class DefaultBeanServer<T extends Bean>
extends Object
implements BeanServer<T>


Constructor Summary
DefaultBeanServer(Admin admin)
           
DefaultBeanServer(BeanFactory<T> beanFactory)
           
 
Method Summary
 void destroy()
           
 void disableAllBeans()
          Disable all currently enabled beans.
 void disableAllBeansAssignableTo(Class<?> interfaceClass)
          Disables all beans that implement the specified interface.
 void disableBean(String beanClassName)
          Disables a bean.
 void enableBean(String beanClassName)
          Disables a bean.
 Map<String,String> getBeanConfig(String beanClassName)
          Get the bean configuration.
 String[] getBeansClassNames()
          Lists the class names of configured beans.
 T getEnabledBean(String beanClassName)
           
 List<T> getEnabledBeansAssignableTo(Class<?>[] interfaceClasses)
           
 String[] getEnabledBeansClassNames()
          Lists the class names of enabled beans.
 List<String> getEnabledBeansClassNamesAssignableTo(Class<?>[] interfaceClasses)
           
 boolean isBeanEnabled(String beanClassName)
           
 boolean removeBeanConfig(String beanClassName)
          Removes a bean configuration.
 boolean replaceBeanAssignableTo(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.
 void setBeanConfig(String beanClassName, Map<String,String> properties)
          Defines a configuration for the specified bean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultBeanServer

public DefaultBeanServer(Admin admin)

DefaultBeanServer

public DefaultBeanServer(BeanFactory<T> beanFactory)
Method Detail

setBeanConfig

public void setBeanConfig(String beanClassName,
                          Map<String,String> properties)
                   throws EnabledBeanConfigCannotBeChangedException
Description copied from interface: BeanConfigPropertiesManager
Defines 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:
setBeanConfig in interface BeanConfigPropertiesManager
Parameters:
beanClassName - the bean class name
properties - 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: BeanConfigPropertiesManager
Disables 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:
enableBean in interface BeanConfigPropertiesManager
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

public void disableBean(String beanClassName)
                 throws BeanConfigNotFoundException
Description copied from interface: BeanConfigPropertiesManager
Disables 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:
disableBean in interface BeanConfigPropertiesManager
Parameters:
beanClassName - the bean class name
Throws:
BeanConfigNotFoundException - bean configuration cannot be found.

removeBeanConfig

public boolean removeBeanConfig(String beanClassName)
                         throws BeanConfigNotFoundException
Description copied from interface: BeanConfigPropertiesManager
Removes a bean configuration.

An exception is raised if the bean is enabled.

Specified by:
removeBeanConfig in interface BeanConfigPropertiesManager
Parameters:
beanClassName - the bean class name
Returns:
true if removed ,false if it did not exist in the first place.
Throws:
BeanConfigNotFoundException - bean configuration cannot be found.

isBeanEnabled

public boolean isBeanEnabled(String beanClassName)
Specified by:
isBeanEnabled in interface BeanConfigPropertiesManager
Parameters:
beanClassName - the bean class name
Returns:
true if the bean is enabled, false if the bean is disabled.

getBeanConfig

public Map<String,String> getBeanConfig(String beanClassName)
                                 throws BeanConfigNotFoundException
Description copied from interface: BeanConfigPropertiesManager
Get the bean configuration.

Specified by:
getBeanConfig in interface BeanConfigPropertiesManager
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

public String[] getBeansClassNames()
Description copied from interface: BeanConfigPropertiesManager
Lists the class names of configured beans.

Specified by:
getBeansClassNames in interface BeanConfigPropertiesManager
Returns:
an array of bean class names that have been configured bean. If no bean configuration exists, a zero length array is returned.

getEnabledBeansClassNames

public String[] getEnabledBeansClassNames()
Description copied from interface: BeanConfigPropertiesManager
Lists the class names of enabled beans.

Specified by:
getEnabledBeansClassNames in interface BeanConfigPropertiesManager
Returns:
an array of enabled beans. If no beans are enabled, a zero length array is returned.
See Also:
BeanConfigPropertiesManager.enableBean(String)

disableAllBeans

public void disableAllBeans()
Description copied from interface: BeanConfigPropertiesManager
Disable all currently enabled beans.

Specified by:
disableAllBeans in interface BeanConfigPropertiesManager
See Also:
BeanConfigPropertiesManager.disableBean(String)

getEnabledBean

public T getEnabledBean(String beanClassName)
Specified by:
getEnabledBean in interface BeanServer<T extends Bean>
Returns:
the bean instance of the specified class name, or null if not enabled.

disableAllBeansAssignableTo

public void disableAllBeansAssignableTo(Class<?> interfaceClass)
Description copied from interface: BeanServer
Disables all beans that implement the specified interface.

Specified by:
disableAllBeansAssignableTo in interface BeanServer<T extends Bean>

replaceBeanAssignableTo

public boolean replaceBeanAssignableTo(Class<?>[] interfaceClasses,
                                       String newBeanClassName,
                                       Map<String,String> newBeanProperties)
                                throws BeanInitializationException
Description copied from interface: BeanServer
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.

Specified by:
replaceBeanAssignableTo in interface BeanServer<T extends Bean>
Parameters:
interfaceClasses - - the interface that the new and old bean need to implement
newBeanClassName - - the class name of the bean
newBeanProperties - - 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:
getEnabledBeansClassNamesAssignableTo in interface BeanServer<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:
destroy in interface BeanServer<T extends Bean>

getEnabledBeansAssignableTo

public List<T> getEnabledBeansAssignableTo(Class<?>[] interfaceClasses)
Specified by:
getEnabledBeansAssignableTo in interface BeanServer<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.

GigaSpaces XAP 9.7.2 API

Copyright © GigaSpaces.