use of com.sun.xml.ws.transport.http.DeploymentDescriptorParser in project gdmatrix by gdmatrix.
the class WSServletContextListener method contextInitialized.
@Override
public void contextInitialized(ServletContextEvent event) {
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info(WsservletMessages.LISTENER_INFO_INITIALIZE());
}
ServletContext context = event.getServletContext();
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = getClass().getClassLoader();
}
try {
// Parse the descriptor file and build endpoint infos
DeploymentDescriptorParser<ServletAdapter> parser = new DeploymentDescriptorParser<>(classLoader, new ServletResourceLoader(context), createContainer(context), new ServletAdapterList());
URL sunJaxWsXml;
File matrixDir = MatrixConfig.getDirectory();
File jaxwsFile = new File(matrixDir, "sun-jaxws.xml");
if (jaxwsFile.exists() && jaxwsFile.isFile()) {
sunJaxWsXml = jaxwsFile.toURI().toURL();
} else {
sunJaxWsXml = context.getResource(JAXWS_RI_RUNTIME);
if (sunJaxWsXml == null) {
throw new WebServiceException(WsservletMessages.NO_SUNJAXWS_XML(JAXWS_RI_RUNTIME));
}
}
List<ServletAdapter> adapters = parser.parse(sunJaxWsXml.toExternalForm(), sunJaxWsXml.openStream());
delegate = createDelegate(adapters, context);
context.setAttribute(WSServlet.JAXWS_RI_RUNTIME_INFO, delegate);
for (ServletAdapter adapter : adapters) {
WSEndpoint endpoint = adapter.getEndpoint();
WSController controller = WSController.getInstance(endpoint);
if (controller != null) {
String endpointName = adapter.getName();
controller.setEndpointName(endpointName);
controller.initialize();
}
}
} catch (IOException | WebServiceException e) {
LOGGER.log(Level.SEVERE, WsservletMessages.LISTENER_PARSING_FAILED(e), e);
context.removeAttribute(WSServlet.JAXWS_RI_RUNTIME_INFO);
throw new WebServiceException("listener.parsingFailed", e);
}
}
use of com.sun.xml.ws.transport.http.DeploymentDescriptorParser in project metro-jax-ws by eclipse-ee4j.
the class JaxwsHttpServer method parseSunJaxws.
private List<Adapter> parseSunJaxws(File warDirFile) throws Exception {
File ddFile = new File(warDirFile, "WEB-INF" + sepChar + "sun-jaxws.xml");
System.out.println("dd file=" + ddFile.getName());
/*
String classesDir = userDir+sepChar+"webapps"+sepChar+warDir+sepChar+
"WEB-INF"+sepChar+"classes";
System.out.println("classes dir="+classesDir);
URL url = new File(classesDir).toURL();
ClassLoader urlc = new URLClassLoader(new URL[] { url },
this.getClass().getClassLoader());
*/
DeploymentDescriptorParser<Adapter> parser = new DeploymentDescriptorParser<Adapter>(this.getClass().getClassLoader(), new FileSystemResourceLoader(warDirFile), null, new AdapterList());
return parser.parse(ddFile);
}
use of com.sun.xml.ws.transport.http.DeploymentDescriptorParser in project metro-jax-ws by eclipse-ee4j.
the class MetroSupport method parseEndpoints.
private List<HelidonAdapter> parseEndpoints(String dd, ResourceLoader loader, Container container) throws IOException {
DeploymentDescriptorParser<HelidonAdapter> parser = new DeploymentDescriptorParser<>(Thread.currentThread().getContextClassLoader(), loader, container, new HelidonAdapterList());
URL cfg = loader.getResource(dd);
try (InputStream is = cfg.openStream()) {
return parser.parse(cfg.toExternalForm(), is);
}
}
use of com.sun.xml.ws.transport.http.DeploymentDescriptorParser in project metro-jax-ws by eclipse-ee4j.
the class LocalTransportFactory method parseEndpoints.
protected static List<WSEndpoint> parseEndpoints(String outputDir) throws IOException {
String riFile = outputDir + "/WEB-INF/sun-jaxws.xml";
DeploymentDescriptorParser<WSEndpoint> parser = new DeploymentDescriptorParser<>(Thread.currentThread().getContextClassLoader(), new FileSystemResourceLoader(new File(outputDir)), null, new AdapterFactory<>() {
@Override
public WSEndpoint createAdapter(String name, String urlPattern, WSEndpoint<?> endpoint) {
return endpoint;
}
});
return parser.parse(new File(riFile));
}
use of com.sun.xml.ws.transport.http.DeploymentDescriptorParser in project metro-jax-ws by eclipse-ee4j.
the class WSServletContextListener method parseAdaptersAndCreateDelegate.
void parseAdaptersAndCreateDelegate(ServletContext context) {
// The same class can be invoked via @WebListener discovery or explicit configuration in deployment descriptor
// avoid redoing the processing of web services.
String alreadyInvoked = (String) context.getAttribute(WSSERVLET_CONTEXT_LISTENER_INVOKED);
if (Boolean.parseBoolean(alreadyInvoked)) {
return;
}
context.setAttribute(WSSERVLET_CONTEXT_LISTENER_INVOKED, "true");
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = getClass().getClassLoader();
}
try {
URL sunJaxWsXml = context.getResource(JAXWS_RI_RUNTIME);
if (sunJaxWsXml == null) {
throw new WebServiceException(WsservletMessages.NO_SUNJAXWS_XML(JAXWS_RI_RUNTIME));
}
// Parse the descriptor file and build endpoint infos
DeploymentDescriptorParser<ServletAdapter> parser = new DeploymentDescriptorParser<>(classLoader, new ServletResourceLoader(context), createContainer(context), new ServletAdapterList(context));
adapters = parser.parse(sunJaxWsXml.toExternalForm(), sunJaxWsXml.openStream());
registerWSServlet(adapters, context);
delegate = createDelegate(adapters, context);
context.setAttribute(WSServlet.JAXWS_RI_RUNTIME_INFO, delegate);
} catch (Throwable e) {
logger.log(Level.SEVERE, WsservletMessages.LISTENER_PARSING_FAILED(e), e);
context.removeAttribute(WSServlet.JAXWS_RI_RUNTIME_INFO);
throw new WSServletException("listener.parsingFailed", e);
}
}
Aggregations