1 21 package oracle.toplink.essentials.exceptions; 23 24 import oracle.toplink.essentials.exceptions.i18n.*; 25 26 public class EntityManagerSetupException extends TopLinkException { 27 public static final int SESSIONS_XML_VALIDATION_EXCEPTION = 28001; 28 public static final int WRONG_SESSION_TYPE_EXCEPTION = 28002; 29 public static final int MISSING_SERVER_PLATFORM_EXCEPTION = 28003; 30 public static final int ERROR_IN_SETUP_OF_EM = 28004; 31 public static final int EXCEPTION_IN_SETUP_OF_EM = 28005; 32 public static final int CLASS_NOT_FOUND_FOR_PROPERTY = 28006; 33 public static final int FAILED_TO_INSTANTIATE_SERVER_PLATFORM = 28007; 34 public static final int CLASS_NOT_FOUND_WHILE_PROCESSING_ANNOTATIONS = 28008; 35 public static final int ATTEMPTED_REDEPLOY_WITHOUT_CLOSE = 28009; 36 public static final int JTA_PERSISTENCE_UNIT_INFO_MISSING_JTA_DATA_SOURCE = 28010; 37 public static final int SESSION_REMOVED_DURING_DEPLOYMENT = 28011; 38 public static final int WRONG_PROPERTY_VALUE_TYPE = 28012; 39 public static final int CANNOT_DEPLOY_WITHOUT_PREDEPLOY = 28013; 40 public static final int FAILED_WHILE_PROCESSING_PROPERTY = 28014; 41 42 43 47 public EntityManagerSetupException() { 48 super(); 49 } 50 51 55 protected EntityManagerSetupException(String message) { 56 super(message); 57 } 58 59 63 protected EntityManagerSetupException(String message, Throwable internalException) { 64 super(message); 65 setInternalException(internalException); 66 } 67 68 public static EntityManagerSetupException attemptedRedeployWithoutClose(String sessionName) { 69 Object [] args = { sessionName }; 70 71 EntityManagerSetupException setupException = new EntityManagerSetupException(ExceptionMessageGenerator.buildMessage(EntityManagerSetupException.class, ATTEMPTED_REDEPLOY_WITHOUT_CLOSE, args)); 72 setupException.setErrorCode(ATTEMPTED_REDEPLOY_WITHOUT_CLOSE); 73 return setupException; 74 } 75 76 public static EntityManagerSetupException missingServerPlatformException(String sessionName, String xmlFileName) { 77 Object [] args = { sessionName, xmlFileName }; 78 79 EntityManagerSetupException setupException = new EntityManagerSetupException(ExceptionMessageGenerator.buildMessage(EntityManagerSetupException.class, MISSING_SERVER_PLATFORM_EXCEPTION, args)); 80 setupException.setErrorCode(MISSING_SERVER_PLATFORM_EXCEPTION); 81 return setupException; 82 } 83 84 public static EntityManagerSetupException sessionRemovedDuringDeployment(String sessionName){ 85 Object [] args = { sessionName }; 86 87 EntityManagerSetupException setupException = new EntityManagerSetupException(ExceptionMessageGenerator.buildMessage(EntityManagerSetupException.class, SESSION_REMOVED_DURING_DEPLOYMENT, args)); 88 setupException.setErrorCode(SESSION_REMOVED_DURING_DEPLOYMENT); 89 return setupException; 90 } 91 92 public static EntityManagerSetupException sessionXMLValidationException(String sessionName, String xmlFileName, ValidationException exception) { 93 Object [] args = { sessionName, xmlFileName }; 94 95 EntityManagerSetupException setupException = new EntityManagerSetupException(ExceptionMessageGenerator.buildMessage(EntityManagerSetupException.class, SESSIONS_XML_VALIDATION_EXCEPTION, args), exception); 96 setupException.setErrorCode(SESSIONS_XML_VALIDATION_EXCEPTION); 97 return setupException; 98 } 99 100 public static EntityManagerSetupException wrongSessionTypeException(String sessionName, String xmlFileName, Exception exception) { 101 Object [] args = { sessionName, xmlFileName }; 102 103 EntityManagerSetupException setupException = new EntityManagerSetupException(ExceptionMessageGenerator.buildMessage(EntityManagerSetupException.class, WRONG_SESSION_TYPE_EXCEPTION, args), exception); 104 setupException.setErrorCode(WRONG_SESSION_TYPE_EXCEPTION); 105 return setupException; 106 } 107 108 public static EntityManagerSetupException errorInSetupOfEM() { 109 Object [] args = { }; 110 111 EntityManagerSetupException setupException = new EntityManagerSetupException(ExceptionMessageGenerator.buildMessage(EntityManagerSetupException.class, ERROR_IN_SETUP_OF_EM, args)); 112 setupException.setErrorCode(ERROR_IN_SETUP_OF_EM); 113 return setupException; 114 } 115 116 public static EntityManagerSetupException exceptionInSetupOfEM(Exception exception) { 117 Object [] args = { }; 118 119 EntityManagerSetupException setupException = new EntityManagerSetupException(ExceptionMessageGenerator.buildMessage(EntityManagerSetupException.class, EXCEPTION_IN_SETUP_OF_EM, args), exception); 120 setupException.setErrorCode(EXCEPTION_IN_SETUP_OF_EM); 121 return setupException; 122 } 123 124 public static EntityManagerSetupException classNotFoundForProperty(String className, String propertyName, Exception exception) { 125 Object [] args = { className, propertyName }; 126 127 EntityManagerSetupException setupException = new EntityManagerSetupException(ExceptionMessageGenerator.buildMessage(EntityManagerSetupException.class, CLASS_NOT_FOUND_FOR_PROPERTY, args), exception); 128 setupException.setErrorCode(CLASS_NOT_FOUND_FOR_PROPERTY); 129 return setupException; 130 } 131 132 public static EntityManagerSetupException failedToInstantiateServerPlatform(String serverPlatformClass, String serverPlatformString, Exception exception) { 133 Object [] args = { serverPlatformClass, serverPlatformString }; 134 135 EntityManagerSetupException setupException = new EntityManagerSetupException(ExceptionMessageGenerator.buildMessage(EntityManagerSetupException.class, FAILED_TO_INSTANTIATE_SERVER_PLATFORM, args), exception); 136 setupException.setErrorCode(FAILED_TO_INSTANTIATE_SERVER_PLATFORM); 137 return setupException; 138 } 139 140 public static EntityManagerSetupException classNotFoundWhileProcessingAnnotations(String className, Exception exception) { 141 Object [] args = { className }; 142 143 EntityManagerSetupException setupException = new EntityManagerSetupException(ExceptionMessageGenerator.buildMessage(EntityManagerSetupException.class, CLASS_NOT_FOUND_WHILE_PROCESSING_ANNOTATIONS, args), exception); 144 setupException.setErrorCode(CLASS_NOT_FOUND_WHILE_PROCESSING_ANNOTATIONS); 145 return setupException; 146 } 147 148 public static EntityManagerSetupException jtaPersistenceUnitInfoMissingJtaDataSource(String persistenceUnitInfoName) { 149 Object [] args = { persistenceUnitInfoName }; 150 151 EntityManagerSetupException setupException = new EntityManagerSetupException(ExceptionMessageGenerator.buildMessage(EntityManagerSetupException.class, JTA_PERSISTENCE_UNIT_INFO_MISSING_JTA_DATA_SOURCE, args)); 152 setupException.setErrorCode(JTA_PERSISTENCE_UNIT_INFO_MISSING_JTA_DATA_SOURCE); 153 return setupException; 154 } 155 156 public static EntityManagerSetupException wrongPropertyValueType(String value, String expectedType, String propertyName) { 157 Object [] args = { value, expectedType, propertyName }; 158 159 EntityManagerSetupException setupException = new EntityManagerSetupException(ExceptionMessageGenerator.buildMessage(EntityManagerSetupException.class, WRONG_PROPERTY_VALUE_TYPE, args)); 160 setupException.setErrorCode(WRONG_PROPERTY_VALUE_TYPE); 161 return setupException; 162 } 163 164 public static EntityManagerSetupException cannotDeployWithoutPredeploy(String persistenceUnitName) { 165 Object [] args = { persistenceUnitName }; 166 167 EntityManagerSetupException setupException = new EntityManagerSetupException(ExceptionMessageGenerator.buildMessage(EntityManagerSetupException.class, CANNOT_DEPLOY_WITHOUT_PREDEPLOY, args)); 168 setupException.setErrorCode(CANNOT_DEPLOY_WITHOUT_PREDEPLOY); 169 return setupException; 170 } 171 172 public static EntityManagerSetupException failedWhileProcessingProperty(String propertyName, String propertyValue, Exception exception) { 173 Object [] args = { propertyName, propertyValue }; 174 175 EntityManagerSetupException setupException = new EntityManagerSetupException(ExceptionMessageGenerator.buildMessage(EntityManagerSetupException.class, FAILED_WHILE_PROCESSING_PROPERTY, args), exception); 176 setupException.setErrorCode(FAILED_WHILE_PROCESSING_PROPERTY); 177 return setupException; 178 } 179 180 } 181 | Popular Tags |