use of javax.xml.ws.handler.Handler in project cxf by apache.
the class HandlerChainBuilderTest method testBuilderCallsInit.
@Test
public void testBuilderCallsInit() {
List<PortComponentHandlerType> hc = createHandlerChainType();
hc.remove(3);
hc.remove(2);
hc.remove(1);
PortComponentHandlerType h = hc.get(0);
List<ParamValueType> params = h.getInitParam();
ParamValueType p = new ParamValueType();
CString pName = new CString();
pName.setValue("foo");
p.setParamName(pName);
XsdStringType pValue = new XsdStringType();
pValue.setValue("1");
p.setParamValue(pValue);
params.add(p);
p = new ParamValueType();
pName = new CString();
pName.setValue("bar");
p.setParamName(pName);
pValue = new XsdStringType();
pValue.setValue("2");
p.setParamValue(pValue);
params.add(p);
List<Handler> chain = builder.buildHandlerChainFromConfiguration(hc);
assertEquals(1, chain.size());
TestLogicalHandler tlh = (TestLogicalHandler) chain.get(0);
assertTrue(tlh.initCalled);
Map cfg = tlh.config;
assertNotNull(tlh.config);
assertEquals(2, cfg.keySet().size());
assertEquals("1", cfg.get("foo"));
assertEquals("2", cfg.get("bar"));
}
use of javax.xml.ws.handler.Handler in project cxf by apache.
the class JavaxAnnotationHandlerChainBuilderTest method testFindHandlerChainAnnotationPerPortServiceBindingWildcard.
@Test
public void testFindHandlerChainAnnotationPerPortServiceBindingWildcard() {
JavaxHandlerTestImpl handlerTestImpl = new JavaxHandlerTestImpl();
AnnotationHandlerChainBuilder chainBuilder = new AnnotationHandlerChainBuilder();
QName portQName = new QName("http://apache.org/handler_test", "SoapPortWildcard");
QName serviceQName = new QName("http://apache.org/handler_test", "SoapServiceWildcard");
String bindingID = "BindingUnknow";
@SuppressWarnings("rawtypes") List<Handler> handlers = chainBuilder.buildHandlerChainFromClass(handlerTestImpl.getClass(), portQName, serviceQName, bindingID);
assertNotNull(handlers);
assertEquals(7, handlers.size());
}
use of javax.xml.ws.handler.Handler in project cxf by apache.
the class BaseHandlerChainBuilder method build.
protected List<Handler> build(String namespace, Element el, QName portQName, QName serviceQName, String bindingID) {
if (!HANDLER_CHAINS_E.equals(el.getLocalName())) {
String xml = StaxUtils.toString(el);
throw new WebServiceException(BundleUtils.getFormattedString(bundle, "NOT_VALID_ROOT_ELEMENT", namespace.equals(el.getNamespaceURI()), HANDLER_CHAINS_E.equals(el.getLocalName()), xml, handlerFileURL));
}
List<Handler> chain = new ArrayList<>();
Node node = el.getFirstChild();
while (node != null) {
if (node instanceof Element) {
el = (Element) node;
if (!namespace.equals(el.getNamespaceURI())) {
throw new WebServiceException(BundleUtils.getFormattedString(bundle, "NOT_VALID_NAMESPACE", el.getNamespaceURI()));
}
if (!HANDLER_CHAIN_E.equals(el.getLocalName())) {
String xml = StaxUtils.toString(el);
throw new WebServiceException(BundleUtils.getFormattedString(bundle, "NOT_VALID_ELEMENT_IN_HANDLER", xml));
}
processHandlerChainElement(namespace, el, chain, portQName, serviceQName, bindingID);
}
node = node.getNextSibling();
}
return chain;
}
use of javax.xml.ws.handler.Handler in project cxf by apache.
the class HandlerChainBuilder method buildHandlerChain.
protected List<Handler> buildHandlerChain(PortComponentHandlerType ht, ClassLoader classLoader) {
List<Handler> handlerChain = new ArrayList<>();
try {
final boolean fineLog = LOG.isLoggable(Level.FINE);
if (fineLog) {
LOG.log(Level.FINE, "loading handler", trimString(ht.getHandlerName().getValue()));
}
Class<? extends Handler> handlerClass = Class.forName(trimString(ht.getHandlerClass().getValue()), true, classLoader).asSubclass(Handler.class);
Handler<?> handler = handlerClass.newInstance();
if (fineLog) {
LOG.fine("adding handler to chain: " + handler);
}
configureHandler(handler, ht);
handlerChain.add(handler);
} catch (Exception e) {
throw new WebServiceException(BUNDLE.getString("HANDLER_INSTANTIATION_EXC"), e);
}
return handlerChain;
}
use of javax.xml.ws.handler.Handler in project cxf by apache.
the class JaxWsProxyFactoryBean method buildHandlerChain.
private void buildHandlerChain(JaxWsClientProxy cp) {
AnnotationHandlerChainBuilder builder = new AnnotationHandlerChainBuilder();
JaxWsServiceFactoryBean sf = (JaxWsServiceFactoryBean) getServiceFactory();
@SuppressWarnings("rawtypes") List<Handler> chain = new ArrayList<>(handlers);
if (loadHandlers) {
chain.addAll(builder.buildHandlerChainFromClass(sf.getServiceClass(), sf.getEndpointInfo().getName(), sf.getServiceQName(), this.getBindingId()));
}
if (!chain.isEmpty()) {
ResourceManager resourceManager = getBus().getExtension(ResourceManager.class);
List<ResourceResolver> resolvers = resourceManager.getResourceResolvers();
resourceManager = new DefaultResourceManager(resolvers);
resourceManager.addResourceResolver(new WebServiceContextResourceResolver());
ResourceInjector injector = new ResourceInjector(resourceManager);
for (Handler<?> h : chain) {
if (Proxy.isProxyClass(h.getClass()) && getServiceClass() != null) {
injector.inject(h, getServiceClass());
injector.construct(h, getServiceClass());
} else {
injector.inject(h);
injector.construct(h);
}
}
}
cp.getBinding().setHandlerChain(chain);
}
Aggregations