01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.object.util;
05:
06: import com.tc.exception.ExceptionWrapper;
07: import com.tc.exception.ExceptionWrapperImpl;
08:
09: /**
10: * Indicates a read-only transaction is trying to access a shared object. This is most likely
11: * a problem with an incorrect lock configuration.
12: */
13: public class ReadOnlyException extends RuntimeException {
14:
15: private static final ExceptionWrapper wrapper = new ExceptionWrapperImpl();
16:
17: /** Indicates a default invalid VM_ID to use */
18: public static final long INVALID_VMID = -1;
19:
20: /**
21: * @param message Message, which will be wrapped
22: */
23: public ReadOnlyException(String message) {
24: super (wrapper.wrap(message));
25: }
26:
27: /**
28: * @param message Message
29: * @param threadName Thread name
30: * @param vmId VM identifier
31: */
32: public ReadOnlyException(String message, String threadName,
33: long vmId) {
34: this (ReadOnlyException.createDisplayableString(message,
35: threadName, vmId));
36: }
37:
38: /**
39: * @param message Message
40: * @param threadName Thread name
41: * @param vmId VM identifier
42: * @param details Additional details
43: */
44: public ReadOnlyException(String message, String threadName,
45: long vmId, String details) {
46: this (ReadOnlyException.createDisplayableString(message,
47: threadName, vmId)
48: + "\n " + details);
49: }
50:
51: private static String createDisplayableString(String message,
52: String threadName, long vmId) {
53: if (vmId == INVALID_VMID) {
54: return message + "\n\n Caused by Thread: " + threadName;
55: }
56: return message + "\n\n Caused by Thread: " + threadName
57: + " in VM(" + vmId + ")";
58: }
59: }
|