public abstract class

AbstractLocalBeanFactory

extends Object
implements LocalBeanFactory
java.lang.Object
   ↳ com.microstrategy.web.beans.AbstractLocalBeanFactory
Known Direct Subclasses

Class Overview

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(Class) can be overridden to create the actual bean instances. Override getBeanClassName(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.

Summary

Protected Constructors
AbstractLocalBeanFactory()
Public Methods
boolean canCreateBean(String beanName)
Check whether this factory can create a bean with a given type name.
WebComponent newBean(String beanName)
Create a bean based on the bean type name.
Protected Methods
WebComponent createBeanInstance(Class beanClass)
Create an instance of beanClass.
String getBeanClassName(String beanName)
Resolve a bean type name to a fully qualified class name (ex: "ReportBean" --> "com.microstrategy.web.beans.ReportBeanImpl").
abstract String getBeanPackage()
Returns the full name of the package associated with this factory (ex: "com.microstrategy.web.beans").
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.microstrategy.web.beans.LocalBeanFactory

Protected Constructors

protected AbstractLocalBeanFactory ()

Public Methods

public boolean canCreateBean (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(String) with that bean type name will result in a BeanNotFoundException.

Parameters
beanName The type name of the bean to check.
Returns
  • true if this factory can create a bean for beanName; false otherwise.

public WebComponent newBean (String beanName)

Create a bean based on the bean type name. This implementation will look for a bean class named "<pkg name>.<beanName>Impl", where <pkg name> is the string returned by getBeanPackage(). This method will call getBeanClassName(String) to resolve beanName to a class name, and createBeanInstance(Class) to create the bean instance.

Parameters
beanName The type name of the desired bean (ex: "ReportBean").
Returns
Throws
IllegalArgumentException If beanName is null or empty.
BeanNotFoundException If beanName could not be resolved to a class.
MSTRUncheckedException If an error occurred in the process of instantiating the bean instance.

Protected Methods

protected WebComponent createBeanInstance (Class beanClass)

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 newInstance().

Parameters
beanClass The class of the desired bean.
Returns
  • An instance of the desired bean class.
Throws
IllegalAccessException
InstantiationException

protected String getBeanClassName (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.

protected abstract 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.