db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian McCallister <mccallis...@forthillcompany.com>
Subject Re: OTM + Connections/Transactions
Date Wed, 24 Sep 2003 18:28:39 GMT

On Wednesday, September 24, 2003, at 01:07 PM, Raghuram Rajah wrote:

> Hi Oleg/Brian,
>
> The reason for registerConnection taking a BaseConnection and not an
> OTMConnection is this. Many environments do not to support arbitrary
> association of connections to transactions.

In these environments, specifically disable it via an 
OperationNotSupported exception.

> So, IMHO, exposing the
> registerConnection is a bad idea. The only environment where this makes
> sense is a j2se environment. The correct way to implement that is to 
> create
> a new TransactionFactory.

I disagree. Multiple connections can in fact be used in a J2EE 
environment -- it is just trickier. It cannot easily be done in a 
clustered environment unless the Transaction is migratable and only 
accessed on a single node at a time.

However, I think disallowing arbitrary associations because it doesn't 
work easily on a minority environment is not a good idea. If it needs 
to be disabled in a specific environment, that environment is the 
exception, not the rule.

The stated design goal to allow 1:M Transaction:Connection 
relationships is most easily accomplished form the User perspective by 
allowing the attachment of a Connection to a Transaction, particularly 
as that behavior is already somewhat exposed. Do not expose methods on 
a the published API (the OTMConnection and Transaction interfaces 
respectively) that the user isn't able to use. It causes chaos and 
confusion.

Requiring Connections be obtained from a specific factory is okay to 
me, as obtaining the Connection and attaching it to a Transaction 
before using it is the required behavior for this. However, if we are 
going to do it that we we need to do it that way, and we need to expose 
a mechanism in the factory interface to do this. Either way, the 
ability needs to be exposed somehow. Based on the present API, it 
should be exposed on the Kit, Connection, or Transaction. As 
Connections and Transactions are required to be aware of each other 
presently, exposing it at that level (as compared to hiding it in the 
Kit) is okay.

I am looking at this from the OJB user perspective..

Kit.acquireConnection(pbKey, transaction) works fine for me, 
Transaction.registerConnection(OTMConnection) works for me as well. 
Heck, Connection.setTransaction(Transaction) works fine too. A good 
case can be made for putting it on the Kit and hiding the 
registerConnection() method (remove it from Transaction entirely) in 
that registerConnection() and setTransaction() would need to invoke 
each other in practice since each needs to know about the other (I 
think it could be done with a Transaction not knowing about Connections 
using it as it is an object-level transaction - it just needs to 
provide services to the Connection) but it isn't done that way at the 
moment.

-Brian

(all of this said, I do *really* like the OTM, I just want more ;-)



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


Mime
View raw message