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-context-ref element contains a declaration
032: * of Deployment Component's reference to a persistence context
033: * associated within a Deployment Component's
034: * environment. It consists of:
035: * <p/>
036: * - an optional description
037: * - the persistence context reference name
038: * - an optional persistence unit name. If not specified,
039: * the default persistence unit is assumed.
040: * - an optional specification as to whether
041: * the persistence context type is Transaction or
042: * Extended. If not specified, Transaction is assumed.
043: * - an optional list of persistence properties
044: * - optional injection targets
045: * <p/>
046: * Examples:
047: * <p/>
048: * <persistence-context-ref>
049: * <persistence-context-ref-name>myPersistenceContext
050: * </persistence-context-ref-name>
051: * </persistence-context-ref>
052: * <p/>
053: * <persistence-context-ref>
054: * <persistence-context-ref-name>myPersistenceContext
055: * </persistence-context-ref-name>
056: * <persistence-unit-name>PersistenceUnit1
057: * </persistence-unit-name>
058: * <persistence-context-type>Extended</persistence-context-type>
059: * </persistence-context-ref>
060: */
061: @XmlAccessorType(XmlAccessType.FIELD)
062: @XmlType(name="persistence-context-refType",propOrder={"description","persistenceContextRefName","persistenceUnitName","persistenceContextType","persistenceProperty","mappedName","injectionTarget"})
063: public class PersistenceContextRef implements JndiReference,
064: PersistenceRef {
065:
066: @XmlElement(required=true)
067: protected List<Text> description;
068: @XmlElement(name="persistence-context-ref-name",required=true)
069: protected String persistenceContextRefName;
070: @XmlElement(name="persistence-unit-name")
071: protected String persistenceUnitName;
072: @XmlElement(name="persistence-context-type")
073: protected PersistenceContextType persistenceContextType;
074: @XmlElement(name="persistence-property",required=true)
075: protected List<Property> persistenceProperty;
076: @XmlElement(name="mapped-name")
077: protected String mappedName;
078: @XmlElement(name="injection-target",required=true)
079: protected List<InjectionTarget> injectionTarget;
080: @XmlAttribute
081: @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
082: @XmlID
083: protected String id;
084:
085: public String getName() {
086: return getPersistenceContextRefName();
087: }
088:
089: public String getKey() {
090: return getName();
091: }
092:
093: public String getType() {
094: return getPersistenceContextType().name();
095: }
096:
097: public void setName(String name) {
098: setPersistenceContextRefName(name);
099: }
100:
101: public void setType(String type) {
102: }
103:
104: public List<Text> getDescription() {
105: if (description == null) {
106: description = new ArrayList<Text>();
107: }
108: return this .description;
109: }
110:
111: public String getPersistenceContextRefName() {
112: return persistenceContextRefName;
113: }
114:
115: public void setPersistenceContextRefName(String value) {
116: this .persistenceContextRefName = value;
117: }
118:
119: public String getPersistenceUnitName() {
120: return persistenceUnitName;
121: }
122:
123: public void setPersistenceUnitName(String value) {
124: this .persistenceUnitName = value;
125: }
126:
127: public PersistenceContextType getPersistenceContextType() {
128: return persistenceContextType;
129: }
130:
131: public void setPersistenceContextType(PersistenceContextType value) {
132: this .persistenceContextType = value;
133: }
134:
135: public List<Property> getPersistenceProperty() {
136: if (persistenceProperty == null) {
137: persistenceProperty = new ArrayList<Property>();
138: }
139: return this .persistenceProperty;
140: }
141:
142: public String getMappedName() {
143: return mappedName;
144: }
145:
146: public void setMappedName(String value) {
147: this .mappedName = value;
148: }
149:
150: public List<InjectionTarget> getInjectionTarget() {
151: if (injectionTarget == null) {
152: injectionTarget = new ArrayList<InjectionTarget>();
153: }
154: return this .injectionTarget;
155: }
156:
157: public String getId() {
158: return id;
159: }
160:
161: public void setId(String value) {
162: this .id = value;
163: }
164:
165: public void setPersistenceProperty(
166: List<Property> persistenceProperty) {
167: this.persistenceProperty = persistenceProperty;
168: }
169:
170: }
|