avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "hammett" <hamm...@apache.org>
Subject Re: [RT] Component Persistence
Date Sat, 01 Nov 2003 23:57:41 GMT
----- Original Message ----- 
From: "Alexis Agahi" <alag@users.sf.net>

> For me a compenent is an object like any other, except it features
lifecycle
> interfaces. So I'm trying to imagine if a component could handle
persistence
> lifecycle interface.

Do you want some messages like "store" and "load" managed by some external
entity (component)?

Then that can be done by a additional extension, but I don't know why this
should be done this way. Niclas see a persistence engine as a different
component and I see components that can handle their own persistence
transparently.

I strongly advise you to support persistence that can be plugged in and off,
so please check http://www.prevayler.org/

Few months ago I worked in a simple business model (using avalon) whose
business objects implemented IBusinessObject that exposed save/remove. These
methods ask for their PersistenceManager (as Niclas commented). So, for Unit
testing we could use prevayler, but in our real solution we used a common
rdbms.

 [AvalonService( typeof(IEntity) )]
 [AvalonComponent( "entity", Lifestyle.Transient )]
 [AvalonDependency( typeof(IEntityPersistence), "Persistence",
Optional.False )]
 public class Entity : AbstractBusinessObject, IEntity, ILookupEnabled
 {
    <....>
  /// <summary>
  /// Saves this object against the storage.
  /// <seealso cref="Keldor.Common.Entity.Persistence.IEntityPersistence"/>
  /// </summary>
  public override void Save()
  {
   IEntityPersistence persistence = (IEntityPersistence)
_manager["Persistence"];
   persistence.Save(this);
  }

  /// <summary>
  /// Removes this object from the storage.
  /// <seealso cref="Keldor.Common.Entity.Persistence.IEntityPersistence"/>
  /// </summary>
  public override void Remove()
  {
   IEntityPersistence persistence = (IEntityPersistence)
_manager["Persistence"];
   persistence.Remove(this);
  }
 }



Regards,

hammett


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


Mime
View raw message