use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project tomee by apache.
the class CxfRsHttpListener method newFactory.
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;
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project bamboobsc by billchen198318.
the class CxfServerBean method start.
public static void start(PublishingCXFServlet servlet, ServletConfig servletConfig, Bus bus, boolean loadBusManual) {
logger.info("start");
CxfServerBean.servlet = servlet;
CxfServerBean.servletConfig = servletConfig;
CxfServerBean.bus = bus;
if (server != null && serverFactoryBean != null) {
logger.warn("Server is found , not start");
return;
}
try {
if (loadBusManual) {
logger.info("load bus manual mode");
CxfServerBean.bus = servlet.loadBusManual(servletConfig);
restartNum = restartNum + 1;
}
BusFactory.setDefaultBus(CxfServerBean.bus);
serverFactoryBean = new JAXRSServerFactoryBean();
serverFactoryBean.setBus(CxfServerBean.bus);
List<TbSysWsConfig> configs = getSystemWsConfigs();
publishDefault(configs);
int r = publishRest(serverFactoryBean, configs);
BindingFactoryManager manager = serverFactoryBean.getBus().getExtension(BindingFactoryManager.class);
bindingFactory = new JAXRSBindingFactory();
bindingFactory.setBus(serverFactoryBean.getBus());
manager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID, bindingFactory);
if (r > 0) {
server = serverFactoryBean.create();
}
} catch (Exception e) {
e.printStackTrace();
}
logger.info("end");
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project camel by apache.
the class CxfRsEndpointBeansTest method testCxfBusInjection.
@Test
public void testCxfBusInjection() {
CxfRsEndpoint serviceEndpoint = context.getEndpoint("cxfrs:bean:serviceEndpoint", CxfRsEndpoint.class);
CxfRsEndpoint routerEndpoint = context.getEndpoint("cxfrs:bean:routerEndpoint", CxfRsEndpoint.class);
JAXRSServerFactoryBean server = routerEndpoint.createJAXRSServerFactoryBean();
JAXRSClientFactoryBean client = serviceEndpoint.createJAXRSClientFactoryBean();
assertEquals("These cxfrs endpoints don't share the same bus", server.getBus().getId(), client.getBus().getId());
}
use of org.apache.cxf.jaxrs.JAXRSServerFactoryBean in project camel by apache.
the class CamelConnectorCatalogRestTest method setup.
@Before
public void setup() {
catalog = new CamelConnectorCatalogRest();
port = AvailablePortFinder.getNextAvailable(9000);
// setup Apache CXF REST server
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(CamelConnectorCatalogRest.class);
sf.setResourceProvider(CamelConnectorCatalogRest.class, new SingletonResourceProvider(catalog));
// 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();
}
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);
}
Aggregations