KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > persistence > spi > PersistenceUnitInfo


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 in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
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 Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24
25 package javax.persistence.spi;
26
27 import javax.sql.DataSource JavaDoc;
28 import java.net.URL JavaDoc;
29 import java.util.List JavaDoc;
30 import java.util.Properties JavaDoc;
31
32 /**
33  * Interface implemented by the container and used by the persistence provider
34  * when creating an {@link javax.persistence.EntityManagerFactory}.
35  *
36  * @since Java Persistence 1.0
37  */

38 public interface PersistenceUnitInfo {
39     /**
40      * Returns the name of the persistence unit. Corresponds to the name attribute
41      * in the persistence.xml file.
42      * @return The name of the persistence unit. Corresponds to the name attribute
43      * in the persistence.xml file.
44      */

45     public String JavaDoc getPersistenceUnitName();
46
47     /**
48      * Returns the fully qualified name of the persistence provider
49      * implementation class. Corresponds to the <provider> element in
50      * the persistence.xml file.
51      * @return The fully qualified name of the persistence provider
52      * implementation class. Corresponds to the <provider> element in
53      * the persistence.xml file.
54      */

55     public String JavaDoc getPersistenceProviderClassName();
56
57     /**
58      * Returns the transaction type of the entity managers created by the
59      * EntityManagerFactory. The transaction type corresponds to the
60      * transaction-type attribute in the persistence.xml file.
61      * @return The transaction type of the entity managers created by the
62      * EntityManagerFactory. The transaction type corresponds to the
63      * transaction-type attribute in the persistence.xml file.
64      */

65     public PersistenceUnitTransactionType getTransactionType();
66
67     /**
68      * Returns the JTA-enabled data source to be used by the persistence
69      * provider. The data source corresponds to the <jta-data-source>
70      * element in the persistence.xml file or is provided at deployment
71      * or by the container.
72      * @return the JTA-enabled data source to be used by the persistence
73      * provider. The data source corresponds to the <jta-data-source>
74      * element in the persistence.xml file or is provided at deployment
75      * or by the container.
76      */

77     public DataSource JavaDoc getJtaDataSource();
78
79     /**
80      * Returns the non-JTA-enabled data source to be used by the persistence
81      * provider for accessing data outside a JTA transaction. The data
82      * source corresponds to the named <non-jta-data-source> element in
83      * the persistence.xml file or provided at deployment or by the
84      * container.
85      * @return The non-JTA-enabled data source to be used by the persistence
86      * provider for accessing data outside a JTA transaction. The data
87      * source corresponds to the named <non-jta-data-source> element in
88      * the persistence.xml file or provided at deployment or by the
89      * container.
90      */

91     public DataSource JavaDoc getNonJtaDataSource();
92
93     /**
94      * Returns the list of mapping file names that the persistence provider must
95      * load to determine the mappings for the entity classes. The
96      * mapping files must be in the standard XML mapping format, be
97      * uniquely named and be resource-loadable from the application
98      * classpath. This list will not include the orm.xml file if one was
99      * specified. Each mapping file name corresponds to a <mapping-file>
100      * element in the persistence.xml file.
101      * @return The list of mapping file names that the persistence provider must
102      * load to determine the mappings for the entity classes. The
103      * mapping files must be in the standard XML mapping format, be
104      * uniquely named and be resource-loadable from the application
105      * classpath. This list will not include the orm.xml file if one was
106      * specified. Each mapping file name corresponds to a <mapping-file>
107      * element in the persistence.xml file.
108      */

109     public List JavaDoc<String JavaDoc> getMappingFileNames();
110
111     /**
112      * Returns a list of URLs for the jar files or exploded jar
113      * file directories that the persistence provider must examine
114      * for managed classes of the persistence unit. Each URL
115      * corresponds to a named <jar-file> element in the
116      * persistence.xml file. A URL will either be a file:
117      * URL referring to a jar file or referring to a directory
118      * that contains an exploded jar file, or some other URL from
119      * which an InputStream in jar format can be obtained.
120      *
121      * @return a list of URL objects referring to jar files or
122      * directories.
123      */

124     public List JavaDoc<URL JavaDoc> getJarFileUrls();
125
126     /**
127      * Returns the URL for the jar file or directory that is the
128      * root of the persistence unit. (If the persistence unit is
129      * rooted in the WEB-INF/classes directory, this will be the
130      * URL of that directory.)
131      * The URL will either be a file: URL referring to a jar file
132      * or referring to a directory that contains an exploded jar
133      * file, or some other URL from which an InputStream in jar
134      * format can be obtained.
135      *
136      * @return a URL referring to a jar file or directory.
137      */

138     public URL JavaDoc getPersistenceUnitRootUrl();
139
140     /**
141      * Returns the list of the names of the classes that the persistence
142      * provider must add it to its set of managed classes. Each name
143      * corresponds to a named &lt;class&gt; element in the persistence.xml
144      * file.
145      * @return The list of the names of the classes that the persistence
146      * provider must add it to its set of managed classes. Each name
147      * corresponds to a named &lt;class&gt; element in the persistence.xml
148      * file.
149      */

150     public List JavaDoc<String JavaDoc> getManagedClassNames();
151
152     /**
153      * Returns whether classes in the root of the persistence unit that have not
154      * been explicitly listed are to be included in the set of managed
155      * classes. This value corresponds to the &lt;exclude-unlisted-classes&gt;
156      * element in the persistence.xml file.
157      * @return Whether classes in the root of the persistence unit that have not
158      * been explicitly listed are to be included in the set of managed
159      * classes. This value corresponds to the &lt;exclude-unlisted-classes&gt;
160      * element in the persistence.xml file.
161      */

162     public boolean excludeUnlistedClasses();
163
164     /**
165      * Returns properties object. Each property corresponds to a &lt;property&gt;
166      * element in the persistence.xml file
167      * @return Properties object. Each property corresponds to a &lt;property&gt;
168      * element in the persistence.xml file
169      */

170     public Properties JavaDoc getProperties();
171
172     /**
173      * Returns ClassLoader that the provider may use to load any classes,
174      * resources, or open URLs.
175      * @return ClassLoader that the provider may use to load any classes,
176      * resources, or open URLs.
177      */

178     public ClassLoader JavaDoc getClassLoader();
179
180     /**
181      * Add a transformer supplied by the provider that will be called for every
182      * new class definition or class redefinition that gets loaded by
183      * the loader returned by the {@link PersistenceUnitInfo#getClassLoader} method. The
184      * transformer has no effect on the result returned by the
185      * {@link PersistenceUnitInfo#getNewTempClassLoader} method. Classes are
186      * only transformed once within the same classloading scope, regardless of
187      * how many persistence units they may be a part of.
188      *
189      * @param transformer A provider-supplied transformer that the Container
190      * invokes at class-(re)definition time
191      */

192     public void addTransformer(ClassTransformer transformer);
193
194     /**
195      * Return a new instance of a ClassLoader that the provider
196      * may use to temporarily load any classes, resources, or
197      * open URLs. The scope and classpath of this loader is
198      * exactly the same as that of the loader returned by
199      * {@link PersistenceUnitInfo#getClassLoader}. None of the classes loaded
200      * by this class loader will be visible to application
201      * components. The provider may only use this ClassLoader
202      * within the scope of the {@link PersistenceProvider#createContainerEntityManagerFactory}
203      * call.
204      *
205      * @return Temporary ClassLoader with same visibility as current
206      * loader
207      */

208     public ClassLoader JavaDoc getNewTempClassLoader();
209 }
210
Popular Tags