Search in sources :

Example 1 with ServerRtException

use of com.sun.xml.ws.server.ServerRtException in project metro-jax-ws by eclipse-ee4j.

the class AbstractInstanceResolver method findAnnotatedMethod.

/**
 * Finds the method that has the given annotation, while making sure that
 * there's only at most one such method.
 */
@Nullable
protected final Method findAnnotatedMethod(Class clazz, Class<? extends Annotation> annType) {
    boolean once = false;
    Method r = null;
    for (Method method : clazz.getDeclaredMethods()) {
        if (method.getAnnotation(annType) != null) {
            if (once)
                throw new ServerRtException(ServerMessages.ANNOTATION_ONLY_ONCE(annType));
            if (method.getParameterTypes().length != 0)
                throw new ServerRtException(ServerMessages.NOT_ZERO_PARAMETERS(method));
            r = method;
            once = true;
        }
    }
    return r;
}
Also used : Method(java.lang.reflect.Method) ServerRtException(com.sun.xml.ws.server.ServerRtException) Nullable(com.sun.istack.Nullable)

Example 2 with ServerRtException

use of com.sun.xml.ws.server.ServerRtException in project metro-jax-ws by eclipse-ee4j.

the class SDDocumentSource method create.

/**
 * Creates {@link SDDocumentSource} from resource path using resolvingClass to read the resource.
 * Required for Jigsaw runtime.
 *
 * @param resolvingClass class used to read resource
 * @param path resource path
 */
private static SDDocumentSource create(final String path, final Class<?> resolvingClass) {
    return new SDDocumentSource() {

        @Override
        public XMLStreamReader read(XMLInputFactory xif) throws IOException, XMLStreamException {
            InputStream is = inputStream();
            return new TidyXMLStreamReader(xif.createXMLStreamReader(path, is), is);
        }

        @Override
        public XMLStreamReader read() throws IOException, XMLStreamException {
            InputStream is = inputStream();
            return new TidyXMLStreamReader(XMLStreamReaderFactory.create(path, is, false), is);
        }

        @Override
        public URL getSystemId() {
            try {
                return new URL("file://" + path);
            } catch (MalformedURLException e) {
                return null;
            }
        }

        private InputStream inputStream() throws IOException {
            java.lang.Module module = resolvingClass.getModule();
            InputStream stream = module.getResourceAsStream(path);
            if (stream != null) {
                return stream;
            }
            throw new ServerRtException("cannot.load.wsdl", path);
        }
    };
}
Also used : MalformedURLException(java.net.MalformedURLException) TidyXMLStreamReader(com.sun.xml.ws.streaming.TidyXMLStreamReader) InputStream(java.io.InputStream) ServerRtException(com.sun.xml.ws.server.ServerRtException) XMLInputFactory(javax.xml.stream.XMLInputFactory) URL(java.net.URL)

Example 3 with ServerRtException

use of com.sun.xml.ws.server.ServerRtException in project metro-jax-ws by eclipse-ee4j.

the class EndpointImpl method buildDocList.

/**
 * Convert metadata sources using identity transform. So that we can
 * reuse the Source object multiple times.
 */
private List<SDDocumentSource> buildDocList() {
    List<SDDocumentSource> r = new ArrayList<>();
    if (metadata != null) {
        for (Source source : metadata) {
            try {
                XMLStreamBufferResult xsbr = XmlUtil.identityTransform(source, new XMLStreamBufferResult());
                String systemId = source.getSystemId();
                r.add(SDDocumentSource.create(new URL(systemId), xsbr.getXMLStreamBuffer()));
            } catch (TransformerException | IOException | SAXException | ParserConfigurationException te) {
                throw new ServerRtException("server.rt.err", te);
            }
        }
    }
    return r;
}
Also used : ArrayList(java.util.ArrayList) XMLStreamBufferResult(com.sun.xml.stream.buffer.XMLStreamBufferResult) IOException(java.io.IOException) ServerRtException(com.sun.xml.ws.server.ServerRtException) Source(javax.xml.transform.Source) URL(java.net.URL) SAXException(org.xml.sax.SAXException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) TransformerException(javax.xml.transform.TransformerException)

Example 4 with ServerRtException

use of com.sun.xml.ws.server.ServerRtException in project metro-jax-ws by eclipse-ee4j.

the class XmlCatalogUtil method createEntityResolver.

/**
 * Gets an EntityResolver using XML catalog
 */
