Search in sources :

Example 1 with AbstractBindingFactory

use of org.apache.cxf.binding.AbstractBindingFactory in project cxf by apache.

the class BindingFactoryManagerImpl method loadAll.

private BindingFactory loadAll(final String namespace) {
    // Try old method of having activationNamespaces configured in.
    // It activates all the factories in the list until one matches, thus
    // it activates stuff that really aren't needed.
    ConfiguredBeanLocator.BeanLoaderListener<BindingFactory> listener = new ConfiguredBeanLocator.BeanLoaderListener<BindingFactory>() {

        public boolean beanLoaded(String name, BindingFactory bean) {
            loaded.add(name);
            if (!bindingFactories.containsKey(namespace)) {
                if (bean instanceof AbstractBindingFactory) {
                    for (String ns : ((AbstractBindingFactory) bean).getActivationNamespaces()) {
                        registerBindingFactory(ns, bean);
                    }
                } else {
                    try {
                        Method m = bean.getClass().getMethod("getActivationNamespace");
                        Collection<String> c = CastUtils.cast((Collection<?>) m.invoke(bean));
                        for (String s : c) {
                            registerBindingFactory(s, bean);
                        }
                    } catch (Exception ex) {
                    // ignore
                    }
                }
            }
            return bindingFactories.containsKey(namespace);
        }

        public boolean loadBean(String name, Class<? extends BindingFactory> type) {
            return !bindingFactories.containsKey(namespace) && !loaded.contains(name);
        }
    };
    bus.getExtension(ConfiguredBeanLocator.class).loadBeansOfType(BindingFactory.class, listener);
    return bindingFactories.get(namespace);
}
Also used : ConfiguredBeanLocator(org.apache.cxf.configuration.ConfiguredBeanLocator) AbstractBindingFactory(org.apache.cxf.binding.AbstractBindingFactory) Method(java.lang.reflect.Method) BusException(org.apache.cxf.BusException) BindingFactory(org.apache.cxf.binding.BindingFactory) AbstractBindingFactory(org.apache.cxf.binding.AbstractBindingFactory)

Example 2 with AbstractBindingFactory

use of org.apache.cxf.binding.AbstractBindingFactory in project cxf by apache.

the class WSDLServiceBuilder method buildBinding.

public BindingInfo buildBinding(ServiceInfo service, Binding binding) {
    BindingInfo bi = null;
    StringBuilder ns = new StringBuilder(100);
    BindingFactory factory = WSDLServiceUtils.getBindingFactory(binding, bus, ns);
    if (factory instanceof WSDLBindingFactory) {
        WSDLBindingFactory wFactory = (WSDLBindingFactory) factory;
        bi = wFactory.createBindingInfo(service, binding, ns.toString());
        copyExtensors(bi, binding.getExtensibilityElements());
        copyExtensionAttributes(bi, binding);
    }
    if (bi == null) {
        boolean onlyExtensors = false;
        if (factory instanceof AbstractBindingFactory) {
            bi = ((AbstractBindingFactory) factory).createBindingInfo(service, ns.toString(), null);
            onlyExtensors = true;
        } else {
            bi = new BindingInfo(service, ns.toString());
        }
        bi.setName(binding.getQName());
        copyExtensors(bi, binding.getExtensibilityElements());
        copyExtensionAttributes(bi, binding);
        for (BindingOperation bop : cast(binding.getBindingOperations(), BindingOperation.class)) {
            if (LOG.isLoggable(Level.FINER)) {
                LOG.finer("binding operation name is " + bop.getName());
            }
            String inName = null;
            String outName = null;
            if (bop.getBindingInput() != null) {
                inName = bop.getBindingInput().getName();
            }
            if (bop.getBindingOutput() != null) {
                outName = bop.getBindingOutput().getName();
            }
            BindingOperationInfo bop2 = null;
            if (onlyExtensors) {
                bop2 = bi.getOperation(new QName(binding.getQName().getNamespaceURI(), bop.getName()));
            } else {
                bop2 = bi.buildOperation(new QName(binding.getQName().getNamespaceURI(), bop.getName()), inName, outName);
                if (bop2 != null) {
                    bi.addOperation(bop2);
                }
            }
            if (bop2 != null) {
                copyExtensors(bop2, bop.getExtensibilityElements());
                copyExtensionAttributes(bop2, bop);
                if (bop.getBindingInput() != null) {
                    copyExtensors(bop2.getInput(), bop.getBindingInput().getExtensibilityElements());
                    copyExtensionAttributes(bop2.getInput(), bop.getBindingInput());
                    handleHeader(bop2.getInput());
                }
                if (bop.getBindingOutput() != null) {
                    copyExtensors(bop2.getOutput(), bop.getBindingOutput().getExtensibilityElements());
                    copyExtensionAttributes(bop2.getOutput(), bop.getBindingOutput());
                    handleHeader(bop2.getOutput());
                }
                for (BindingFault f : cast(bop.getBindingFaults().values(), BindingFault.class)) {
                    BindingFaultInfo bif = bop2.getFault(new QName(service.getTargetNamespace(), f.getName()));
                    copyExtensors(bif, bop.getBindingFault(f.getName()).getExtensibilityElements());
                    copyExtensionAttributes(bif, bop.getBindingFault(f.getName()));
                }
            }
        }
    }
    service.addBinding(bi);
    DescriptionInfo d = service.getDescription();
    if (null != d) {
        d.getDescribed().add(bi);
    }
    return bi;
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingFault(javax.wsdl.BindingFault) QName(javax.xml.namespace.QName) WSDLBindingFactory(org.apache.cxf.wsdl.binding.WSDLBindingFactory) AbstractBindingFactory(org.apache.cxf.binding.AbstractBindingFactory) BindingOperation(javax.wsdl.BindingOperation) BindingInfo(org.apache.cxf.service.model.BindingInfo) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) WSDLBindingFactory(org.apache.cxf.wsdl.binding.WSDLBindingFactory) AbstractBindingFactory(org.apache.cxf.binding.AbstractBindingFactory) BindingFactory(org.apache.cxf.binding.BindingFactory)

Aggregations

AbstractBindingFactory (org.apache.cxf.binding.AbstractBindingFactory)2 BindingFactory (org.apache.cxf.binding.BindingFactory)2 Method (java.lang.reflect.Method)1 BindingFault (javax.wsdl.BindingFault)1 BindingOperation (javax.wsdl.BindingOperation)1 QName (javax.xml.namespace.QName)1 BusException (org.apache.cxf.BusException)1 ConfiguredBeanLocator (org.apache.cxf.configuration.ConfiguredBeanLocator)1 BindingFaultInfo (org.apache.cxf.service.model.BindingFaultInfo)1 BindingInfo (org.apache.cxf.service.model.BindingInfo)1 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)1 DescriptionInfo (org.apache.cxf.service.model.DescriptionInfo)1 WSDLBindingFactory (org.apache.cxf.wsdl.binding.WSDLBindingFactory)1