Search in sources :

Example 31 with Handler

use of jakarta.xml.ws.handler.Handler 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(jakarta.xml.ws.handler.Handler) HandlerChains(org.apache.openejb.jee.HandlerChains) InitialContext(javax.naming.InitialContext)

Example 32 with Handler

use of jakarta.xml.ws.handler.Handler in project tomee by apache.

the class ClientHandlerResolverImpl method sortHandlers.

/**
 * sorts the handlers into correct order. All of the logical handlers first
 * followed by the protocol handlers
 *
 * @param handlers List
 * @return sorted list of handlers
 */
private List<Handler> sortHandlers(final List<Handler> handlers) {
    final List<LogicalHandler> logicalHandlers = new ArrayList<LogicalHandler>();
    final List<Handler> protocolHandlers = new ArrayList<Handler>();
    for (final Handler handler : handlers) {
        if (handler instanceof LogicalHandler) {
            logicalHandlers.add((LogicalHandler) handler);
        } else {
            protocolHandlers.add(handler);
        }
    }
    final List<Handler> sortedHandlers = new ArrayList<Handler>();
    sortedHandlers.addAll(logicalHandlers);
    sortedHandlers.addAll(protocolHandlers);
    return sortedHandlers;
}
Also used : LogicalHandler(jakarta.xml.ws.handler.LogicalHandler) ArrayList(java.util.ArrayList) Handler(jakarta.xml.ws.handler.Handler) LogicalHandler(jakarta.xml.ws.handler.LogicalHandler)

Example 33 with Handler

use of jakarta.xml.ws.handler.Handler in project tomee by apache.

the class CxfEndpoint method initHandlers.

/**
 * Set appropriate handlers for the port/service/bindings.
 */
protected void initHandlers() throws Exception {
    PortInfoImpl portInfo = new PortInfoImpl(implInfo.getBindingType(), serviceFactory.getEndpointName(), service.getName());
    handlerResolver = new HandlerResolverImpl(port.getHandlerChains(), port.getInjections(), context);
    List<Handler> chain = handlerResolver.getHandlerChain(portInfo);
    getBinding().setHandlerChain(chain);
}
Also used : HandlerResolverImpl(org.apache.openejb.core.webservices.HandlerResolverImpl) Handler(jakarta.xml.ws.handler.Handler) PortInfoImpl(org.apache.cxf.jaxws.handler.PortInfoImpl)

Example 34 with Handler

use of jakarta.xml.ws.handler.Handler in project metro-jax-ws by eclipse-ee4j.

the class WSEndpointImpl method dispose.

@Override
public synchronized void dispose() {
    if (disposed) {
        return;
    }
    disposed = true;
    masterTubeline.preDestroy();
    for (Handler handler : binding.getHandlerChain()) {
        for (Method method : handler.getClass().getMethods()) {
            if (method.getAnnotation(PreDestroy.class) == null) {
                continue;
            }
            try {
                method.invoke(handler);
            } catch (Exception e) {
                logger.log(Level.WARNING, HandlerMessages.HANDLER_PREDESTROY_IGNORE(e.getMessage()), e);
            }
            break;
        }
    }
    closeManagedObjectManager();
    LazyMOMProvider.INSTANCE.unregisterEndpoint(this);
}
Also used : PreDestroy(jakarta.annotation.PreDestroy) Handler(jakarta.xml.ws.handler.Handler) Method(java.lang.reflect.Method) XMLStreamException(javax.xml.stream.XMLStreamException) WebServiceException(jakarta.xml.ws.WebServiceException)

Example 35 with Handler

use of jakarta.xml.ws.handler.Handler in project metro-jax-ws by eclipse-ee4j.

the class BindingTester method testBinding1.

/*
     * test the binding objects for the right number of handlers
     */
public void testBinding1() throws Exception {
    TestService_Service service = getService();
    TestService testStub = getTestStub(service);
    ReportService reportStub = getReportStub(service);
    // get the bindings
    Binding testBinding = ((BindingProvider) testStub).getBinding();
    Binding reportBinding = ((BindingProvider) reportStub).getBinding();
    assertNotNull("Binding object should not be null", testBinding);
    assertNotNull("Binding object should not be null", reportBinding);
    // check the handlers
    List<Handler> testHandlers = testBinding.getHandlerChain();
    List<Handler> reportHandlers = reportBinding.getHandlerChain();
    assertNotNull("Handler list should not be null", testHandlers);
    assertNotNull("Handler list should not be null", reportHandlers);
    // check number of handlers
    assertEquals("got wrong number of handlers in test binding", SERVICE_HANDLERS + TEST_PORT_HANDLERS + PROTOCOL_HANDLERS, testHandlers.size());
    assertEquals("got wrong number of handlers in report binding", SERVICE_HANDLERS + REPORT_PORT_HANDLERS + PROTOCOL_HANDLERS, reportHandlers.size());
    // check handler names -- see config file for order
    int[] testNames = { 4, 0, 5, 1, 7, 3 };
    int[] reportNames = { 4, 0, 2, 6, 7, 3 };
    String foundName = null;
    for (int i = 0; i < testNames.length; i++) {
        foundName = ((HasName) testHandlers.get(i)).getName();
        assertEquals("found unexpected handler in chain", CLIENT_PREFIX + testNames[i], foundName);
    }
    for (int i = 0; i < reportNames.length; i++) {
        foundName = ((HasName) reportHandlers.get(i)).getName();
        assertEquals("found unexpected handler in chain", CLIENT_PREFIX + reportNames[i], foundName);
    }
}
Also used : SOAPBinding(jakarta.xml.ws.soap.SOAPBinding) Binding(jakarta.xml.ws.Binding) BaseSOAPHandler(fromwsdl.handler.common.BaseSOAPHandler) Handler(jakarta.xml.ws.handler.Handler) BindingProvider(jakarta.xml.ws.BindingProvider)

Aggregations

Handler (jakarta.xml.ws.handler.Handler)53 Binding (jakarta.xml.ws.Binding)30 BindingProvider (jakarta.xml.ws.BindingProvider)28 ArrayList (java.util.ArrayList)22 SOAPBinding (jakarta.xml.ws.soap.SOAPBinding)15 SOAPTestHandler (fromwsdl.handler_simple.common.SOAPTestHandler)7 Service (jakarta.xml.ws.Service)7 List (java.util.List)7 WebServiceException (jakarta.xml.ws.WebServiceException)6 HandlerResolver (jakarta.xml.ws.handler.HandlerResolver)6 PortInfo (jakarta.xml.ws.handler.PortInfo)6 SOAPTestHandler (fromwsdl.handler_simple_rpclit.common.SOAPTestHandler)5 InitialContext (javax.naming.InitialContext)5 HandlerChainInfo (org.apache.openejb.assembler.classic.HandlerChainInfo)5 HandlerChains (org.apache.openejb.jee.HandlerChains)5 BaseSOAPHandler (fromwsdl.handler.common.BaseSOAPHandler)4 LogicalHandler (jakarta.xml.ws.handler.LogicalHandler)4 QName (javax.xml.namespace.QName)4 Source (javax.xml.transform.Source)4 HandlerTracker (fromwsdl.handler.common.HandlerTracker)3