Search in sources :

Example 1 with HandlerChain

use of jakarta.jws.HandlerChain in project metro-jax-ws by eclipse-ee4j.

the class HandlerAnnotationProcessor method buildHandlerChainsModel.

public static HandlerChainsModel buildHandlerChainsModel(final Class<?> clazz) {
    if (clazz == null) {
        return null;
    }
    HandlerChain handlerChain = clazz.getAnnotation(HandlerChain.class);
    if (handlerChain == null)
        return null;
    InputStream iStream = getFileAsStream(clazz, handlerChain);
    XMLStreamReader reader = XMLStreamReaderFactory.create(null, iStream, true);
    XMLStreamReaderUtil.nextElementContent(reader);
    HandlerChainsModel handlerChainsModel = HandlerChainsModel.parseHandlerConfigFile(clazz, reader);
    try {
        reader.close();
        iStream.close();
    } catch (XMLStreamException | IOException e) {
        e.printStackTrace();
        throw new UtilException(e.getMessage());
    }
    return handlerChainsModel;
}
Also used : HandlerChain(jakarta.jws.HandlerChain) XMLStreamReader(javax.xml.stream.XMLStreamReader) XMLStreamException(javax.xml.stream.XMLStreamException) InputStream(java.io.InputStream) HandlerChainsModel(com.sun.xml.ws.handler.HandlerChainsModel) IOException(java.io.IOException)

Example 2 with HandlerChain

use of jakarta.jws.HandlerChain in project metro-jax-ws by eclipse-ee4j.

the class HandlerAnnotationProcessor method buildHandlerInfo.

/**
 * <p>This method is called by
 * {@link EndpointFactory} when
 * they have an annotated class.
 *
 * <p>If there is no handler chain annotation on the class,
 * this method will return null. Otherwise it will load the
 * class and call the parseHandlerFile method to read the
 * information.
 *
 * @return A HandlerAnnotationInfo object that stores the
 * handlers and roles. Will return null if the class passed
 * in has no handler chain annotation.
 */
public static HandlerAnnotationInfo buildHandlerInfo(@NotNull Class<?> clazz, QName serviceName, QName portName, WSBinding binding) {
    MetadataReader metadataReader = EndpointFactory.getExternalMetadatReader(clazz, binding);
    if (metadataReader == null) {
        metadataReader = new ReflectAnnotationReader();
    }
    // clazz = checkClass(clazz);
    HandlerChain handlerChain = metadataReader.getAnnotation(HandlerChain.class, clazz);
    if (handlerChain == null) {
        clazz = getSEI(clazz, metadataReader);
        if (clazz != null)
            handlerChain = metadataReader.getAnnotation(HandlerChain.class, clazz);
        if (handlerChain == null)
            return null;
    }
    if (clazz.getAnnotation(SOAPMessageHandlers.class) != null) {
        throw new UtilException("util.handler.cannot.combine.soapmessagehandlers");
    }
    InputStream iStream = getFileAsStream(clazz, handlerChain);
    XMLStreamReader reader = XMLStreamReaderFactory.create(null, iStream, true);
    XMLStreamReaderUtil.nextElementContent(reader);
    HandlerAnnotationInfo handlerAnnInfo = HandlerChainsModel.parseHandlerFile(reader, clazz.getClassLoader(), serviceName, portName, binding);
    try {
        reader.close();
        iStream.close();
    } catch (XMLStreamException | IOException e) {
        e.printStackTrace();
        throw new UtilException(e.getMessage());
    }
    return handlerAnnInfo;
}
Also used : HandlerChain(jakarta.jws.HandlerChain) XMLStreamReader(javax.xml.stream.XMLStreamReader) XMLStreamException(javax.xml.stream.XMLStreamException) InputStream(java.io.InputStream) MetadataReader(com.sun.xml.ws.api.databinding.MetadataReader) SOAPMessageHandlers(jakarta.jws.soap.SOAPMessageHandlers) IOException(java.io.IOException) ReflectAnnotationReader(com.sun.xml.ws.model.ReflectAnnotationReader)

Aggregations

HandlerChain (jakarta.jws.HandlerChain)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 XMLStreamReader (javax.xml.stream.XMLStreamReader)2 MetadataReader (com.sun.xml.ws.api.databinding.MetadataReader)1 HandlerChainsModel (com.sun.xml.ws.handler.HandlerChainsModel)1 ReflectAnnotationReader (com.sun.xml.ws.model.ReflectAnnotationReader)1 SOAPMessageHandlers (jakarta.jws.soap.SOAPMessageHandlers)1