KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.io.File JavaDoc;
25 import java.net.URL JavaDoc;
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     /**
44      * INTERNAL:
45      * TopLink exceptions should only be thrown by TopLink.
46      */

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

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

63     protected PersistenceUnitLoadingException(String JavaDoc message, Throwable JavaDoc internalException) {
64         super(message);
65         setInternalException(internalException);
66     }
67     
68     public static PersistenceUnitLoadingException exceptionLoadingFromDirectory(File JavaDoc directory, Exception JavaDoc cause) {
69         Object JavaDoc[] 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 JavaDoc filePath) {
77         Object JavaDoc[] 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 JavaDoc jarFile, Exception JavaDoc cause) {
85         Object JavaDoc[] 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 JavaDoc url, Exception JavaDoc cause) {
93         Object JavaDoc[] 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 JavaDoc url, Exception JavaDoc cause) {
101         Object JavaDoc[] 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 JavaDoc url, Exception JavaDoc cause) {
109         Object JavaDoc[] 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 JavaDoc loader, Exception JavaDoc cause) {
117         Object JavaDoc[] 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 JavaDoc url, Exception JavaDoc cause) {
125         Object JavaDoc[] 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 JavaDoc className, Exception JavaDoc cause) {
133         Object JavaDoc[] 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 JavaDoc fileName, Exception JavaDoc cause) {
141         Object JavaDoc[] 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 JavaDoc url) {
149         Object JavaDoc[] 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