Search in sources :

Example 11 with BindingFactoryManager

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

the class SpringBusFactoryTest method testDefault.

@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());
}
Also used : Bus(org.apache.cxf.Bus) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) PhaseManager(org.apache.cxf.phase.PhaseManager) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) ServerRegistry(org.apache.cxf.endpoint.ServerRegistry) BusLifeCycleManager(org.apache.cxf.buslifecycle.BusLifeCycleManager) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) ResourceManager(org.apache.cxf.resource.ResourceManager) Configurer(org.apache.cxf.configuration.Configurer) WorkQueueManager(org.apache.cxf.workqueue.WorkQueueManager) BusException(org.apache.cxf.BusException) Test(org.junit.Test)

Example 12 with BindingFactoryManager

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

the class AbstractWSDLBasedEndpointFactory method createBindingInfo.

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);
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Message(org.apache.cxf.common.i18n.Message) SoapBindingConfiguration(org.apache.cxf.binding.soap.SoapBindingConfiguration) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) Method(java.lang.reflect.Method) ServiceConstructionException(org.apache.cxf.service.factory.ServiceConstructionException) BusException(org.apache.cxf.BusException)

Example 13 with BindingFactoryManager

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

the class ReflectionServiceFactoryBean method createEndpoints.

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);
            }
        }
    }
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) EndpointException(org.apache.cxf.endpoint.EndpointException) Service(org.apache.cxf.service.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) ServiceConstructionException(org.apache.cxf.service.factory.ServiceConstructionException) BusException(org.apache.cxf.BusException)

Example 14 with BindingFactoryManager

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

the class SpringBusFactoryTest method checkBindingExtensions.

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
    }
}
Also used : BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) BusException(org.apache.cxf.BusException)

Example 15 with BindingFactoryManager

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

the class CorbaBindingFactoryConfigurerTest method testOrbConfiguration.

@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));
}
Also used : SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) CorbaBindingFactory(org.apache.cxf.binding.corba.CorbaBindingFactory) OrbConfig(org.apache.cxf.binding.corba.utils.OrbConfig) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) Properties(java.util.Properties) URL(java.net.URL) Test(org.junit.Test)

Aggregations

BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)33 Bus (org.apache.cxf.Bus)15 DestinationFactoryManager (org.apache.cxf.transport.DestinationFactoryManager)11 WSDLServiceBuilder (org.apache.cxf.wsdl11.WSDLServiceBuilder)8 Before (org.junit.Before)8 BindingInfo (org.apache.cxf.service.model.BindingInfo)7 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)7 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)7 IMocksControl (org.easymock.IMocksControl)7 Definition (javax.wsdl.Definition)6 BusException (org.apache.cxf.BusException)6 BindingFactory (org.apache.cxf.binding.BindingFactory)6 Test (org.junit.Test)6 Service (javax.wsdl.Service)5 WSDLReader (javax.wsdl.xml.WSDLReader)5 QName (javax.xml.namespace.QName)5 SoapBindingInfo (org.apache.cxf.binding.soap.model.SoapBindingInfo)5 JAXRSBindingFactory (org.apache.cxf.jaxrs.JAXRSBindingFactory)5 JAXRSServerFactoryBean (org.apache.cxf.jaxrs.JAXRSServerFactoryBean)4 WSDLFactory (javax.wsdl.factory.WSDLFactory)3