001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.metamodel.descriptor;
023:
024: import java.util.ArrayList;
025: import java.util.Collection;
026: import java.util.HashMap;
027: import java.util.List;
028:
029: import org.jboss.logging.Logger;
030: import org.jboss.ws.integration.ServiceRefMetaData;
031:
032: /**
033: * @author <a href="mailto:bdecoste@jboss.com">William DeCoste</a>
034: * @version <tt>$Revision: 61248 $</tt>
035: */
036: public abstract class EnvironmentRefGroup {
037: private static final Logger log = Logger
038: .getLogger(EnvironmentRefGroup.class);
039:
040: protected HashMap<String, EjbLocalRef> ejbLocalRefs = new HashMap<String, EjbLocalRef>();
041: protected HashMap<String, EjbRef> ejbRefs = new HashMap<String, EjbRef>();
042: protected HashMap<String, EnvEntry> envEntries = new HashMap<String, EnvEntry>();
043: protected HashMap<String, ResourceEnvRef> resourceEnvRefs = new HashMap<String, ResourceEnvRef>();
044: protected HashMap<String, ResourceRef> resourceRefs = new HashMap<String, ResourceRef>();
045: protected HashMap<String, MessageDestinationRef> messageDestinationRefs = new HashMap<String, MessageDestinationRef>();
046: /** An index of MessageDestinationRef keyed by message-destination-link values */
047: protected HashMap<String, MessageDestinationRef> messageDestinationRefsByLink = new HashMap<String, MessageDestinationRef>();
048: protected HashMap<String, ServiceRefMetaData> serviceRefs = new HashMap<String, ServiceRefMetaData>();
049: protected HashMap<String, JndiRef> jndiRefs = new HashMap<String, JndiRef>();
050: protected List<PersistenceContextRef> persistenceContextRefs = new ArrayList<PersistenceContextRef>();
051: protected List<PersistenceUnitRef> persistenceUnitRefs = new ArrayList<PersistenceUnitRef>();
052:
053: public Collection<MessageDestinationRef> getMessageDestinationRefs() {
054: return messageDestinationRefs.values();
055: }
056:
057: public void addMessageDestinationRef(MessageDestinationRef ref) {
058: log.debug("addMessageDestinationRef, " + ref);
059: messageDestinationRefs.put(ref.getMessageDestinationRefName(),
060: ref);
061: String link = ref.getMessageDestinationLink();
062: if (link != null) {
063: messageDestinationRefsByLink.put(link, ref);
064: }
065: }
066:
067: public Collection<EjbLocalRef> getEjbLocalRefs() {
068: return ejbLocalRefs.values();
069: }
070:
071: public void addEjbLocalRef(EjbLocalRef ref) {
072: ejbLocalRefs.put(ref.getEjbRefName(), ref);
073: }
074:
075: public Collection<EjbRef> getEjbRefs() {
076: return ejbRefs.values();
077: }
078:
079: public void addEjbRef(EjbRef ref) {
080: ejbRefs.put(ref.getEjbRefName(), ref);
081: }
082:
083: public Collection<EnvEntry> getEnvEntries() {
084: return envEntries.values();
085: }
086:
087: public void addEnvEntry(EnvEntry entry) {
088: envEntries.put(entry.getEnvEntryName(), entry);
089: }
090:
091: public Collection<ResourceEnvRef> getResourceEnvRefs() {
092: return resourceEnvRefs.values();
093: }
094:
095: public void addResourceEnvRef(ResourceEnvRef envRef) {
096: resourceEnvRefs.put(envRef.getResRefName(), envRef);
097: }
098:
099: public Collection<ResourceRef> getResourceRefs() {
100: return resourceRefs.values();
101: }
102:
103: public void addResourceRef(ResourceRef ref) {
104: resourceRefs.put(ref.getResRefName(), ref);
105: }
106:
107: public Collection<JndiRef> getJndiRefs() {
108: return jndiRefs.values();
109: }
110:
111: public void addJndiRef(JndiRef ref) {
112: jndiRefs.put(ref.getJndiRefName(), ref);
113: }
114:
115: public Collection<ServiceRefMetaData> getServiceRefs() {
116: return serviceRefs.values();
117: }
118:
119: public void addServiceRef(ServiceRefMetaData ref) {
120: serviceRefs.put(ref.getServiceRefName(), ref);
121: }
122:
123: public void updateEjbRef(EjbRef updatedRef) {
124: EjbRef ref = (EjbRef) ejbRefs.get(updatedRef.getEjbRefName());
125: if (ref != null) {
126: ref.setMappedName(updatedRef.getMappedName());
127: ref.setIgnoreDependency(updatedRef.isIgnoreDependency());
128: } else {
129: ejbRefs.put(updatedRef.getEjbRefName(), updatedRef);
130: }
131: }
132:
133: public void updateEjbLocalRef(EjbLocalRef updatedRef) {
134: EjbLocalRef ref = (EjbLocalRef) ejbLocalRefs.get(updatedRef
135: .getEjbRefName());
136: if (ref != null) {
137: ref.setMappedName(updatedRef.getMappedName());
138: ref.setIgnoreDependency(updatedRef.isIgnoreDependency());
139: } else {
140: ejbLocalRefs.put(updatedRef.getEjbRefName(), updatedRef);
141: }
142: }
143:
144: public void updateResourceRef(ResourceRef updatedRef) {
145: ResourceRef ref = (ResourceRef) resourceRefs.get(updatedRef
146: .getResRefName());
147: if (ref != null) {
148: ref.setMappedName(updatedRef.getMappedName());
149: ref.setResUrl(updatedRef.getResUrl());
150: ref.setResourceName(updatedRef.getResourceName());
151: } else {
152: resourceRefs.put(updatedRef.getResRefName(), updatedRef);
153: }
154: }
155:
156: public void updateResourceEnvRef(ResourceEnvRef updatedRef) {
157: ResourceEnvRef ref = (ResourceEnvRef) resourceEnvRefs
158: .get(updatedRef.getResRefName());
159: if (ref != null) {
160: ref.setMappedName(updatedRef.getMappedName());
161: } else {
162: resourceEnvRefs.put(updatedRef.getResRefName(), updatedRef);
163: }
164: }
165:
166: public void updateMessageDestinationRef(
167: MessageDestinationRef updatedRef) {
168: log.debug("updateMessageDestinationRef, " + updatedRef);
169: MessageDestinationRef ref = (MessageDestinationRef) messageDestinationRefs
170: .get(updatedRef.getMessageDestinationRefName());
171: if (ref != null) {
172: ref.setMappedName(updatedRef.getMappedName());
173: } else {
174: messageDestinationRefs.put(updatedRef
175: .getMessageDestinationRefName(), updatedRef);
176: ref = updatedRef;
177: }
178: }
179:
180: public String toString() {
181: StringBuffer sb = new StringBuffer(100);
182: return sb.toString();
183: }
184:
185: public List<PersistenceContextRef> getPersistenceContextRefs() {
186: return persistenceContextRefs;
187: }
188:
189: public List<PersistenceUnitRef> getPersistenceUnitRefs() {
190: return persistenceUnitRefs;
191: }
192:
193: public void addPersistenceContextRef(PersistenceContextRef ref) {
194: persistenceContextRefs.add(ref);
195: }
196:
197: public void addPersistenceUnitRef(PersistenceUnitRef ref) {
198: persistenceUnitRefs.add(ref);
199: }
200:
201: public MessageDestinationRef getMessageDestinationRefForLink(
202: String link) {
203: MessageDestinationRef ref = messageDestinationRefsByLink
204: .get(link);
205: return ref;
206: }
207: }
|