Class BusinessObjectFactoryImpl
- All Implemented Interfaces:
BusinessObject
,BusinessObjectFactory
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Properties
This factory's component settings.private Properties
This factory's application settings.private DAOFactory
This factory'sDAOFactory
.private com.google.common.eventbus.EventBus
This factory'sEventBus
.private com.google.inject.Injector
This factory'sInjector
.(package private) static org.apache.commons.logging.Log
private Settings
This factory'sSettings
instance.private User
This factory'sUser
. -
Constructor Summary
Constructors -
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.findImplementer
(String type) 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
.Methods inherited from class com.softslate.commerce.businessobjects.core.BaseBusinessObject
initialize
-
Field Details
-
log
static org.apache.commons.logging.Log log -
user
This factory'sUser
. The currentUser
accessing the system, for which business processing is to be performed by business objects created by this factory. This factory will pass theUser
to every business object it creates. -
settings
This factory'sSettings
instance. The currentSettings
, containing various settings to be used by business objects created by this factory. This factory will pass theSettings
to every business object it creates. -
appSettings
This factory's application settings. The current application settings for the system. 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 theSettingsBean
, which stores settings drawn from the database. -
appComponents
This factory's component settings. The component settings identify which Java classes implement the various interfaces used by the system. -
daoFactory
This factory'sDAOFactory
. The currentDAOFactory
for the system, which will allow business objects created by this factory to create data access objects. This factory will pass theDAOFactory
to every business object it creates. -
injector
private com.google.inject.Injector injectorThis factory'sInjector
. When this BusinessObjectFactory creates and object, it will populate that objects injector property so the object can use it to invoke other objects using dependency injection (Guice). -
eventBus
private com.google.common.eventbus.EventBus eventBusThis factory'sEventBus
. When this BusinessObjectFactory creates and object, it will populate that object's eventBus property so the object can use it to post events and trigger subscribers to run their code.
-
-
Constructor Details
-
BusinessObjectFactoryImpl
public BusinessObjectFactoryImpl() -
BusinessObjectFactoryImpl
-
-
Method Details
-
getUser
Description copied from interface:BusinessObjectFactory
Retrieves theUser
previously set for this factory.- Specified by:
getUser
in interfaceBusinessObjectFactory
- Returns:
- A
User
object that represents the user currently accessing the system.
-
setUser
Description copied from interface:BusinessObjectFactory
Sets this factory'sUser
. This factory will pass theUser
to every business object it creates.- Specified by:
setUser
in interfaceBusinessObjectFactory
- Parameters:
user
- The currentUser
accessing the system, for which business processing is to be performed by business objects created by this factory.
-
getSettings
Description copied from interface:BusinessObjectFactory
Retrieves theSettings
previously set for this factory.- Specified by:
getSettings
in interfaceBusinessObjectFactory
- Returns:
- A
Settings
object that represents various settings for the system.
-
setSettings
Description copied from interface:BusinessObjectFactory
Sets this factory'sSettings
instance. This factory will pass theSettings
to every business object it creates.- Specified by:
setSettings
in interfaceBusinessObjectFactory
- Parameters:
settings
- The currentSettings
for the system, containing various settings to be used by business objects created by this factory.
-
getAppSettings
Description copied from interface:BusinessObjectFactory
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.- Specified by:
getAppSettings
in interfaceBusinessObjectFactory
- Returns:
- A
Properties
object that represents various settings for the application.
-
setAppSettings
Description copied from interface:BusinessObjectFactory
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.- Specified by:
setAppSettings
in interfaceBusinessObjectFactory
- Parameters:
appSettings
- The current application settings in effect for the system.
-
getAppComponents
Description copied from interface:BusinessObjectFactory
Retrieves the application components previously set for this factory. The components identify which Java class implement the various Interfaces used by the system.- Specified by:
getAppComponents
in interfaceBusinessObjectFactory
- Returns:
- A
Properties
object that represents the components for the application.
-
setAppComponents
Description copied from interface:BusinessObjectFactory
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.- Specified by:
setAppComponents
in interfaceBusinessObjectFactory
- Parameters:
appComponents
- The current application components in effect for the system.
-
getDaoFactory
Description copied from interface:BusinessObjectFactory
Retrieves theDAOFactory
previously set for this factory.- Specified by:
getDaoFactory
in interfaceBusinessObjectFactory
- Returns:
- A
DAOFactory
object that can be used to create data access objects.
-
setDaoFactory
Description copied from interface:BusinessObjectFactory
Sets this factory'sDAOFactory
. This factory will pass theDAOFactory
to every business object it creates.- Specified by:
setDaoFactory
in interfaceBusinessObjectFactory
- Parameters:
daoFactory
- The currentDAOFactory
for the system, which will allow business objects created by this factory to create data access objects.
-
getInjector
public com.google.inject.Injector getInjector()Description copied from interface:BusinessObjectFactory
Retrieves theInjector
previously set for this factory.- Specified by:
getInjector
in interfaceBusinessObjectFactory
- Returns:
- A
Injector
object that can be used to create other objects and inject them with dependencies.
-
setInjector
public void setInjector(com.google.inject.Injector injector) Description copied from interface:BusinessObjectFactory
Sets this factory'sInjector
. This factory will pass theInjector
to every business object it creates.- Specified by:
setInjector
in interfaceBusinessObjectFactory
- Parameters:
injector
- The currentInjector
for the system, which can be used to create other objects and inject them with dependencies.
-
getEventBus
public com.google.common.eventbus.EventBus getEventBus()Description copied from interface:BusinessObjectFactory
Retrieves theEventBus
previously set for this factory.- Specified by:
getEventBus
in interfaceBusinessObjectFactory
- Returns:
- A
EventBus
object that can be used to post events and trigger subscribers to run their code.
-
setEventBus
public void setEventBus(com.google.common.eventbus.EventBus eventBus) Description copied from interface:BusinessObjectFactory
Sets this factory'sEventBus
. This factory will pass theEventBus
to every business object it creates.- Specified by:
setEventBus
in interfaceBusinessObjectFactory
- Parameters:
eventBus
- The currentEventBus
for the system, which can be used to post events to subscribers
-
createObject
Description copied from interface:BusinessObjectFactory
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.
- Specified by:
createObject
in interfaceBusinessObjectFactory
- 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
-
createObject
- Specified by:
createObject
in interfaceBusinessObjectFactory
-
createObjectFromClassName
Description copied from interface:BusinessObjectFactory
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.- Specified by:
createObjectFromClassName
in interfaceBusinessObjectFactory
- 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
public <T extends BusinessObject> T createObjectFromClassDefinition(Class classDefinition) throws Exception - Specified by:
createObjectFromClassDefinition
in interfaceBusinessObjectFactory
- Throws:
Exception
-
createUtilsObject
- Specified by:
createUtilsObject
in interfaceBusinessObjectFactory
-
createUtilsObject
Description copied from interface:BusinessObjectFactory
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):
- Specified by:
createUtilsObject
in interfaceBusinessObjectFactory
- Parameters:
type
- AString
such as "formUtilsImplementer" corresponding to a key in theappComponents.properties
file.- Returns:
- An instance of the requested business object.
-
findImplementer
-
invokeMultipleProcessors
Description copied from interface:BusinessObjectFactory
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.- Specified by:
invokeMultipleProcessors
in interfaceBusinessObjectFactory
- 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
public Collection invokeMultipleCollectionProcessors(String type, String method, Map argument) throws Exception Description copied from interface:BusinessObjectFactory
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.- Specified by:
invokeMultipleCollectionProcessors
in interfaceBusinessObjectFactory
- 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
-
getTransferMap
Description copied from interface:BusinessObjectFactory
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.- Specified by:
getTransferMap
in interfaceBusinessObjectFactory
- Returns:
- A
Map
of this factory's properties.
-