use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project camel by apache.
the class CamelCatalogRestMain method run.
public void run() {
LOGGER.info("Starting ...");
catalog = new CamelCatalogRest();
connectorCatalog = new CamelConnectorCatalogRest();
// setup Apache CXF REST server
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(CamelCatalogRest.class, CamelConnectorCatalogRest.class);
sf.setResourceProvider(CamelCatalogRest.class, new SingletonResourceProvider(catalog));
sf.setResourceProvider(CamelConnectorCatalogRest.class, new SingletonResourceProvider(connectorCatalog));
Swagger2Feature swagger = new Swagger2Feature();
swagger.setBasePath("/");
swagger.setScanAllResources(false);
swagger.setPrettyPrint(true);
swagger.setSupportSwaggerUi(true);
swagger.setTitle("Camel Catalog and Connector Catalog REST Api");
swagger.setDescription("REST Api for the Camel Catalog and Connector Catalog");
swagger.setVersion(catalog.getCatalogVersion());
swagger.setContact("Apache Camel");
sf.getFeatures().add(swagger);
// to use jackson for json
sf.setProvider(JacksonJsonProvider.class);
sf.setAddress("http://localhost:" + port);
// create and start the CXF server (non blocking)
server = sf.create();
server.start();
LOGGER.info("CamelCatalog REST Api started");
LOGGER.info("");
LOGGER.info("\tRest API base path: http://localhost:{}/camel-catalog", port);
LOGGER.info("\tRest API version: http://localhost:{}/camel-catalog/catalogVersion", port);
LOGGER.info("");
LOGGER.info("CamelConnectorCatalog REST Api started");
LOGGER.info("");
LOGGER.info("\tRest API base path: http://localhost:{}/camel-connector-catalog", port);
LOGGER.info("");
LOGGER.info("\tSwagger Doc: http://localhost:{}/swagger.json", port);
LOGGER.info("\tSwagger UI: http://localhost:{}/api-docs?url=/swagger.json", port);
LOGGER.info("");
LOGGER.info("Press Enter to stop");
Console console = System.console();
console.readLine();
LOGGER.info("Stopping ...");
server.stop();
server.destroy();
LOGGER.info("CamelCatalog REST Api stopped");
System.exit(0);
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project ddf by codice.
the class TestPlugin method startServer.
private static void startServer() {
LOGGER.info("Starting server.");
endpoint = mock(MockRestEndpoint.class);
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(MockRestEndpoint.class);
sf.setAddress(ENDPOINT_ADDRESS);
sf.setResourceProvider(MockRestEndpoint.class, new SingletonResourceProvider(endpoint, true));
LOGGER.info("Creating server.");
server = sf.create();
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.
the class MultipartServer method run.
protected void run() {
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(MultipartStore.class);
Map<String, Object> props = new HashMap<>();
props.put(AttachmentDeserializer.ATTACHMENT_MAX_SIZE, String.valueOf(1024 * 10));
props.put(AttachmentDeserializer.ATTACHMENT_MEMORY_THRESHOLD, String.valueOf(1024 * 5));
props.put(AttachmentDeserializer.ATTACHMENT_MAX_HEADER_SIZE, String.valueOf(400));
sf.setProperties(props);
// default lifecycle is per-request, change it to singleton
sf.setResourceProvider(MultipartStore.class, new SingletonResourceProvider(new MultipartStore()));
sf.setAddress("http://localhost:" + PORT + "/");
server = sf.create();
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.
the class BookServerWebSocket method run.
protected void run() {
Bus bus = BusFactory.getDefaultBus();
setBus(bus);
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setBus(bus);
sf.setResourceClasses(BookStoreWebSocket.class, BookStorePerRequest.class);
sf.setProvider(new StreamingResponseProvider<Book>());
sf.setResourceProvider(BookStoreWebSocket.class, new SingletonResourceProvider(new BookStoreWebSocket(), true));
sf.setAddress("ws://localhost:" + port + "/websocket");
server = sf.create();
BusFactory.setDefaultBus(null);
BusFactory.setThreadDefaultBus(null);
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project cxf by apache.
the class BookServer20 method run.
protected void run() {
Bus bus = BusFactory.getDefaultBus();
setBus(bus);
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setBus(bus);
sf.setResourceClasses(BookStore.class);
List<Object> providers = new ArrayList<>();
providers.add(new PreMatchContainerRequestFilter2());
providers.add(new PreMatchContainerRequestFilter());
providers.add(new PostMatchContainerResponseFilter());
providers.add((Feature) context -> {
context.register(new PostMatchContainerResponseFilter3());
return true;
});
providers.add(new PostMatchContainerResponseFilter2());
providers.add(new CustomReaderBoundInterceptor());
providers.add(new CustomReaderInterceptor());
providers.add(new CustomWriterInterceptor());
providers.add(new CustomDynamicFeature());
providers.add(new PostMatchContainerRequestFilter());
providers.add(new FaultyContainerRequestFilter());
providers.add(new PreMatchReplaceStreamOrAddress());
providers.add(new ServerTestFeature());
providers.add(new JacksonJaxbJsonProvider());
providers.add(new IOExceptionMapper());
sf.setApplication(new Application());
sf.setProviders(providers);
sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore(), true));
sf.setAddress("http://localhost:" + PORT + "/");
server = sf.create();
BusFactory.setDefaultBus(null);
BusFactory.setThreadDefaultBus(null);
}
Aggregations