Interface BusinessObjectFactory
- All Known Implementing Classes:
BusinessObjectFactoryImpl
BusinessObjectFactoryImpl
.
Objects are created with the createObject
,
createObjectFromClassName
, or createUtilsObject
methods.
Generally, this class uses its appComponents
property to look
up the fully-qualified class name of the requested interface (taken from the
appComponents.properties
file. Then it uses the Java
reflection API to create the instance.
An instance of BusinessObjectFactory
is created in the Struts
layer. Its properties are populated there with the application's
DAOFactory
,
Settings
,
appComponents
, appSettings
, and with the
User
currently accessing
the system.
Immediately after instantiating the requested business object, this factory passes its own properties to it so that the newly created object can use them to communicate with the rest of the application.
- Author:
- David Tobey
-
Method Summary
Modifier and TypeMethodDescription<T extends BusinessObject>
TcreateObject
(Class<T> type) <T extends BusinessObject>
TcreateObject
(String type) Creates a business object.<T extends BusinessObject>
TcreateObjectFromClassDefinition
(Class classDefinition) <T extends BusinessObject>
TcreateObjectFromClassName
(String className) Creates a business object.<T> T
createUtilsObject
(Class<T> type) createUtilsObject
(String type) Given a type corresponding to a key in theappComponents.properties
file, creates and returns a utility object corresponding to the key.Retrieves the application components previously set for this factory.Retrieves the application settings previously set for this factory.Retrieves theDAOFactory
previously set for this factory.com.google.common.eventbus.EventBus
Retrieves theEventBus
previously set for this factory.com.google.inject.Injector
Retrieves theInjector
previously set for this factory.Retrieves theSettings
previously set for this factory.Creates aMap
of this factory's properties.getUser()
Retrieves theUser
previously set for this factory.invokeMultipleCollectionProcessors
(String type, String method, Map argument) Given a type corresponding to a key in theappComponents.properties
file, a method name, and a Map as the argument, loops through allBusinessProcessor
s configured inappComponents.properties
, calling each in turn.invokeMultipleProcessors
(String type, String method, Map argument) Given a type corresponding to a key in theappComponents.properties
file, a method name, and aMap
as the argument, loops through allBusinessProcessor
s configured inappComponents.properties
, calling each in turn.void
setAppComponents
(Properties appComponents) Sets this factory's application components.void
setAppSettings
(Properties appSettings) Sets this factory's application settings.void
setDaoFactory
(DAOFactory daoFactory) Sets this factory'sDAOFactory
.void
setEventBus
(com.google.common.eventbus.EventBus eventBus) Sets this factory'sEventBus
.void
setInjector
(com.google.inject.Injector injector) Sets this factory'sInjector
.void
setSettings
(Settings settings) Sets this factory'sSettings
instance.void
Sets this factory'sUser
.
-
Method Details
-
getAppSettings
Properties getAppSettings()Retrieves the application settings previously set for this factory. The application settings are settings for information unique to a given installation, such as the location of files on the server, as opposed to theSettings
, which stores settings drawn from the database.- Returns:
- A
Properties
object that represents various settings for the application.
-
setAppSettings
Sets this factory's application settings. This factory will pass the application settings to every business object it creates. The application settings are settings for information unique to a given installation, such as the location of files on the server, as opposed to theSettings
interface, which stores settings drawn from the database.- Parameters:
appSettings
- The current application settings in effect for the system.
-
getAppComponents
Properties getAppComponents()Retrieves the application components previously set for this factory. The components identify which Java class implement the various Interfaces used by the system.- Returns:
- A
Properties
object that represents the components for the application.
-
setAppComponents
Sets this factory's application components. This factory will pass the application components to every business object it creates. The components identify which Java class implement the various Interfaces used by the system.- Parameters:
appComponents
- The current application components in effect for the system.
-
getUser
User getUser()Retrieves theUser
previously set for this factory.- Returns:
- A
User
object that represents the user currently accessing the system.
-
setUser
Sets this factory'sUser
. This factory will pass theUser
to every business object it creates.- Parameters:
user
- The currentUser
accessing the system, for which business processing is to be performed by business objects created by this factory.
-
getSettings
Settings getSettings()Retrieves theSettings
previously set for this factory.- Returns:
- A
Settings
object that represents various settings for the system.
-
setSettings
Sets this factory'sSettings
instance. This factory will pass theSettings
to every business object it creates.- Parameters:
settings
- The currentSettings
for the system, containing various settings to be used by business objects created by this factory.
-
getDaoFactory
DAOFactory getDaoFactory()Retrieves theDAOFactory
previously set for this factory.- Returns:
- A
DAOFactory
object that can be used to create data access objects.
-
setDaoFactory
Sets this factory'sDAOFactory
. This factory will pass theDAOFactory
to every business object it creates.- Parameters:
daoFactory
- The currentDAOFactory
for the system, which will allow business objects created by this factory to create data access objects.
-
getInjector
com.google.inject.Injector getInjector()Retrieves theInjector
previously set for this factory.- Returns:
- A
Injector
object that can be used to create other objects and inject them with dependencies.
-
setInjector
void setInjector(com.google.inject.Injector injector) Sets this factory'sInjector
. This factory will pass theInjector
to every business object it creates.- Parameters:
injector
- The currentInjector
for the system, which can be used to create other objects and inject them with dependencies.
-
getEventBus
com.google.common.eventbus.EventBus getEventBus()Retrieves theEventBus
previously set for this factory.- Returns:
- A
EventBus
object that can be used to post events and trigger subscribers to run their code.
-
setEventBus
void setEventBus(com.google.common.eventbus.EventBus eventBus) Sets this factory'sEventBus
. This factory will pass theEventBus
to every business object it creates.- Parameters:
eventBus
- The currentEventBus
for the system, which can be used to post events to subscribers
-
createObject
Creates a business object.A lookup is performed first to find the fully-qualified Java class name of the object to create. The
type
parameter corresponds to a key in theappComponents.properties
file. This factory uses itsappComponents
property to perform the lookup.If the Java class name is found, an object is created, and then this factory populates it with its own properties. These properties allow the newly create object to communicate with the rest of the application.
- Parameters:
type
- AString
associated with the class name of the business object to be created.- Returns:
- An instance of the requested business object, or
null
, if an error occurs. - Throws:
Exception
-
createObjectFromClassName
Creates a business object.Using the
className
parameter, this factory creates an object, and then populates it with its own properties. These properties allow the newly create object to communicate with the rest of the application.- Parameters:
className
- AString
associated with the class name of the business object to be created.- Returns:
- An instance of the requested business object, or
null
, if an error occurs. - Throws:
Exception
-
createObjectFromClassDefinition
<T extends BusinessObject> T createObjectFromClassDefinition(Class classDefinition) throws Exception - Throws:
Exception
-
createObject
-
invokeMultipleProcessors
Given a type corresponding to a key in theappComponents.properties
file, a method name, and aMap
as the argument, loops through allBusinessProcessor
s configured inappComponents.properties
, calling each in turn. Returns aMap
compling all the results of eachBusinessProcessor
called. If any of theBusinessProcessor
s returns aMap
with a key ofresultCode
that is not equal to "0", processing of all remaining processors is halted, and this method returns immediately.- Parameters:
type
- A String such as "activePaymentProcessors" corresponding to a key in theappComponents.properties
file.method
- The method of eachBusinessProcessor
to invoke in turn.argument
- AMap
representing the single argument the method accepts.- Returns:
- A
Map
representing all the results of each processor combined. They are combined into a singleMap
using theMap.putAll()
method. - Throws:
Exception
-
invokeMultipleCollectionProcessors
Collection invokeMultipleCollectionProcessors(String type, String method, Map argument) throws Exception Given a type corresponding to a key in theappComponents.properties
file, a method name, and a Map as the argument, loops through allBusinessProcessor
s configured inappComponents.properties
, calling each in turn. Returns aCollection
compling all the results of eachBusinessProcessor
called.- Parameters:
type
- AString
such as "activeShippingProcessors" corresponding to a key in theappComponents.properties
file.method
- The method of eachBusinessProcessor
to invoke in turn. (E.g. "loadShippingOptions")argument
- AMap
representing the single argument the method accepts.- Returns:
- A
Collection
representing all the results of each processor combined. - Throws:
Exception
-
createUtilsObject
Given a type corresponding to a key in theappComponents.properties
file, creates and returns a utility object corresponding to the key.If no class can be instantiated for the given class name, an instance of one of the following classes is automatically returned (depending on the value of the type parameter):
- Parameters:
type
- AString
such as "formUtilsImplementer" corresponding to a key in theappComponents.properties
file.- Returns:
- An instance of the requested business object.
-
createUtilsObject
-
getTransferMap
Map getTransferMap()Creates aMap
of this factory's properties. This factory will pass theMap
to theinitialize(Map parameters)
method of each business object it creates, which in turn populates the object's properties.- Returns:
- A
Map
of this factory's properties.
-