org.apache.cxf.binding.BindingFactory Java Examples

The following examples show how to use org.apache.cxf.binding.BindingFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BareInInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    bus = BusFactory.newInstance().createBus();

    BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);

    IMocksControl control = createNiceControl();
    BindingFactory bf = control.createMock(BindingFactory.class);
    Binding binding = control.createMock(Binding.class);
    expect(bf.createBinding(null)).andStubReturn(binding);
    expect(binding.getInFaultInterceptors())
        .andStubReturn(new ArrayList<Interceptor<? extends Message>>());
    expect(binding.getOutFaultInterceptors())
        .andStubReturn(new ArrayList<Interceptor<? extends Message>>());

    bfm.registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bf);

}
 
Example #2
Source File: DocLiteralInInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    bus = BusFactory.newInstance().createBus();

    BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);

    IMocksControl control = createNiceControl();
    BindingFactory bf = control.createMock(BindingFactory.class);
    Binding binding = control.createMock(Binding.class);
    expect(bf.createBinding(null)).andStubReturn(binding);
    expect(binding.getInFaultInterceptors())
        .andStubReturn(new ArrayList<Interceptor<? extends Message>>());
    expect(binding.getOutFaultInterceptors())
        .andStubReturn(new ArrayList<Interceptor<? extends Message>>());

    bfm.registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bf);
}
 
Example #3
Source File: WSDLServiceUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #4
Source File: BindingFactoryManagerImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
public BindingFactory getBindingFactory(final String namespace) throws BusException {
    BindingFactory factory = bindingFactories.get(namespace);
    if (null == factory) {
        if (!failed.contains(namespace)) {
            factory = loadActivationNamespace(namespace);
            if (factory == null) {
                factory = loadDefaultNamespace(namespace);
            }
            if (factory == null) {
                factory = loadAll(namespace);
            }
        }
        if (factory == null) {
            failed.add(namespace);
            throw new BusException(new Message("NO_BINDING_FACTORY_EXC", BUNDLE, namespace));
        }
    }
    return factory;
}
 
Example #5
Source File: EndpointImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
final void createBinding(BindingInfo bi) throws EndpointException {
    if (null != bi) {
        String namespace = bi.getBindingId();
        BindingFactory bf = null;
        try {
            bf = bus.getExtension(BindingFactoryManager.class).getBindingFactory(namespace);
            if (null == bf) {
                Message msg = new Message("NO_BINDING_FACTORY", BUNDLE, namespace);
                throw new EndpointException(msg);
            }
            binding = bf.createBinding(bi);
        } catch (BusException ex) {
            throw new EndpointException(ex);
        }
    }
}
 
Example #6
Source File: ProtobufServerFactoryBean.java    From fuchsia with Apache License 2.0 6 votes vote down vote up
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 = ProtobufBindingFactory.PROTOBUF_BINDING_ID;
    }

    try {
        BindingFactory bindingFactory = mgr.getBindingFactory(binding);
        setBindingFactory(bindingFactory);
        return bindingFactory.createBindingInfo(serviceFactory.getService(), binding, bindingConfig);
    } catch (BusException ex) {
        log.error("Failed to create CXF bus ",ex);
    }
    return null;
}
 
Example #7
Source File: AbstractJAXRSFactoryBean.java    From cxf with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #8
Source File: ServerImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
public ServerImpl(Bus bus,
                  Endpoint endpoint,
                  DestinationFactory destinationFactory,
                  BindingFactory bindingFactory) throws BusException, IOException {
    this.endpoint = endpoint;
    this.bus = bus;
    this.bindingFactory = bindingFactory;

    initDestination(destinationFactory);
}
 
Example #9
Source File: TestBase.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
    bus = BusFactory.newInstance().createBus();

    BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);

    IMocksControl control = createNiceControl();
    BindingFactory bf = control.createMock(BindingFactory.class);
    Binding binding = control.createMock(Binding.class);
    expect(bf.createBinding(null)).andStubReturn(binding);
    expect(binding.getInFaultInterceptors())
        .andStubReturn(new ArrayList<Interceptor<? extends Message>>());
    expect(binding.getOutFaultInterceptors())
        .andStubReturn(new ArrayList<Interceptor<? extends Message>>());

    bfm.registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bf);

    String ns = "http://apache.org/hello_world_soap_http";
    WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass()
        .getResource("/org/apache/cxf/jaxb/resources/wsdl/hello_world.wsdl").toString(),
                                                        new QName(ns, "SOAPService"));

    service = factory.create();
    endpointInfo = service.getEndpointInfo(new QName(ns, "SoapPort"));
    endpoint = new EndpointImpl(bus, service, endpointInfo);
    JAXBDataBinding db = new JAXBDataBinding();
    db.setContext(JAXBContext.newInstance(new Class[] {
        GreetMe.class,
        GreetMeResponse.class
    }));
    service.setDataBinding(db);

    operation = endpointInfo.getBinding().getOperation(new QName(ns, "greetMe"));
    operation.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(GreetMe.class);
    operation.getOperationInfo().getOutput()
        .getMessagePartByIndex(0).setTypeClass(GreetMeResponse.class);

    message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    message.setExchange(exchange);

    exchange.put(Service.class, service);
    exchange.put(Endpoint.class, endpoint);
    exchange.put(Binding.class, endpoint.getBinding());
}
 
Example #10
Source File: BindingFactoryManagerImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
public void registerBindingFactory(String name,
                                   BindingFactory factory) {
    bindingFactories.put(name, factory);
}
 
Example #11
Source File: AbstractEndpointFactory.java    From cxf with Apache License 2.0 4 votes vote down vote up
public BindingFactory getBindingFactory() {
    return bindingFactory;
}
 
Example #12
Source File: AbstractEndpointFactory.java    From cxf with Apache License 2.0 4 votes vote down vote up
public void setBindingFactory(BindingFactory bf) {
    this.bindingFactory = bf;
}