1 7 package org.jboss.webservice; 8 9 11 import org.jboss.axis.EngineConfiguration; 12 import org.jboss.axis.configuration.FileProvider; 13 import org.jboss.logging.Logger; 14 15 import java.io.File ; 16 import java.io.IOException ; 17 import java.io.InputStream ; 18 import java.net.MalformedURLException ; 19 import java.net.URL ; 20 21 27 public final class EngineConfigurationFinder 28 { 29 private static final Logger log = Logger.getLogger(EngineConfigurationFinder.class); 31 32 public static final String DEFAULT_SERVER_CONFIG = "META-INF/axis-server-config.xml"; 33 public static final String DEFAULT_CLIENT_CONFIG = "META-INF/axis-client-config.xml"; 34 35 46 public static EngineConfiguration getClientEngineConfiguration() 47 { 48 String configLocation = System.getProperty(Constants.CLIENT_CONFIG); 49 if (configLocation == null) 50 configLocation = DEFAULT_CLIENT_CONFIG; 51 52 return getEngineConfiguration(configLocation); 53 } 54 55 66 public static EngineConfiguration getServerEngineConfiguration() 67 { 68 String configLocation = System.getProperty(Constants.SERVER_CONFIG); 69 if (configLocation == null) 70 configLocation = DEFAULT_SERVER_CONFIG; 71 72 return getEngineConfiguration(configLocation); 73 74 75 } 76 77 80 private static EngineConfiguration getEngineConfiguration(String configLocation) 81 { 82 EngineConfiguration config = null; 83 84 try 86 { 87 URL url = new URL (configLocation); 88 InputStream is = url.openStream(); 89 if (is != null) 90 config = new FileProvider(is); 91 } 92 catch (MalformedURLException e) 93 { 94 } 96 catch (IOException e) 97 { 98 } 100 101 if (config == null && new File (configLocation).exists()) 103 { 104 config = new FileProvider(configLocation); 105 } 106 107 108 if (config == null) 110 { 111 ClassLoader cl = EngineConfigurationFinder.class.getClassLoader(); 112 URL configURL = cl.getResource(configLocation); 113 if (configURL != null) 114 { 115 log.debug("Found config at: " + configURL); 116 try 117 { 118 InputStream is = configURL.openStream(); 119 if (is != null) 120 config = new FileProvider(is); 121 } 122 catch (IOException e) 123 { 124 log.debug("Failed to open config", e); 125 } 126 } 127 } 128 129 if (config == null) 130 log.warn("Cannot find engine configuration at: " + configLocation); 131 132 return config; 133 } 134 } 135 | Popular Tags |