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.oejb3;
017:
018: import javax.xml.bind.annotation.XmlAccessType;
019: import javax.xml.bind.annotation.XmlAccessorType;
020: import javax.xml.bind.annotation.XmlAttribute;
021: import javax.xml.bind.annotation.XmlElement;
022: import javax.xml.bind.annotation.XmlID;
023: import javax.xml.bind.annotation.XmlRootElement;
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: import java.util.Map;
030: import java.util.LinkedHashMap;
031: import java.util.Iterator;
032:
033: @XmlAccessorType(XmlAccessType.FIELD)
034: @XmlType(propOrder={"jndi","ejbLink","resourceLink","query"})
035: @XmlRootElement(name="ejb-deployment")
036: public class EjbDeployment {
037:
038: @XmlElement(name="jndi",required=true)
039: protected List<Jndi> jndi;
040:
041: @XmlElement(name="ejb-link",required=true)
042: protected List<EjbLink> ejbLink;
043:
044: @XmlElement(name="resource-link",required=true)
045: protected List<ResourceLink> resourceLink;
046:
047: @XmlElement(required=true)
048: protected List<Query> query;
049:
050: @XmlAttribute(name="container-id")
051: protected String containerId;
052:
053: @XmlAttribute(name="deployment-id")
054: @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
055: @XmlID
056: protected String deploymentId;
057:
058: @XmlAttribute(name="ejb-name")
059: protected String ejbName;
060:
061: public EjbDeployment() {
062: }
063:
064: public EjbDeployment(String containerId, String deploymentId,
065: String ejbName) {
066: this .containerId = containerId;
067: this .deploymentId = deploymentId;
068: this .ejbName = ejbName;
069: }
070:
071: public List<EjbLink> getEjbLink() {
072: if (ejbLink == null) {
073: ejbLink = new ArrayList<EjbLink>();
074: }
075: return this .ejbLink;
076: }
077:
078: public List<Jndi> getJndi() {
079: if (jndi == null) {
080: jndi = new ArrayList<Jndi>();
081: }
082: return jndi;
083: }
084:
085: public List<ResourceLink> getResourceLink() {
086: if (resourceLink == null) {
087: resourceLink = new ArrayList<ResourceLink>();
088: }
089: return this .resourceLink;
090: }
091:
092: public List<Query> getQuery() {
093: if (query == null) {
094: query = new ArrayList<Query>();
095: }
096: return this .query;
097: }
098:
099: public ResourceLink getResourceLink(String refName) {
100: return getResourceLinksMap().get(refName);
101: }
102:
103: public Map<String, ResourceLink> getResourceLinksMap() {
104: Map<String, ResourceLink> map = new LinkedHashMap<String, ResourceLink>();
105: for (ResourceLink link : getResourceLink()) {
106: map.put(link.getResRefName(), link);
107: }
108: return map;
109: }
110:
111: public EjbLink getEjbLink(String refName) {
112: return getEjbLinksMap().get(refName);
113: }
114:
115: public Map<String, EjbLink> getEjbLinksMap() {
116: Map<String, EjbLink> map = new LinkedHashMap<String, EjbLink>();
117: for (EjbLink link : getEjbLink()) {
118: map.put(link.getEjbRefName(), link);
119: }
120: return map;
121: }
122:
123: public String getContainerId() {
124: return containerId;
125: }
126:
127: public void setContainerId(String value) {
128: this .containerId = value;
129: }
130:
131: public String getDeploymentId() {
132: return deploymentId;
133: }
134:
135: public void setDeploymentId(String value) {
136: this .deploymentId = value;
137: }
138:
139: public String getEjbName() {
140: return ejbName;
141: }
142:
143: public void setEjbName(String value) {
144: this .ejbName = value;
145: }
146:
147: public void addResourceLink(ResourceLink resourceLink) {
148: getResourceLink().add(resourceLink);
149: }
150:
151: public void removeResourceLink(String resRefName) {
152: for (Iterator<ResourceLink> iterator = resourceLink.iterator(); iterator
153: .hasNext();) {
154: ResourceLink link = iterator.next();
155: if (resRefName.equals(link.getResRefName())) {
156: iterator.remove();
157: }
158: }
159: }
160:
161: public void addEjbLink(EjbLink ejbLink) {
162: getEjbLink().add(ejbLink);
163: }
164:
165: public void addQuery(Query query) {
166: getQuery().add(query);
167: }
168: }
|