| Homes |
|
BeanHome (com.javelin.beans.BeanHome) It is the responsibility of the BeanHome interface to find, create, update and remove individual beans from their persistent store; whilst it is the responsibility of the session to coordinate that persistence behavior. The BeanHome should (generally) not be used directly by the application programmer. The BeanHome has a few of methods to allow the Session to be aware of its context, The key represents the current key (User) on the system, this set on the Home before the home is got from the ClassContext. This key could be a Thread or User name and can be used by the Home to retrieve objects bound in its own context. public Object getKey(); The ClassContext represents the current ClassContext for the Home. Public ClassContext getClassContext(); The BeanHome has a set of 'abstract' persistence methods that allow the BeanSession to coordinate persistence of dependent Beans. It is the responsibility of implementation of the BeanHome class to implement these methods. These methods are as follows: - public Bean findBeanByPrimaryKey( Object primaryKey
) throws FinderException, ValidationException; |
|
AbstractBeanHome (com.javelin.beans.AbstractBeanHome) The AbstractBeanHome is a helper class that specific BeanHomes extend. The AbstractBeanHome has the following functionality: -
|
|
HomeInterfaceWriter (com.javeln.generator.beans.HomeInterfaceWriter) The HomeInterfaceWriter is responsible for writing out the BeanHome interfaces for every table. |
|
Instantiating Bean Homes BeanHomes are instantiated by the ClassContext. This is done to hide the implementation of the BeanHomes. BeanHomes are instantiated using the following syntax: - <ClassName>Home home = <ContextName>Context.getDefault().new<ClassName>Home(); <ClassName>Home home = <ContextName>Context.getDefault().get<ClassName>Home(); <ClassName>Home home = <ContextName>Context.getDefault().get<ClassName>Home(Object key); To get a new AccountHome from the NorthwindContext, all you have to do is call : - AccountHome accountHome = NorthwindContext.getDefault().newAccountHome(); |
|
Finding Beans The BeanSession is required to find beans using the BeanHome interface. This is because of caching constraints. All the findBy methods on the BeanSession are replicated on the BeanHome. |
|
Counting Beans Counting Beans, using the countBy methods is not a requirement on homes. It is is the responsibility of the Session to count beans and there is no requirement to use a BeanHome instance to do this. |
|
Loading Beans The BeanHome is responsible for loading beans. Every BeanHome will have the following syntax: - public void load( <ClassName> <className ) throws LoadException, ValidationException; The BeanHome will only load the bean that is has been requested to. It is the responsibility of the BeanSession to coordinate calling the load methods on all the BeansHomes for all the dependent beans when a Bean is loaded on a BeanSession. |
|
Creating Beans The BeanHome is responsible for creating beans. Every BeanHome will have the following syntax: - public void create( <ClassName> <className ) throws CreateException, ValidationException; The BeanHome will only create the bean that is has been requested to. It is the responsibility of the BeanSession to coordinate calling the create and store methods on all the BeansHomes for all the dependent beans when a Bean is saved on a BeanSession. |
|
Storing Beans The BeanHome is responsible for storing beans. Every BeanHome will have the following syntax: - public void store( <ClassName> <className ) throws StoreException, ValidationException; The BeanHome will only store the bean that is has been requested to. It is the responsibility of the BeanSession to coordinate calling the create and store methods on all the BeansHomes for all the dependent beans when a Bean is saved on a BeanSession. |
|
Removing Beans The BeanHome is responsible for removing beans. Every BeanHome will have the following syntax: - public void store( <ClassName> <className ) throws StoreException, ValidationException; The BeanHome will only remove the bean that is has been request to. It is the responsibility of the BeanSession to coordinate calling the remove methods on all the BeansHomes for all the dependent beans when a Bean is remove on a BeanSession. |
|
Example Home Here is an example of a (simple) Home Interfaces for Addresses to give a big picture of what is generated. /* package com.javelin.jcommerce; import java.util.*; /** public interface AddressHome extends BeanHome /** /** /** /** /** /** /** /** /** /** } |