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


Java JAXRSServerFactoryBean.setResourceProviders方法代碼示例

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


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

示例1: NutchServer

import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
private NutchServer() {
  configManager = new ConfManagerImpl();
  BlockingQueue<Runnable> runnables = Queues.newArrayBlockingQueue(JOB_CAPACITY);
  NutchServerPoolExecutor executor = new NutchServerPoolExecutor(10, JOB_CAPACITY, 1, TimeUnit.HOURS, runnables);
  jobManager = new JobManagerImpl(new JobFactory(), configManager, executor);
  fetchNodeDb = FetchNodeDb.getInstance();

  sf = new JAXRSServerFactoryBean();
  BindingFactoryManager manager = sf.getBus().getExtension(BindingFactoryManager.class);
  JAXRSBindingFactory factory = new JAXRSBindingFactory();
  factory.setBus(sf.getBus());
  manager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID, factory);
  sf.setResourceClasses(getClasses());
  sf.setResourceProviders(getResourceProviders());
  sf.setProvider(new JacksonJaxbJsonProvider());

}
 
開發者ID:jorcox,項目名稱:GeoCrawler,代碼行數:18,代碼來源:NutchServer.java

示例2: jaxRsServer

import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
@Bean
public Server jaxRsServer(){
    List<ResourceProvider> resourceProviders = new LinkedList<ResourceProvider>();
    for (String beanName : ctx.getBeanDefinitionNames()) {
        if (ctx.findAnnotationOnBean(beanName, Path.class) != null) {
            SpringResourceFactory resourceFactory = new SpringResourceFactory(beanName);
            resourceFactory.setApplicationContext(ctx);
            resourceProviders.add(resourceFactory);
        }
    }

    JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
    factory.setBus(ctx.getBean(SpringBus.class));

    JacksonJsonProvider jacksonJsonProvider = new JacksonJsonProvider();
    ObjectMapper objectMapper = new ObjectMapper();
    //set up ISO 8601 date/time stamp format:
    final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:sss'Z'");
    df.setTimeZone(TimeZone.getTimeZone("UTC"));
    objectMapper.setDateFormat(df);
    jacksonJsonProvider.setMapper(objectMapper);

    factory.setProviders(Arrays.asList(jacksonJsonProvider, new DefaultExceptionMapper()));
    factory.setResourceProviders(resourceProviders);

    return factory.create();
}
 
開發者ID:fernandocamargoti,項目名稱:JavaMagazineRESTfulAPI,代碼行數:28,代碼來源:JaxRsServerConfig.java

示例3: initialize

import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
/**
 * Configure Shiro and start the server
 * @throws Exception
 */
@BeforeClass
public static void initialize() throws Exception {

	//
	// Set up roles
	//
	createTestUsersAndRoles();
	
	//
	// This is for unit testing only and uses the test.shiro.ini configuration
	//
	Factory<SecurityManager> factory = new IniSecurityManagerFactory("classpath:test.shiro.ini");
	SecurityManager securityManager = factory.getInstance();
	SecurityUtils.setSecurityManager(securityManager);
	
	//
	// Create an embedded server with JSON processing
	//

	
	//
	// Create an embedded server with JSON processing
	//
	JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
	
	ArrayList<Object> providers = new ArrayList<Object>();
	providers.add(new JacksonJsonProvider());
	//providers.add(new UnrecognizedPropertyExceptionMapper());
	//providers.add(new ValidationExceptionMapper());
	sf.setProviders(providers);
	
	//
	// Add our REST resources to the server
	//
	ArrayList<ResourceProvider> resources = new ArrayList<ResourceProvider>();
	
	//
	// Add our REST resources to the server
	//
	resources.add(new SingletonResourceProvider(new Database(), true));
	
	sf.setResourceProviders(resources);
	
	//
	// Start the server at the endpoint
	//
	sf.setAddress(ENDPOINT_ADDRESS);
	server = sf.create(); 
	databases = new ArrayList<DatabaseReference>();
	startServer();
}
 
開發者ID:ox-it,項目名稱:ords-database-api,代碼行數:56,代碼來源:AbstractResourceTest.java


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