Java Code Examples for org.apache.cxf.binding.BindingFactoryManager#getBindingFactory()

The following examples show how to use org.apache.cxf.binding.BindingFactoryManager#getBindingFactory() . 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: CorbaHandlerUtilsTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {

    bus = BusFactory.getDefaultBus();
    BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
    factory = bfm.getBindingFactory("http://cxf.apache.org/bindings/corba");
    bfm.registerBindingFactory(CorbaConstants.NU_WSDL_CORBA, factory);

    java.util.Properties props = System.getProperties();


    props.put("yoko.orb.id", "CXF-CORBA-Server-Binding");
    orb = ORB.init(new String[0], props);

    CorbaDestination destination = getDestination();
    service = destination.getBindingInfo().getService();
    List<TypeMappingType> corbaTypes
        = service.getDescription().getExtensors(TypeMappingType.class);
    typeMap = CorbaUtils.createCorbaTypeMap(corbaTypes);
}
 
Example 2
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 3
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 4
Source File: SpringBusFactoryTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void checkBindingExtensions(Bus bus) throws BusException {
    BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
    assertNotNull("No binding factory manager", bfm);
    assertNotNull("binding factory not available",
                  bfm.getBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/"));
    try {
        bfm.getBindingFactory("http://cxf.apache.org/unknown");
    } catch (BusException ex) {
        // expected
    }
}
 
Example 5
Source File: AbstractJAXRSFactoryBean.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void checkBindingFactory(Bus bus) {
    BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
    try {
        bfm.getBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID);
    } catch (Throwable b) {
        //not registered, let's register one
        bfm.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID,
                                   new JAXRSBindingFactory(bus));
    }
}
 
Example 6
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 7
Source File: TestUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
public TestUtils() {
    bus = BusFactory.getDefaultBus();
    BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
    try {
        factory = (CorbaBindingFactory)bfm.getBindingFactory(
                   "http://cxf.apache.org/bindings/corba");
        bfm.registerBindingFactory(CorbaConstants.NU_WSDL_CORBA, factory);
    } catch (BusException ex) {
        ex.printStackTrace();
    }
}
 
Example 8
Source File: CorbaBindingFactoryTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    bus = BusFactory.getDefaultBus();
    BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
    factory = (CorbaBindingFactory)bfm.getBindingFactory("http://cxf.apache.org/bindings/corba");
    bfm.registerBindingFactory(CorbaConstants.NU_WSDL_CORBA, factory);
}
 
Example 9
Source File: ReflectionServiceFactoryBean.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void createEndpoints() {
    Service service = getService();

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

    for (ServiceInfo inf : service.getServiceInfos()) {
        for (EndpointInfo ei : inf.getEndpoints()) {

            for (BindingOperationInfo boi : ei.getBinding().getOperations()) {
                updateBindingOperation(boi);
            }
            try {
                bfm.getBindingFactory(ei.getBinding().getBindingId());
            } catch (BusException e1) {
                continue;
            }

            try {
                Endpoint ep = createEndpoint(ei);

                service.getEndpoints().put(ei.getName(), ep);
            } catch (EndpointException e) {
                throw new ServiceConstructionException(e);
            }
        }
    }
}
 
Example 10
Source File: SpringBusFactoryTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefault() {
    Bus bus = new SpringBusFactory().createBus();
    assertNotNull(bus);
    BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
    assertNotNull("No binding factory manager", bfm);
    assertNotNull("No configurer", bus.getExtension(Configurer.class));
    assertNotNull("No resource manager", bus.getExtension(ResourceManager.class));
    assertNotNull("No destination factory manager", bus.getExtension(DestinationFactoryManager.class));
    assertNotNull("No conduit initiator manager", bus.getExtension(ConduitInitiatorManager.class));
    assertNotNull("No phase manager", bus.getExtension(PhaseManager.class));
    assertNotNull("No workqueue manager", bus.getExtension(WorkQueueManager.class));
    assertNotNull("No lifecycle manager", bus.getExtension(BusLifeCycleManager.class));
    assertNotNull("No service registry", bus.getExtension(ServerRegistry.class));

    try {
        bfm.getBindingFactory("http://cxf.apache.org/unknown");
    } catch (BusException ex) {
        // expected
    }

    assertEquals("Unexpected interceptors", 0, bus.getInInterceptors().size());
    assertEquals("Unexpected interceptors", 0, bus.getInFaultInterceptors().size());
    assertEquals("Unexpected interceptors", 0, bus.getOutInterceptors().size());
    assertEquals("Unexpected interceptors", 0, bus.getOutFaultInterceptors().size());

}
 
