use of javax.xml.ws.spi.Provider in project tomee by apache.
the class ProviderWrapperTest method test.
public void test() throws Exception {
System.setProperty(Provider.class.getName(), MockProvider.class.getName());
Provider provider = Provider.provider();
assertNotNull("provider is null", provider);
assertFalse("provider should not be an instance of ProviderWrapper", provider instanceof ProviderWrapper);
ProviderWrapper.beforeCreate(null, null, null);
try {
provider = Provider.provider();
assertNotNull("provider is null", provider);
assertTrue("provider should be an instance of ProviderWrapper", provider instanceof ProviderWrapper);
final ProviderWrapper providerWrapper = (ProviderWrapper) provider;
// check delegate
final Provider delegate = providerWrapper.getDelegate();
assertNotNull("providerWrapper delegate is null", delegate);
assertFalse("providerWrapper delegate should not be an instance of ProviderWrapper", delegate instanceof ProviderWrapper);
} finally {
ProviderWrapper.afterCreate();
}
}
use of javax.xml.ws.spi.Provider in project tomee by apache.
the class JaxWsProviderWrapperTest method test.
public void test() throws Exception {
System.setProperty(Provider.class.getName(), MockProvider.class.getName());
Provider provider = Provider.provider();
assertNotNull("provider is null", provider);
assertFalse("provider should not be an instance of ProviderWrapper", provider instanceof JaxWsProviderWrapper);
JaxWsProviderWrapper.beforeCreate(null);
try {
provider = Provider.provider();
assertNotNull("provider is null", provider);
assertTrue("provider should be an instance of ProviderWrapper", provider instanceof JaxWsProviderWrapper);
final JaxWsProviderWrapper providerWrapper = (JaxWsProviderWrapper) provider;
// check delegate
final Provider delegate = providerWrapper.getDelegate();
assertNotNull("providerWrapper delegate is null", delegate);
assertFalse("providerWrapper delegate should not be an instance of ProviderWrapper", delegate instanceof JaxWsProviderWrapper);
} finally {
JaxWsProviderWrapper.afterCreate();
}
}
use of javax.xml.ws.spi.Provider in project tomee by apache.
the class JaxWsProviderWrapper method findProvider.
private static Provider findProvider() {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = ClassLoader.getSystemClassLoader();
}
// 0. System.getProperty("openejb.javax.xml.ws.spi.Provider")
// This is so those using old axis rules still work as expected
String providerClass = System.getProperty("openejb." + JAXWSPROVIDER_PROPERTY);
Provider provider = createProviderInstance(providerClass, classLoader);
if (provider != null) {
return provider;
}
// 1. META-INF/services/javax.xml.ws.spi.Provider
try {
for (final URL url : Collections.list(classLoader.getResources("META-INF/services/" + JAXWSPROVIDER_PROPERTY))) {
BufferedReader in = null;
try {
in = new BufferedReader(new InputStreamReader(url.openStream()));
providerClass = in.readLine();
provider = createProviderInstance(providerClass, classLoader);
if (provider != null) {
return provider;
}
} catch (Exception ignored) {
} finally {
if (in != null) {
try {
in.close();
} catch (Throwable e) {
//ignore
}
}
}
}
} catch (Exception ingored) {
logger.log(Level.INFO, "No META-INF/services/javax.xml.ws.spi.Provider found");
}
// 2. $java.home/lib/jaxws.properties
final String javaHome = System.getProperty("java.home");
final File jaxrpcPropertiesFile = new File(new File(javaHome, "lib"), "jaxrpc.properties");
if (jaxrpcPropertiesFile.exists()) {
InputStream in = null;
try {
in = new FileInputStream(jaxrpcPropertiesFile);
final Properties properties = new Properties();
properties.load(in);
providerClass = properties.getProperty(JAXWSPROVIDER_PROPERTY);
provider = createProviderInstance(providerClass, classLoader);
if (provider != null) {
return provider;
}
} catch (Exception ignored) {
} finally {
if (in != null) {
try {
in.close();
} catch (Throwable e) {
//Ignore
}
}
}
}
// 3. System.getProperty("javax.xml.ws.spi.Provider")
providerClass = System.getProperty(JAXWSPROVIDER_PROPERTY);
provider = createProviderInstance(providerClass, classLoader);
if (provider != null) {
return provider;
}
// 4. Use javax.xml.ws.spi.Provider default
try {
// disable the OpenEJB JaxWS provider
if (classLoader instanceof ProviderClassLoader) {
((ProviderClassLoader) classLoader).enabled = false;
}
System.getProperties().remove(JAXWSPROVIDER_PROPERTY);
provider = Provider.provider();
if (provider != null && !provider.getClass().getName().equals(JaxWsProviderWrapper.class.getName())) {
return provider;
}
} finally {
// reenable the OpenEJB JaxWS provider
System.setProperty(JAXWSPROVIDER_PROPERTY, providerClass);
if (classLoader instanceof ProviderClassLoader) {
((ProviderClassLoader) classLoader).enabled = true;
}
}
throw new WebServiceException("No " + JAXWSPROVIDER_PROPERTY + " implementation found");
}
use of javax.xml.ws.spi.Provider in project tomee by apache.
the class ProviderWrapper method findProvider.
private static Provider findProvider() {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = ClassLoader.getSystemClassLoader();
}
// 0. System.getProperty("openejb.javax.xml.ws.spi.Provider")
// This is so those using old axis rules still work as expected
String providerClass = JavaSecurityManagers.getSystemProperty("openejb." + JAXWSPROVIDER_PROPERTY);
Provider provider = createProviderInstance(providerClass, classLoader);
if (provider != null) {
return provider;
}
// 1. META-INF/services/javax.xml.ws.spi.Provider
try {
for (final URL url : Collections.list(classLoader.getResources("META-INF/services/" + JAXWSPROVIDER_PROPERTY))) {
BufferedReader in = null;
try {
in = new BufferedReader(new InputStreamReader(url.openStream()));
providerClass = in.readLine();
provider = createProviderInstance(providerClass, classLoader);
if (provider != null) {
return provider;
}
} catch (final Exception ignored) {
// no-op
} finally {
if (in != null) {
try {
in.close();
} catch (final IOException e) {
// no-op
}
}
}
}
} catch (final Exception ingored) {
// no-op
}
// 2. $java.home/lib/jaxws.properties
final String javaHome = JavaSecurityManagers.getSystemProperty("java.home");
final File jaxrpcPropertiesFile = new File(new File(javaHome, "lib"), "jaxrpc.properties");
if (jaxrpcPropertiesFile.exists()) {
try {
final Properties properties = IO.readProperties(jaxrpcPropertiesFile);
providerClass = properties.getProperty(JAXWSPROVIDER_PROPERTY);
provider = createProviderInstance(providerClass, classLoader);
if (provider != null) {
return provider;
}
} catch (final Exception ignored) {
// no-op
}
}
// 3. System.getProperty("javax.xml.ws.spi.Provider")
providerClass = JavaSecurityManagers.getSystemProperty(JAXWSPROVIDER_PROPERTY);
provider = createProviderInstance(providerClass, classLoader);
if (provider != null) {
return provider;
}
// 4. Use javax.xml.ws.spi.Provider default
try {
JavaSecurityManagers.removeSystemProperty(JAXWSPROVIDER_PROPERTY);
provider = Provider.provider();
if (provider != null && !provider.getClass().getName().equals(ProviderWrapper.class.getName())) {
return provider;
}
} finally {
// restore original jax provider property
JavaSecurityManagers.setSystemProperty(JAXWSPROVIDER_PROPERTY, providerClass);
}
throw new WebServiceException("No " + JAXWSPROVIDER_PROPERTY + " implementation found");
}
Aggregations