org.apache.cxf.binding.BindingFactoryManager Java Examples

The following examples show how to use org.apache.cxf.binding.BindingFactoryManager. 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: ConfiguredEndpointTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void initializeBus() {
    Bus bus = BusFactory.getDefaultBus();

    SoapBindingFactory bindingFactory = new SoapBindingFactory();

    bus.getExtension(BindingFactoryManager.class)
        .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);

    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    SoapTransportFactory soapDF = new SoapTransportFactory();
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/", soapDF);

    LocalTransportFactory localTransport = new LocalTransportFactory();
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
}
 
Example #2
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 #3
Source File: CxfServerBean.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
public static void shutdown() throws Exception {
	logger.warn("shutdown");
	if (restartNum > 0) {
		throw new Exception("Cannot support shutdown again");
	}		
	if (server != null) {
		server.stop();
		server.destroy();
		server = null;
	}
	if (serverFactoryBean != null) {
		serverFactoryBean.getBus().shutdown(true);
		BindingFactoryManager manager = serverFactoryBean.getBus().getExtension(BindingFactoryManager.class);
		manager.unregisterBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID);
		serverFactoryBean = null;
		bindingFactory.getBus().shutdown(true);
		bindingFactory = null;
	}
}
 
Example #4
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 #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: 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 #7
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 #8
Source File: CXFBusImplTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testConstructionWithExtensions() throws BusException {

    IMocksControl control;
    BindingFactoryManager bindingFactoryManager;
    InstrumentationManager instrumentationManager;
    PhaseManager phaseManager;

    control = EasyMock.createNiceControl();

    Map<Class<?>, Object> extensions = new HashMap<>();
    bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    instrumentationManager = control.createMock(InstrumentationManager.class);
    phaseManager = control.createMock(PhaseManager.class);

    extensions.put(BindingFactoryManager.class, bindingFactoryManager);
    extensions.put(InstrumentationManager.class, instrumentationManager);
    extensions.put(PhaseManager.class, phaseManager);

    Bus bus = new ExtensionManagerBus(extensions);

    assertSame(bindingFactoryManager, bus.getExtension(BindingFactoryManager.class));
    assertSame(instrumentationManager, bus.getExtension(InstrumentationManager.class));
    assertSame(phaseManager, bus.getExtension(PhaseManager.class));

}
 
Example #9
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 #10
Source File: CXFBusImplTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testConstructionWithoutExtensions() throws BusException {

    Bus bus = new ExtensionManagerBus();
    assertNotNull(bus.getExtension(BindingFactoryManager.class));
    assertNotNull(bus.getExtension(ConduitInitiatorManager.class));
    assertNotNull(bus.getExtension(DestinationFactoryManager.class));
    assertNotNull(bus.getExtension(PhaseManager.class));
    bus.shutdown(true);
}
 
Example #11
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 #12
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 #13
Source File: BindingFactoryManagerImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Resource
public void setBus(Bus b) {
    bus = b;
    if (null != bus) {
        bus.setExtension(this, BindingFactoryManager.class);
    }
}
 
Example #14
Source File: ServiceWSDLBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void setupWSDL(String wsdlPath, boolean doXsdImports) throws Exception {
    String wsdlUrl = getClass().getResource(wsdlPath).toString();
    LOG.info("the path of wsdl file is " + wsdlUrl);
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    def = wsdlReader.readWSDL(wsdlUrl);

    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
    bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    destinationFactoryManager = control.createMock(DestinationFactoryManager.class);
    destinationFactory = control.createMock(DestinationFactory.class);
    wsdlServiceBuilder = new WSDLServiceBuilder(bus, false);

    for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
        if (serv != null) {
            service = serv;
            break;
        }
    }
    EasyMock.expect(bus.getExtension(WSDLManager.class)).andReturn(new WSDLManagerImpl()).anyTimes();

    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class))
        .andReturn(destinationFactoryManager);

    EasyMock.expect(destinationFactoryManager
                    .getDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/"))
        .andReturn(destinationFactory);

    control.replay();

    serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0);
    ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, serviceInfo);
    builder.setUseSchemaImports(doXsdImports);
    builder.setBaseFileName("HelloWorld");
    newDef = builder.build(new HashMap<String, SchemaInfo>());
}
 
Example #15
Source File: WSDLServiceBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void buildService(QName endpointName) throws Exception {
    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
    bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    destinationFactoryManager = control.createMock(DestinationFactoryManager.class);
    DestinationFactory destinationFactory = control.createMock(DestinationFactory.class);

    WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);

    EasyMock.expect(bus.getExtension(BindingFactoryManager.class))
        .andReturn(bindingFactoryManager).anyTimes();

    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class))
        .andReturn(destinationFactoryManager).atLeastOnce();

    EasyMock.expect(destinationFactoryManager
                    .getDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/"))
        .andReturn(destinationFactory).anyTimes();


    control.replay();
    serviceInfos = wsdlServiceBuilder.buildServices(def, service, endpointName);
    if (!serviceInfos.isEmpty()) {
        serviceInfo = serviceInfos.get(0);
    } else {
        serviceInfo = null;
    }

}
 
