1 16 17 package org.apache.axis.components.jms; 18 19 import org.apache.axis.AxisProperties; 20 import java.util.HashMap ; 21 22 30 public class JMSVendorAdapterFactory 31 { 32 private static HashMap s_adapters = new HashMap (); 33 private final static String VENDOR_PKG = "org.apache.axis.components.jms"; 34 35 static { 36 AxisProperties.setClassDefault(JMSVendorAdapter.class, 37 VENDOR_PKG + ".JNDIVendorAdapter"); 38 } 39 40 public static final JMSVendorAdapter getJMSVendorAdapter() 41 { 42 return (JMSVendorAdapter)AxisProperties.newInstance(JMSVendorAdapter.class); 43 } 44 45 public static final JMSVendorAdapter getJMSVendorAdapter(String vendorId) 46 { 47 if (s_adapters.containsKey(vendorId)) 49 return (JMSVendorAdapter)s_adapters.get(vendorId); 50 51 JMSVendorAdapter adapter = null; 53 try 54 { 55 Class vendorClass = Class.forName(getVendorAdapterClassname(vendorId)); 56 adapter = (JMSVendorAdapter)vendorClass.newInstance(); 57 } 58 catch (Exception e) 59 { 60 return null; 61 } 62 63 synchronized (s_adapters) 64 { 65 if (s_adapters.containsKey(vendorId)) 66 return (JMSVendorAdapter)s_adapters.get(vendorId); 67 68 if (adapter != null) 69 s_adapters.put(vendorId, adapter); 70 } 71 72 return adapter; 73 } 74 75 private static String getVendorAdapterClassname(String vendorId) 76 { 77 StringBuffer sb = new StringBuffer (VENDOR_PKG).append("."); 78 sb.append(vendorId); 79 sb.append("VendorAdapter"); 80 81 return sb.toString(); 82 } 83 } | Popular Tags |