本文整理匯總了Java中org.apache.cxf.jaxrs.JAXRSServerFactoryBean.setProviders方法的典型用法代碼示例。如果您正苦於以下問題:Java JAXRSServerFactoryBean.setProviders方法的具體用法?Java JAXRSServerFactoryBean.setProviders怎麽用?Java JAXRSServerFactoryBean.setProviders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.cxf.jaxrs.JAXRSServerFactoryBean
的用法示例。
在下文中一共展示了JAXRSServerFactoryBean.setProviders方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getJaxRestServer
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
@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();
}
示例2: 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();
}
示例3: 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;
}
示例4: publishRest
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
private static int publishRest(JAXRSServerFactoryBean sf, List<TbSysWsConfig> configs) {
int c = 0;
for (TbSysWsConfig config : configs) {
if (!WSConfig.TYPE_REST.equals(config.getType())) {
continue;
}
try {
sf.setServiceBean(AppContext.getBean(config.getBeanId()));
c++;
} catch (Exception e) {
e.printStackTrace();
}
}
sf.setProviders(getProvider());
sf.setAddress(WSConfig.getJAXRSServerFactoryBeanAddress());
return c;
}
示例5: startServices
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
/**
* Helper method to start all rest services on a Jettison server as supplied
* by the Apache cxf libraries.
*
* @throws Exception
*/
private static void startServices() throws Exception {
List<JSONProvider> providers = new ArrayList<JSONProvider>();
JSONProvider jsonProvider = new JSONProvider();
// jsonProvider.setSerializeAsArray(false);
// jsonProvider.setConvertTypesToStrings(true);
Map<String, String> map = new HashMap<String, String>();
map.put("http://www.goodrick.ch", "brewcontrol");
jsonProvider.setNamespaceMap(map);
providers.add(jsonProvider);
JAXRSServerFactoryBean factoryBean = new JAXRSServerFactoryBean();
factoryBean.setResourceClasses(RestService.class, MashingService.class, InfoService.class);
factoryBean.setBindingId(JAXRSBindingFactory.JAXRS_BINDING_ID);
factoryBean.setAddress("http://" + getNetworkAddress() + ":8080/");
factoryBean.setProviders(providers);
factoryBean.create();
}
示例6: startServer
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
/**
* Starts a local cxf server that listens for defined SOAP operation.
* This means that each operation should have its own test.
* @param type the implementing type of AbstractWebService, i.e. SakaiLogin.class
*/
private <T extends AbstractWebService> void startServer(Class<T> type) {
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(type);
List<Object> providers = new ArrayList<Object>();
// add custom providers if any
// CXF supports String, byte[], InputStream, Reader, File, JAXP Source, JAX-RS StreamingOutput,
// JAXB-annotated types with application/xml, text/xml and application/json formats as well as JAXBElement
sf.setProviders(providers);
AbstractWebService service = MockingAbstractWebService.getMockedAbstractWebService(type);
addServiceMocks(service);
sf.setResourceProvider(type, new SingletonResourceProvider(service, true));
sf.setAddress(getFullEndpointAddress());
server = sf.create();
}
示例7: startServer
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
@Before
public void startServer() {
JAXRSServerFactoryBean serverFactory = new JAXRSServerFactoryBean();
serverFactory.setResourceClasses(TestCxfResource.class);
// add custom providers if any
serverFactory.setProviders(new ArrayList<Object>());
serverFactory.setResourceProvider(TestCxfResource.class, new SingletonResourceProvider(new TestCxfResource(), true));
serverFactory.setAddress(ENDPOINT_ADDRESS);
serverFactory.getInInterceptors().add(new CxfInAgent());
serverFactory.getOutInterceptors().add(this.buildCxfOutAgent());
this.server = serverFactory.create();
}
示例8: startServer
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
/**
* this files up a CXF based Jetty server to host tile rest service
* @throws Exception
*/
private static void startServer() throws Exception {
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(TileFetcher.class);
List<Object> providers = new ArrayList<Object>();
// add custom providers if any
providers.add(new org.apache.cxf.jaxrs.provider.JAXBElementProvider());
providers.add(new org.apache.cxf.jaxrs.provider.json.JSONProvider());
sf.setProviders(providers);
sf.setResourceProvider(TileFetcher.class,
new SingletonResourceProvider(new TileFetcher(), true));
sf.setAddress(ENDPOINT_ADDRESS);
server = sf.create();
}
示例9: setupServer
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
private void setupServer(Application application) {
jaxrsServerFactoryBean = new JAXRSServerFactoryBean();
List<Class<?>> resourceClasses = new ArrayList<Class<?>>();
List<Object> providerInstances = new ArrayList<Object>();
// separate the providers and resources from the application returned classes
separateProvidersAndResources(application, resourceClasses, providerInstances);
jaxrsServerFactoryBean.setResourceClasses(resourceClasses);
jaxrsServerFactoryBean.setProviders(providerInstances);
// set up address
Properties serverProperties = readProperties();
propertyPort = serverProperties.getProperty(PORT_PROPERTY);
jaxrsServerFactoryBean.setAddress("http://localhost:" + propertyPort + ROOT_RESOURCE_PATH);
// set start to false so create call does not start server
jaxrsServerFactoryBean.setStart(false);
server = jaxrsServerFactoryBean.create();
}
示例10: getV1JaxResServer
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
@Bean
public Server getV1JaxResServer() {
final JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
factory.setAddress("/v1.0");
factory.setServiceBeans(getV1ServiceBeans());
factory.setProviders(getV1Providers());
return factory.create();
}
示例11: 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();
}
示例12: activate
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
@Activate
public void activate() {
JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
factory.setServiceClass(SimpleResource.class);
factory.setResourceProvider(SimpleResource.class, new SingletonResourceProvider(this));
factory.setProviders(singletonList(BraveTracingFeature.create(brave)));
factory.setAddress("/simple");
server = factory.create();
}
示例13: 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();
}
示例14: jaxRsServer
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
@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();
}
示例15: jaxRsServer
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; //導入方法依賴的package包/類
@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();
}