1 21 package oracle.toplink.essentials.exceptions; 23 24 import java.io.File ; 25 import java.net.URL ; 26 27 import oracle.toplink.essentials.exceptions.i18n.*; 28 29 public class PersistenceUnitLoadingException extends TopLinkException { 30 31 public static final int EXCEPTION_LOADING_FROM_DIRECTORY = 30001; 32 public static final int EXCEPTION_LOADING_FROM_JAR = 30002; 33 public static final int EXCEPTION_PROCESSING_PERSISTENCE_UNIT = 30003; 34 public static final int EXCEPTION_PROCESSING_PERSISTENCE_XML = 30004; 35 public static final int EXCEPTION_SEARCHING_FOR_PERSISTENCE_RESOURCES = 30005; 36 public static final int EXCEPTION_SEARCHING_FOR_ENTITIES = 30006; 37 public static final int EXCEPTION_LOADING_CLASS = 30007; 38 public static final int FILE_PATH_MISSING_EXCEPTION = 30008; 39 public static final int EXCEPTION_LOADING_FROM_URL = 30009; 40 public static final int EXCEPTION_OPENING_ORM_XML = 30010; 41 public static final int COULD_NOT_GET_CLASS_NAMES_FROM_URL = 30011; 42 43 47 public PersistenceUnitLoadingException() { 48 super(); 49 } 50 51 55 protected PersistenceUnitLoadingException(String message) { 56 super(message); 57 } 58 59 63 protected PersistenceUnitLoadingException(String message, Throwable internalException) { 64 super(message); 65 setInternalException(internalException); 66 } 67 68 public static PersistenceUnitLoadingException exceptionLoadingFromDirectory(File directory, Exception cause) { 69 Object [] args = { directory }; 70 71 PersistenceUnitLoadingException loadingException = new PersistenceUnitLoadingException(ExceptionMessageGenerator.buildMessage(PersistenceUnitLoadingException.class, EXCEPTION_LOADING_FROM_DIRECTORY, args), cause); 72 loadingException.setErrorCode(EXCEPTION_LOADING_FROM_DIRECTORY); 73 return loadingException; 74 } 75 76 public static PersistenceUnitLoadingException filePathMissingException(String filePath) { 77 Object [] args = { filePath }; 78 79 PersistenceUnitLoadingException loadingException = new PersistenceUnitLoadingException(ExceptionMessageGenerator.buildMessage(PersistenceUnitLoadingException.class, FILE_PATH_MISSING_EXCEPTION, args)); 80 loadingException.setErrorCode(FILE_PATH_MISSING_EXCEPTION); 81 return loadingException; 82 } 83 84 public static PersistenceUnitLoadingException exceptionLoadingFromJar(URL jarFile, Exception cause) { 85 Object [] args = { jarFile }; 86 87 PersistenceUnitLoadingException loadingException = new PersistenceUnitLoadingException(ExceptionMessageGenerator.buildMessage(PersistenceUnitLoadingException.class, EXCEPTION_LOADING_FROM_JAR, args), cause); 88 loadingException.setErrorCode(EXCEPTION_LOADING_FROM_JAR); 89 return loadingException; 90 } 91 92 public static PersistenceUnitLoadingException exceptionLoadingFromUrl(String url, Exception cause) { 93 Object [] args = { url }; 94 95 PersistenceUnitLoadingException loadingException = new PersistenceUnitLoadingException(ExceptionMessageGenerator.buildMessage(PersistenceUnitLoadingException.class, EXCEPTION_LOADING_FROM_URL, args), cause); 96 loadingException.setErrorCode(EXCEPTION_LOADING_FROM_URL); 97 return loadingException; 98 } 99 100 public static PersistenceUnitLoadingException exceptionProcessingPersistenceUnit(URL url, Exception cause) { 101 Object [] args = { url }; 102 103 PersistenceUnitLoadingException loadingException = new PersistenceUnitLoadingException(ExceptionMessageGenerator.buildMessage(PersistenceUnitLoadingException.class, EXCEPTION_PROCESSING_PERSISTENCE_UNIT, args), cause); 104 loadingException.setErrorCode(EXCEPTION_PROCESSING_PERSISTENCE_UNIT); 105 return loadingException; 106 } 107 108 public static PersistenceUnitLoadingException exceptionProcessingPersistenceXML(URL url, Exception cause) { 109 Object [] args = { url }; 110 111 PersistenceUnitLoadingException loadingException = new PersistenceUnitLoadingException(ExceptionMessageGenerator.buildMessage(PersistenceUnitLoadingException.class, EXCEPTION_PROCESSING_PERSISTENCE_XML, args), cause); 112 loadingException.setErrorCode(EXCEPTION_PROCESSING_PERSISTENCE_XML); 113 return loadingException; 114 } 115 116 public static PersistenceUnitLoadingException exceptionSearchingForPersistenceResources(ClassLoader loader, Exception cause) { 117 Object [] args = { loader }; 118 119 PersistenceUnitLoadingException loadingException = new PersistenceUnitLoadingException(ExceptionMessageGenerator.buildMessage(PersistenceUnitLoadingException.class, EXCEPTION_SEARCHING_FOR_PERSISTENCE_RESOURCES, args), cause); 120 loadingException.setErrorCode(EXCEPTION_SEARCHING_FOR_PERSISTENCE_RESOURCES); 121 return loadingException; 122 } 123 124 public static PersistenceUnitLoadingException exceptionSearchingForEntities(URL url, Exception cause) { 125 Object [] args = { url }; 126 127 PersistenceUnitLoadingException loadingException = new PersistenceUnitLoadingException(ExceptionMessageGenerator.buildMessage(PersistenceUnitLoadingException.class, EXCEPTION_SEARCHING_FOR_ENTITIES, args), cause); 128 loadingException.setErrorCode(EXCEPTION_SEARCHING_FOR_ENTITIES); 129 return loadingException; 130 } 131 132 public static PersistenceUnitLoadingException exceptionLoadingClassWhileLookingForAnnotations(String className, Exception cause) { 133 Object [] args = { className }; 134 135 PersistenceUnitLoadingException loadingException = new PersistenceUnitLoadingException(ExceptionMessageGenerator.buildMessage(PersistenceUnitLoadingException.class, EXCEPTION_LOADING_CLASS, args), cause); 136 loadingException.setErrorCode(EXCEPTION_LOADING_CLASS); 137 return loadingException; 138 } 139 140 public static PersistenceUnitLoadingException exceptionLoadingORMXML(String fileName, Exception cause) { 141 Object [] args = { fileName }; 142 143 PersistenceUnitLoadingException loadingException = new PersistenceUnitLoadingException(ExceptionMessageGenerator.buildMessage(PersistenceUnitLoadingException.class, EXCEPTION_OPENING_ORM_XML, args), cause); 144 loadingException.setErrorCode(EXCEPTION_OPENING_ORM_XML); 145 return loadingException; 146 } 147 148 public static PersistenceUnitLoadingException couldNotGetClassNamesFromUrl(URL url) { 149 Object [] args = { url }; 150 151 PersistenceUnitLoadingException loadingException = new PersistenceUnitLoadingException(ExceptionMessageGenerator.buildMessage(PersistenceUnitLoadingException.class, COULD_NOT_GET_CLASS_NAMES_FROM_URL, args)); 152 loadingException.setErrorCode(COULD_NOT_GET_CLASS_NAMES_FROM_URL); 153 return loadingException; 154 } 155 156 } 157 | Popular Tags |