Search in sources :

Example 1 with HandlerChainInfo

use of org.apache.openejb.assembler.classic.HandlerChainInfo in project tomee by apache.

the class HandlerResolverImplTest method testBasic.

public void testBasic() throws Exception {
    final HandlerChains handlerChains = readHandlerChains("/handlers.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(3, 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 2 with HandlerChainInfo

use of org.apache.openejb.assembler.classic.HandlerChainInfo in project tomee by apache.

the class HandlerResolverImplTest method testServiceMatching.

public void testServiceMatching() throws Exception {
    final HandlerChains handlerChains = readHandlerChains("/handlers_service.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");
    handlers = resolver.getHandlerChain(new TestPortInfo(null, null, serviceName1));
    assertEquals(1, handlers.size());
    final QName serviceName2 = new QName("http://java.sun.com/xml/ns/javaee", "Foo");
    handlers = resolver.getHandlerChain(new TestPortInfo(null, null, serviceName2));
    assertEquals(2, handlers.size());
    final QName serviceName3 = new QName("http://java.sun.com/xml/ns/javaee", "FooBar");
    handlers = resolver.getHandlerChain(new TestPortInfo(null, null, serviceName3));
    assertEquals(1, handlers.size());
    final QName serviceName4 = new QName("http://java.sun.com/xml/ns/javaee", "BarFoo");
    handlers = resolver.getHandlerChain(new TestPortInfo(null, null, serviceName4));
    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)

Example 3 with HandlerChainInfo

use of org.apache.openejb.assembler.classic.HandlerChainInfo in project tomee by apache.

the class AppInfoBuilder method configureWebservices.

private List<PortInfo> configureWebservices(final Webservices webservices) {
    final List<PortInfo> portMap = new ArrayList<>();
    if (webservices == null) {
        return portMap;
    }
    for (final WebserviceDescription desc : webservices.getWebserviceDescription()) {
        final String wsdlFile = desc.getWsdlFile();
        final String serviceName = desc.getWebserviceDescriptionName();
        for (final PortComponent port : desc.getPortComponent()) {
            final PortInfo portInfo = new PortInfo();
            final ServiceImplBean serviceImplBean = port.getServiceImplBean();
            portInfo.serviceId = desc.getId();
            portInfo.portId = port.getId();
            portInfo.serviceLink = serviceImplBean.getEjbLink();
            if (portInfo.serviceLink == null) {
                portInfo.serviceLink = serviceImplBean.getServletLink();
            }
            portInfo.seiInterfaceName = port.getServiceEndpointInterface();
            portInfo.portName = port.getPortComponentName();
            portInfo.binding = port.getProtocolBinding();
            portInfo.serviceName = serviceName;
            portInfo.wsdlFile = wsdlFile;
            portInfo.mtomEnabled = port.isEnableMtom();
            portInfo.wsdlPort = port.getWsdlPort();
            portInfo.wsdlService = port.getWsdlService();
            portInfo.location = port.getLocation();
            final List<HandlerChainInfo> handlerChains = ConfigurationFactory.toHandlerChainInfo(port.getHandlerChains());
            portInfo.handlerChains.addAll(handlerChains);
            // todo configure jaxrpc mappings here
            portMap.add(portInfo);
        }
    }
    return portMap;
}
Also used : PortInfo(org.apache.openejb.assembler.classic.PortInfo) PortComponent(org.apache.openejb.jee.PortComponent) ServiceImplBean(org.apache.openejb.jee.ServiceImplBean) HandlerChainInfo(org.apache.openejb.assembler.classic.HandlerChainInfo) WebserviceDescription(org.apache.openejb.jee.WebserviceDescription) ArrayList(java.util.ArrayList)

Example 4 with HandlerChainInfo

use of org.apache.openejb.assembler.classic.HandlerChainInfo in project tomee by apache.

the class ConfigurationFactory method toHandlerChainInfo.

public static List<HandlerChainInfo> toHandlerChainInfo(final HandlerChains chains) {
    final List<HandlerChainInfo> handlerChains = new ArrayList<>();
    if (chains == null) {
        return handlerChains;
    }
    for (final HandlerChain handlerChain : chains.getHandlerChain()) {
        final HandlerChainInfo handlerChainInfo = new HandlerChainInfo();
        handlerChainInfo.serviceNamePattern = handlerChain.getServiceNamePattern();
        handlerChainInfo.portNamePattern = handlerChain.getPortNamePattern();
        handlerChainInfo.protocolBindings.addAll(handlerChain.getProtocolBindings());
        for (final Handler handler : handlerChain.getHandler()) {
            final HandlerInfo handlerInfo = new HandlerInfo();
            handlerInfo.handlerName = handler.getHandlerName();
            handlerInfo.handlerClass = handler.getHandlerClass();
            handlerInfo.soapHeaders.addAll(handler.getSoapHeader());
            handlerInfo.soapRoles.addAll(handler.getSoapRole());
            for (final ParamValue param : handler.getInitParam()) {
                handlerInfo.initParams.setProperty(param.getParamName(), param.getParamValue());
            }
            handlerChainInfo.handlers.add(handlerInfo);
        }
        handlerChains.add(handlerChainInfo);
    }
    return handlerChains;
}
Also used : HandlerChain(org.apache.openejb.jee.HandlerChain) HandlerChainInfo(org.apache.openejb.assembler.classic.HandlerChainInfo) ArrayList(java.util.ArrayList) Handler(org.apache.openejb.jee.Handler) ParamValue(org.apache.openejb.jee.ParamValue) HandlerInfo(org.apache.openejb.assembler.classic.HandlerInfo)

Example 5 with HandlerChainInfo

use of org.apache.openejb.assembler.classic.HandlerChainInfo 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

HandlerChainInfo (org.apache.openejb.assembler.classic.HandlerChainInfo)7 InitialContext (javax.naming.InitialContext)5 Handler (javax.xml.ws.handler.Handler)5 HandlerChains (org.apache.openejb.jee.HandlerChains)5 QName (javax.xml.namespace.QName)3 ArrayList (java.util.ArrayList)2 HandlerInfo (org.apache.openejb.assembler.classic.HandlerInfo)1 PortInfo (org.apache.openejb.assembler.classic.PortInfo)1 Handler (org.apache.openejb.jee.Handler)1 HandlerChain (org.apache.openejb.jee.HandlerChain)1 ParamValue (org.apache.openejb.jee.ParamValue)1 PortComponent (org.apache.openejb.jee.PortComponent)1 ServiceImplBean (org.apache.openejb.jee.ServiceImplBean)1 WebserviceDescription (org.apache.openejb.jee.WebserviceDescription)1