java.lang.Object | |
↳ | com.microstrategy.web.beans.BeanFactory |
The BeanFactory
class allows the user to create both MicroStrategy
beans and custom beans. It is used by the MicroStrategy Web application to
create beans specified in the page configuration files.
Clients create beans using the newBean
method, which takes a bean type name and retuns an instance of the
corresponding bean class. To map a bean name to a bean class, the
factory uses a set of bean mappings and an ordered list of packages. A bean
mapping maps a bean name (ex: "ReportBean") to a fully qualified classname.
The package list provides a set of packages that will be searched in the
event that a given bean name isn't explicitly mapped to a class.
Specifically, the logic for creating a bean based on the type name is as
follows:
LocalBeanFactory
instance)."<bean name> + Impl"
. If such a class exists,
instantiate and return a new instance.BeanNotFoundException
.<beanfactory-config> <bean-mappings> <bean-mapping bean-name="Bean1" bean-class="test.pkg1.Bean1"/> </bean-mappings> <bean-packages> <bean-package package-name="misc.dummypkg2"/> <bean-package package-name="misc.dummypkg4" local-factory="DummyPkg4Factory"/> </bean-packages> </beanfactory-config>The XML above adds one new mapping, from "Bean1" to
test.pkg1.Bean1
,
to those that already exist. It also appends two packages to the list of
packages to search. To create beans in the second package,
misc.dummypkg4
, the BeanFactory
will delegate to
an instance of that package's factory,
misc.dummypkg4.DummyPkg4Factory
.local-factory
attribute must meet the following requirements:
LocalBeanFactory
interface. (See
AbstractLocalBeanFactory
for a default implementation of this
interface.)public static <return-type> getInstance();
newBean
method implementation must
be thread-safe.BeanFactory
is a singleton, so any instance-level setters
take effect globally.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
class | BeanFactory.BeanFactoryInfo | ||||||||||
class | BeanFactory.BeanMappingInfo | ||||||||||
class | BeanFactory.BeanMappingInfoList | ||||||||||
class | BeanFactory.BeanPackageInfo | ||||||||||
class | BeanFactory.BeanPackageInfoList |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String |
getConfigurationPath()
Get the path for the
BeanFactory configuration file. | ||||||||||
static BeanFactory |
getInstance()
Return a BeanFactory instance.
| ||||||||||
WebComponent |
newBean(String beanName)
Create a bean based on the bean type name.
| ||||||||||
void |
setConfigurationPath(String configPath)
Specify the path for the application's beanFactoryConfig.xml file,
relative to the root of the application.
| ||||||||||
void |
update(Observable o, Object arg)
Exposed so that this class can update its state when customizations change.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Get the path for the BeanFactory
configuration file.
Return a BeanFactory instance.
Create a bean based on the bean type name.
beanName | The type name of the desired bean (ex: "ReportBean"). |
---|
WebComponent
instance that corresponds to
beanName
.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. |
Specify the path for the application's beanFactoryConfig.xml file,
relative to the root of the application. This method should be called
when the application is initialized, before any instances of this class
are used. It is not threadsafe with respect to other
BeanFactory
instance methods. The value of this property is
by default an empty string, which means that no application-level
configuration file will be used. (In this case, the factory will contain
no bean mappings and a single package:
com.microstrategy.web.beans
.)
configPath | The path to the configuration file, relative to the application root directory (ex: "/WEB-INF/xml/config/beanFactoryConfig.xml"). |
---|
IllegalArgumentException | If configPath is null.
|
---|
Exposed so that this class can update its state when customizations change.
Clients should not call this method directly. This method is not threadsafe
with respect to other BeanFactory
methods.