Example #16
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 #17
Source File: ProtobufferImporterTest.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
protected void startStandaloneServer(ProtobufferImportDeclarationWrapper pojo) {

        Bus cxfbus = BusFactory.getDefaultBus(true);
        BindingFactoryManager mgr = cxfbus.getExtension(BindingFactoryManager.class);
        mgr.registerBindingFactory(ProtobufBindingFactory.PROTOBUF_BINDING_ID, new ProtobufBindingFactory(cxfbus));
        ProtobufServerFactoryBean serverFactoryBean = new ProtobufServerFactoryBean();
        serverFactoryBean.setAddress(pojo.getAddress());
        serverFactoryBean.setBus(cxfbus);
        serverFactoryBean.setServiceBean(protobufferRemoteService);
        serverFactoryBean.setMessageClass(AddressBookProtos.AddressBookServiceMessage.class);
        Thread.currentThread().setContextClassLoader(Container.class.getClassLoader());
        server = serverFactoryBean.create();

    }
 
Example #18
Source File: ProtobufferExporterTest.java    From fuchsia with Apache License 2.0 5 votes vote down vote up
private AddressBookProtos.AddressBookService connectExportedProtobufAddress(ExportDeclaration declaration) throws EndpointException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, BinderException {
    ProtobufferExportDeclarationWrapper pojo = ProtobufferExportDeclarationWrapper.create(declaration);
    Bus cxfbus = BusFactory.getThreadDefaultBus();
    BindingFactoryManager mgr = cxfbus.getExtension(BindingFactoryManager.class);
    mgr.registerBindingFactory(ProtobufBindingFactory.PROTOBUF_BINDING_ID, new ProtobufBindingFactory(cxfbus));
    Class<?> bufferService = AddressBookProtos.AddressBookService.class;
    Class<?> bufferMessage = AddressBookProtos.AddressBookServiceMessage.class;
    Class<? extends Message> generic = bufferMessage.asSubclass(Message.class);
    RpcChannel channel = new SimpleRpcChannel(pojo.getAddress(), generic);
    Method method = bufferService.getMethod("newStub", RpcChannel.class);
    Object service = method.invoke(bufferService, channel);
    AddressBookProtos.AddressBookService addressBook = (AddressBookProtos.AddressBookService) service;
    return addressBook;
}
 
Example #19
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 #20
Source File: AbstractAegisTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    super.setUpBus();

    SoapBindingFactory bindingFactory = new SoapBindingFactory();
    bindingFactory.setBus(bus);

    bus.getExtension(BindingFactoryManager.class)
        .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);

    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);

    SoapTransportFactory soapDF = new SoapTransportFactory();
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
    dfm.registerDestinationFactory(SoapBindingConstants.SOAP11_BINDING_ID, soapDF);
    dfm.registerDestinationFactory("http://cxf.apache.org/transports/local", soapDF);

    localTransport = new LocalTransportFactory();
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
    dfm.registerDestinationFactory("http://cxf.apache.org/bindings/xformat", localTransport);
    dfm.registerDestinationFactory("http://cxf.apache.org/transports/local", localTransport);

    ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
    extension.registerConduitInitiator(LocalTransportFactory.TRANSPORT_ID, localTransport);
    extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/", localTransport);
    extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", localTransport);
    extension.registerConduitInitiator(SoapBindingConstants.SOAP11_BINDING_ID, localTransport);

    bus.setExtension(new WSDLManagerImpl(), WSDLManager.class);
    //WoodstoxValidationImpl wstxVal = new WoodstoxValidationImpl();



    addNamespace("wsdl", WSDLConstants.NS_WSDL11);
    addNamespace("wsdlsoap", WSDLConstants.NS_SOAP11);
    addNamespace("xsd", WSDLConstants.NS_SCHEMA_XSD);

}
 
