Search in sources :

Example 6 with HandlerChains$JAXB.readHandlerChains

use of org.apache.openejb.jee.HandlerChains$JAXB.readHandlerChains in project tomee by apache.

the class WsDeployer method getHandlerChains.

public static HandlerChains getHandlerChains(Class<?> declaringClass, final String serviceEndpoint, final ClassLoader classLoader) throws OpenEJBException {
    HandlerChain handlerChain = declaringClass.getAnnotation(HandlerChain.class);
    if (handlerChain == null && serviceEndpoint != null) {
        try {
            declaringClass = classLoader.loadClass(serviceEndpoint);
            handlerChain = declaringClass.getAnnotation(HandlerChain.class);
        } catch (final ClassNotFoundException ignored) {
        // no-op
        }
    }
    HandlerChains handlerChains = null;
    if (handlerChain != null) {
        try {
            final URL handlerFileURL = declaringClass.getResource(handlerChain.file());
            handlerChains = ReadDescriptors.readHandlerChains(handlerFileURL);
        } catch (final Throwable e) {
            throw new OpenEJBException("Unable to load handler chain file: " + handlerChain.file(), e);
        }
    }
    return handlerChains;
}
Also used : OpenEJBException(org.apache.openejb.OpenEJBException) HandlerChain(javax.jws.HandlerChain) HandlerChains(org.apache.openejb.jee.HandlerChains) URL(java.net.URL)

Example 7 with HandlerChains$JAXB.readHandlerChains

use of org.apache.openejb.jee.HandlerChains$JAXB.readHandlerChains in project tomee by apache.

the class ServiceRef$JAXB method _write.

