001: /**
002: *
003: * Licensed to the Apache Software Foundation (ASF) under one or more
004: * contributor license agreements. See the NOTICE file distributed with
005: * this work for additional information regarding copyright ownership.
006: * The ASF licenses this file to You under the Apache License, Version 2.0
007: * (the "License"); you may not use this file except in compliance with
008: * the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */package org.apache.openejb.jee.jpa.unit;
018:
019: import javax.xml.bind.annotation.XmlAccessorType;
020: import javax.xml.bind.annotation.XmlAccessType;
021: import javax.xml.bind.annotation.XmlType;
022: import javax.xml.bind.annotation.XmlElement;
023: import javax.xml.bind.annotation.XmlAttribute;
024: import javax.xml.bind.annotation.XmlTransient;
025: import java.util.List;
026: import java.util.ArrayList;
027:
028: /**
029: *
030: * Configuration of a persistence unit.
031: *
032: *
033: * <p>Java class for anonymous complex type.
034: *
035: * <p>The following schema fragment specifies the expected content contained within this class.
036: *
037: * <pre>
038: * <complexType>
039: * <complexContent>
040: * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
041: * <sequence>
042: * <element name="description" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
043: * <element name="provider" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
044: * <element name="jta-data-source" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
045: * <element name="non-jta-data-source" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
046: * <element name="mapping-file" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
047: * <element name="jar-file" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
048: * <element name="class" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
049: * <element name="exclude-unlisted-classes" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
050: * <element name="properties" minOccurs="0">
051: * <complexType>
052: * <complexContent>
053: * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
054: * <sequence>
055: * <element name="property" maxOccurs="unbounded" minOccurs="0">
056: * <complexType>
057: * <complexContent>
058: * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
059: * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
060: * <attribute name="value" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
061: * </restriction>
062: * </complexContent>
063: * </complexType>
064: * </element>
065: * </sequence>
066: * </restriction>
067: * </complexContent>
068: * </complexType>
069: * </element>
070: * </sequence>
071: * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
072: * <attribute name="transaction-type" type="{http://java.sun.com/xml/ns/persistence}persistence-unit-transaction-type" />
073: * </restriction>
074: * </complexContent>
075: * </complexType>
076: * </pre>
077: *
078: *
079: */
080: @XmlAccessorType(XmlAccessType.FIELD)
081: @XmlType(name="",propOrder={"description","provider","jtaDataSource","nonJtaDataSource","mappingFile","jarFile","clazz","excludeUnlistedClasses","properties"})
082: public class PersistenceUnit {
083:
084: @XmlTransient
085: private String id;
086:
087: protected String description;
088: protected String provider;
089: @XmlElement(name="jta-data-source")
090: protected String jtaDataSource;
091: @XmlElement(name="non-jta-data-source")
092: protected String nonJtaDataSource;
093: @XmlElement(name="mapping-file",required=true)
094: protected List<String> mappingFile;
095: @XmlElement(name="jar-file",required=true)
096: protected List<String> jarFile;
097: @XmlElement(name="class",required=true)
098: protected List<String> clazz;
099: @XmlElement(name="exclude-unlisted-classes",defaultValue="false")
100: protected Boolean excludeUnlistedClasses;
101: protected Properties properties;
102: @XmlAttribute(required=true)
103: protected String name;
104: @XmlAttribute(name="transaction-type")
105: protected TransactionType transactionType;
106:
107: public PersistenceUnit(String name, String provider) {
108: this .name = name;
109: this .provider = provider;
110: }
111:
112: public PersistenceUnit() {
113: }
114:
115: public PersistenceUnit(String unitName) {
116: this .name = unitName;
117: }
118:
119: public String getId() {
120: return id;
121: }
122:
123: public void setId(String id) {
124: this .id = id;
125: }
126:
127: public String getDescription() {
128: return description;
129: }
130:
131: public void setDescription(String value) {
132: this .description = value;
133: }
134:
135: public String getProvider() {
136: return provider;
137: }
138:
139: public void setProvider(String value) {
140: this .provider = value;
141: }
142:
143: public String getJtaDataSource() {
144: return jtaDataSource;
145: }
146:
147: public void setJtaDataSource(String value) {
148: this .jtaDataSource = value;
149: }
150:
151: public String getNonJtaDataSource() {
152: return nonJtaDataSource;
153: }
154:
155: public void setNonJtaDataSource(String value) {
156: this .nonJtaDataSource = value;
157: }
158:
159: public List<String> getMappingFile() {
160: if (mappingFile == null) {
161: mappingFile = new ArrayList<String>();
162: }
163: return this .mappingFile;
164: }
165:
166: public List<String> getJarFile() {
167: if (jarFile == null) {
168: jarFile = new ArrayList<String>();
169: }
170: return this .jarFile;
171: }
172:
173: public List<String> getClazz() {
174: if (clazz == null) {
175: clazz = new ArrayList<String>();
176: }
177: return this .clazz;
178: }
179:
180: public Boolean isExcludeUnlistedClasses() {
181: return excludeUnlistedClasses;
182: }
183:
184: public void setExcludeUnlistedClasses(Boolean value) {
185: this .excludeUnlistedClasses = value;
186: }
187:
188: public Properties getProperties() {
189: return properties;
190: }
191:
192: public void setProperties(Properties value) {
193: this .properties = value;
194: }
195:
196: public String getName() {
197: return name;
198: }
199:
200: public void setName(String value) {
201: this .name = value;
202: }
203:
204: public TransactionType getTransactionType() {
205: // TODO: Is this the correct default?
206: return (transactionType == null) ? TransactionType.JTA
207: : transactionType;
208: }
209:
210: public void setTransactionType(TransactionType value) {
211: this.transactionType = value;
212: }
213:
214: }
|