Example #21
Source File: Wsdl11AttachmentPolicyProviderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void oneTimeSetUp() throws Exception {

    IMocksControl control = EasyMock.createNiceControl();
    Bus bus = control.createMock(Bus.class);
    WSDLManager manager = new WSDLManagerImpl();
    WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andReturn(dfm).anyTimes();
    EasyMock.expect(dfm.getDestinationFactory(EasyMock.isA(String.class))).andReturn(null).anyTimes();
    BindingFactoryManager bfm = control.createMock(BindingFactoryManager.class);
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bfm).anyTimes();
    EasyMock.expect(bfm.getBindingFactory(EasyMock.isA(String.class))).andReturn(null).anyTimes();
    control.replay();

    int n = 19;
    services = new ServiceInfo[n];
    endpoints = new EndpointInfo[n];
    for (int i = 0; i < n; i++) {
        String resourceName = "/attachment/wsdl11/test" + i + ".wsdl";
        URL url = Wsdl11AttachmentPolicyProviderTest.class.getResource(resourceName);
        try {
            services[i] = builder.buildServices(manager.getDefinition(url.toString())).get(0);
        } catch (WSDLException ex) {
            ex.printStackTrace();
            fail("Failed to build service from resource " + resourceName);
        }
        assertNotNull(services[i]);
        endpoints[i] = services[i].getEndpoints().iterator().next();
        assertNotNull(endpoints[i]);
    }

    control.verify();

}
 
Example #22
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 #23
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 #24
Source File: AbstractSimpleFrontendTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    super.setUpBus();

    Bus bus = getBus();

    SoapBindingFactory bindingFactory = new SoapBindingFactory();

    bus.getExtension(BindingFactoryManager.class)
        .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);

    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    SoapTransportFactory soapTF = new SoapTransportFactory();
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapTF);
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/", soapTF);

    LocalTransportFactory localTransport = new LocalTransportFactory();
    localTransport.getUriPrefixes().add("http");
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);

    ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
    extension.registerConduitInitiator(LocalTransportFactory.TRANSPORT_ID, localTransport);
    extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
    extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", localTransport);

    extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/", soapTF);
}
 
Example #25
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 #26
Source File: AbstractJaxWsTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Before
public void setUpBus() throws Exception {
    super.setUpBus();

    SoapBindingFactory bindingFactory = new SoapBindingFactory();
    bindingFactory.setBus(bus);
    bus.getExtension(BindingFactoryManager.class)
        .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);
    bus.getExtension(BindingFactoryManager.class)
        .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/http", bindingFactory);

    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);

    SoapTransportFactory soapDF = new SoapTransportFactory();
    dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
    dfm.registerDestinationFactory(SoapBindingConstants.SOAP11_BINDING_ID, soapDF);
    dfm.registerDestinationFactory(SoapBindingConstants.SOAP12_BINDING_ID, soapDF);
    dfm.registerDestinationFactory("http://cxf.apache.org/transports/local", soapDF);

    localTransport = new LocalTransportFactory();
    localTransport.setUriPrefixes(new HashSet<>(Arrays.asList("http", "local")));
    dfm.registerDestinationFactory(LocalTransportFactory.TRANSPORT_ID, localTransport);
    dfm.registerDestinationFactory("http://cxf.apache.org/transports/http", localTransport);
    dfm.registerDestinationFactory("http://cxf.apache.org/transports/http/configuration", localTransport);

    ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
    extension.registerConduitInitiator(LocalTransportFactory.TRANSPORT_ID, localTransport);
    extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", localTransport);
    extension.registerConduitInitiator("http://cxf.apache.org/transports/http", localTransport);
    extension.registerConduitInitiator("http://cxf.apache.org/transports/http/configuration",
                                       localTransport);
}
 
Example #27
Source File: JAXBDataBindingTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    jaxbDataBinding = new JAXBDataBinding();
    String wsdlUrl = getClass().getResource(WSDL_PATH).toString();
    LOG.info("the path of wsdl file is " + wsdlUrl);
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    def = wsdlReader.readWSDL(wsdlUrl);


    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
    bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    destinationFactoryManager = control.createMock(DestinationFactoryManager.class);

    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andStubReturn(bindingFactoryManager);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class))
        .andStubReturn(destinationFactoryManager);

    control.replay();

    WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
    for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
        if (serv != null) {
            service = serv;
            break;
        }
    }

    wsdlServiceBuilder.buildServices(def, service);
}
 
