db-ojb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Mahler <thm...@web.de>
Subject Re: ODMG patch: per-transaction implicit locking
Date Fri, 03 Oct 2003 12:43:12 GMT
Hi Phil,

I like your idea. I've just checked in some code that implements it. I 
added the method setImplicitLocking to the TransactionExt interface. 
This allows to have it available in TransactionImpl *and* in 
NarrowTransaction.
By this trick I only had to change OJB but not OJBJ2EE_2.

thanks for this interesting patch!

Thomas

Phil Warrick wrote:
> Hi,
> 
> I have been using the following patch to control the implicit locking 
> flag at the transaction level (instead of a single global setting).  I 
> developed it because I wanted to do ODMG reading without implicit 
> locking and to do ODMG writing with implicit locking.  Even with a 
> schema that is fully proxied, I found that read locking propagates 
> across the proxies leading to a potentially large graph traversal.
> 
> The changes are really just the addition of a 
> setImplicitLocking(boolean) method to the following three classes:
> 
> 1)org.apache.ojb.odmg.TransactionImpl
> 2)org.apache.ojb.odmg.OJB
> 3)org.apache.ojb.odmg.OJBJ2EE_2
> 
> This has been tested in both a single JVM setting and in a J2EE/EJB 
> environment.
> 
> The changes (below) are so trivial that I didn't do make a true patch 
> file.  I hope one of the developers can review these changes and 
> incorporate them if appropriate.
> 
> This change can be thought of as an extension to the ODMG api, giving 
> greater control to the locking stategy (the ODMG standard enforces no
> particular implicit locking strategy).  The global setting 
> "ImplicitLocking" specified in OJB.properties is used when a 
> org.apache.ojb.odmg.TransactionImpl is created.  A subsequent call to 
> OJB#setImplicitLocking(boolean) or
> OJBJ2EE_2#setImplicitLocking(boolean) within the transaction overrides 
> the global setting.
> 
> The reason that I did not use the approach
>         ((OjbConfiguration)getConfiguration()).setUseImplicitLocking(in);
> 
> to set the global configuration setting is that this is not thread-safe, 
> as far as I can tell.
> 
> Of course if there's an easier way to do this I'd like to know.
> 
> Phil
> 
> 1) org.apache.ojb.odmg.TransactionImpl.java
> public void setImplicitLocking(boolean in)
> {
> useImplicitLocking = in;
> }
> 
> 2) org.apache.ojb.odmg.OJB.java
> public void setImplicitLocking(boolean in)
> {
> ((TransactionImpl)currentTransaction()).setImplicitLocking(in);
> }
> 
> 3) org.apache.ojb.odmg.OJBJ2EE_2.java
> public void setImplicitLocking(boolean in)
> {
> currentTransaction();
> ((TransactionImpl)super.currentTransaction()).setImplicitLocking(in);
> }
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Mime
View raw message