1 21 package oracle.toplink.essentials.exceptions; 23 24 import oracle.toplink.essentials.exceptions.i18n.ExceptionMessageGenerator; 25 26 29 public class ConcurrencyException extends TopLinkException { 30 public final static int WAIT_WAS_INTERRUPTED = 2001; 31 public final static int WAIT_FAILURE_SERVER = 2002; 32 public final static int WAIT_FAILURE_CLIENT = 2003; 33 public final static int SIGNAL_ATTEMPTED_BEFORE_WAIT = 2004; 34 public final static int WAIT_FAILURE_SEQ_DATABASE_SESSION = 2005; 35 public final static int SEQUENCING_MULTITHREAD_THRU_CONNECTION = 2006; 36 public final static int MAX_TRIES_EXCEDED_FOR_LOCK_ON_CLONE = 2007; 37 public final static int MAX_TRIES_EXCEDED_FOR_LOCK_ON_MERGE = 2008; 38 public final static int MAX_TRIES_EXCEDED_FOR_LOCK_ON_BUILD_OBJECT = 2009; 39 43 protected ConcurrencyException(String theMessage) { 44 super(theMessage); 45 } 46 47 51 protected ConcurrencyException(String theMessage, Exception exception) { 52 super(theMessage, exception); 53 } 54 55 public static ConcurrencyException maxTriesLockOnCloneExceded(Object objectToClone) { 56 Object [] args = { objectToClone, CR }; 57 58 ConcurrencyException concurrencyException = new ConcurrencyException(ExceptionMessageGenerator.buildMessage(ConcurrencyException.class, MAX_TRIES_EXCEDED_FOR_LOCK_ON_CLONE, args)); 59 concurrencyException.setErrorCode(MAX_TRIES_EXCEDED_FOR_LOCK_ON_CLONE); 60 return concurrencyException; 61 } 62 63 public static ConcurrencyException maxTriesLockOnMergeExceded(Object objectToClone) { 64 Object [] args = { objectToClone, CR }; 65 66 ConcurrencyException concurrencyException = new ConcurrencyException(ExceptionMessageGenerator.buildMessage(ConcurrencyException.class, MAX_TRIES_EXCEDED_FOR_LOCK_ON_MERGE, args)); 67 concurrencyException.setErrorCode(MAX_TRIES_EXCEDED_FOR_LOCK_ON_MERGE); 68 return concurrencyException; 69 } 70 71 public static ConcurrencyException maxTriesLockOnBuildObjectExceded(Thread cacheKeyThread, Thread currentThread) { 72 Object [] args = { cacheKeyThread, currentThread, CR }; 73 74 ConcurrencyException concurrencyException = new ConcurrencyException(ExceptionMessageGenerator.buildMessage(ConcurrencyException.class, MAX_TRIES_EXCEDED_FOR_LOCK_ON_MERGE, args)); 75 concurrencyException.setErrorCode(MAX_TRIES_EXCEDED_FOR_LOCK_ON_BUILD_OBJECT); 76 return concurrencyException; 77 } 78 79 public static ConcurrencyException signalAttemptedBeforeWait() { 80 Object [] args = { CR }; 81 82 ConcurrencyException concurrencyException = new ConcurrencyException(ExceptionMessageGenerator.buildMessage(ConcurrencyException.class, SIGNAL_ATTEMPTED_BEFORE_WAIT, args)); 83 concurrencyException.setErrorCode(SIGNAL_ATTEMPTED_BEFORE_WAIT); 84 return concurrencyException; 85 } 86 87 public static ConcurrencyException waitFailureOnClientSession(InterruptedException exception) { 88 Object [] args = { }; 89 90 ConcurrencyException concurrencyException = new ConcurrencyException(ExceptionMessageGenerator.buildMessage(ConcurrencyException.class, WAIT_FAILURE_CLIENT, args), exception); 91 concurrencyException.setErrorCode(WAIT_FAILURE_CLIENT); 92 return concurrencyException; 93 } 94 95 public static ConcurrencyException waitFailureOnServerSession(InterruptedException exception) { 96 Object [] args = { }; 97 98 ConcurrencyException concurrencyException = new ConcurrencyException(ExceptionMessageGenerator.buildMessage(ConcurrencyException.class, WAIT_FAILURE_SERVER, args), exception); 99 concurrencyException.setErrorCode(WAIT_FAILURE_SERVER); 100 return concurrencyException; 101 } 102 103 public static ConcurrencyException waitWasInterrupted(String message) { 104 Object [] args = { CR, message }; 105 106 ConcurrencyException concurrencyException = new ConcurrencyException(ExceptionMessageGenerator.buildMessage(ConcurrencyException.class, WAIT_WAS_INTERRUPTED, args)); 107 concurrencyException.setErrorCode(WAIT_WAS_INTERRUPTED); 108 return concurrencyException; 109 } 110 111 public static ConcurrencyException waitFailureOnSequencingForDatabaseSession(InterruptedException exception) { 112 Object [] args = { }; 113 114 ConcurrencyException concurrencyException = new ConcurrencyException(ExceptionMessageGenerator.buildMessage(ConcurrencyException.class, WAIT_FAILURE_SEQ_DATABASE_SESSION, args), exception); 115 concurrencyException.setErrorCode(WAIT_FAILURE_SEQ_DATABASE_SESSION); 116 return concurrencyException; 117 } 118 119 public static ConcurrencyException sequencingMultithreadThruConnection(String accessor) { 120 Object [] args = { accessor }; 121 122 ConcurrencyException concurrencyException = new ConcurrencyException(ExceptionMessageGenerator.buildMessage(ConcurrencyException.class, SEQUENCING_MULTITHREAD_THRU_CONNECTION, args)); 123 concurrencyException.setErrorCode(SEQUENCING_MULTITHREAD_THRU_CONNECTION); 124 return concurrencyException; 125 } 126 } 127 | Popular Tags |