com.softslate.commerce.businessobjects.core
Class BusinessObjectFactory

java.lang.Object
  extended bycom.softslate.commerce.businessobjects.core.BusinessObjectFactory

public class BusinessObjectFactory
extends java.lang.Object

Factory class used to create instances of business layer objects.

Generally, this class uses a SettingsBean instance to look up the fully-qualified class name of the requested business object. 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, SettingsBean, 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
private  DAOFactory daoFactory
          This factory's DAOFactory.
(package private) static org.apache.commons.logging.Log log
           
private  SettingsBean settingsBean
          This factory's SettingsBean.
private  User user
          This factory's User.
 
Constructor Summary
BusinessObjectFactory()
           
BusinessObjectFactory(SettingsBean settingsBean)
           
 
Method Summary
 java.lang.Object createObject(java.lang.String type)
          Creates a business object.
 java.lang.Object createObjectFromClassName(java.lang.String className)
          Creates a business object.
 DAOFactory getDaoFactory()
          Retrieves the DAOFactory previously set for this factory.
 SettingsBean getSettingsBean()
          Retrieves the SettingsBean previously set for this factory.
 java.util.Map getTransferMap()
          Creates a Map of this factory's properties.
 User getUser()
          Retrieves the User previously set for this factory.
 void setDaoFactory(DAOFactory daoFactory)
          Sets this factory's DAOFactory.
 void setSettingsBean(SettingsBean settingsBean)
          Sets this factory's SettingsBean.
 void setUser(User user)
          Sets this factory's User.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

static org.apache.commons.logging.Log log

user

private User user
This factory's User. The current User accessing the system, for which business processing is to be performed by business objects created by this factory. This factory will pass the User to every business object it creates.


settingsBean

private SettingsBean settingsBean
This factory's SettingsBean. The current SettingsBean, containing various settings to be used by business objects created by this factory. This factory will pass the SettingsBean to every business object it creates.


daoFactory

private DAOFactory daoFactory
This factory's DAOFactory. The current DAOFactory for the system, which will allow business objects created by this factory to create data access objects. This factory will pass the DAOFactory to every business object it creates.

Constructor Detail

BusinessObjectFactory

public BusinessObjectFactory()

BusinessObjectFactory

public BusinessObjectFactory(SettingsBean settingsBean)
Method Detail

getUser

public User getUser()
Retrieves the User previously set for this factory.

Returns:
A User object that represents the user currently accessing the system.

setUser

public void setUser(User user)
Sets this factory's User. This factory will pass the User to every business object it creates.

Parameters:
user - The current User accessing the system, for which business processing is to be performed by business objects created by this factory.

getSettingsBean

public SettingsBean getSettingsBean()
Retrieves the SettingsBean previously set for this factory.

Returns:
A SettingsBean object that represents various settings for the system.

setSettingsBean

public void setSettingsBean(SettingsBean settingsBean)
Sets this factory's SettingsBean. This factory will pass the SettingsBean to every business object it creates.

Parameters:
settingsBean - The current SettingsBean for the system, containing various settings to be used by business objects created by this factory.

getDaoFactory

public DAOFactory getDaoFactory()
Retrieves the DAOFactory previously set for this factory.

Returns:
A DAOFactory object that can be used to create data access objects.

setDaoFactory

public void setDaoFactory(DAOFactory daoFactory)
Sets this factory's DAOFactory. This factory will pass the DAOFactory to every business object it creates.

Parameters:
daoFactory - The current DAOFactory for the system, which will allow business objects created by this factory to create data access objects.

getTransferMap

public java.util.Map getTransferMap()
Creates a Map of this factory's properties. This factory will pass the Map to the initialize(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.

createObject

public java.lang.Object createObject(java.lang.String type)
                              throws java.lang.Exception
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 the code field in the npcSetting table of the database. This factory uses its SettingsBean 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 - A String 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:
java.lang.Exception

createObjectFromClassName

public java.lang.Object createObjectFromClassName(java.lang.String className)
                                           throws java.lang.Exception
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 - A String 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:
java.lang.Exception


Copyright © SoftSlate, Inc. 2003–2005