avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Pugh" <ep...@upstate.com>
Subject RE: [RT] Component Persistence
Date Sat, 01 Nov 2003 18:44:03 GMT
Also,  related to what you are looking for, the Xingu project has a
Persistence component: http://xingu.sf.net that persists objects via both
OJB and Hibernate depending on what you pick.  It leverages the Hibernate
component to handle starting up hibernate.  If you write to it, you can
provide other backends quite easily.

Part of the reason I was involved in the project was to validate the concept
that with a good API you could have multiple backend providers.

Eric

> -----Original Message-----
> From: Peter Courcoux [mailto:peter@courcoux.biz]
> Sent: Saturday, November 01, 2003 4:35 PM
> To: Avalon Dev List
> Subject: Re: [RT] Component Persistence
>
>
> Alex,
>
> O/T a bit for this thread but possibly of interest.
>
> If you're not already aware of it, Eric Pugh wrote a
> hibernate component
> for ECM which, I believe, is on the Hibernate site.
>
> Regards,
>
> Peter
>
> On Sat, 2003-11-01 at 09:14, Alexis Agahi wrote:
> > Hi,
> >
> > As I'm now using hibernate on current biz project, some
> ideas come to my brain
> > about how could have transparent persistence with avalon compenent.
> >
> > Based on hibernate (JDO?) approach that all object could be
> mapped in database
> > with get/setter method to populate the object field from db
> (or persist state
> > to db), any component could support such feature.
> >
> > The main problem would be how manage compenent persistance.
> > I have a suggestion: via a Persitence interface that could
> be added in
> > component lifecycle.
> >
> > such as
> > public interface Persistence
> > {
> > 	public void persitence( PersistenceManager persistenceManager );
> > }
> >
> > PersistenceManager class would manage object
> persistance/lookup(load) and
> > transaction provider.
> >
> >
> >
> > For exemple:
> >
> > Let say we have a persistant component called "Foo"
> >
> > /**
> >  * @avalon.component version="1.0" name="Foo" lifestyle="transient"
> >  * @avalon.service type="Foo"
> >  */
> > public class Foo implements (AvalonFrameWorksStuff)
> > {
> > 	Long m_primaryKey;
> > 	String m_value;
> > 	....
> >
> > 	public void setId( Long id )
> > 	{
> > 		m_primaryKey = id;
> > 	}
> > 	public Long getId()
> > 	{
> > 		return m_primaryKey;
> > 	}
> >
> >
> > 	public void setValue( String value )
> > 	{
> > 		m_value = value;
> > 	}
> > 	public String getValue()
> > 	{
> > 		return m_value;
> > 	}
> > }
> >
> > We suppose that this object is mapped in db using
> persistence mapping
> > descriptor (such as hibernate or jdo) file.
> >
> >
> > Now we have a compenent Bar depending on Foo
> >
> > /**
> >  * @avalon.component version="1.0" name="Bar" lifestyle="transient"
> >  * @avalon.service type="Bar"
> >  */
> > public class Bar implements
> > Servicealbe, Persistence
> > {
> > 	String m_serviceManager;
> > 	....
> > 	/**
> > 	  * @avalon.dependency type="Foo:1.0"  key="Foo"
> >  	 */
> > 	public void service( ServiceManager serviceManager)
> > 	throws ServiceException
> > 	{
> > 		m_serviceManager = serviceManager;
> > 	}
> >
> >
> >
> > 	public void persitence( PersistanceManager persistanceManager ){
> >
> > 		PrimaryLookupCriteria criteria = new
> PrimaryLookupCriteria( new Long( 1 ) );
> > 		Foo foo = persistanceManager.lookup(
> m_serviceManager, "Foo", criteria );
> >
> > 		getLogger().info( foo.getValue() );
> >
> > 		Transaction = null;
> > 		try{
> > 			tx = persistanceManager.getTransaction();
> > 			foo.setValue( "Dude!" );
> > 			tx.save( foo );
> > 			tx.commit();
> > 		}
> > 		catch( TransactionExcetion te )
> > 		{
> > 			tx.rollback();
> > 		}
> > 		finally
> > 		{
> > 			if( tx != null ) tx.close();
> > 		}
> >
> >
> > 	}
> >
> > }
> >
> >
> >
> >
> > Cheers
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
> > For additional commands, e-mail: dev-help@avalon.apache.org
> --
> Peter Courcoux <peter@courcoux.biz>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
> For additional commands, e-mail: dev-help@avalon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Mime
View raw message