Search in sources :

Example 11 with BindingFactory

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

the class AbstractJAXRSFactoryBean method createBindingInfo.

protected BindingInfo createBindingInfo() {
    BindingFactoryManager mgr = getBus().getExtension(BindingFactoryManager.class);
    String binding = getBindingId();
    BindingConfiguration bindingConfig = getBindingConfig();
    if (binding == null && bindingConfig != null) {
        binding = bindingConfig.getBindingId();
    }
    if (binding == null) {
        binding = JAXRSBindingFactory.JAXRS_BINDING_ID;
    }
    try {
        BindingFactory bindingFactory = mgr.getBindingFactory(binding);
        setBindingFactory(bindingFactory);
        BindingInfo bi = bindingFactory.createBindingInfo(serviceFactory.getService(), binding, bindingConfig);
        for (BindingOperationInfo boi : bi.getOperations()) {
            serviceFactory.sendEvent(FactoryBeanListener.Event.BINDING_OPERATION_CREATED, bi, boi, null);
        }
        serviceFactory.sendEvent(FactoryBeanListener.Event.BINDING_CREATED, bi);
        return bi;
    } catch (BusException ex) {
        ex.printStackTrace();
    // do nothing
    }
    return null;
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) BusException(org.apache.cxf.BusException) BindingConfiguration(org.apache.cxf.binding.BindingConfiguration) BindingFactory(org.apache.cxf.binding.BindingFactory)

Example 12 with BindingFactory

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

the class STSUtils method createSTSEndpoint.

// CHECKSTYLE:OFF
private static Endpoint createSTSEndpoint(Bus bus, String namespace, String transportId, String location, String soapVersion, Policy policy, QName epName, boolean sc) throws BusException, EndpointException {
    // CHECKSTYLE:ON
    String ns = namespace + "/wsdl";
    ServiceInfo si = new ServiceInfo();
    QName iName = new QName(ns, sc ? "SecureConversationTokenService" : "SecurityTokenService");
    si.setName(iName);
    InterfaceInfo ii = new InterfaceInfo(si, iName);
    OperationInfo ioi = addIssueOperation(ii, namespace, ns);
    OperationInfo coi = addCancelOperation(ii, namespace, ns);
    OperationInfo roi = addRenewOperation(ii, namespace, ns);
    si.setInterface(ii);
    Service service = new ServiceImpl(si);
    BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
    BindingFactory bindingFactory = bfm.getBindingFactory(soapVersion);
    BindingInfo bi = bindingFactory.createBindingInfo(service, soapVersion, null);
    si.addBinding(bi);
    if (transportId == null) {
        ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
        ConduitInitiator ci = cim.getConduitInitiatorForUri(location);
        transportId = ci.getTransportIds().get(0);
    }
    EndpointInfo ei = new EndpointInfo(si, transportId);
    ei.setBinding(bi);
    ei.setName(epName == null ? iName : epName);
    ei.setAddress(location);
    si.addEndpoint(ei);
    if (policy != null) {
        ei.addExtensor(policy);
    }
    BindingOperationInfo boi = bi.getOperation(ioi);
    SoapOperationInfo soi = boi.getExtensor(SoapOperationInfo.class);
    if (soi == null) {
        soi = new SoapOperationInfo();
        boi.addExtensor(soi);
    }
    soi.setAction(namespace + (sc ? "/RST/SCT" : "/RST/Issue"));
    boi = bi.getOperation(coi);
    soi = boi.getExtensor(SoapOperationInfo.class);
    if (soi == null) {
        soi = new SoapOperationInfo();
        boi.addExtensor(soi);
    }
    soi.setAction(namespace + (sc ? "/RST/SCT/Cancel" : "/RST/Cancel"));
    boi = bi.getOperation(roi);
    soi = boi.getExtensor(SoapOperationInfo.class);
    if (soi == null) {
        soi = new SoapOperationInfo();
        boi.addExtensor(soi);
    }
    soi.setAction(namespace + (sc ? "/RST/SCT/Renew" : "/RST/Renew"));
    service.setDataBinding(new SourceDataBinding());
    return new EndpointImpl(bus, service, ei);
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) QName(javax.xml.namespace.QName) ServiceImpl(org.apache.cxf.service.ServiceImpl) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) Service(org.apache.cxf.service.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) SourceDataBinding(org.apache.cxf.databinding.source.SourceDataBinding) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) ConduitInitiator(org.apache.cxf.transport.ConduitInitiator) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) BindingFactory(org.apache.cxf.binding.BindingFactory)

Example 13 with BindingFactory

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

the class WSDLServiceUtils method getBindingFactory.

public static BindingFactory getBindingFactory(Binding binding, Bus bus, StringBuilder sb) {
    BindingFactory factory = null;
    for (Object obj : binding.getExtensibilityElements()) {
        if (obj instanceof ExtensibilityElement) {
            ExtensibilityElement ext = (ExtensibilityElement) obj;
            sb.delete(0, sb.length());
            sb.append(ext.getElementType().getNamespaceURI());
            try {
                BindingFactoryManager manager = bus.getExtension(BindingFactoryManager.class);
                if (manager != null) {
                    factory = manager.getBindingFactory(sb.toString());
                }
            } catch (BusException e) {
            // ignore, we'll use a generic BindingInfo
            }
            if (factory != null) {
                break;
            }
        }
    }
    return factory;
}
Also used : BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) BusException(org.apache.cxf.BusException) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) BindingFactory(org.apache.cxf.binding.BindingFactory)

Aggregations

BindingFactory (org.apache.cxf.binding.BindingFactory)13 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)9 BusException (org.apache.cxf.BusException)7 AbstractBindingFactory (org.apache.cxf.binding.AbstractBindingFactory)4 QName (javax.xml.namespace.QName)3 Binding (org.apache.cxf.binding.Binding)3 ConfiguredBeanLocator (org.apache.cxf.configuration.ConfiguredBeanLocator)3 Interceptor (org.apache.cxf.interceptor.Interceptor)3 Message (org.apache.cxf.message.Message)3 BindingInfo (org.apache.cxf.service.model.BindingInfo)3 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)3 IMocksControl (org.easymock.IMocksControl)3 Before (org.junit.Before)3 Field (java.lang.reflect.Field)2 Message (org.apache.cxf.common.i18n.Message)2 EndpointImpl (org.apache.cxf.endpoint.EndpointImpl)2 Method (java.lang.reflect.Method)1 Collection (java.util.Collection)1 BindingFault (javax.wsdl.BindingFault)1 BindingOperation (javax.wsdl.BindingOperation)1