1 22 package org.jboss.metamodel.descriptor; 23 24 import java.util.HashMap ; 25 import java.util.Collection ; 26 import java.util.List ; 27 import java.util.ArrayList ; 28 29 import org.jboss.logging.Logger; 30 31 import org.jboss.metamodel.descriptor.EjbLocalRef; 32 import org.jboss.metamodel.descriptor.EjbRef; 33 import org.jboss.metamodel.descriptor.EnvEntry; 34 import org.jboss.metamodel.descriptor.JndiRef; 35 import org.jboss.metamodel.descriptor.MessageDestinationRef; 36 import org.jboss.metamodel.descriptor.ResourceEnvRef; 37 import org.jboss.metamodel.descriptor.ResourceRef; 38 import org.jboss.metamodel.descriptor.ServiceRef; 39 40 44 public abstract class EnvironmentRefGroup 45 { 46 private static final Logger log = Logger.getLogger(EnvironmentRefGroup.class); 47 48 protected HashMap <String , EjbLocalRef> ejbLocalRefs = new HashMap <String , EjbLocalRef>(); 49 protected HashMap <String , EjbRef> ejbRefs = new HashMap <String , EjbRef>(); 50 protected HashMap <String , EnvEntry> envEntries = new HashMap <String , EnvEntry>(); 51 protected HashMap <String , ResourceEnvRef> resourceEnvRefs = new HashMap <String , ResourceEnvRef>(); 52 protected HashMap <String , ResourceRef> resourceRefs = new HashMap <String , ResourceRef>(); 53 protected HashMap <String , MessageDestinationRef> messageDestinationRefs = new HashMap <String , MessageDestinationRef>(); 54 55 protected HashMap <String , MessageDestinationRef> messageDestinationRefsByLink = new HashMap <String , MessageDestinationRef>(); 56 protected HashMap <String , ServiceRef> serviceRefs = new HashMap <String , ServiceRef>(); 57 protected HashMap <String , JndiRef> jndiRefs = new HashMap <String , JndiRef>(); 58 protected List <PersistenceContextRef> persistenceContextRefs = new ArrayList <PersistenceContextRef>(); 59 protected List <PersistenceUnitRef> persistenceUnitRefs = new ArrayList <PersistenceUnitRef>(); 60 61 public Collection <MessageDestinationRef> getMessageDestinationRefs() 62 { 63 return messageDestinationRefs.values(); 64 } 65 66 public void addMessageDestinationRef(MessageDestinationRef ref) 67 { 68 log.debug("addMessageDestinationRef, "+ref); 69 messageDestinationRefs.put(ref.getMessageDestinationRefName(), ref); 70 String link = ref.getMessageDestinationLink(); 71 if( link != null ) 72 { 73 messageDestinationRefsByLink.put(link, ref); 74 } 75 } 76 77 public Collection <EjbLocalRef> getEjbLocalRefs() 78 { 79 return ejbLocalRefs.values(); 80 } 81 82 public void addEjbLocalRef(EjbLocalRef ref) 83 { 84 ejbLocalRefs.put(ref.getEjbRefName(), ref); 85 } 86 87 public Collection <EjbRef> getEjbRefs() 88 { 89 return ejbRefs.values(); 90 } 91 92 public void addEjbRef(EjbRef ref) 93 { 94 ejbRefs.put(ref.getEjbRefName(), ref); 95 } 96 97 public Collection <EnvEntry> getEnvEntries() 98 { 99 return envEntries.values(); 100 } 101 102 public void addEnvEntry(EnvEntry entry) 103 { 104 envEntries.put(entry.getEnvEntryName(), entry); 105 } 106 107 public Collection <ResourceEnvRef> getResourceEnvRefs() 108 { 109 return resourceEnvRefs.values(); 110 } 111 112 public void addResourceEnvRef(ResourceEnvRef envRef) 113 { 114 resourceEnvRefs.put(envRef.getResRefName(), envRef); 115 } 116 117 public Collection <ResourceRef> getResourceRefs() 118 { 119 return resourceRefs.values(); 120 } 121 122 public void addResourceRef(ResourceRef ref) 123 { 124 resourceRefs.put(ref.getResRefName(), ref); 125 } 126 127 public Collection <JndiRef> getJndiRefs() 128 { 129 return jndiRefs.values(); 130 } 131 132 public void addJndiRef(JndiRef ref) 133 { 134 jndiRefs.put(ref.getJndiRefName(), ref); 135 } 136 137 public Collection <ServiceRef> getServiceRefs() 138 { 139 return serviceRefs.values(); 140 } 141 142 public void addServiceRef(ServiceRef ref) 143 { 144 serviceRefs.put(ref.getEncName(), ref); 145 } 146 147 public void updateEjbRef(EjbRef updatedRef) 148 { 149 EjbRef ref = (EjbRef)ejbRefs.get(updatedRef.getEjbRefName()); 150 if (ref != null) 151 { 152 ref.setMappedName(updatedRef.getMappedName()); 153 ref.setIgnoreDependency(updatedRef.isIgnoreDependency()); 154 } 155 else 156 { 157 ejbRefs.put(updatedRef.getEjbRefName(), updatedRef); 158 } 159 } 160 161 public void updateEjbLocalRef(EjbLocalRef updatedRef) 162 { 163 EjbLocalRef ref = (EjbLocalRef)ejbLocalRefs.get(updatedRef.getEjbRefName()); 164 if (ref != null) 165 { 166 ref.setMappedName(updatedRef.getMappedName()); 167 ref.setIgnoreDependency(updatedRef.isIgnoreDependency()); 168 } 169 else 170 { 171 ejbLocalRefs.put(updatedRef.getEjbRefName(), updatedRef); 172 } 173 } 174 175 public void updateResourceRef(ResourceRef updatedRef) 176 { 177 ResourceRef ref = (ResourceRef)resourceRefs.get(updatedRef.getResRefName()); 178 if (ref != null) 179 { 180 ref.setMappedName(updatedRef.getMappedName()); 181 ref.setResUrl(updatedRef.getResUrl()); 182 ref.setResourceName(updatedRef.getResourceName()); 183 } 184 else 185 { 186 resourceRefs.put(updatedRef.getResRefName(), updatedRef); 187 } 188 } 189 190 public void updateResourceEnvRef(ResourceEnvRef updatedRef) 191 { 192 ResourceEnvRef ref = (ResourceEnvRef)resourceEnvRefs.get(updatedRef.getResRefName()); 193 if (ref != null) 194 { 195 ref.setMappedName(updatedRef.getMappedName()); 196 } 197 else 198 { 199 resourceEnvRefs.put(updatedRef.getResRefName(), updatedRef); 200 } 201 } 202 203 public void updateMessageDestinationRef(MessageDestinationRef updatedRef) 204 { 205 log.debug("updateMessageDestinationRef, "+updatedRef); 206 MessageDestinationRef ref = (MessageDestinationRef)messageDestinationRefs.get(updatedRef.getMessageDestinationRefName()); 207 if (ref != null) 208 { 209 ref.setMappedName(updatedRef.getMappedName()); 210 } 211 else 212 { 213 messageDestinationRefs.put(updatedRef.getMessageDestinationRefName(), updatedRef); 214 ref = updatedRef; 215 } 216 } 217 218 public String toString() 219 { 220 StringBuffer sb = new StringBuffer (100); 221 return sb.toString(); 222 } 223 224 public List <PersistenceContextRef> getPersistenceContextRefs() 225 { 226 return persistenceContextRefs; 227 } 228 229 public List <PersistenceUnitRef> getPersistenceUnitRefs() 230 { 231 return persistenceUnitRefs; 232 } 233 234 public void addPersistenceContextRef(PersistenceContextRef ref) 235 { 236 persistenceContextRefs.add(ref); 237 } 238 239 public void addPersistenceUnitRef(PersistenceUnitRef ref) 240 { 241 persistenceUnitRefs.add(ref); 242 } 243 244 public MessageDestinationRef getMessageDestinationRefForLink(String link) 245 { 246 MessageDestinationRef ref = messageDestinationRefsByLink.get(link); 247 return ref; 248 } 249 } 250 | Popular Tags |