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());
}
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;
}
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);
}
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);
}
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);
}
}
Aggregations