KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > resource > metadata > ConnectorMetaData


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.resource.metadata;
23
24 import java.net.URL JavaDoc;
25 import java.util.Collection JavaDoc;
26 import java.util.HashSet JavaDoc;
27 import java.util.Iterator JavaDoc;
28 import java.util.Locale JavaDoc;
29
30 import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
31
32 /**
33  * Connector meta data
34  *
35  * @author <a HREF="mailto:adrian@jboss.com">Adrian Brock</a>
36  * @version $Revision: 57108 $
37  */

38 public class ConnectorMetaData extends ConfigPropertyMetaDataContainer
39 {
40    private static final long serialVersionUID = -3049391010669865389L;
41
42    /** The url TODO move to RARDeploymentMetaData */
43    private URL JavaDoc url;
44    
45    /** The version */
46    private String JavaDoc version = "1.0";
47
48    /** The vendor name */
49    private String JavaDoc vendorName;
50
51    /** The eis type */
52    private String JavaDoc eisType;
53
54    /** The resource adapter version */
55    private String JavaDoc raVersion;
56
57    /** The resource adapter class */
58    private String JavaDoc raClass;
59
60    /** Reauthentication support */
61    private boolean reauthenticationSupport;
62
63    /** The license */
64    private LicenseMetaData lmd = new LicenseMetaData();
65
66    /** The descriptions */
67    private ConcurrentReaderHashMap descriptions = new ConcurrentReaderHashMap();
68
69    /** The connection definitions */
70    private HashSet JavaDoc connectionDefinitions = new HashSet JavaDoc();
71
72    /** The transaction support meta data */
73    private TransactionSupportMetaData tsmd = new TransactionSupportMetaData();
74
75    /** The authentication mechanism meta data */
76    private AuthenticationMechanismMetaData ammd = new AuthenticationMechanismMetaData();
77
78    /** The message listeners */
79    private HashSet JavaDoc listeners = new HashSet JavaDoc();
80
81    /** The admin objects */
82    private HashSet JavaDoc adminObjects = new HashSet JavaDoc();
83
84    /** The security permissions */
85    private HashSet JavaDoc securityPermissions = new HashSet JavaDoc();
86
87    public ConnectorMetaData()
88    {
89       DescriptionGroupMetaData dmd = new DescriptionGroupMetaData();
90       descriptions.put(dmd.getLanguage(), dmd);
91    }
92
93    /**
94     * Get the url.
95     *
96     * @return the url.
97     */

98    public URL JavaDoc getURL()
99    {
100       return url;
101    }
102
103    /**
104     * Set the url.
105     *
106     * @param url the url.
107     */

108    public void setURL(URL JavaDoc url)
109    {
110       this.url = url;
111    }
112
113    /**
114     * Get the connector version
115     *
116     * @return the connector version
117     */

118    public String JavaDoc getVersion()
119    {
120       return version;
121    }
122
123    /**
124     * Set the connector version
125     *
126     * @param version the connector version
127     */

128    public void setVersion(String JavaDoc version)
129    {
130       this.version = version;
131    }
132
133    /**
134     * Get the vendor name
135     *
136     * @return the vendor name
137     */

138    public String JavaDoc getVendorName()
139    {
140       return vendorName;
141    }
142
143    /**
144     * Set the vendor name
145     *
146     * @param vendorName the vendor name
147     */

148    public void setVendorName(String JavaDoc vendorName)
149    {
150       this.vendorName = vendorName;
151    }
152
153    /**
154     * Get the eis type
155     *
156     * @return the eis type
157     */

158    public String JavaDoc getEISType()
159    {
160       return eisType;
161    }
162
163    /**
164     * Set the eis Type
165     *
166     * @param eisType the eis type
167     */

168    public void setEISType(String JavaDoc eisType)
169    {
170       this.eisType = eisType;
171    }
172
173    /**
174     * Get the resource adapter version
175     *
176     * @return the resource adapter version
177     */

178    public String JavaDoc getRAVersion()
179    {
180       return raVersion;
181    }
182
183    /**
184     * Set the resource adapter version
185     *
186     * @param version the resource adapter version
187     */

188    public void setRAVersion(String JavaDoc version)
189    {
190       this.raVersion = version;
191    }
192
193    /**
194     * Get the resource adapter class
195     *
196     * @return the resource adapter class
197     */

198    public String JavaDoc getRAClass()
199    {
200       return raClass;
201    }
202
203    /**
204     * Set the resource adapter class
205     *
206     * @param raClass the resource adapter class
207     */

208    public void setRAClass(String JavaDoc raClass)
209    {
210       this.raClass = raClass;
211    }
212
213    /**
214     * Get the reauthentication support
215     *
216     * @return the reauthentication support
217     */

218    public boolean getReauthenticationSupport()
219    {
220       return reauthenticationSupport;
221    }
222
223    /**
224     * Set the reauthentication support
225     *
226     * @param reauthenticationSupport true for support, false otherwise
227     */

228    public void setReauthenticationSupport(boolean reauthenticationSupport)
229    {
230       this.reauthenticationSupport = reauthenticationSupport;
231    }
232
233    /**
234     * Get the license
235     *
236     * @return the license
237     */

238    public LicenseMetaData getLicense()
239    {
240       return lmd;
241    }
242
243    /**
244     * Get the description for the default language
245     *
246     * @return the description for the default langugage
247     */

248    public DescriptionGroupMetaData getDescription()
249    {
250       DescriptionGroupMetaData dgmd = (DescriptionGroupMetaData) descriptions.get(Locale.getDefault().getLanguage());
251       // No description using the default locale, just use the first
252
if (dgmd == null)
253       {
254          for (Iterator JavaDoc i = descriptions.values().iterator(); i.hasNext();)
255          {
256             dgmd = (DescriptionGroupMetaData) i.next();
257             break;
258          }
259       }
260       return dgmd;
261    }
262    
263    /**
264     * Get the description for the give language
265     *
266     * @param lang the language
267     * @return the description
268     */

269    public DescriptionGroupMetaData getDescription(String JavaDoc lang)
270    {
271       return (DescriptionGroupMetaData) descriptions.get(lang);
272    }
273    
274    /**
275     * Add a description
276     *
277     * @param dmd the description
278     */

279    public void addDescription(DescriptionGroupMetaData dmd)
280    {
281       descriptions.put(dmd.getLanguage(), dmd);
282    }
283
284    /**
285     * Get the transaction support
286     *
287     * @return the transaction support
288     */

289    public TransactionSupportMetaData getTransactionSupport()
290    {
291       return tsmd;
292    }
293
294    /**
295     * Set the transaction support
296     *
297     * @param tsmd the transaction support
298     */

299    public void setTransactionSupport(TransactionSupportMetaData tsmd)
300    {
301       this.tsmd = tsmd;
302    }
303    /**
304     * Get the authentication mechanism
305     *
306     * @return the authentication mechanism
307     */

308    public AuthenticationMechanismMetaData getAuthenticationMechanism()
309    {
310       return ammd;
311    }
312
313    /**
314     * Set the authentication mechansim
315     *
316     * @param ammd the authentication mechansim
317     */

318    public void setAuthenticationMechansim(AuthenticationMechanismMetaData ammd)
319    {
320       this.ammd = ammd;
321    }
322    
323    /**
324     * Add a connection definition
325     *
326     * @param cdmd the connection definition
327     */

328    public void addConnectionDefinition(ConnectionDefinitionMetaData cdmd)
329    {
330       connectionDefinitions.add(cdmd);
331    }
332    
333    /**
334     * Get the connection definition
335     *
336     * @param connectionDefinition the idenitifying factory
337     * @return the metadata or null if there isn't one
338     */

339    public ConnectionDefinitionMetaData getConnectionDefinition(String JavaDoc connectionDefinition)
340    {
341       for (Iterator JavaDoc i = connectionDefinitions.iterator(); i.hasNext();)
342       {
343          ConnectionDefinitionMetaData cdmd = (ConnectionDefinitionMetaData) i.next();
344          if (cdmd.getConnectionFactoryInterfaceClass().equals(connectionDefinition))
345             return cdmd;
346       }
347       return null;
348    }
349    
350    /**
351     * Add a message listener
352     *
353     * @param mlmd the message listener
354     */

355    public void addMessageListener(MessageListenerMetaData mlmd)
356    {
357       listeners.add(mlmd);
358    }
359    
360    /**
361     * Get the message listener
362     *
363     * @param messagingType the identifying listener interface
364     * @return the metadata or null if there isn't one
365     */

366    public MessageListenerMetaData getMessageListener(String JavaDoc messagingType)
367    {
368       for (Iterator JavaDoc i = listeners.iterator(); i.hasNext();)
369       {
370          MessageListenerMetaData mlmd = (MessageListenerMetaData) i.next();
371          if (mlmd.getType().equals(messagingType))
372             return mlmd;
373       }
374       return null;
375    }
376    
377    /**
378     * Add an administered object
379     *
380     * @param aomd the administered object
381     */

382    public void addAdminObject(AdminObjectMetaData aomd)
383    {
384       adminObjects.add(aomd);
385    }
386    
387    /**
388     * Get the admin object
389     *
390     * @param interfaceName the identifying admin object interface
391     * @return the metadata or null if there isn't one
392     */

393    public AdminObjectMetaData getAdminObject(String JavaDoc interfaceName)
394    {
395       for (Iterator JavaDoc i = adminObjects.iterator(); i.hasNext();)
396       {
397          AdminObjectMetaData aomd = (AdminObjectMetaData) i.next();
398          if (aomd.getAdminObjectInterfaceClass().equals(interfaceName))
399             return aomd;
400       }
401       return null;
402    }
403    
404    public Collection JavaDoc getAdminObjects()
405    {
406       return adminObjects;
407    }
408    
409    /**
410     * Add a security permission
411     *
412     * @param spmd the security permission
413     */

414    public void addSecurityPermission(SecurityPermissionMetaData spmd)
415    {
416       securityPermissions.add(spmd);
417    }
418    
419    public String JavaDoc toString()
420    {
421       StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
422       buffer.append("ConnectorMetaData").append('@');
423       buffer.append(Integer.toHexString(System.identityHashCode(this)));
424       buffer.append("[version=").append(version);
425       buffer.append(" vendorName=").append(vendorName);
426       buffer.append(" eisType=").append(eisType);
427       buffer.append(" resourceAdapterVersion=").append(raVersion);
428       buffer.append(" resourceAdapterClass=").append(raClass);
429       buffer.append(" license=").append(lmd);
430       buffer.append(" properties=").append(getProperties());
431       buffer.append(" descriptions=").append(descriptions.values());
432       buffer.append(" connectionDefinitions=").append(connectionDefinitions);
433       buffer.append(" transactionSupport=").append(tsmd);
434       buffer.append(" authenticationMechanism=").append(ammd);
435       buffer.append(" reauthenticationSupport=").append(reauthenticationSupport);
436       buffer.append(" messageListeners=").append(listeners);
437       buffer.append(" adminobjects=").append(adminObjects);
438       buffer.append(" securityPermissions=").append(securityPermissions);
439       buffer.append(']');
440       return buffer.toString();
441    }
442 }
443
Popular Tags