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


Java JAXRSServerFactoryBean.setBus方法代碼示例

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


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

示例1: jaxRsServer

import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
@Bean
public Server jaxRsServer() {

  // List<Object> restServiceBeans = new
  // ArrayList<>(this.applicationContext.getBeansOfType(RestService.class).values());
  Collection<Object> restServices = findRestServices();
  if (restServices.isEmpty()) {
    LOG.info("No REST Services have been found. Rest Endpoint will not be enabled in CXF.");
    return null;
  }
  Collection<Object> providers = this.applicationContext.getBeansWithAnnotation(Provider.class).values();

  JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
  factory.setBus(springBus());
  factory.setAddress(URL_FOLDER_REST);
  // factory.set
  factory.setServiceBeans(new ArrayList<>(restServices));
  factory.setProviders(new ArrayList<>(providers));

  return factory.create();
}
 
開發者ID:oasp,項目名稱:oasp-tutorial-sources,代碼行數:22,代碼來源:ServiceConfig.java

示例2: createJaxrsServer

import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
@Override
public JaxrsServer createJaxrsServer(Class<?> serviceInterface, Object serviceImplementation) {
    final String serviceName = namingStrategy.get().serviceName(serviceInterface);
    final Config serverConfig = configService.createServerConfig(serviceInterface, serviceName);
    final String baseAddress = serverConfig.value(BASE_ADDRESS_PROP).orElse(StringUtils.EMPTY);
    final String serverAddress = serverConfig.value(SERVER_ADDRESS_PROP).orElse(namingStrategy.get().serverAddress(serviceInterface));
    final String fullAddress = baseAddress + serverAddress;
    LOGGER.info("Starting {} JAX-RS server ({})...", serviceInterface.getSimpleName(), fullAddress);

    final DefaultJaxrsServiceDescriptor descriptor = new DefaultJaxrsServiceDescriptor(serviceInterface, serviceName);
    decorate(descriptor, serverConfig);
    final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setBus(BusFactory.getDefaultBus(true));
    sf.setServiceBean(serviceImplementation);

    sf.setAddress(fullAddress);
    sf.setFeatures(descriptor.getFeatures());
    sf.setProviders(descriptor.getProviders());
    final Server server = sf.create();
    LOGGER.info("Successfully started {} JAX-RS server ({}).", serviceInterface.getSimpleName(), serverAddress);
    return server::destroy;
}
 
開發者ID:Microbule,項目名稱:microbule,代碼行數:23,代碼來源:DefaultJaxrsServerFactory.java

示例3: serverEndPoint

import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
@Bean
public Server serverEndPoint(final SpringBus bus)
{
	final JacksonJaxbJsonProvider jacksonJaxbJsonProvider = new JacksonJaxbJsonProvider();

	final JMSConfigFeature jmsConfigFeature = createJMSConfigFeature();

	final JAXRSServerFactoryBean svrFactory = new JAXRSServerFactoryBean();
	svrFactory.setBus(bus);
	svrFactory.setResourceClasses(AgentSync.class);

	svrFactory.getFeatures().add(jmsConfigFeature);
	svrFactory.getFeatures().add(loggingFeature);

	svrFactory.setProvider(jacksonJaxbJsonProvider);
	svrFactory.setAddress("/");
	svrFactory.setTransportId("http://cxf.apache.org/transports/jms");

	final Server server = svrFactory.create();
	return server;
}
 
開發者ID:metasfresh,項目名稱:metasfresh-procurement-webui,代碼行數:22,代碼來源:SyncConfiguration.java

示例4: jaxRsServer

import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
@Bean
  @DependsOn("cxf")
  public Server jaxRsServer() {
      JAXRSServerFactoryBean serverFactory = RuntimeDelegate.getInstance().createEndpoint(jaxRsApiApplication(), JAXRSServerFactoryBean.class);
      
      //factory.setServiceBean(new DenialCategoryRest());
      
// get all the class annotated with @JaxrsService
      List<Object> beans = configUtil.findBeans( JaxrsService.class );

if (beans.size() > 0) {
	
	// add all the CXF service classes into the CXF stack
	serverFactory.setServiceBeans( beans );
	serverFactory.setAddress("/"+ serverFactory.getAddress());
	serverFactory.setBus(springBus);
	serverFactory.setStart(true);
	
	// set JSON as the response serializer
	JacksonJsonProvider provider = new JacksonJsonProvider();
	serverFactory.setProvider(provider);
       
}
      
return serverFactory.create();
  }
 
開發者ID:amoldavsky,項目名稱:restful-api-cxf-spring-java,代碼行數:27,代碼來源:CxfConfig.java

示例5: doPublishRestful

import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
private void doPublishRestful(Map<Class<?>, ResourceProvider> springResources) {
		JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
		sf.setBus(getBus());
		for (Entry<Class<?>, ResourceProvider> e : springResources.entrySet()) {
			sf.setResourceClasses(e.getKey());
			sf.setResourceProvider(e.getKey(), e.getValue());
			log.info("Publishing JAX-RS Service {} at {}", e, httpPrefix + restBasePath);
		}
		sf.setAddress(httpPrefix + restBasePath);
//		if (restUseFastJson == 1) {
//			sf.setProvider(new FastJSONProvider(false, restJsonWithClassname));
//		} else {
			sf.setProvider(new FastJSONProvider(true, restJsonWithClassname));
//		}
		sf.getInInterceptors().add(new LoggingInInterceptor());
		sf.getOutInterceptors().add(new LoggingOutInterceptor());
		sf.create();

	}
 
