The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Cyclical dependancy

Posted by Calahans on January 10, 2001 at 10:08 AM


Looking at your example:

1) BOException

Is a specific Exception class derived from 'Throwable' (i.e. BOException extends Throwable). This is a custom exception class which contains some of the transaction information (like connection name, username, userid etc.).

2) BOTransaction

Is a transaction class containing transaction details

As per case 1), since BOException contains transaction information it depends on BOTransaction.
As per case 2), since BOTransaction needs to handle Exception within itself it depends on BOException.

I think the problem is that the first exception is merely that. It should not need to import the transaction objects or extend them (I'm not sure which fron your example). The exception should have one or two properties which can be filled by the transaction object creating then exception and passing in the details to its constructor, for example

throw new BOException("invalid user",connection()..);

Hope I'm clear.


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us