當前位置: 首頁>>代碼示例>>Java>>正文


Java JAXRSServerFactoryBean.setExtensionMappings方法代碼示例

本文整理匯總了Java中org.apache.cxf.jaxrs.JAXRSServerFactoryBean.setExtensionMappings方法的典型用法代碼示例。如果您正苦於以下問題:Java JAXRSServerFactoryBean.setExtensionMappings方法的具體用法?Java JAXRSServerFactoryBean.setExtensionMappings怎麽用?Java JAXRSServerFactoryBean.setExtensionMappings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.cxf.jaxrs.JAXRSServerFactoryBean的用法示例。


在下文中一共展示了JAXRSServerFactoryBean.setExtensionMappings方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: rsServer

import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
@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();
}
 
開發者ID:jotorren,項目名稱:microservices-transactions-tcc,代碼行數:28,代碼來源:WebServicesConfiguration.java

示例2: ControlCenterServer

import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
protected ControlCenterServer() throws Exception {
    ControlCenterApp application = new ControlCenterApp();
    RuntimeDelegate delegate = RuntimeDelegate.getInstance();

    Map<Object, Object> mappings = new HashMap<Object, Object>();
    mappings.put("json", "application/json");
    mappings.put("xml", "application/xml");
    
    JAXRSServerFactoryBean bean = delegate.createEndpoint(application, JAXRSServerFactoryBean.class);
    bean.setAddress("http://localhost:9000/services" + bean.getAddress());
    bean.setExtensionMappings(mappings);
    server = bean.create();
    server.start();
}
 
開發者ID:hzbarcea,項目名稱:activemq-samples,代碼行數:15,代碼來源:ControlCenterServer.java

示例3: publishService

import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
/**
	 * 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();
	}
 
開發者ID:kuali,項目名稱:kc-rice,代碼行數:56,代碼來源:RESTServiceExporter.java


注:本文中的org.apache.cxf.jaxrs.JAXRSServerFactoryBean.setExtensionMappings方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。