Java Code Examples for org.apache.cxf.jaxrs.JAXRSServerFactoryBean#setExtensionMappings()
The following examples show how to use
org.apache.cxf.jaxrs.JAXRSServerFactoryBean#setExtensionMappings() .
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: AbstractSpringConfigurationFactory.java From cxf with Apache License 2.0 | 6 votes |
protected Server createJaxRsServer() { JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean(); factory.setAddress(getAddress()); factory.setTransportId(getTransportId()); factory.setBus(getBus()); setJaxrsResources(factory); factory.setInInterceptors(getInInterceptors()); factory.setOutInterceptors(getOutInterceptors()); factory.setOutFaultInterceptors(getOutFaultInterceptors()); factory.setFeatures(getFeatures()); if (!StringUtils.isEmpty(jaxrsExtensions)) { factory.setExtensionMappings(CastUtils.cast((Map<?, ?>)parseMapSequence(jaxrsExtensions))); } finalizeFactorySetup(factory); return factory.create(); }
Example 2
Source File: CXFNonSpringJaxrsServlet.java From JaxRSProviders with Apache License 2.0 | 5 votes |
protected void setExtensions(JAXRSServerFactoryBean bean, ServletConfig servletConfig) { bean.setExtensionMappings( CastUtils.cast((Map<?, ?>)parseMapSequence(servletConfig.getInitParameter(EXTENSIONS_PARAM)))); bean.setLanguageMappings( CastUtils.cast((Map<?, ?>)parseMapSequence(servletConfig.getInitParameter(LANGUAGES_PARAM)))); bean.setProperties(CastUtils.cast( parseMapSequence(servletConfig.getInitParameter(PROPERTIES_PARAM)), String.class, Object.class)); }
Example 3
Source File: AbstractSwagger2ServiceDescriptionTest.java From cxf with Apache License 2.0 | 5 votes |
@Override protected void run() { final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStoreSwagger2.class); sf.setResourceClasses(BookStoreStylesheetsSwagger2.class); sf.setResourceProvider(BookStoreSwagger2.class, new SingletonResourceProvider(new BookStoreSwagger2())); sf.setProvider(new JacksonJsonProvider()); final Swagger2Feature feature = createSwagger2Feature(); sf.setFeatures(Arrays.asList(feature)); sf.setAddress("http://localhost:" + port + "/"); sf.setExtensionMappings( Collections.singletonMap("json", "application/json;charset=UTF-8")); sf.create(); }
Example 4
Source File: CXFNonSpringJaxrsServlet.java From cxf with Apache License 2.0 | 5 votes |
protected void setExtensions(JAXRSServerFactoryBean bean, ServletConfig servletConfig) { bean.setExtensionMappings( CastUtils.cast((Map<?, ?>)parseMapSequence(servletConfig.getInitParameter(EXTENSIONS_PARAM)))); bean.setLanguageMappings( CastUtils.cast((Map<?, ?>)parseMapSequence(servletConfig.getInitParameter(LANGUAGES_PARAM)))); Map<String, Object> properties = CastUtils.cast( parseMapSequence(servletConfig.getInitParameter(PROPERTIES_PARAM)), String.class, Object.class); if (properties != null) { bean.getProperties(true).putAll(properties); } }
Example 5
Source File: WebServicesConfiguration.java From microservices-transactions-tcc with Apache License 2.0 | 4 votes |
@Bean public Server rsServer() { JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean(); endpoint.setBus(bus); endpoint.setAddress("/"); endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new ExceptionRestHandler())); Map<Object, Object> mappings = new HashMap<Object, Object>(); mappings.put("json", "application/json"); endpoint.setExtensionMappings(mappings); Swagger2Feature swagger2Feature = new Swagger2Feature(); swagger2Feature.setTitle(title); swagger2Feature.setDescription(description); swagger2Feature.setVersion(version); swagger2Feature.setContact(contact); swagger2Feature.setSchemes(schemes.split(",")); swagger2Feature.setBasePath(basePath); swagger2Feature.setResourcePackage(resourcePackage); swagger2Feature.setPrettyPrint(prettyPrint); swagger2Feature.setScan(scan); endpoint.setFeatures(Arrays.asList(new LoggingFeature(), swagger2Feature)); endpoint.setServiceBeans(Arrays.asList(tccCoordinatorService, compositeController)); return endpoint.create(); }
Example 6
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(); }