001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.openejb.jee.jpa.unit;
017:
018: import java.util.ArrayList;
019: import java.util.List;
020: import javax.xml.bind.annotation.XmlAccessType;
021: import javax.xml.bind.annotation.XmlAccessorType;
022: import javax.xml.bind.annotation.XmlAttribute;
023: import javax.xml.bind.annotation.XmlElement;
024: import javax.xml.bind.annotation.XmlRootElement;
025: import javax.xml.bind.annotation.XmlType;
026: import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
027: import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
028:
029: /**
030: * <p>Java class for anonymous complex type.
031: *
032: * <p>The following schema fragment specifies the expected content contained within this class.
033: *
034: * <pre>
035: * <complexType>
036: * <complexContent>
037: * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
038: * <sequence>
039: * <element name="persistence-unit" maxOccurs="unbounded" minOccurs="0">
040: * <complexType>
041: * <complexContent>
042: * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
043: * <sequence>
044: * <element name="description" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
045: * <element name="provider" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
046: * <element name="jta-data-source" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
047: * <element name="non-jta-data-source" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
048: * <element name="mapping-file" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
049: * <element name="jar-file" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
050: * <element name="class" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
051: * <element name="exclude-unlisted-classes" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
052: * <element name="properties" minOccurs="0">
053: * <complexType>
054: * <complexContent>
055: * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
056: * <sequence>
057: * <element name="property" maxOccurs="unbounded" minOccurs="0">
058: * <complexType>
059: * <complexContent>
060: * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
061: * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
062: * <attribute name="value" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
063: * </restriction>
064: * </complexContent>
065: * </complexType>
066: * </element>
067: * </sequence>
068: * </restriction>
069: * </complexContent>
070: * </complexType>
071: * </element>
072: * </sequence>
073: * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
074: * <attribute name="transaction-type" type="{http://java.sun.com/xml/ns/persistence}persistence-unit-transaction-type" />
075: * </restriction>
076: * </complexContent>
077: * </complexType>
078: * </element>
079: * </sequence>
080: * <attribute name="version" use="required" type="{http://java.sun.com/xml/ns/persistence}versionType" fixed="1.0" />
081: * </restriction>
082: * </complexContent>
083: * </complexType>
084: * </pre>
085: *
086: *
087: */
088: @XmlAccessorType(XmlAccessType.FIELD)
089: @XmlType(name="",propOrder={"persistenceUnit"})
090: @XmlRootElement(name="persistence")
091: public class Persistence {
092:
093: @XmlElement(name="persistence-unit",required=true)
094: protected List<PersistenceUnit> persistenceUnit;
095: @XmlAttribute(required=true)
096: @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
097: protected String version = "1.0";
098:
099: public Persistence() {
100: }
101:
102: public Persistence(PersistenceUnit... persistenceUnit) {
103: for (PersistenceUnit unit : persistenceUnit) {
104: getPersistenceUnit().add(unit);
105: }
106: }
107:
108: /**
109: * Gets the value of the persistenceUnit property.
110: *
111: * <p>
112: * This accessor method returns a reference to the live list,
113: * not a snapshot. Therefore any modification you make to the
114: * returned list will be present inside the JAXB object.
115: * This is why there is not a <CODE>set</CODE> method for the persistenceUnit property.
116: *
117: * <p>
118: * For example, to add a new item, do as follows:
119: * <pre>
120: * getPersistenceUnit().add(newItem);
121: * </pre>
122: *
123: *
124: * <p>
125: * Objects of the following type(s) are allowed in the list
126: * {@link PersistenceUnit }
127: *
128: *
129: */
130: public List<PersistenceUnit> getPersistenceUnit() {
131: if (persistenceUnit == null) {
132: persistenceUnit = new ArrayList<PersistenceUnit>();
133: }
134: return this .persistenceUnit;
135: }
136:
137: /**
138: * Gets the value of the version property.
139: *
140: * @return
141: * possible object is
142: * {@link String }
143: *
144: */
145: public String getVersion() {
146: if (version == null) {
147: return "1.0";
148: } else {
149: return version;
150: }
151: }
152:
153: /**
154: * Sets the value of the version property.
155: *
156: * @param value
157: * allowed object is
158: * {@link String }
159: *
160: */
161: public void setVersion(String value) {
162: this.version = value;
163: }
164:
165: }
|