開發者ID:GeeQuery,項目名稱:cxf-plus,代碼行數:20,代碼來源:CXFPlusServlet.java

示例6: 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

示例7: rsServer

import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
@Bean
public Server rsServer() {
    // setup CXF-RS
    JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
    endpoint.setBus(bus);
    endpoint.setServiceBeans(Arrays.<Object>asList(new HelloServiceImpl()));
    endpoint.setAddress("/");
    endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
    return endpoint.create();
}
 
開發者ID:fabric8-quickstarts,項目名稱:spring-boot-cxf-jaxrs,代碼行數:11,代碼來源:SampleRestApplication.java

示例8: jaxRsServer

import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
@Bean
  @DependsOn("cxf")
  public Server jaxRsServer() {
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
// sf.setResourceClasses( MyJaxrsResource.class );

List<Object> providers = new ArrayList<Object>();
// add custom providers if any
sf.setProviders(providers);

// factory.setServiceBean(new DenialCategoryRest());

// get all the class annotated with @JaxrsService
List<Object> beans = configUtil.findBeans(JaxrsService.class);
// List<Class> beansClasses = configUtil.findClasses( JaxrsService.class
// );

if (beans.size() > 0) {

	// add all the CXF service classes into the CXF stack
	//sf.setResourceClasses(UserRestImpl.class);
	sf.setServiceBeans(beans);
	sf.setAddress("http://localhost:8080/api");
	sf.setBus(springBus);
	sf.setStart(true);

	// set JSON as the response serializer
	JacksonJsonProvider provider = new JacksonJsonProvider();
	sf.setProvider(provider);

}

return sf.create();
  }
 
開發者ID:amoldavsky,項目名稱:restful-api-cxf-spring-java,代碼行數:35,代碼來源:CxfTestConfig.java

示例9: CxfRsConsumer

import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
public CxfRsConsumer(CxfRsEndpoint endpoint, Processor processor) {
    super(endpoint, processor);
    CxfRsInvoker cxfRsInvoker = new CxfRsInvoker(endpoint, this);
    JAXRSServerFactoryBean svrBean = endpoint.createJAXRSServerFactoryBean();
    Bus bus = ((CxfRsEndpoint)getEndpoint()).getBus();
    // We need to apply the bus setting from the CxfRsEndpoint which is not use the default bus
    if (bus != null) {
        svrBean.setBus(bus);
    }
    svrBean.setInvoker(cxfRsInvoker);
    server = svrBean.create();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:13,代碼來源:CxfRsConsumer.java

示例10: 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

示例11: newFactory

import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
private JAXRSServerFactoryBean newFactory(final String prefix, final String service, final String endpoint) {
    final JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean() {
        @Override
        protected Endpoint createEndpoint() throws BusException, EndpointException {
            final Endpoint created = super.createEndpoint();
            created.put(ManagedEndpoint.SERVICE_NAME, service);
            created.put(ManagedEndpoint.ENDPOINT_NAME, endpoint);
            return created;
        }
    };
    factory.setDestinationFactory(transportFactory);
    factory.setBus(CxfUtil.getBus());
    factory.setAddress(prefix);
    return factory;
}
 
開發者ID:apache,項目名稱:tomee,代碼行數:16,代碼來源:CxfRsHttpListener.java

示例12: rewire

import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
protected synchronized void rewire() {
	if (_server != null) {
		_server.destroy();
	}

	RuntimeDelegate runtimeDelegate = RuntimeDelegate.getInstance();

	JAXRSServerFactoryBean jaxRsServerFactoryBean =
		runtimeDelegate.createEndpoint(
			_application, JAXRSServerFactoryBean.class);

	jaxRsServerFactoryBean.setBus(_bus);
	jaxRsServerFactoryBean.setProperties(_properties);

	JSONProvider<Object> jsonProvider = new JSONProvider<>();

	jsonProvider.setDropCollectionWrapperElement(true);
	jsonProvider.setDropRootElement(true);
	jsonProvider.setSerializeAsArray(true);
	jsonProvider.setSupportUnwrapped(true);

	jaxRsServerFactoryBean.setProvider(jsonProvider);

	for (Object provider : _providers) {
		jaxRsServerFactoryBean.setProvider(provider);
	}

	for (Object service : _services) {
		jaxRsServerFactoryBean.setResourceProvider(
			new SingletonResourceProvider(service, true));
	}

	String address = _properties.get("CXF_ENDPOINT_ADDRESS").toString();

	if (address != null) {
		jaxRsServerFactoryBean.setAddress(address);
	}

	_server = jaxRsServerFactoryBean.create();

	_server.start();
}
 
開發者ID:csierra,項目名稱:osgi-jaxrs-extracted,代碼行數:43,代碼來源:CXFJaxRsServiceRegistrator.java

示例13: 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.setBus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。