Example 11
Source File: CorbaBindingFactoryConfigurerTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testOrbConfiguration() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL cxfConfig = null;

    cxfConfig = ClassLoaderUtils.getResource("corba_binding_factory_configurer.xml", this.getClass());

    bus = bf.createBus(cxfConfig);
    BusFactory.setDefaultBus(bus);

    BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
    CorbaBindingFactory factory =
        (CorbaBindingFactory)bfm.getBindingFactory("http://cxf.apache.org/bindings/corba");
    OrbConfig orbConfig = factory.getOrbConfig();
    assertNotNull("CorbaBindingFactoryConfigurer is null", orbConfig);
    Properties props = orbConfig.getOrbProperties();
    assertNotNull("probs is null", props);
    assertTrue("prob1 is not equal to value1",
            "value1".equals(props.get("prop1")));
    assertTrue("prob2 is not equal to value2",
            "value2".equals(props.get("prop2")));
    assertTrue("ORBClass is not equal to MyORBImpl",
            "com.orbimplco.MyORBImpl".equals(props.get("org.omg.CORBA.ORBClass")));
    assertTrue("ORBSingletonClass is not equal to MyORBSingleton",
            "com.orbimplco.MyORBSingleton".equals(props.get("org.omg.CORBA.ORBSingletonClass")));
    List <String> orbArgs = orbConfig.getOrbArgs();
    assertNotNull("orbArgs is null", orbArgs);
    String domainNameId = orbArgs.get(0);
    assertTrue("domainNameId is not equal to -ORBdomain_name",
            "-ORBdomain_name".equals(domainNameId));
    String domainNameValue = orbArgs.get(1);
    assertTrue("domainNameValue is not equal to test-domain",
            "test-domain".equals(domainNameValue));
    String configDomainsDirId = orbArgs.get(2);
    assertTrue("configDomainsDirId is not equal to -ORBconfig_domains_dir",
            "-ORBconfig_domains_dir".equals(configDomainsDirId));
    String configDomainsDirValue = orbArgs.get(3);
    assertTrue("configDomainsDirValue is not equal to src/test/resources",
            "src/test/resources".equals(configDomainsDirValue));
    String orbNameId = orbArgs.get(4);
    assertTrue("orbNameId is not equal to -ORBname",
            "-ORBname".equals(orbNameId));
    String orbNameValue = orbArgs.get(5);
    assertTrue("orbNameValue is not equal to test",
            "test".equals(orbNameValue));
}
 
Example 12
Source File: AbstractWSDLBasedEndpointFactory.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected BindingInfo createBindingInfo() {
    BindingFactoryManager mgr = bus.getExtension(BindingFactoryManager.class);
    String binding = bindingId;

    if (binding == null && bindingConfig != null) {
        binding = bindingConfig.getBindingId();
    }

    if (binding == null) {
        // default to soap binding
        binding = "http://schemas.xmlsoap.org/soap/";
    }

    try {
        if (binding.contains("/soap")) {
            if (bindingConfig == null) {
                bindingConfig = createSoapBindingConfig();
            }
            if (bindingConfig instanceof SoapBindingConfiguration
                && !((SoapBindingConfiguration)bindingConfig).isSetStyle()) {
                ((SoapBindingConfiguration)bindingConfig).setStyle(serviceFactory.getStyle());
            }
        }

        bindingFactory = mgr.getBindingFactory(binding);

        BindingInfo inf = bindingFactory.createBindingInfo(serviceFactory.getService(),
                                                binding, bindingConfig);

        for (BindingOperationInfo boi : inf.getOperations()) {
            serviceFactory.updateBindingOperation(boi);
            Method m = serviceFactory.getMethodDispatcher().getMethod(boi);
            serviceFactory.sendEvent(FactoryBeanListener.Event.BINDING_OPERATION_CREATED, inf, boi, m);
        }
        serviceFactory.sendEvent(FactoryBeanListener.Event.BINDING_CREATED, inf);
        return inf;
    } catch (BusException ex) {
        throw new ServiceConstructionException(
               new Message("COULD.NOT.RESOLVE.BINDING", LOG, bindingId), ex);
    }
}