public static EntityResolver createEntityResolver(@Nullable URL catalogUrl) {
    ArrayList<URL> urlsArray = new ArrayList<>();
    EntityResolver er;
    if (catalogUrl != null) {
        urlsArray.add(catalogUrl);
    }
    try {
        er = createCatalogResolver(urlsArray);
    } catch (Exception e) {
        throw new ServerRtException("server.rt.err", e);
    }
    return er;
}
Also used : ArrayList(java.util.ArrayList) EntityResolver(org.xml.sax.EntityResolver) ServerRtException(com.sun.xml.ws.server.ServerRtException) URL(java.net.URL) ServerRtException(com.sun.xml.ws.server.ServerRtException) WebServiceException(jakarta.xml.ws.WebServiceException)

Example 5 with ServerRtException

use of com.sun.xml.ws.server.ServerRtException in project metro-jax-ws by eclipse-ee4j.

the class DeploymentDescriptorParser method createBinding.

/**
 * @param ddBindingId   binding id explicitlyspecified in the DeploymentDescriptor or parameter
 * @param implClass     Endpoint Implementation class
 * @param mtomEnabled   represents mtom-enabled attribute in DD
 * @param mtomThreshold threshold value specified in DD
 * @return is returned with only MTOMFeature set resolving the various precendece rules
 */
private static WSBinding createBinding(String ddBindingId, Class implClass, String mtomEnabled, String mtomThreshold, String dataBindingMode) {
    // Features specified through DD
    WebServiceFeatureList features;
    MTOMFeature mtomfeature = null;
    if (mtomEnabled != null) {
        if (mtomThreshold != null) {
            mtomfeature = new MTOMFeature(Boolean.valueOf(mtomEnabled), Integer.parseInt(mtomThreshold));
        } else {
            mtomfeature = new MTOMFeature(Boolean.valueOf(mtomEnabled));
        }
    }
    BindingID bindingID;
    if (ddBindingId != null) {
        bindingID = BindingID.parse(ddBindingId);
        features = bindingID.createBuiltinFeatureList();
        if (checkMtomConflict(features.get(MTOMFeature.class), mtomfeature)) {
            throw new ServerRtException(ServerMessages.DD_MTOM_CONFLICT(ddBindingId, mtomEnabled));
        }
    } else {
        bindingID = BindingID.parse(implClass);
        // Since bindingID is coming from implclass,
        // mtom through Feature annotation or DD takes precendece
        features = new WebServiceFeatureList();
        if (mtomfeature != null) {
            // this wins over MTOM setting in bindingID
            features.add(mtomfeature);
        }
        features.addAll(bindingID.createBuiltinFeatureList());
    }
    if (dataBindingMode != null) {
        features.add(new DatabindingModeFeature(dataBindingMode));
    }
    return bindingID.createBinding(features.toArray());
}
Also used : MTOMFeature(jakarta.xml.ws.soap.MTOMFeature) DatabindingModeFeature(com.oracle.webservices.api.databinding.DatabindingModeFeature) WebServiceFeatureList(com.sun.xml.ws.binding.WebServiceFeatureList) BindingID(com.sun.xml.ws.api.BindingID) ServerRtException(com.sun.xml.ws.server.ServerRtException)

Aggregations

ServerRtException (com.sun.xml.ws.server.ServerRtException)7 URL (java.net.URL)4 TidyXMLStreamReader (com.sun.xml.ws.streaming.TidyXMLStreamReader)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 DatabindingModeFeature (com.oracle.webservices.api.databinding.DatabindingModeFeature)1 NotNull (com.sun.istack.NotNull)1 Nullable (com.sun.istack.Nullable)1 HttpContext (com.sun.net.httpserver.HttpContext)1 HttpServer (com.sun.net.httpserver.HttpServer)1 XMLStreamBufferResult (com.sun.xml.stream.buffer.XMLStreamBufferResult)1 BindingID (com.sun.xml.ws.api.BindingID)1 WebServiceFeatureList (com.sun.xml.ws.binding.WebServiceFeatureList)1 WebServiceException (jakarta.xml.ws.WebServiceException)1 MTOMFeature (jakarta.xml.ws.soap.MTOMFeature)1 InputStream (java.io.InputStream)1 Method (java.lang.reflect.Method)1 InetSocketAddress (java.net.InetSocketAddress)1 MalformedURLException (java.net.MalformedURLException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1