io.tracee.contextlogger.contextprovider.jaxws.TraceeClientHandlerResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of contextprovider-jaxws Show documentation
Show all versions of contextprovider-jaxws Show documentation
Please refer to https://github.com/tracee/contextlogger.
package io.tracee.contextlogger.contextprovider.jaxws;
import java.util.ArrayList;
import java.util.List;
import javax.xml.ws.handler.Handler;
import javax.xml.ws.handler.HandlerResolver;
import javax.xml.ws.handler.PortInfo;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A client handler resolver that provides the {@link TraceeClientErrorLoggingHandler}.
* It allows you to add other handlers via a fluent api.
*/
public class TraceeClientHandlerResolver implements HandlerResolver, TraceeClientHandlerResolverBuilder {
private final Logger logger = LoggerFactory.getLogger(TraceeClientHandlerResolver.class);
private final List handlerList = new ArrayList();
public TraceeClientHandlerResolver() {
// handlerList.add(new ClientHandler();
}
@Override
public final List getHandlerChain(final PortInfo portInfo) {
return handlerList;
}
@Override
public HandlerResolver build() {
this.handlerList.add(new TraceeClientErrorLoggingHandler());
return this;
}
@Override
public TraceeClientHandlerResolverBuilder add(SOAPHandler handler) {
if (handler != null) {
this.handlerList.add(handler);
}
return this;
}
@Override
public TraceeClientHandlerResolverBuilder add(Class extends SOAPHandler> handlerType) {
if (handlerType != null) {
try {
SOAPHandler handler = handlerType.newInstance();
this.handlerList.add(handler);
}
catch (Exception e) {
logger.error("HandlerResolver of type '" + handlerType.getCanonicalName() + "' couldn't be added to HandlerResolver", e);
}
}
return this;
}
/**
* Allows you to build a handler resolver via the fluent api.
*
* @return the client handler resolver builder
*/
public static TraceeClientHandlerResolverBuilder buildHandlerResolver() {
return new TraceeClientHandlerResolver();
}
/**
* Creates a handler resolver that only contains the {@link TraceeClientErrorLoggingHandler}.
*
* @return the client handler resolver builder
*/
public static HandlerResolver createSimpleHandlerResolver() {
return new TraceeClientHandlerResolver().build();
}
}