Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 17222 invoked from network); 10 Jun 2004 13:27:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 10 Jun 2004 13:27:36 -0000 Received: (qmail 48048 invoked by uid 500); 10 Jun 2004 13:27:39 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 47944 invoked by uid 500); 10 Jun 2004 13:27:38 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 47902 invoked by uid 99); 10 Jun 2004 13:27:38 -0000 Received: from [66.199.152.34] (HELO kgb07.kgbinternet.com) (66.199.152.34) by apache.org (qpsmtpd/0.27.1) with ESMTP; Thu, 10 Jun 2004 06:27:38 -0700 Received: from [192.168.1.101] (pool-138-88-71-139.res.east.verizon.net [138.88.71.139]) (authenticated bits=0) by kgb07.kgbinternet.com (8.12.8/8.12.8) with ESMTP id i5ADRSlI027411 for ; Thu, 10 Jun 2004 07:27:28 -0600 Mime-Version: 1.0 (Apple Message framework v618) To: List Developers OJB Message-Id: Content-Type: multipart/mixed; boundary=Apple-Mail-1--954805247 From: Robert Sfeir Subject: [patch] a couple more quick fixes Date: Thu, 10 Jun 2004 09:27:40 -0400 X-Mailer: Apple Mail (2.618) X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N --Apple-Mail-1--954805247 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed No biggie here. I am working on fixing recursions. These will take a bit longer since i need to understand what the code is doing better. There are 14 instances of Tail Recursions. --Apple-Mail-1--954805247 Content-Transfer-Encoding: 7bit Content-Type: text/plain; x-unix-mode=0644; name="AbstractTransactionManagerFactory.txt" Content-Disposition: attachment; filename=AbstractTransactionManagerFactory.txt Index: AbstractTransactionManagerFactory.java =================================================================== RCS file: /home/cvspublic/db-ojb/src/java/org/apache/ojb/broker/transaction/tm/AbstractTransactionManagerFactory.java,v retrieving revision 1.1 diff -r1.1 AbstractTransactionManagerFactory.java 103c103 < throw new TransactionManagerFactoryException("Can't lookup transaction manager:" + EOL + msg.toString()); --- > throw new TransactionManagerFactoryException("Can't lookup transaction manager:" + EOL + msg); --Apple-Mail-1--954805247 Content-Transfer-Encoding: 7bit Content-Type: text/plain; x-unix-mode=0644; name="PBKey.txt" Content-Disposition: attachment; filename=PBKey.txt Index: PBKey.java =================================================================== RCS file: /home/cvspublic/db-ojb/src/java/org/apache/ojb/broker/PBKey.java,v retrieving revision 1.10 diff -r1.10 PBKey.java 77c77 < hashCode = new String(this.jcdAlias + this.user + this.password).hashCode(); --- > hashCode = ( this.jcdAlias + this.user + this.password ).hashCode(); --Apple-Mail-1--954805247 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; x-unix-mode=0644; name="ReadCommittedStrategy.txt" Content-Disposition: attachment; filename=ReadCommittedStrategy.txt Index: ReadCommittedStrategy.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: = /home/cvspublic/db-ojb/src/java/org/apache/ojb/odmg/locking/ReadCommittedS= trategy.java,v retrieving revision 1.4 diff -r1.4 ReadCommittedStrategy.java 1c1 < package org.apache.ojb.odmg.locking;=0D --- > package org.apache.ojb.odmg.locking; 17,186c17,176 < =0D < import org.apache.ojb.odmg.TransactionImpl;=0D < =0D < /**=0D < * The implementation of the Commited Reads Locking stra=0D < * ReadCommitted - Reads and Writes require locks.=0D < *=0D < * Locks are acquired for reading and modifying the database.=0D < * Locks are released after reading but locks on modified objects=0D < * are held until EOT.=0D < *=0D < * Allows:=0D < * Non-Repeatable Reads=0D < * Phantom Readstegy.=0D < *=0D < * @author Thomas Mahler & David Dixon-Peugh=0D < */=0D < public class ReadCommittedStrategy extends AbstractLockStrategy=0D < {=0D < =0D < /**=0D < * acquire a read lock on Object obj for Transaction tx.=0D < * @param tx the transaction requesting the lock=0D < * @param obj the Object to be locked=0D < * @return true if successful, else false=0D < *=0D < */=0D < public boolean readLock(TransactionImpl tx, Object obj)=0D < {=0D < =0D < LockEntry writer =3D getWriter(obj);=0D < if (writer =3D=3D null)=0D < {=0D < addReader(tx, obj);=0D < // if there has been a successful write locking, try again=0D= < if (getWriter(obj) =3D=3D null)=0D < return true;=0D < else=0D < {=0D < removeReader(tx, obj);=0D < return readLock(tx, obj);=0D < }=0D < }=0D < if (writer.isOwnedBy(tx))=0D < {=0D < return true; // If I'm the writer, I can read.=0D < }=0D < else=0D < {=0D < return false;=0D < }=0D < }=0D < =0D < /**=0D < * acquire a write lock on Object obj for Transaction tx.=0D < * @param tx the transaction requesting the lock=0D < * @param obj the Object to be locked=0D < * @return true if successful, else false=0D < *=0D < */=0D < public boolean writeLock(TransactionImpl tx, Object obj)=0D < {=0D < LockEntry writer =3D getWriter(obj);=0D < // if there is no writer yet we can try to get the global = write lock=0D < if (writer =3D=3D null)=0D < {=0D < // if lock could be acquired return true=0D < if (setWriter(tx, obj))=0D < return true;=0D < // else try again=0D < else=0D < return writeLock(tx, obj);=0D < }=0D < if (writer.isOwnedBy(tx))=0D < {=0D < return true; // If I'm the writer, then I can write.=0D < }=0D < =0D < return false;=0D < }=0D < =0D < /**=0D < * acquire a lock upgrade (from read to write) lock on Object obj = for Transaction tx.=0D < * @param tx the transaction requesting the lock=0D < * @param obj the Object to be locked=0D < * @return true if successful, else false=0D < *=0D < */=0D < public boolean upgradeLock(TransactionImpl tx, Object obj)=0D < {=0D < LockEntry writer =3D getWriter(obj);=0D < if (writer =3D=3D null)=0D < {=0D < // if lock could be acquired return true=0D < if (setWriter(tx, obj))=0D < return true;=0D < // else try again=0D < else=0D < return upgradeLock(tx, obj);=0D < }=0D < if (writer.isOwnedBy(tx))=0D < {=0D < return true; // If I already have Write, then I've = upgraded.=0D < }=0D < =0D < return false;=0D < }=0D < =0D < /**=0D < * release a lock on Object obj for Transaction tx.=0D < * @param tx the transaction releasing the lock=0D < * @param obj the Object to be unlocked=0D < * @return true if successful, else false=0D < *=0D < */=0D < public boolean releaseLock(TransactionImpl tx, Object obj)=0D < {=0D < LockEntry writer =3D getWriter(obj);=0D < =0D < if (writer !=3D null && writer.isOwnedBy(tx))=0D < {=0D < removeWriter(writer);=0D < return true;=0D < }=0D < =0D < if (hasReadLock(tx, obj))=0D < {=0D < removeReader(tx, obj);=0D < return true;=0D < }=0D < return false;=0D < }=0D < =0D < /**=0D < * checks whether the specified Object obj is read-locked by = Transaction tx.=0D < * @param tx the transaction=0D < * @param obj the Object to be checked=0D < * @return true if lock exists, else false=0D < */=0D < public boolean checkRead(TransactionImpl tx, Object obj)=0D < {=0D < if (hasReadLock(tx, obj))=0D < {=0D < return true;=0D < }=0D < LockEntry writer =3D getWriter(obj);=0D < if (writer.isOwnedBy(tx))=0D < {=0D < return true;=0D < }=0D < return false;=0D < }=0D < =0D < /**=0D < * checks whether the specified Object obj is write-locked by = Transaction tx.=0D < * @param tx the transaction=0D < * @param obj the Object to be checked=0D < * @return true if lock exists, else false=0D < */=0D < public boolean checkWrite(TransactionImpl tx, Object obj)=0D < {=0D < LockEntry writer =3D getWriter(obj);=0D < if (writer =3D=3D null)=0D < return false;=0D < else if (writer.isOwnedBy(tx))=0D < return true;=0D < else=0D < return false;=0D < }=0D < }=0D --- >=20 > import org.apache.ojb.odmg.TransactionImpl; >=20 > /** > * The implementation of the Commited Reads Locking stra > * ReadCommitted - Reads and Writes require locks. > * > * Locks are acquired for reading and modifying the database. > * Locks are released after reading but locks on modified objects > * are held until EOT. > * > * Allows: > * Non-Repeatable Reads > * Phantom Readstegy. > * > * @author Thomas Mahler & David Dixon-Peugh > */ > public class ReadCommittedStrategy extends AbstractLockStrategy > { >=20 > /** > * acquire a read lock on Object obj for Transaction tx. > * @param tx the transaction requesting the lock > * @param obj the Object to be locked > * @return true if successful, else false > * > */ > public boolean readLock(TransactionImpl tx, Object obj) > { >=20 > LockEntry writer =3D getWriter(obj); > if (writer =3D=3D null) > { > addReader(tx, obj); > // if there has been a successful write locking, try again > if (getWriter(obj) =3D=3D null) > return true; > else > { > removeReader(tx, obj); > return readLock(tx, obj); > } > } > return writer.isOwnedBy( tx ); > } >=20 > /** > * acquire a write lock on Object obj for Transaction tx. > * @param tx the transaction requesting the lock > * @param obj the Object to be locked > * @return true if successful, else false > * > */ > public boolean writeLock(TransactionImpl tx, Object obj) > { > LockEntry writer =3D getWriter(obj); > // if there is no writer yet we can try to get the global = write lock > if (writer =3D=3D null) > { > // if lock could be acquired return true > if (setWriter(tx, obj)) > return true; > // else try again > else > return writeLock(tx, obj); > } > if (writer.isOwnedBy(tx)) > { > return true; // If I'm the writer, then I can write. > } >=20 > return false; > } >=20 > /** > * acquire a lock upgrade (from read to write) lock on Object obj = for Transaction tx. > * @param tx the transaction requesting the lock > * @param obj the Object to be locked > * @return true if successful, else false > * > */ > public boolean upgradeLock(TransactionImpl tx, Object obj) > { > LockEntry writer =3D getWriter(obj); > if (writer =3D=3D null) > { > // if lock could be acquired return true > if (setWriter(tx, obj)) > return true; > // else try again > else > return upgradeLock(tx, obj); > } > if (writer.isOwnedBy(tx)) > { > return true; // If I already have Write, then I've = upgraded. > } >=20 > return false; > } >=20 > /** > * release a lock on Object obj for Transaction tx. > * @param tx the transaction releasing the lock > * @param obj the Object to be unlocked > * @return true if successful, else false > * > */ > public boolean releaseLock(TransactionImpl tx, Object obj) > { > LockEntry writer =3D getWriter(obj); >=20 > if (writer !=3D null && writer.isOwnedBy(tx)) > { > removeWriter(writer); > return true; > } >=20 > if (hasReadLock(tx, obj)) > { > removeReader(tx, obj); > return true; > } > return false; > } >=20 > /** > * checks whether the specified Object obj is read-locked by = Transaction tx. > * @param tx the transaction > * @param obj the Object to be checked > * @return true if lock exists, else false > */ > public boolean checkRead(TransactionImpl tx, Object obj) > { > if (hasReadLock(tx, obj)) > { > return true; > } > LockEntry writer =3D getWriter(obj); > if (writer.isOwnedBy(tx)) > { > return true; > } > return false; > } >=20 > /** > * checks whether the specified Object obj is write-locked by = Transaction tx. > * @param tx the transaction > * @param obj the Object to be checked > * @return true if lock exists, else false > */ > public boolean checkWrite(TransactionImpl tx, Object obj) > { > LockEntry writer =3D getWriter(obj); > if (writer =3D=3D null) > return false; > else return writer.isOwnedBy( tx ); > } > } --Apple-Mail-1--954805247 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org --Apple-Mail-1--954805247--