Skip to content

Commit

Permalink
PAYARA-3691 Support reading catalog/wsdl from WEB-INF
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Pielage <[email protected]>
  • Loading branch information
Pandrex247 committed Apr 13, 2021
1 parent d50f5db commit e7933ff
Showing 1 changed file with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,21 @@
import com.sun.org.apache.xml.internal.resolver.Catalog;
import com.sun.org.apache.xml.internal.resolver.CatalogManager;
import com.sun.org.apache.xml.internal.resolver.tools.CatalogResolver;
import com.sun.xml.ws.api.ResourceLoader;
import com.sun.xml.ws.server.ServerRtException;
import com.sun.xml.ws.util.ServiceFinder;

import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import javax.xml.ws.WebServiceException;

import org.xml.sax.EntityResolver;

import com.sun.xml.ws.api.ResourceLoader;
import com.sun.xml.ws.server.ServerRtException;
import com.sun.xml.ws.util.ServiceFinder;

/**
*
* @author lukas
Expand Down Expand Up @@ -61,11 +69,15 @@ public static EntityResolver createDefaultCatalogResolver() {
manager.setIgnoreMissingProperties(true);
// Using static catalog may result in to sharing of the catalog by multiple apps running in a container
manager.setUseStaticCatalog(false);
// parse the catalog

// Activates debug via system property, if set
manager.getVerbosity();

// Parse the catalog
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Catalog catalog = manager.getCatalog();
parseResourcesToCatalog(cl, catalog, "META-INF/jax-ws-catalog.xml");
parseResourcesToCatalog(cl, catalog, "/WEB-INF/jax-ws-catalog.xml");
parseResourcesToCatalog(catalog, "jax-ws-catalog.xml");

return workaroundCatalogResolver(catalog);
}
Expand All @@ -88,6 +100,19 @@ private static void parseResourcesToCatalog(ClassLoader classLoader, Catalog cat
}
}

private static void parseResourcesToCatalog(Catalog catalog, String resourceName) {
try {
for (ResourceLoader resourceLoader : ServiceFinder.find(ResourceLoader.class)) {
URL resource = resourceLoader.getResource(resourceName);
if (resource != null) {
catalog.parseCatalog(resourceLoader.getResource(resourceName));
}
}
} catch (IOException e) {
throw new WebServiceException(e);
}
}

/**
* Default CatalogResolver implementation is broken as it depends on
* CatalogManager.getCatalog() which will always create useStaticCatalog is
Expand Down

0 comments on commit e7933ff

Please sign in to comment.