/* * JBoss, Home of Professional Open Source. * Copyright 2006, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metamodel.descriptor; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import org.jboss.logging.Logger; import org.jboss.ws.integration.ServiceRefMetaData; /** * @author William DeCoste * @version $Revision: 61248 $ */ public abstract class EnvironmentRefGroup { private static final Logger log = Logger.getLogger(EnvironmentRefGroup.class); protected HashMap ejbLocalRefs = new HashMap(); protected HashMap ejbRefs = new HashMap(); protected HashMap envEntries = new HashMap(); protected HashMap resourceEnvRefs = new HashMap(); protected HashMap resourceRefs = new HashMap(); protected HashMap messageDestinationRefs = new HashMap(); /** An index of MessageDestinationRef keyed by message-destination-link values */ protected HashMap messageDestinationRefsByLink = new HashMap(); protected HashMap serviceRefs = new HashMap(); protected HashMap jndiRefs = new HashMap(); protected List persistenceContextRefs = new ArrayList(); protected List persistenceUnitRefs = new ArrayList(); public Collection getMessageDestinationRefs() { return messageDestinationRefs.values(); } public void addMessageDestinationRef(MessageDestinationRef ref) { log.debug("addMessageDestinationRef, "+ref); messageDestinationRefs.put(ref.getMessageDestinationRefName(), ref); String link = ref.getMessageDestinationLink(); if( link != null ) { messageDestinationRefsByLink.put(link, ref); } } public Collection getEjbLocalRefs() { return ejbLocalRefs.values(); } public void addEjbLocalRef(EjbLocalRef ref) { ejbLocalRefs.put(ref.getEjbRefName(), ref); } public Collection getEjbRefs() { return ejbRefs.values(); } public void addEjbRef(EjbRef ref) { ejbRefs.put(ref.getEjbRefName(), ref); } public Collection getEnvEntries() { return envEntries.values(); } public void addEnvEntry(EnvEntry entry) { envEntries.put(entry.getEnvEntryName(), entry); } public Collection getResourceEnvRefs() { return resourceEnvRefs.values(); } public void addResourceEnvRef(ResourceEnvRef envRef) { resourceEnvRefs.put(envRef.getResRefName(), envRef); } public Collection getResourceRefs() { return resourceRefs.values(); } public void addResourceRef(ResourceRef ref) { resourceRefs.put(ref.getResRefName(), ref); } public Collection getJndiRefs() { return jndiRefs.values(); } public void addJndiRef(JndiRef ref) { jndiRefs.put(ref.getJndiRefName(), ref); } public Collection getServiceRefs() { return serviceRefs.values(); } public void addServiceRef(ServiceRefMetaData ref) { serviceRefs.put(ref.getServiceRefName(), ref); } public void updateEjbRef(EjbRef updatedRef) { EjbRef ref = (EjbRef)ejbRefs.get(updatedRef.getEjbRefName()); if (ref != null) { ref.setMappedName(updatedRef.getMappedName()); ref.setIgnoreDependency(updatedRef.isIgnoreDependency()); } else { ejbRefs.put(updatedRef.getEjbRefName(), updatedRef); } } public void updateEjbLocalRef(EjbLocalRef updatedRef) { EjbLocalRef ref = (EjbLocalRef)ejbLocalRefs.get(updatedRef.getEjbRefName()); if (ref != null) { ref.setMappedName(updatedRef.getMappedName()); ref.setIgnoreDependency(updatedRef.isIgnoreDependency()); } else { ejbLocalRefs.put(updatedRef.getEjbRefName(), updatedRef); } } public void updateResourceRef(ResourceRef updatedRef) { ResourceRef ref = (ResourceRef)resourceRefs.get(updatedRef.getResRefName()); if (ref != null) { ref.setMappedName(updatedRef.getMappedName()); ref.setResUrl(updatedRef.getResUrl()); ref.setResourceName(updatedRef.getResourceName()); } else { resourceRefs.put(updatedRef.getResRefName(), updatedRef); } } public void updateResourceEnvRef(ResourceEnvRef updatedRef) { ResourceEnvRef ref = (ResourceEnvRef)resourceEnvRefs.get(updatedRef.getResRefName()); if (ref != null) { ref.setMappedName(updatedRef.getMappedName()); } else { resourceEnvRefs.put(updatedRef.getResRefName(), updatedRef); } } public void updateMessageDestinationRef(MessageDestinationRef updatedRef) { log.debug("updateMessageDestinationRef, "+updatedRef); MessageDestinationRef ref = (MessageDestinationRef)messageDestinationRefs.get(updatedRef.getMessageDestinationRefName()); if (ref != null) { ref.setMappedName(updatedRef.getMappedName()); } else { messageDestinationRefs.put(updatedRef.getMessageDestinationRefName(), updatedRef); ref = updatedRef; } } public String toString() { StringBuffer sb = new StringBuffer(100); return sb.toString(); } public List getPersistenceContextRefs() { return persistenceContextRefs; } public List getPersistenceUnitRefs() { return persistenceUnitRefs; } public void addPersistenceContextRef(PersistenceContextRef ref) { persistenceContextRefs.add(ref); } public void addPersistenceUnitRef(PersistenceUnitRef ref) { persistenceUnitRefs.add(ref); } public MessageDestinationRef getMessageDestinationRefForLink(String link) { MessageDestinationRef ref = messageDestinationRefsByLink.get(link); return ref; } }