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;
018:
019: import javax.xml.bind.annotation.XmlAccessType;
020: import javax.xml.bind.annotation.XmlAccessorType;
021: import javax.xml.bind.annotation.XmlAttribute;
022: import javax.xml.bind.annotation.XmlElement;
023: import javax.xml.bind.annotation.XmlID;
024: import javax.xml.bind.annotation.XmlType;
025: import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
026: import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
027: import java.util.ArrayList;
028: import java.util.List;
029:
030: /**
031: * The persistence-unit-ref element contains a declaration
032: * of Deployment Component's reference to a persistence unit
033: * associated within a Deployment Component's
034: * environment. It consists of:
035: * <p/>
036: * - an optional description
037: * - the persistence unit reference name
038: * - an optional persistence unit name. If not specified,
039: * the default persistence unit is assumed.
040: * - optional injection targets
041: * <p/>
042: * Examples:
043: * <p/>
044: * <persistence-unit-ref>
045: * <persistence-unit-ref-name>myPersistenceUnit
046: * </persistence-unit-ref-name>
047: * </persistence-unit-ref>
048: * <p/>
049: * <persistence-unit-ref>
050: * <persistence-unit-ref-name>myPersistenceUnit
051: * </persistence-unit-ref-name>
052: * <persistence-unit-name>PersistenceUnit1
053: * </persistence-unit-name>
054: * </persistence-unit-ref>
055: */
056: @XmlAccessorType(XmlAccessType.FIELD)
057: @XmlType(name="persistence-unit-refType",propOrder={"description","persistenceUnitRefName","persistenceUnitName","mappedName","injectionTarget"})
058: public class PersistenceUnitRef implements JndiReference,
059: PersistenceRef {
060:
061: @XmlElement(required=true)
062: protected List<Text> description;
063: @XmlElement(name="persistence-unit-ref-name",required=true)
064: protected String persistenceUnitRefName;
065: @XmlElement(name="persistence-unit-name")
066: protected String persistenceUnitName;
067: @XmlElement(name="mapped-name")
068: protected String mappedName;
069: @XmlElement(name="injection-target",required=true)
070: protected List<InjectionTarget> injectionTarget;
071: @XmlAttribute
072: @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
073: @XmlID
074: protected String id;
075:
076: public String getName() {
077: return getPersistenceUnitRefName();
078: }
079:
080: public String getType() {
081: return getPersistenceUnitName();
082: }
083:
084: public void setName(String name) {
085: setPersistenceUnitRefName(name);
086: }
087:
088: public String getKey() {
089: return getName();
090: }
091:
092: public void setType(String type) {
093: }
094:
095: public List<Text> getDescription() {
096: if (description == null) {
097: description = new ArrayList<Text>();
098: }
099: return this .description;
100: }
101:
102: public String getPersistenceUnitRefName() {
103: return persistenceUnitRefName;
104: }
105:
106: public void setPersistenceUnitRefName(String value) {
107: this .persistenceUnitRefName = value;
108: }
109:
110: public String getPersistenceUnitName() {
111: return persistenceUnitName;
112: }
113:
114: public void setPersistenceUnitName(String value) {
115: this .persistenceUnitName = value;
116: }
117:
118: public String getMappedName() {
119: return mappedName;
120: }
121:
122: public void setMappedName(String value) {
123: this .mappedName = value;
124: }
125:
126: public List<InjectionTarget> getInjectionTarget() {
127: if (injectionTarget == null) {
128: injectionTarget = new ArrayList<InjectionTarget>();
129: }
130: return this .injectionTarget;
131: }
132:
133: public String getId() {
134: return id;
135: }
136:
137: public void setId(String value) {
138: this.id = value;
139: }
140:
141: }
|