Search in sources :

Example 1 with DeploymentDescriptorParser

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);
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) DeploymentDescriptorParser(com.sun.xml.ws.transport.http.DeploymentDescriptorParser) IOException(java.io.IOException) URL(java.net.URL) WSEndpoint(com.sun.xml.ws.api.server.WSEndpoint) ServletContext(javax.servlet.ServletContext) File(java.io.File)

Example 2 with DeploymentDescriptorParser

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);
}
Also used : DeploymentDescriptorParser(com.sun.xml.ws.transport.http.DeploymentDescriptorParser) HttpAdapterList(com.sun.xml.ws.transport.http.HttpAdapterList) FileSystemResourceLoader(com.sun.xml.ws.transport.local.FileSystemResourceLoader) HttpAdapter(com.sun.xml.ws.transport.http.HttpAdapter) File(java.io.File)

Example 3 with DeploymentDescriptorParser

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);
    }
}
Also used : DeploymentDescriptorParser(com.sun.xml.ws.transport.http.DeploymentDescriptorParser) InputStream(java.io.InputStream) URL(java.net.URL)

Example 4 with DeploymentDescriptorParser

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));
}
Also used : DeploymentDescriptorParser(com.sun.xml.ws.transport.http.DeploymentDescriptorParser) WSEndpoint(com.sun.xml.ws.api.server.WSEndpoint) File(java.io.File)

Example 5 with DeploymentDescriptorParser

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);
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) DeploymentDescriptorParser(com.sun.xml.ws.transport.http.DeploymentDescriptorParser) URL(java.net.URL)

Aggregations

DeploymentDescriptorParser (com.sun.xml.ws.transport.http.DeploymentDescriptorParser)6 File (java.io.File)4 WSEndpoint (com.sun.xml.ws.api.server.WSEndpoint)3 URL (java.net.URL)3 FileSystemResourceLoader (com.sun.xml.ws.transport.local.FileSystemResourceLoader)2 DocumentAddressResolver (com.sun.xml.ws.api.server.DocumentAddressResolver)1 PortAddressResolver (com.sun.xml.ws.api.server.PortAddressResolver)1 SDDocument (com.sun.xml.ws.api.server.SDDocument)1 ServiceDefinition (com.sun.xml.ws.api.server.ServiceDefinition)1 HttpAdapter (com.sun.xml.ws.transport.http.HttpAdapter)1 HttpAdapterList (com.sun.xml.ws.transport.http.HttpAdapterList)1 ByteArrayBuffer (com.sun.xml.ws.util.ByteArrayBuffer)1 WebServiceException (jakarta.xml.ws.WebServiceException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ServletContext (javax.servlet.ServletContext)1 QName (javax.xml.namespace.QName)1 WebServiceException (javax.xml.ws.WebServiceException)1