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.resource.metadata;
023:
024: import java.util.HashSet;
025: import java.util.Iterator;
026: import java.util.Locale;
027:
028: import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
029:
030: /**
031: * Connector meta data
032: *
033: * @author <a href="mailto:adrian@jboss.com">Adrian Brock</a>
034: * @version $Revision: 57189 $
035: */
036: public class ConnectorMetaData extends ConfigPropertyMetaDataContainer {
037: private static final long serialVersionUID = -3049391010669865389L;
038:
039: /** The version */
040: private String version = "1.0";
041:
042: /** The vendor name */
043: private String vendorName;
044:
045: /** The eis type */
046: private String eisType;
047:
048: /** The resource adapter version */
049: private String raVersion;
050:
051: /** The resource adapter class */
052: private String raClass;
053:
054: /** Reauthentication support */
055: private boolean reauthenticationSupport;
056:
057: /** The license */
058: private LicenseMetaData lmd = new LicenseMetaData();
059:
060: /** The descriptions */
061: private ConcurrentReaderHashMap descriptions = new ConcurrentReaderHashMap();
062:
063: /** The connection definitions */
064: private HashSet connectionDefinitions = new HashSet();
065:
066: /** The transaction support meta data */
067: private TransactionSupportMetaData tsmd = new TransactionSupportMetaData();
068:
069: /** The authentication mechanism meta data */
070: private AuthenticationMechanismMetaData ammd = new AuthenticationMechanismMetaData();
071:
072: /** The message listeners */
073: private HashSet listeners = new HashSet();
074:
075: /** The admin objects */
076: private HashSet adminObjects = new HashSet();
077:
078: /** The security permissions */
079: private HashSet securityPermissions = new HashSet();
080:
081: public ConnectorMetaData() {
082: DescriptionGroupMetaData dmd = new DescriptionGroupMetaData();
083: descriptions.put(dmd.getLanguage(), dmd);
084: }
085:
086: /**
087: * Get the connector version
088: *
089: * @return the connector version
090: */
091: public String getVersion() {
092: return version;
093: }
094:
095: /**
096: * Set the connector version
097: *
098: * @param version the connector version
099: */
100: public void setVersion(String version) {
101: this .version = version;
102: }
103:
104: /**
105: * Get the vendor name
106: *
107: * @return the vendor name
108: */
109: public String getVendorName() {
110: return vendorName;
111: }
112:
113: /**
114: * Set the vendor name
115: *
116: * @param vendorName the vendor name
117: */
118: public void setVendorName(String vendorName) {
119: this .vendorName = vendorName;
120: }
121:
122: /**
123: * Get the eis type
124: *
125: * @return the eis type
126: */
127: public String getEISType() {
128: return eisType;
129: }
130:
131: /**
132: * Set the eis Type
133: *
134: * @param eisType the eis type
135: */
136: public void setEISType(String eisType) {
137: this .eisType = eisType;
138: }
139:
140: /**
141: * Get the resource adapter version
142: *
143: * @return the resource adapter version
144: */
145: public String getRAVersion() {
146: return raVersion;
147: }
148:
149: /**
150: * Set the resource adapter version
151: *
152: * @param version the resource adapter version
153: */
154: public void setRAVersion(String version) {
155: this .raVersion = version;
156: }
157:
158: /**
159: * Get the resource adapter class
160: *
161: * @return the resource adapter class
162: */
163: public String getRAClass() {
164: return raClass;
165: }
166:
167: /**
168: * Set the resource adapter class
169: *
170: * @param raClass the resource adapter class
171: */
172: public void setRAClass(String raClass) {
173: this .raClass = raClass;
174: }
175:
176: /**
177: * Get the reauthentication support
178: *
179: * @return the reauthentication support
180: */
181: public boolean getReauthenticationSupport() {
182: return reauthenticationSupport;
183: }
184:
185: /**
186: * Set the reauthentication support
187: *
188: * @param reauthenticationSupport true for support, false otherwise
189: */
190: public void setReauthenticationSupport(
191: boolean reauthenticationSupport) {
192: this .reauthenticationSupport = reauthenticationSupport;
193: }
194:
195: /**
196: * Get the license
197: *
198: * @return the license
199: */
200: public LicenseMetaData getLicense() {
201: return lmd;
202: }
203:
204: /**
205: * Get the description for the default language
206: *
207: * @return the description for the default langugage
208: */
209: public DescriptionGroupMetaData getDescription() {
210: DescriptionGroupMetaData dgmd = (DescriptionGroupMetaData) descriptions
211: .get(Locale.getDefault().getLanguage());
212: // No description using the default locale, just use the first
213: if (dgmd == null) {
214: for (Iterator i = descriptions.values().iterator(); i
215: .hasNext();) {
216: dgmd = (DescriptionGroupMetaData) i.next();
217: break;
218: }
219: }
220: return dgmd;
221: }
222:
223: /**
224: * Get the description for the give language
225: *
226: * @param lang the language
227: * @return the description
228: */
229: public DescriptionGroupMetaData getDescription(String lang) {
230: return (DescriptionGroupMetaData) descriptions.get(lang);
231: }
232:
233: /**
234: * Add a description
235: *
236: * @param dmd the description
237: */
238: public void addDescription(DescriptionGroupMetaData dmd) {
239: descriptions.put(dmd.getLanguage(), dmd);
240: }
241:
242: /**
243: * Get the transaction support
244: *
245: * @return the transaction support
246: */
247: public TransactionSupportMetaData getTransactionSupport() {
248: return tsmd;
249: }
250:
251: /**
252: * Set the transaction support
253: *
254: * @param tsmd the transaction support
255: */
256: public void setTransactionSupport(TransactionSupportMetaData tsmd) {
257: this .tsmd = tsmd;
258: }
259:
260: /**
261: * Get the authentication mechanism
262: *
263: * @return the authentication mechanism
264: */
265: public AuthenticationMechanismMetaData getAuthenticationMechanism() {
266: return ammd;
267: }
268:
269: /**
270: * Set the authentication mechansim
271: *
272: * @param ammd the authentication mechansim
273: */
274: public void setAuthenticationMechansim(
275: AuthenticationMechanismMetaData ammd) {
276: this .ammd = ammd;
277: }
278:
279: /**
280: * Add a connection definition
281: *
282: * @param cdmd the connection definition
283: */
284: public void addConnectionDefinition(
285: ConnectionDefinitionMetaData cdmd) {
286: connectionDefinitions.add(cdmd);
287: }
288:
289: /**
290: * Get the connection definition
291: *
292: * @param connectionDefinition the idenitifying factory
293: * @return the metadata or null if there isn't one
294: */
295: public ConnectionDefinitionMetaData getConnectionDefinition(
296: String connectionDefinition) {
297: for (Iterator i = connectionDefinitions.iterator(); i.hasNext();) {
298: ConnectionDefinitionMetaData cdmd = (ConnectionDefinitionMetaData) i
299: .next();
300: if (cdmd.getConnectionFactoryInterfaceClass().equals(
301: connectionDefinition))
302: return cdmd;
303: }
304: return null;
305: }
306:
307: /**
308: * Add a message listener
309: *
310: * @param mlmd the message listener
311: */
312: public void addMessageListener(MessageListenerMetaData mlmd) {
313: listeners.add(mlmd);
314: }
315:
316: /**
317: * Get the message listener
318: *
319: * @param messagingType the identifying listener interface
320: * @return the metadata or null if there isn't one
321: */
322: public MessageListenerMetaData getMessageListener(
323: String messagingType) {
324: for (Iterator i = listeners.iterator(); i.hasNext();) {
325: MessageListenerMetaData mlmd = (MessageListenerMetaData) i
326: .next();
327: if (mlmd.getType().equals(messagingType))
328: return mlmd;
329: }
330: return null;
331: }
332:
333: /**
334: * Add an administered object
335: *
336: * @param aomd the administered object
337: */
338: public void addAdminObject(AdminObjectMetaData aomd) {
339: adminObjects.add(aomd);
340: }
341:
342: /**
343: * Get the admin object
344: *
345: * @param interfaceName the identifying admin object interface
346: * @return the metadata or null if there isn't one
347: */
348: public AdminObjectMetaData getAdminObject(String interfaceName) {
349: for (Iterator i = adminObjects.iterator(); i.hasNext();) {
350: AdminObjectMetaData aomd = (AdminObjectMetaData) i.next();
351: if (aomd.getAdminObjectInterfaceClass().equals(
352: interfaceName))
353: return aomd;
354: }
355: return null;
356: }
357:
358: /**
359: * Add a security permission
360: *
361: * @param spmd the security permission
362: */
363: public void addSecurityPermission(SecurityPermissionMetaData spmd) {
364: securityPermissions.add(spmd);
365: }
366:
367: public String toString() {
368: StringBuffer buffer = new StringBuffer();
369: buffer.append("ConnectorMetaData").append('@');
370: buffer.append(Integer
371: .toHexString(System.identityHashCode(this )));
372: buffer.append("[version=").append(version);
373: buffer.append(" vendorName=").append(vendorName);
374: buffer.append(" eisType=").append(eisType);
375: buffer.append(" resourceAdapterVersion=").append(raVersion);
376: buffer.append(" resourceAdapterClass=").append(raClass);
377: buffer.append(" license=").append(lmd);
378: buffer.append(" properties=").append(getProperties());
379: buffer.append(" descriptions=").append(descriptions.values());
380: buffer.append(" connectionDefinitions=").append(
381: connectionDefinitions);
382: buffer.append(" transactionSupport=").append(tsmd);
383: buffer.append(" authenticationMechanism=").append(ammd);
384: buffer.append(" reauthenticationSupport=").append(
385: reauthenticationSupport);
386: buffer.append(" messageListeners=").append(listeners);
387: buffer.append(" adminobjects=").append(adminObjects);
388: buffer.append(" securityPermissions=").append(
389: securityPermissions);
390: buffer.append(']');
391: return buffer.toString();
392: }
393: }
|