Example #28
Source File: ExtensionManagerBus.java    From cxf with Apache License 2.0 4 votes vote down vote up
public ExtensionManagerBus(Map<Class<?>, Object> extensions, Map<String, Object> props,
      ClassLoader extensionClassLoader) {
    this.extensions = extensions == null ? new ConcurrentHashMap<>(16, 0.75f, 4)
            : new ConcurrentHashMap<>(extensions);
    this.missingExtensions = new CopyOnWriteArraySet<>();


    state = BusState.INITIAL;

    BusFactory.possiblySetDefaultBus(this);
    if (null != props) {
        properties.putAll(props);
    }

    Configurer configurer = (Configurer)this.extensions.get(Configurer.class);
    if (null == configurer) {
        configurer = new NullConfigurer();
        this.extensions.put(Configurer.class, configurer);
    }

    id = getBusId(properties);

    ResourceManager resourceManager = new DefaultResourceManager();

    properties.put(BUS_ID_PROPERTY_NAME, BUS_PROPERTY_NAME);
    properties.put(BUS_PROPERTY_NAME, this);
    properties.put(DEFAULT_BUS_ID, this);

    ResourceResolver propertiesResolver = new PropertiesResolver(properties);
    resourceManager.addResourceResolver(propertiesResolver);

    ResourceResolver busResolver = new SinglePropertyResolver(BUS_PROPERTY_NAME, this);
    resourceManager.addResourceResolver(busResolver);
    resourceManager.addResourceResolver(new ObjectTypeResolver(this));

    busResolver = new SinglePropertyResolver(DEFAULT_BUS_ID, this);
    resourceManager.addResourceResolver(busResolver);
    resourceManager.addResourceResolver(new ObjectTypeResolver(this));
    resourceManager.addResourceResolver(new ResourceResolver() {
        public <T> T resolve(String resourceName, Class<T> resourceType) {
            if (extensionManager != null) {
                return extensionManager.getExtension(resourceName, resourceType);
            }
            return null;
        }
        public InputStream getAsStream(String name) {
            return null;
        }
    });

    this.extensions.put(ResourceManager.class, resourceManager);

    extensionManager = new ExtensionManagerImpl(new String[0],
                                                extensionClassLoader,
                                                this.extensions,
                                                resourceManager,
                                                this);

    setState(BusState.INITIAL);

    if (null == this.getExtension(DestinationFactoryManager.class)) {
        new DestinationFactoryManagerImpl(this);
    }

    if (null == this.getExtension(ConduitInitiatorManager.class)) {
        new ConduitInitiatorManagerImpl(this);
    }

    if (null == this.getExtension(BindingFactoryManager.class)) {
        new BindingFactoryManagerImpl(this);
    }
    extensionManager.load(new String[] {ExtensionManagerImpl.BUS_EXTENSION_RESOURCE});
    extensionManager.activateAllByType(ResourceResolver.class);

    this.extensions.put(ExtensionManager.class, extensionManager);
}
 
Example #29
Source File: RESTServiceExporter.java    From rice with Educational Community License v2.0 4 votes vote down vote up
/**
	 * This publishes the cxf service onto the cxf bus.
	 *
	 * @param serviceImpl
	 * @throws Exception
	 */
	@Override
	public void publishService(ServiceDefinition serviceDefinition, Object serviceImpl, String address) {
		RestServiceDefinition restServiceDef = (RestServiceDefinition)serviceDefinition;

		LOG.info("Creating JAXRSService " + restServiceDef.getServiceName());
		JAXRSServerFactoryBean svrFactory = new JAXRSServerFactoryBean();
        svrFactory.setBus(getCXFBus());

        List<Object> resources = restServiceDef.getResources();
        if (resources != null && !resources.isEmpty()) {
        	svrFactory.setServiceBeans(resources);
        } else {
        	try {
        		Class<?> resourceClass = this.getClass().getClassLoader().loadClass(restServiceDef.getResourceClass());
        		svrFactory.setResourceClasses(resourceClass);
        		svrFactory.setResourceProvider(resourceClass, new SingletonResourceProvider(serviceImpl));
        	} catch (ClassNotFoundException e) {
        		throw new RiceRuntimeException("Failed to publish the service because resource class could not be loaded: " + restServiceDef.getResourceClass(), e);
        	}
        }

        svrFactory.setServiceName(restServiceDef.getServiceName());
        svrFactory.setAddress(address);
        svrFactory.setExtensionMappings(restServiceDef.getExtensionMappings());
        svrFactory.setLanguageMappings(restServiceDef.getLanguageMappings());

        List<Object> providers = restServiceDef.getProviders();
        if (providers != null) {
        	svrFactory.setProviders(providers);
        }

        BindingFactoryManager bindingFactoryManager = getCXFBus().getExtension(BindingFactoryManager.class);
        JAXRSBindingFactory bindingFactory = new JAXRSBindingFactory();
        bindingFactory.setBus(getCXFBus());
        bindingFactoryManager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID, bindingFactory);

		//Set logging interceptors
        if (LOG.isDebugEnabled()) {
        	svrFactory.getInInterceptors().add(new LoggingInInterceptor());
        }
//        svrFactory.getInInterceptors().add(new RESTConnector.VerifyingInInterceptor());
        if (LOG.isDebugEnabled()) {
        	svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
        }
//		svrFactory.getOutInterceptors().add(new RESTConnector.SigningOutInterceptor());

        svrFactory.setPublishedEndpointUrl(restServiceDef.getEndpointUrl().toExternalForm());
		svrFactory.create();
	}
 
Example #30
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));
}