Class AbstractLocalBeanFactory

  • All Implemented Interfaces:
    LocalBeanFactory
    Direct Known Subclasses:
    AdminBeanFactory, AppBeanFactory, WebBeanFactory

    public abstract class AbstractLocalBeanFactory
    extends java.lang.Object
    implements LocalBeanFactory
    Default implementation of the LocalBeanFactory interface that resolves bean type names to bean classes by appending "Impl" to the bean type name. A given subclass should implement getBeanPackage() to specify the package associated with the factory. If the factory supports creating non-public bean implementation classes, createBeanInstance(java.lang.Class) can be overridden to create the actual bean instances. Override getBeanClassName(java.lang.String) to change the way bean type names are resolved to class names. Note that the implementation caches resolved bean class objects, so a given bean type name is only resolved to a bean class name once.
    Since:
    MicroStrategy Web 9.0.0
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canCreateBean​(java.lang.String beanName)
      Check whether this factory can create a bean with a given type name.
      protected WebComponent createBeanInstance​(java.lang.Class beanClass)
      Create an instance of beanClass.
      protected java.lang.String getBeanClassName​(java.lang.String beanName)
      Resolve a bean type name to a fully qualified class name (ex: "ReportBean" --> "com.microstrategy.web.beans.ReportBeanImpl").
      protected abstract java.lang.String getBeanPackage()
      Returns the full name of the package associated with this factory (ex: "com.microstrategy.web.beans").
      WebComponent newBean​(java.lang.String beanName)
      Create a bean based on the bean type name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractLocalBeanFactory

        protected AbstractLocalBeanFactory()
    • Method Detail

      • getBeanClassName

        protected java.lang.String getBeanClassName​(java.lang.String beanName)
        Resolve a bean type name to a fully qualified class name (ex: "ReportBean" --> "com.microstrategy.web.beans.ReportBeanImpl"). This implementation simply returns getBeanPackage() + "." + beanName + "Impl". Override this method to change the way bean type names are resolved to class names.
        Parameters:
        beanName - Bean type name to resolve.
        Returns:
        Fully qualified bean class name corresponding to beanName.
      • createBeanInstance

        protected WebComponent createBeanInstance​(java.lang.Class beanClass)
                                           throws java.lang.IllegalAccessException,
                                                  java.lang.InstantiationException
        Create an instance of beanClass. This implementation simply calls beanClass.newInstance(). Override this method in a derived class to create instances of non-public bean classes. Throws the same exceptions as Class.newInstance().
        Parameters:
        beanClass - The class of the desired bean.
        Returns:
        An instance of the desired bean class.
        Throws:
        java.lang.IllegalAccessException
        java.lang.InstantiationException
      • getBeanPackage

        protected abstract java.lang.String getBeanPackage()
        Returns the full name of the package associated with this factory (ex: "com.microstrategy.web.beans").
        Returns:
        The name of the package associated with this factory.
      • canCreateBean

        public boolean canCreateBean​(java.lang.String beanName)
        Check whether this factory can create a bean with a given type name. If this method returns false for a given bean type name, then calling newBean(java.lang.String) with that bean type name will result in a BeanNotFoundException.
        Specified by:
        canCreateBean in interface LocalBeanFactory
        Parameters:
        beanName - The type name of the bean to check.
        Returns:
        true if this factory can create a bean for beanName; false otherwise.