KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > exceptions > EntityManagerSetupException


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2006, Oracle. All rights reserved.
22
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     /**
44      * INTERNAL:
45      * TopLink exceptions should only be thrown by TopLink.
46      */

47     public EntityManagerSetupException() {
48         super();
49     }
50
51     /**
52      * INTERNAL:
53      * TopLink exceptions should only be thrown by TopLink.
54      */

55     protected EntityManagerSetupException(String JavaDoc message) {
56         super(message);
57     }
58
59     /**
60      * INTERNAL:
61      * TopLink exceptions should only be thrown by TopLink.
62      */

63     protected EntityManagerSetupException(String JavaDoc message, Throwable JavaDoc internalException) {
64         super(message);
65         setInternalException(internalException);
66     }
67
68     public static EntityManagerSetupException attemptedRedeployWithoutClose(String JavaDoc sessionName) {
69         Object JavaDoc[] 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 JavaDoc sessionName, String JavaDoc xmlFileName) {
77         Object JavaDoc[] 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 JavaDoc sessionName){
85         Object JavaDoc[] 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 JavaDoc sessionName, String JavaDoc xmlFileName, ValidationException exception) {
93         Object JavaDoc[] 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 JavaDoc sessionName, String JavaDoc xmlFileName, Exception JavaDoc exception) {
101         Object JavaDoc[] 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 JavaDoc[] 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 JavaDoc exception) {
117         Object JavaDoc[] 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 JavaDoc className, String JavaDoc propertyName, Exception JavaDoc exception) {
125         Object JavaDoc[] 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 JavaDoc serverPlatformClass, String JavaDoc serverPlatformString, Exception JavaDoc exception) {
133         Object JavaDoc[] 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 JavaDoc className, Exception JavaDoc exception) {
141         Object JavaDoc[] 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 JavaDoc persistenceUnitInfoName) {
149         Object JavaDoc[] 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 JavaDoc value, String JavaDoc expectedType, String JavaDoc propertyName) {
157         Object JavaDoc[] 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 JavaDoc persistenceUnitName) {
165         Object JavaDoc[] 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 JavaDoc propertyName, String JavaDoc propertyValue, Exception JavaDoc exception) {
173         Object JavaDoc[] 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