Java Code Examples for org.apache.cxf.binding.BindingFactoryManager#registerBindingFactory()
The following examples show how to use
org.apache.cxf.binding.BindingFactoryManager#registerBindingFactory() .
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 |
@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 |
@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: CorbaHandlerUtilsTest.java From cxf with Apache License 2.0 | 6 votes |
@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 4
Source File: AbstractJAXRSFactoryBean.java From cxf with Apache License 2.0 | 5 votes |
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 5
Source File: TestUtils.java From cxf with Apache License 2.0 | 5 votes |
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 6
Source File: CorbaBindingFactoryTest.java From cxf with Apache License 2.0 | 5 votes |
@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 7
Source File: ProtobufferImporterTest.java From fuchsia with Apache License 2.0 | 5 votes |
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 8
Source File: ProtobufferExporterTest.java From fuchsia with Apache License 2.0 | 5 votes |
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 9
Source File: RESTServiceExporter.java From rice with Educational Community License v2.0 | 4 votes |
/** * 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 10
Source File: TestBase.java From cxf with Apache License 2.0 | 4 votes |
@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 11
Source File: SoapBindingFactoryTest.java From cxf with Apache License 2.0 | 4 votes |
private BindingFactoryManager getBindingFactoryManager(String ns, Bus bus) throws BusException { SoapBindingFactory bindingFactory = new SoapBindingFactory(); BindingFactoryManager bfm = new BindingFactoryManagerImpl(); bfm.registerBindingFactory(ns, bindingFactory); return bfm; }