public static final void _write(final XoXMLStreamWriter writer, final ServiceRef serviceRef, RuntimeContext context) throws Exception {
    if (serviceRef == null) {
        writer.writeXsiNil();
        return;
    }
    if (context == null) {
        context = new RuntimeContext();
    }
    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (ServiceRef.class != serviceRef.getClass()) {
        context.unexpectedSubclass(writer, serviceRef, ServiceRef.class);
        return;
    }
    context.beforeMarshal(serviceRef, LifecycleCallback.NONE);
    // ATTRIBUTE: id
    final String idRaw = serviceRef.id;
    if (idRaw != null) {
        String id = null;
        try {
            id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
        } catch (final Exception e) {
            context.xmlAdapterError(serviceRef, "id", CollapsedStringAdapter.class, String.class, String.class, e);
        }
        writer.writeAttribute("", "", "id", id);
    }
    // ELEMENT: descriptions
    Text[] descriptions = null;
    try {
        descriptions = serviceRef.getDescriptions();
    } catch (final Exception e) {
        context.getterError(serviceRef, "descriptions", ServiceRef.class, "getDescriptions", e);
    }
    if (descriptions != null) {
        for (final Text descriptionsItem : descriptions) {
            if (descriptionsItem != null) {
                writer.writeStartElement(prefix, "description", "http://java.sun.com/xml/ns/javaee");
                writeText(writer, descriptionsItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(serviceRef, "descriptions");
            }
        }
    }
    // ELEMENT: displayNames
    Text[] displayNames = null;
    try {
        displayNames = serviceRef.getDisplayNames();
    } catch (final Exception e) {
        context.getterError(serviceRef, "displayNames", ServiceRef.class, "getDisplayNames", e);
    }
    if (displayNames != null) {
        for (final Text displayNamesItem : displayNames) {
            if (displayNamesItem != null) {
                writer.writeStartElement(prefix, "display-name", "http://java.sun.com/xml/ns/javaee");
                writeText(writer, displayNamesItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(serviceRef, "displayNames");
            }
        }
    }
    // ELEMENT: icon
    final LocalCollection<Icon> icon = serviceRef.icon;
    if (icon != null) {
        for (final Icon iconItem : icon) {
            if (iconItem != null) {
                writer.writeStartElement(prefix, "icon", "http://java.sun.com/xml/ns/javaee");
                writeIcon(writer, iconItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(serviceRef, "icon");
            }
        }
    }
    // ELEMENT: serviceRefName
    final String serviceRefNameRaw = serviceRef.serviceRefName;
    String serviceRefName = null;
    try {
        serviceRefName = Adapters.collapsedStringAdapterAdapter.marshal(serviceRefNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(serviceRef, "serviceRefName", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (serviceRefName != null) {
        writer.writeStartElement(prefix, "service-ref-name", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(serviceRefName);
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(serviceRef, "serviceRefName");
    }
    // ELEMENT: serviceInterface
    final String serviceInterfaceRaw = serviceRef.serviceInterface;
    String serviceInterface = null;
    try {
        serviceInterface = Adapters.collapsedStringAdapterAdapter.marshal(serviceInterfaceRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(serviceRef, "serviceInterface", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (serviceInterface != null) {
        writer.writeStartElement(prefix, "service-interface", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(serviceInterface);
        writer.writeEndElement();
    } else {
        context.unexpectedNullValue(serviceRef, "serviceInterface");
    }
    // ELEMENT: serviceRefType
    final String serviceRefTypeRaw = serviceRef.serviceRefType;
    String serviceRefType = null;
    try {
        serviceRefType = Adapters.collapsedStringAdapterAdapter.marshal(serviceRefTypeRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(serviceRef, "serviceRefType", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (serviceRefType != null) {
        writer.writeStartElement(prefix, "service-ref-type", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(serviceRefType);
        writer.writeEndElement();
    }
    // ELEMENT: wsdlFile
    final String wsdlFileRaw = serviceRef.wsdlFile;
    String wsdlFile = null;
    try {
        wsdlFile = Adapters.collapsedStringAdapterAdapter.marshal(wsdlFileRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(serviceRef, "wsdlFile", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (wsdlFile != null) {
        writer.writeStartElement(prefix, "wsdl-file", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(wsdlFile);
        writer.writeEndElement();
    }
    // ELEMENT: jaxrpcMappingFile
    final String jaxrpcMappingFileRaw = serviceRef.jaxrpcMappingFile;
    String jaxrpcMappingFile = null;
    try {
        jaxrpcMappingFile = Adapters.collapsedStringAdapterAdapter.marshal(jaxrpcMappingFileRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(serviceRef, "jaxrpcMappingFile", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (jaxrpcMappingFile != null) {
        writer.writeStartElement(prefix, "jaxrpc-mapping-file", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(jaxrpcMappingFile);
        writer.writeEndElement();
    }
    // ELEMENT: serviceQname
    final QName serviceQname = serviceRef.serviceQname;
    if (serviceQname != null) {
        writer.writeStartElement(prefix, "service-qname", "http://java.sun.com/xml/ns/javaee");
        writer.writeQName(serviceQname);
        writer.writeEndElement();
    }
    // ELEMENT: portComponentRef
    final List<PortComponentRef> portComponentRef = serviceRef.portComponentRef;
    if (portComponentRef != null) {
        for (final PortComponentRef portComponentRefItem : portComponentRef) {
            if (portComponentRefItem != null) {
                writer.writeStartElement(prefix, "port-component-ref", "http://java.sun.com/xml/ns/javaee");
                writePortComponentRef(writer, portComponentRefItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(serviceRef, "portComponentRef");
            }
        }
    }
    // ELEMENT: handler
    final List<Handler> handler = serviceRef.handler;
    if (handler != null) {
        for (final Handler handlerItem : handler) {
            if (handlerItem != null) {
                writer.writeStartElement(prefix, "handler", "http://java.sun.com/xml/ns/javaee");
                writeHandler(writer, handlerItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(serviceRef, "handler");
            }
        }
    }
    // ELEMENT: handlerChains
    final HandlerChains handlerChains = serviceRef.handlerChains;
    if (handlerChains != null) {
        writer.writeStartElement(prefix, "handler-chains", "http://java.sun.com/xml/ns/javaee");
        writeHandlerChains(writer, handlerChains, context);
        writer.writeEndElement();
    }
    // ELEMENT: mappedName
    final String mappedNameRaw = serviceRef.mappedName;
    String mappedName = null;
    try {
        mappedName = Adapters.collapsedStringAdapterAdapter.marshal(mappedNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(serviceRef, "mappedName", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (mappedName != null) {
        writer.writeStartElement(prefix, "mapped-name", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(mappedName);
        writer.writeEndElement();
    }
    // ELEMENT: injectionTarget
    final Set<InjectionTarget> injectionTarget = serviceRef.injectionTarget;
    if (injectionTarget != null) {
        for (final InjectionTarget injectionTargetItem : injectionTarget) {
            if (injectionTargetItem != null) {
                writer.writeStartElement(prefix, "injection-target", "http://java.sun.com/xml/ns/javaee");
                writeInjectionTarget(writer, injectionTargetItem, context);
                writer.writeEndElement();
            } else {
                context.unexpectedNullValue(serviceRef, "injectionTarget");
            }
        }
    }
    // ELEMENT: lookupName
    final String lookupNameRaw = serviceRef.lookupName;
    String lookupName = null;
    try {
        lookupName = Adapters.collapsedStringAdapterAdapter.marshal(lookupNameRaw);
    } catch (final Exception e) {
        context.xmlAdapterError(serviceRef, "lookupName", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (lookupName != null) {
        writer.writeStartElement(prefix, "lookup-name", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters(lookupName);
        writer.writeEndElement();
    }
    context.afterMarshal(serviceRef, LifecycleCallback.NONE);
}
Also used : CollapsedStringAdapter(javax.xml.bind.annotation.adapters.CollapsedStringAdapter) QName(javax.xml.namespace.QName) Handler$JAXB.readHandler(org.apache.openejb.jee.Handler$JAXB.readHandler) Handler$JAXB.writeHandler(org.apache.openejb.jee.Handler$JAXB.writeHandler) Text$JAXB.readText(org.apache.openejb.jee.Text$JAXB.readText) Text$JAXB.writeText(org.apache.openejb.jee.Text$JAXB.writeText) HandlerChains$JAXB.readHandlerChains(org.apache.openejb.jee.HandlerChains$JAXB.readHandlerChains) HandlerChains$JAXB.writeHandlerChains(org.apache.openejb.jee.HandlerChains$JAXB.writeHandlerChains) PortComponentRef$JAXB.readPortComponentRef(org.apache.openejb.jee.PortComponentRef$JAXB.readPortComponentRef) PortComponentRef$JAXB.writePortComponentRef(org.apache.openejb.jee.PortComponentRef$JAXB.writePortComponentRef) InjectionTarget$JAXB.readInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.readInjectionTarget) InjectionTarget$JAXB.writeInjectionTarget(org.apache.openejb.jee.InjectionTarget$JAXB.writeInjectionTarget) Icon$JAXB.readIcon(org.apache.openejb.jee.Icon$JAXB.readIcon) Icon$JAXB.writeIcon(org.apache.openejb.jee.Icon$JAXB.writeIcon) RuntimeContext(org.metatype.sxc.jaxb.RuntimeContext)

Example 8 with HandlerChains$JAXB.readHandlerChains

use of org.apache.openejb.jee.HandlerChains$JAXB.readHandlerChains in project tomee by apache.

the class HandlerResolverImplTest method testBindingMatching.

public void testBindingMatching() throws Exception {
    final HandlerChains handlerChains = readHandlerChains("/handlers_bindings.xml");
    assertEquals(3, handlerChains.getHandlerChain().size());
    final List<HandlerChainInfo> handlerChainInfos = ConfigurationFactory.toHandlerChainInfo(handlerChains);
    final List<HandlerChainData> handlerChainDatas = WsBuilder.toHandlerChainData(handlerChainInfos, getClass().getClassLoader());
    final HandlerResolverImpl resolver = new HandlerResolverImpl(handlerChainDatas, null, new InitialContext());
    List<Handler> handlers = null;
    handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null));
    assertEquals(0, handlers.size());
    handlers = resolver.getHandlerChain(new TestPortInfo("##SOAP12_HTTP", null, null));
    assertEquals(0, handlers.size());
    handlers = resolver.getHandlerChain(new TestPortInfo("##SOAP11_HTTP", null, null));
    assertEquals(2, handlers.size());
    handlers = resolver.getHandlerChain(new TestPortInfo("##SOAP11_HTTP_MTOM", null, null));
    assertEquals(1, handlers.size());
}
Also used : HandlerChainInfo(org.apache.openejb.assembler.classic.HandlerChainInfo) Handler(javax.xml.ws.handler.Handler) HandlerChains(org.apache.openejb.jee.HandlerChains) InitialContext(javax.naming.InitialContext)

Example 9 with HandlerChains$JAXB.readHandlerChains

use of org.apache.openejb.jee.HandlerChains$JAXB.readHandlerChains in project tomee by apache.

the class HandlerResolverImplTest method testMixedMatching.

public void testMixedMatching() throws Exception {
    final HandlerChains handlerChains = readHandlerChains("/handlers_mixed.xml");
    assertEquals(3, handlerChains.getHandlerChain().size());
    final List<HandlerChainInfo> handlerChainInfos = ConfigurationFactory.toHandlerChainInfo(handlerChains);
    final List<HandlerChainData> handlerChainDatas = WsBuilder.toHandlerChainData(handlerChainInfos, getClass().getClassLoader());
    final HandlerResolverImpl resolver = new HandlerResolverImpl(handlerChainDatas, null, new InitialContext());
    List<Handler> handlers = null;
    handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null));
    assertEquals(0, handlers.size());
    final QName serviceName1 = new QName("http://java.sun.com/xml/ns/javaee", "Bar");
    final QName portName1 = new QName("http://java.sun.com/xml/ns/javaee", "FooBar");
    final String binding1 = "##XML_HTTP";
    handlers = resolver.getHandlerChain(new TestPortInfo(binding1, portName1, serviceName1));
    assertEquals(3, handlers.size());
    final String binding2 = "##SOAP11_HTTP";
    handlers = resolver.getHandlerChain(new TestPortInfo(binding2, portName1, serviceName1));
    assertEquals(2, handlers.size());
    final QName serviceName2 = new QName("http://java.sun.com/xml/ns/javaee", "Baaz");
    final QName portName2 = new QName("http://java.sun.com/xml/ns/javaee", "Baaz");
    handlers = resolver.getHandlerChain(new TestPortInfo(binding1, portName2, serviceName2));
    assertEquals(1, handlers.size());
}
Also used : HandlerChainInfo(org.apache.openejb.assembler.classic.HandlerChainInfo) QName(javax.xml.namespace.QName) Handler(javax.xml.ws.handler.Handler) HandlerChains(org.apache.openejb.jee.HandlerChains) InitialContext(javax.naming.InitialContext)

Example 10 with HandlerChains$JAXB.readHandlerChains

use of org.apache.openejb.jee.HandlerChains$JAXB.readHandlerChains in project tomee by apache.

the class HandlerResolverImplTest method testPortMatching.

public void testPortMatching() throws Exception {
    final HandlerChains handlerChains = readHandlerChains("/handlers_port.xml");
    assertEquals(3, handlerChains.getHandlerChain().size());
    final List<HandlerChainInfo> handlerChainInfos = ConfigurationFactory.toHandlerChainInfo(handlerChains);
    final List<HandlerChainData> handlerChainDatas = WsBuilder.toHandlerChainData(handlerChainInfos, getClass().getClassLoader());
    final HandlerResolverImpl resolver = new HandlerResolverImpl(handlerChainDatas, null, new InitialContext());
    List<Handler> handlers = null;
    handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null));
    assertEquals(0, handlers.size());
    final QName portName1 = new QName("http://java.sun.com/xml/ns/javaee", "Bar");
    handlers = resolver.getHandlerChain(new TestPortInfo(null, portName1, null));
    assertEquals(1, handlers.size());
    final QName portName2 = new QName("http://java.sun.com/xml/ns/javaee", "Foo");
    handlers = resolver.getHandlerChain(new TestPortInfo(null, portName2, null));
    assertEquals(2, handlers.size());
    final QName portName3 = new QName("http://java.sun.com/xml/ns/javaee", "FooBar");
    handlers = resolver.getHandlerChain(new TestPortInfo(null, portName3, null));
    assertEquals(1, handlers.size());
    final QName portName4 = new QName("http://java.sun.com/xml/ns/javaee", "BarFoo");
    handlers = resolver.getHandlerChain(new TestPortInfo(null, portName4, null));
    assertEquals(0, handlers.size());
}
Also used : HandlerChainInfo(org.apache.openejb.assembler.classic.HandlerChainInfo) QName(javax.xml.namespace.QName) Handler(javax.xml.ws.handler.Handler) HandlerChains(org.apache.openejb.jee.HandlerChains) InitialContext(javax.naming.InitialContext)

Aggregations

QName (javax.xml.namespace.QName)9 HandlerChains (org.apache.openejb.jee.HandlerChains)9 InitialContext (javax.naming.InitialContext)5 Handler (javax.xml.ws.handler.Handler)5 HandlerChainInfo (org.apache.openejb.assembler.classic.HandlerChainInfo)5 CollapsedStringAdapter (javax.xml.bind.annotation.adapters.CollapsedStringAdapter)4 Handler$JAXB.readHandler (org.apache.openejb.jee.Handler$JAXB.readHandler)4 Handler$JAXB.writeHandler (org.apache.openejb.jee.Handler$JAXB.writeHandler)4 HandlerChains$JAXB.readHandlerChains (org.apache.openejb.jee.HandlerChains$JAXB.readHandlerChains)4 HandlerChains$JAXB.writeHandlerChains (org.apache.openejb.jee.HandlerChains$JAXB.writeHandlerChains)4 Icon$JAXB.readIcon (org.apache.openejb.jee.Icon$JAXB.readIcon)4 Icon$JAXB.writeIcon (org.apache.openejb.jee.Icon$JAXB.writeIcon)4 RuntimeContext (org.metatype.sxc.jaxb.RuntimeContext)4 OpenEJBException (org.apache.openejb.OpenEJBException)3 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 TreeMap (java.util.TreeMap)2 Definition (javax.wsdl.Definition)2 Addressing$JAXB.readAddressing (org.apache.openejb.jee.Addressing$JAXB.readAddressing)2 Addressing$JAXB.writeAddressing (org.apache.openejb.jee.Addressing$JAXB.writeAddressing)2