Java Code Examples for org.apache.cxf.jaxrs.JAXRSServerFactoryBean#setServiceBeans()
The following examples show how to use
org.apache.cxf.jaxrs.JAXRSServerFactoryBean#setServiceBeans() .
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: AbstractJaxrsClassesScanServer.java From cxf with Apache License 2.0 | 6 votes |
protected void setJaxrsResources(JAXRSServerFactoryBean factory) { try { final Map< Class< ? extends Annotation >, Collection< Class< ? > > > classes = ClasspathScanner.findClasses(basePackages, Provider.class, Path.class); List<Object> jaxrsServices = JAXRSServerFactoryBeanDefinitionParser .createBeansFromDiscoveredClasses(super.applicationContext, classes.get(Path.class), null); List<Object> jaxrsProviders = JAXRSServerFactoryBeanDefinitionParser .createBeansFromDiscoveredClasses(super.applicationContext, classes.get(Provider.class), null); factory.setServiceBeans(jaxrsServices); factory.setProviders(jaxrsProviders); } catch (Exception ex) { throw new ServiceConstructionException(ex); } }
Example 2
Source File: WebServiceConfig.java From jwala with Apache License 2.0 | 6 votes |
@Bean public Server getJaxRestServer(final GroupServiceRest groupServiceRest, final JvmServiceRest jvmServiceRest) { final JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean(); factory.setAddress("/v2.0"); final List<Object> serviceBeans = new ArrayList<>(); serviceBeans.add(groupServiceRest); serviceBeans.add(jvmServiceRest); factory.setServiceBeans(serviceBeans); List<Object> providers = new ArrayList<>(); providers.add(getJacksonJsonProvider()); providers.add(getInternalServerErrorHandler()); factory.setProviders(providers); return factory.create(); }
Example 3
Source File: CoffeeConfig.java From product-ei with Apache License 2.0 | 5 votes |
@Bean public org.apache.cxf.endpoint.Server jaxRsServer() { JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().createEndpoint( jaxRsApiApplication(), JAXRSServerFactoryBean.class ); factory.setServiceBeans( Arrays.< Object >asList(starbucksOutletService()) ); factory.setAddress( "/" + factory.getAddress() ); List<Object> providers = new ArrayList<Object>(); providers.add(jsonProvider()); providers.add(new OrderReader()); factory.setProviders(providers); //factory.setProviders( Arrays.< Object >asList( jsonProvider() ) ); return factory.create(); }
Example 4
Source File: AppConfig.java From service-autodiscovery with Apache License 2.0 | 5 votes |
@Bean @DependsOn( "cxf" ) public Server jaxRsServer() { JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().createEndpoint( jaxRsApiApplication(), JAXRSServerFactoryBean.class ); factory.setServiceBeans( Arrays.< Object >asList( peopleRestService() ) ); factory.setAddress( factory.getAddress() ); factory.setProviders( Arrays.< Object >asList( jsonProvider() ) ); return factory.create(); }
Example 5
Source File: SpringServletContextTest.java From cxf with Apache License 2.0 | 5 votes |
@Bean @DependsOn("cxf") public Server jaxRsServer() { final JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean(); factory.setServiceBeans(Arrays.asList(contextRestService())); factory.setAddress("/services/context"); return factory.create(); }
Example 6
Source File: SampleRestApplication.java From cxf with Apache License 2.0 | 5 votes |
@Bean public Server rsServer() { JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean(); endpoint.setBus(bus); endpoint.setServiceBeans(Arrays.<Object>asList(new HelloServiceImpl1(), new HelloServiceImpl2())); endpoint.setAddress("/"); endpoint.setFeatures(Arrays.asList(createOpenApiFeature(), new LoggingFeature())); return endpoint.create(); }
Example 7
Source File: JAXRSCdiResourceExtension.java From cxf with Apache License 2.0 | 5 votes |
/** * Create the JAXRSServerFactoryBean from the application and all discovered service and provider instances. * @param application application instance * @param services all discovered services * @param providers all discovered providers * @return JAXRSServerFactoryBean instance */ private JAXRSServerFactoryBean createFactoryInstance(final Application application, final List< ? > services, final List< ? > providers, final List< ? extends Feature > features) { final JAXRSServerFactoryBean instance = ResourceUtils.createApplication(application, false, false, false, bus); instance.setServiceBeans(new ArrayList<>(services)); instance.setProviders(providers); instance.setProviders(loadExternalProviders()); instance.setFeatures(features); return instance; }
Example 8
Source File: CustomerConfig.java From product-ei with Apache License 2.0 | 5 votes |
@Bean public org.apache.cxf.endpoint.Server jaxRsServer() { JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().createEndpoint( jaxRsApiApplication(), JAXRSServerFactoryBean.class ); factory.setServiceBeans( Arrays.< Object >asList(customerService()) ); factory.setAddress( "/" + factory.getAddress() ); factory.setProviders( Arrays.< Object >asList( jsonProvider() ) ); return factory.create(); }
Example 9
Source File: MusicConfig.java From product-ei with Apache License 2.0 | 5 votes |
@Bean public Server jaxRsServer() { JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().createEndpoint( jaxRsApiApplication(), JAXRSServerFactoryBean.class ); factory.setServiceBeans( Arrays.< Object >asList(musicRestService()) ); factory.setAddress( "/" + factory.getAddress() ); factory.setProviders( Arrays.< Object >asList( jsonProvider() ) ); return factory.create(); }
Example 10
Source File: AppConfig.java From product-ei with Apache License 2.0 | 5 votes |
@Bean public Server jaxRsServer() { JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().createEndpoint( jaxRsApiApplication(), JAXRSServerFactoryBean.class ); factory.setServiceBeans( Arrays.< Object >asList( peopleRestService() ) ); factory.setAddress( "/" + factory.getAddress() ); factory.setProviders( Arrays.< Object >asList( jsonProvider() ) ); return factory.create(); }
Example 11
Source File: CoffeeConfig.java From micro-integrator with Apache License 2.0 | 5 votes |
@Bean public org.apache.cxf.endpoint.Server jaxRsServer() { JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance() .createEndpoint(jaxRsApiApplication(), JAXRSServerFactoryBean.class); factory.setServiceBeans(Arrays.<Object>asList(starbucksOutletService())); factory.setAddress("/" + factory.getAddress()); List<Object> providers = new ArrayList<Object>(); providers.add(jsonProvider()); providers.add(new OrderReader()); factory.setProviders(providers); //factory.setProviders( Arrays.< Object >asList( jsonProvider() ) ); return factory.create(); }
Example 12
Source File: CxfConfig.java From coditori with Apache License 2.0 | 5 votes |
@Bean public Server rsServer() { final JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean(); endpoint.setProvider(new JacksonJsonProvider()); endpoint.setBus(bus); endpoint.setAddress("/"); endpoint.setServiceBeans(Arrays.<Object>asList(userController())); endpoint.setFeatures(Arrays.asList(new Swagger2Feature())); return endpoint.create(); }
Example 13
Source File: CxfConfig.java From coditori with Apache License 2.0 | 5 votes |
@Bean public Server rsServer() { final JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean(); endpoint.setProvider(new JacksonJsonProvider()); endpoint.setProvider(getExceptionHandler()); endpoint.setBus(bus); endpoint.setAddress("/"); endpoint.setServiceBeans(Arrays.<Object>asList(indexController(), userController())); endpoint.setFeatures(Arrays.asList(new Swagger2Feature())); return endpoint.create(); }
Example 14
Source File: AemWebServiceConfiguration.java From jwala with Apache License 2.0 | 5 votes |
@Bean public Server getV1JaxResServer() { final JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean(); factory.setAddress("/v1.0"); factory.setServiceBeans(getV1ServiceBeans()); factory.setProviders(getV1Providers()); return factory.create(); }
Example 15
Source File: CustomerConfig.java From micro-integrator with Apache License 2.0 | 5 votes |
@Bean public org.apache.cxf.endpoint.Server jaxRsServer() { JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance() .createEndpoint(jaxRsApiApplication(), JAXRSServerFactoryBean.class); factory.setServiceBeans(Arrays.<Object>asList(customerService())); factory.setAddress("/" + factory.getAddress()); factory.setProviders(Arrays.<Object>asList(jsonProvider())); return factory.create(); }
Example 16
Source File: MusicConfig.java From micro-integrator with Apache License 2.0 | 5 votes |
@Bean public Server jaxRsServer() { JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance() .createEndpoint(jaxRsApiApplication(), JAXRSServerFactoryBean.class); factory.setServiceBeans(Arrays.<Object>asList(musicRestService())); factory.setAddress("/" + factory.getAddress()); factory.setProviders(Arrays.<Object>asList(jsonProvider())); return factory.create(); }
Example 17
Source File: AppConfig.java From micro-integrator with Apache License 2.0 | 5 votes |
@Bean public Server jaxRsServer() { JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance() .createEndpoint(jaxRsApiApplication(), JAXRSServerFactoryBean.class); factory.setServiceBeans(Arrays.<Object>asList(peopleRestService())); factory.setAddress("/" + factory.getAddress()); factory.setProviders(Arrays.<Object>asList(jsonProvider())); return factory.create(); }
Example 18
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 19
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(); }