use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.
the class Server method cxfServer.
@Bean
org.apache.cxf.endpoint.Server cxfServer(@Qualifier("cxf") final Tracer tracer) {
final JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
endpoint.setBus(bus);
endpoint.setAddress("/");
endpoint.setServiceBean(new Catalog());
endpoint.setProvider(new OpenTracingFeature(tracer));
endpoint.setProvider(new JacksonJsonProvider());
return endpoint.create();
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.
the class SampleRestApplication method rsServer.
@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();
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.
the class JAXRSCdiResourceExtension method load.
public void load(@Observes final AfterDeploymentValidation event, final BeanManager beanManager) {
// no need of creational context, it only works for app scoped instances anyway
final Bean<?> busBean = beanManager.resolve(beanManager.getBeans(CdiBusBean.CXF));
bus = (Bus) beanManager.getReference(busBean, Bus.class, beanManager.createCreationalContext(busBean));
// Adding the extension for dynamic providers registration and instantiation
if (bus.getExtension(ServerConfigurableFactory.class) == null) {
bus.setExtension(new CdiServerConfigurableFactory(beanManager), ServerConfigurableFactory.class);
}
for (final Bean<?> application : applicationBeans) {
final Application instance = (Application) beanManager.getReference(application, application.getBeanClass(), createCreationalContext(beanManager, application));
// create a server factory bean with all services and providers discovered.
if (instance.getSingletons().isEmpty() && instance.getClasses().isEmpty()) {
final JAXRSServerFactoryBean factory = createFactoryInstance(instance, loadServices(beanManager, Collections.<Class<?>>emptySet()), loadProviders(beanManager, Collections.<Class<?>>emptySet()), loadFeatures(beanManager, Collections.<Class<?>>emptySet()));
customize(beanManager, factory);
factory.init();
} else {
// If there is an application with any singletons or classes defined, we will
// create a server factory bean with only application singletons and classes.
final JAXRSServerFactoryBean factory = createFactoryInstance(instance, beanManager);
customize(beanManager, factory);
factory.init();
}
}
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.
the class JAXRSCdiResourceExtension method createFactoryInstance.
/**
* 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;
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.
the class JAXRSCdiResourceExtension method createFactoryInstance.
/**
* Create the JAXRSServerFactoryBean from the objects declared by application itself.
* @param application application instance
* @return JAXRSServerFactoryBean instance
*/
private JAXRSServerFactoryBean createFactoryInstance(final Application application, final BeanManager beanManager) {
final JAXRSServerFactoryBean instance = ResourceUtils.createApplication(application, false, false, false, bus);
final ClassifiedClasses classified = classes2singletons(application, beanManager);
instance.setProviders(classified.getProviders());
instance.getFeatures().addAll(classified.getFeatures());
for (final CdiResourceProvider resourceProvider : classified.getResourceProviders()) {
instance.setResourceProvider(resourceProvider.getResourceClass(), resourceProvider);
}
return instance;
}
Aggregations