Coverage Report - net.wotonomy.access.EOAdaptorContext
 
Classes in this File Line Coverage Branch Coverage Complexity
EOAdaptorContext
0% 
0% 
1.429
 
 1  
 /*
 2  
  Wotonomy: OpenStep design patterns for pure Java applications.
 3  
  Copyright (C) 2001 Michael Powers
 4  
 
 5  
  This library is free software; you can redistribute it and/or
 6  
  modify it under the terms of the GNU Lesser General Public
 7  
  License as published by the Free Software Foundation; either
 8  
  version 2.1 of the License, or (at your option) any later version.
 9  
 
 10  
  This library is distributed in the hope that it will be useful,
 11  
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
  Lesser General Public License for more details.
 14  
 
 15  
  You should have received a copy of the GNU Lesser General Public
 16  
  License along with this library; if not, see http://www.gnu.org
 17  
  */
 18  
 package net.wotonomy.access;
 19  
 
 20  
 import net.wotonomy.foundation.NSArray;
 21  
 import net.wotonomy.foundation.NSMutableArray;
 22  
 import net.wotonomy.foundation.NSNotificationCenter;
 23  
 
 24  
 /**
 25  
 *
 26  
 * @author ezamudio@nasoft.com
 27  
 * @author $Author: cgruber $
 28  
 * @version $Revision: 894 $
 29  
 */
 30  
 
 31  
 public abstract class EOAdaptorContext {
 32  
 
 33  
         public static final String AdaptorContextBeginTransactionNotification = "AdaptorContextBeginTransaction";
 34  
         public static final String AdaptorContextCommitTransactionNotification = "AdaptorContextCommitTransaction";
 35  
         public static final String AdaptorContextRollbackTransactionNotification = "AdaptorContextRollbackTransaction";
 36  
 
 37  
         protected EOAdaptor _adaptor;
 38  0
         protected NSMutableArray _channels = new NSMutableArray();
 39  
         protected boolean _hasOpenTransaction;
 40  
 
 41  
         public EOAdaptorContext(EOAdaptor adaptor) {
 42  0
                 super();
 43  0
                 _adaptor = adaptor;
 44  0
         }
 45  
 
 46  
         public EOAdaptor adaptor() {
 47  0
                 return _adaptor;
 48  
         }
 49  
 
 50  
         public abstract void beginTransaction();
 51  
 
 52  
         public abstract void commitTransaction();
 53  
 
 54  
         public abstract void rollbackTransaction();
 55  
 
 56  
         public abstract EOAdaptorChannel createAdaptorChannel();
 57  
 
 58  
         public abstract void handleDroppedConnection();
 59  
 
 60  
         public NSArray channels() {
 61  0
                 return new NSArray(_channels);
 62  
         }
 63  
 
 64  
         public boolean hasBusyChannels() {
 65  0
                 for (int i = 0; i < _channels.count(); i++) {
 66  0
                         EOAdaptorChannel chan = (EOAdaptorChannel)_channels.objectAtIndex(i);
 67  0
                         if (chan.isFetchInProgress())
 68  0
                                 return true;
 69  
                 }
 70  0
                 return false;
 71  
         }
 72  
 
 73  
         public boolean hasOpenChannels() {
 74  0
                 for (int i = 0; i < _channels.count(); i++) {
 75  0
                         EOAdaptorChannel chan = (EOAdaptorChannel)_channels.objectAtIndex(i);
 76  0
                         if (chan.isOpen())
 77  0
                                 return true;
 78  
                 }
 79  0
                 return false;
 80  
         }
 81  
 
 82  
         public boolean hasOpenTransaction() {
 83  0
                 return _hasOpenTransaction;
 84  
         }
 85  
 
 86  
         public void transactionDidBegin() {
 87  0
                 _hasOpenTransaction = true;
 88  0
                 NSNotificationCenter.defaultCenter().postNotification(
 89  0
                         AdaptorContextBeginTransactionNotification, this);
 90  0
         }
 91  
 
 92  
         public void transactionDidCommit() {
 93  0
                 _hasOpenTransaction = false;
 94  0
                 NSNotificationCenter.defaultCenter().postNotification(
 95  0
                         AdaptorContextCommitTransactionNotification, this);
 96  0
         }
 97  
 
 98  
         public void transactionDidRollback() {
 99  0
                 _hasOpenTransaction = false;
 100  0
                 NSNotificationCenter.defaultCenter().postNotification(
 101  0
                         AdaptorContextRollbackTransactionNotification, this);
 102  0
         }
 103  
 
 104  
 }
 105  
 /*
 106  
  * $Log$
 107  
  * Revision 1.2  2006/02/16 16:47:14  cgruber
 108  
  * Move some classes in to "internal" packages and re-work imports, etc.
 109  
  *
 110  
  * Also use UnsupportedOperationExceptions where appropriate, instead of WotonomyExceptions.
 111  
  *
 112  
  * Revision 1.1  2006/02/16 13:19:57  cgruber
 113  
  * Check in all sources in eclipse-friendly maven-enabled packages.
 114  
  *
 115  
  * Revision 1.1  2003/08/13 00:37:45  chochos
 116  
  * an almost complete implementation of the abstract adaptor-layer classes
 117  
  *
 118  
  */