1 16 package org.apache.axis2.om; 17 18 import org.apache.axis2.soap.SOAPFactory; 19 20 21 24 class FactoryFinder { 25 private static final String DEFAULT_OM_FACTORY_CLASS_NAME = 26 "org.apache.axis2.om.impl.llom.factory.OMLinkedListImplFactory"; 27 private static final String DEFAULT_SOAP11_FACTORY_CLASS_NAME = 28 "org.apache.axis2.soap.impl.llom.soap11.SOAP11Factory"; 29 private static final String DEFAULT_SOAP12_FACTORY_CLASS_NAME = 30 "org.apache.axis2.soap.impl.llom.soap12.SOAP12Factory"; 31 32 private static final String OM_FACTORY_NAME_PROPERTY = "om.factory"; 33 private static final String SOAP11_FACTORY_NAME_PROPERTY = "soap11.factory"; 34 private static final String SOAP12_FACTORY_NAME_PROPERTY = "soap12.factory"; 35 36 37 43 44 45 private static Object findFactory(ClassLoader loader, String factoryClass, String systemPropertyName) 46 throws OMFactoryException { 47 48 String factoryClassName = factoryClass; 49 50 if (System.getProperty(systemPropertyName) != null) { 52 factoryClassName = systemPropertyName; 53 } 54 ; 55 56 Object factory = null; 57 try { 58 if (loader == null) { 59 factory = Class.forName(factoryClassName).newInstance(); 60 } else { 61 factory = loader.loadClass(factoryClassName).newInstance(); 62 } 63 } catch (Exception e) { 64 throw new OMFactoryException(e); 65 } 66 return factory; 67 } 68 69 80 public static SOAPFactory findSOAP11Factory(ClassLoader loader) 81 throws OMFactoryException { 82 return (SOAPFactory) findFactory(loader, DEFAULT_SOAP11_FACTORY_CLASS_NAME, SOAP11_FACTORY_NAME_PROPERTY); 83 } 84 85 96 public static SOAPFactory findSOAP12Factory(ClassLoader loader) 97 throws OMFactoryException { 98 return (SOAPFactory) findFactory(loader, DEFAULT_SOAP12_FACTORY_CLASS_NAME, SOAP12_FACTORY_NAME_PROPERTY); 99 } 100 101 112 public static OMFactory findOMFactory(ClassLoader loader) 113 throws OMFactoryException { 114 return (OMFactory) findFactory(loader, DEFAULT_OM_FACTORY_CLASS_NAME, OM_FACTORY_NAME_PROPERTY); 115 } 116 } 117 | Popular Tags |