Hi !
my name's Alessandro Colantoni.
It's almost a couple of years I'm using Ojb.
I developed a small framework called Mandragora. I would like someone help
me to put it in apache as a new project, if it is evaluated useful.
Mandragora would be a framework that helps implementing Business Delegate
and DAO patterns.
In my controller class I want to use methods of an an Interface BD (Business
delegate) to manipulate my beans without worry about their implementation
technology, about implementation logic (my business logic) and so on.
I have just to fix on my control logic. I don't want to Know if I'm in a
managed environment or not, if I'm using session bean, if they are stateful
or not or other...
'Cause the control logic I need is very similar all around my application
(and more, this similarity is visible through almost all applications) I
want these methods be very general, and I want to switch form an
implementation to an other just changing a a properties file.
So through my application i want to use just my interface BD, retrieved by a
ServiceLocator class which I have just to pass to the name of the
implementation mapped in an properties file ( or nothing to use the default
implementation)
Of course I can use different implementations in different application
areas.
BD implementation class communicate with media store through a DAO in the
same way controller communicate with BD layer.
I don't want worry if my DAO is implemented with OJB or Hibernate , or other
(the only implementation I developed is based on Ojb persistence broker :-))
More I can say that I don't worry if my media store is an an RDBMS or other.
In this way I just fix on logic control, of particular aspects of my
business logic.
It will be right, that each time we need to do a manipulation of beans that
we can't do with any combination of methods BD interface, we will do an
effort to write a general method to add to implementation class and so to
the interface.
Analogous for the DAO layer, we can write alway more methods that execute
more different queries.
In this way we can way following the pattern controller--> BD--> DAO having
to write alway less logic business, 'cause the number of the existing
methods grows up.
The mechanism, based on factory pattern , to retrieve implementation classes
based on file properties has been copied form Ojb mechanism.
AS said , at the moment I just wrote an implementation for DAO interface
based on Ojb, and a standard interface for DB interface, that is not
suitable for managed environments.
The method I dispose in my BD interface are the following:.
public Object findByPrimaryKey(Class realClass,String[] fieldName, Object[]
pkValues)
public Object findByPrimaryKey(Class realClass, Object pkValue)
public Collection findCollectionByTemplate(Object templateVO)
public Object findObjectByTemplate(Object templateVO)
public Object insert(Object insertVO)
public Object insert(Object insertVO,boolean commit)
public Object update(Object updateVO)
public Object update(Object updateVO,boolean commit)
public void delete(Object deleteVO);
public void delete(Object deleteVO,boolean commit);
public void retrieveReference(Object pInstance, String pAttributeName)
public void retrieveAllReferences(Object pInstance);
public Object updateCollectionReference(Object storeVO, String
pAttributeName, boolean commit);
public Object updateCollectionReference(Object storeVO, String
pAttributeName);
public Collection findOrderedCollectionByTemplate(Object templateVO, String
orderingField, boolean asc);
public Object updateCollectionReferences(Object storeVO, boolean commit)
public Object updateCollectionReferences(Object storeVO)
public Collection findCollectionByNullFields(Class clazz, String[]
nullFields)
public Collection findCollectionByLogicCondition(Class clazz,LogicCondition
logicCondition)
For example If in a controller class I need to get an object of a class Bean
whose unique key value is "key"
I just write:
ServiceLocator.getInstance().getManagerBD("BDFactoryDefaultClass","
StandardBDDefaultClass"). findByPrimaryKey (Bean.class,"key"");
At the moment are just few methods, but I hope the structure is good, so I
can write always more.
I just wrote some more that just do complex manipulation without storing,
that I'm sure will use in next projects to.
I hope this could be interesting.
Thanks for attention.