KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > metamodel > descriptor > EnvironmentRefGroup


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.metamodel.descriptor;
23
24 import java.util.HashMap JavaDoc;
25 import java.util.Collection JavaDoc;
26 import java.util.List JavaDoc;
27 import java.util.ArrayList JavaDoc;
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 /**
41  * @author <a HREF="mailto:bdecoste@jboss.com">William DeCoste</a>
42  * @version <tt>$Revision: 58121 $</tt>
43  */

44 public abstract class EnvironmentRefGroup
45 {
46    private static final Logger log = Logger.getLogger(EnvironmentRefGroup.class);
47
48    protected HashMap JavaDoc<String JavaDoc, EjbLocalRef> ejbLocalRefs = new HashMap JavaDoc<String JavaDoc, EjbLocalRef>();
49    protected HashMap JavaDoc<String JavaDoc, EjbRef> ejbRefs = new HashMap JavaDoc<String JavaDoc, EjbRef>();
50    protected HashMap JavaDoc<String JavaDoc, EnvEntry> envEntries = new HashMap JavaDoc<String JavaDoc, EnvEntry>();
51    protected HashMap JavaDoc<String JavaDoc, ResourceEnvRef> resourceEnvRefs = new HashMap JavaDoc<String JavaDoc, ResourceEnvRef>();
52    protected HashMap JavaDoc<String JavaDoc, ResourceRef> resourceRefs = new HashMap JavaDoc<String JavaDoc, ResourceRef>();
53    protected HashMap JavaDoc<String JavaDoc, MessageDestinationRef> messageDestinationRefs = new HashMap JavaDoc<String JavaDoc, MessageDestinationRef>();
54    /** An index of MessageDestinationRef keyed by message-destination-link values */
55    protected HashMap JavaDoc<String JavaDoc, MessageDestinationRef> messageDestinationRefsByLink = new HashMap JavaDoc<String JavaDoc, MessageDestinationRef>();
56    protected HashMap JavaDoc<String JavaDoc, ServiceRef> serviceRefs = new HashMap JavaDoc<String JavaDoc, ServiceRef>();
57    protected HashMap JavaDoc<String JavaDoc, JndiRef> jndiRefs = new HashMap JavaDoc<String JavaDoc, JndiRef>();
58    protected List JavaDoc<PersistenceContextRef> persistenceContextRefs = new ArrayList JavaDoc<PersistenceContextRef>();
59    protected List JavaDoc<PersistenceUnitRef> persistenceUnitRefs = new ArrayList JavaDoc<PersistenceUnitRef>();
60
61    public Collection JavaDoc<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 JavaDoc link = ref.getMessageDestinationLink();
71       if( link != null )
72       {
73          messageDestinationRefsByLink.put(link, ref);
74       }
75    }
76
77    public Collection JavaDoc<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 JavaDoc<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 JavaDoc<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 JavaDoc<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 JavaDoc<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 JavaDoc<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 JavaDoc<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 JavaDoc toString()
219    {
220       StringBuffer JavaDoc sb = new StringBuffer JavaDoc(100);
221       return sb.toString();
222    }
223
224    public List JavaDoc<PersistenceContextRef> getPersistenceContextRefs()
225    {
226       return persistenceContextRefs;
227    }
228
229    public List JavaDoc<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 JavaDoc link)
245    {
246       MessageDestinationRef ref = messageDestinationRefsByLink.get(link);
247       return ref;
248    }
249 }
250
Popular Tags