KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > PersistenceUnitDescriptor


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 com.sun.enterprise.deployment;
26
27 import java.util.ArrayList JavaDoc;
28 import java.util.Collections JavaDoc;
29 import java.util.List JavaDoc;
30 import java.util.Properties JavaDoc;
31
32 /**
33  * A persistence.xml file can contain one or more <persistence-unit>s
34  * This class represents information about a <persistence-unit>.
35  * @author Sanjeeb.Sahoo@Sun.COM
36  */

37 public class PersistenceUnitDescriptor extends Descriptor {
38
39     private PersistenceUnitsDescriptor parent;
40
41     private String JavaDoc name;
42
43     private String JavaDoc transactionType = "JTA"; // in persistence.xsd default is JTA
44

45     private String JavaDoc description;
46
47     private String JavaDoc provider;
48
49     private String JavaDoc jtaDataSource;
50
51     private String JavaDoc nonJtaDataSource;
52
53     private List JavaDoc<String JavaDoc> mappingFiles = new ArrayList JavaDoc<String JavaDoc>();
54
55     private List JavaDoc<String JavaDoc> jarFiles = new ArrayList JavaDoc<String JavaDoc>();
56
57     private List JavaDoc<String JavaDoc> classes = new ArrayList JavaDoc<String JavaDoc>();
58
59     private Properties JavaDoc properties = new Properties JavaDoc();
60
61     private boolean excludeUnlistedClasses = false;
62
63     public PersistenceUnitDescriptor() {
64     }
65
66     public PersistenceUnitsDescriptor getParent() {
67         return parent;
68     }
69
70     protected void setParent(PersistenceUnitsDescriptor parent) {
71         assert(this.parent==null);
72         this.parent = parent;
73     }
74
75     // NOW let's implement some methods specific to this descriptor
76
// Most of these setter methods are invoked using reflection
77
// by PersistenceNode. So any change here has to be reflcted there as
78
// well. Compiler won't catch them for you.
79

80     public String JavaDoc getName() {
81         return name;
82     }
83
84     public void setName(String JavaDoc value) {
85         this.name = value;
86         this.changed();
87     }
88
89     public String JavaDoc getTransactionType() {
90         return transactionType;
91     }
92
93     public void setTransactionType(String JavaDoc transactionType) {
94         this.transactionType = transactionType;
95     }
96
97     public String JavaDoc getDescription() {
98         return description;
99     }
100
101     public void setDescription(String JavaDoc description) {
102         this.description = description;
103     }
104
105     public String JavaDoc getProvider() {
106         return provider;
107     }
108
109     public void setProvider(String JavaDoc value) {
110         this.changed();
111         this.provider = value;
112     }
113
114     public String JavaDoc getJtaDataSource() {
115         return jtaDataSource;
116     }
117
118     public void setJtaDataSource(String JavaDoc value) {
119         this.jtaDataSource = value;
120         this.changed();
121     }
122
123     public String JavaDoc getNonJtaDataSource() {
124         return nonJtaDataSource;
125     }
126
127     public void setNonJtaDataSource(String JavaDoc value) {
128         this.nonJtaDataSource = value;
129         this.changed();
130     }
131
132     public List JavaDoc<String JavaDoc> getMappingFiles() {
133         return Collections.unmodifiableList(mappingFiles);
134     }
135
136     public void addMappingFile(String JavaDoc mappingFile) {
137         mappingFiles.add(mappingFile);
138     }
139
140     public List JavaDoc<String JavaDoc> getJarFiles() {
141         return Collections.unmodifiableList(jarFiles);
142     }
143
144     public void addJarFile(String JavaDoc jarFile) {
145         jarFiles.add(jarFile);
146         this.changed();
147     }
148
149     public List JavaDoc<String JavaDoc> getClasses() {
150         return Collections.unmodifiableList(classes);
151     }
152
153     public void addClass(String JavaDoc className) {
154         classes.add(className);
155         this.changed();
156     }
157
158     public Properties JavaDoc getProperties() {
159         return (Properties JavaDoc) properties.clone();
160     }
161
162     public void addProperty(String JavaDoc name, Object JavaDoc value) {
163         properties.put(name, value);
164         this.changed();
165     }
166
167     public boolean isExcludeUnlistedClasses() {
168         return excludeUnlistedClasses;
169     }
170
171     public void setExcludeUnlistedClasses(boolean excludeUnlistedClasses) {
172         this.excludeUnlistedClasses = excludeUnlistedClasses;
173     }
174
175     public ClassLoader JavaDoc getClassLoader() {
176         return getParent().getClassLoader();
177     }
178
179     public String JavaDoc getPuRoot() {
180         return parent.getPuRoot();
181     }
182
183     /**
184      * @return the absolute path of the root of this persistence unit
185      * @see #getPuRoot()
186      * @see PersistenceUnitsDescriptor#getAbsolutePuRoot()
187      */

188     public String JavaDoc getAbsolutePuRoot() {
189         return getParent().getAbsolutePuRoot();
190      }
191 }
192
Popular Tags