本文整理汇总了Java中org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider类的典型用法代码示例。如果您正苦于以下问题:Java SingletonResourceProvider类的具体用法?Java SingletonResourceProvider怎么用?Java SingletonResourceProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SingletonResourceProvider类属于org.apache.cxf.jaxrs.lifecycle包,在下文中一共展示了SingletonResourceProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider; //导入依赖的package包/类
@Before
public void setup() {
catalog = new CamelCatalogRest();
port = AvailablePortFinder.getNextAvailable(9000);
// setup Apache CXF REST server
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(CamelCatalogRest.class);
sf.setResourceProvider(CamelCatalogRest.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();
}
示例2: main
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// create dummy backend
DummyOrderService dummy = new DummyOrderService();
dummy.setupDummyOrders();
// create CXF REST service and inject the dummy backend
RestOrderService rest = new RestOrderService();
rest.setOrderService(dummy);
// setup Apache CXF REST server on port 9000
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(RestOrderService.class);
sf.setResourceProvider(RestOrderService.class, new SingletonResourceProvider(rest));
sf.setAddress("http://localhost:9000/");
// create and start the CXF server (non blocking)
Server server = sf.create();
server.start();
// keep the JVM running
Console console = System.console();
System.out.println("Server started on http://localhost:9000/");
System.out.println("");
// If you run the main class from IDEA/Eclipse then you may not have a console, which is null)
if (console != null) {
System.out.println(" Press ENTER to stop server");
console.readLine();
} else {
System.out.println(" Stopping after 5 minutes or press ctrl + C to stop");
Thread.sleep(5 * 60 * 1000);
}
// stop CXF server
server.stop();
System.exit(0);
}
示例3: startServer
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider; //导入依赖的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();
}
示例4: startServer
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider; //导入依赖的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();
}
示例5: processJaxRs
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider; //导入依赖的package包/类
public void processJaxRs() {
if (RSlookup == null)
return;
log.debug("Start procesing the Restful-Services.");
Map<Class<?>, ResourceProvider> resProviders = new HashMap<Class<?>, ResourceProvider>();
for (ServiceDefinition def : RSlookup.getServices()) {
if (def.getServiceClass() == null)
continue;
if (canPublish(def.getName(), restNamePattern)) {
ServiceDefinition context = serviceUtill.processServiceDef(def);
if (context != null) {
resProviders.put(context.getServiceClass(), new SingletonResourceProvider(context.getServiceBean()));
}
}
}
// 计算完成开始发布
if (!resProviders.isEmpty()) {
doPublishRestful(resProviders);
}
}
示例6: startServer
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider; //导入依赖的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();
}
示例7: addingService
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider; //导入依赖的package包/类
@Override
public Object addingService(ServiceReference serviceReference) {
final Object trackedService = context.getService(serviceReference);
if (trackedService instanceof EntityService) {
final EntityServiceRest restApi = new EntityServiceRest();
restApi.setEntityService((EntityService) trackedService);
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(restApi.getClass());
sf.setResourceProvider(restApi.getClass(), new SingletonResourceProvider(restApi));
sf.setAddress("/entity");
sf.setProvider(new JacksonJsonProvider());
server = sf.create();
}
return trackedService;
}
示例8: activate
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider; //导入依赖的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();
}
示例9: Server
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider; //导入依赖的package包/类
protected Server(String filePath) throws Exception {
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(TestDataResourceImpl.class);
sf.setResourceProvider(TestDataResourceImpl.class,
new SingletonResourceProvider(new TestDataResourceImpl(filePath)));
sf.setAddress("http://localhost:9000/");
sf.create();
}
示例10: Server
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider; //导入依赖的package包/类
protected Server() throws Exception {
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(InvoiceServiceCRUDV1ResourceImpl.class);
sf.setResourceProvider(InvoiceServiceCRUDV1ResourceImpl.class,
new SingletonResourceProvider(new InvoiceServiceCRUDV1ResourceImpl()));
sf.setAddress("http://localhost:9000/");
sf.create();
}
示例11: Server
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider; //导入依赖的package包/类
protected Server() throws Exception {
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(InvoiceserviceV1ResourceImpl.class);
sf.setResourceProvider(InvoiceserviceV1ResourceImpl.class,
new SingletonResourceProvider(new InvoiceserviceV1ResourceImpl()));
sf.setAddress("http://localhost:9000/");
sf.create();
}
示例12: Server
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider; //导入依赖的package包/类
protected Server() throws Exception {
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(CustomerService.class);
sf.setResourceProvider(CustomerService.class,
new SingletonResourceProvider(new CustomerService()));
sf.setAddress("http://localhost:9000/");
sf.create();
}
示例13: setup
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider; //导入依赖的package包/类
@Before
public void setup() {
catalog = new CamelCatalogRest();
port = AvailablePortFinder.getNextAvailable(9000);
// setup Apache CXF REST server
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(CamelCatalogRest.class);
sf.setResourceProvider(CamelCatalogRest.class, new SingletonResourceProvider(catalog));
Swagger2Feature swagger = new Swagger2Feature();
swagger.setBasePath("/");
swagger.setScanAllResources(false);
swagger.setPrettyPrint(true);
swagger.setSupportSwaggerUi(true);
swagger.setTitle("Camel Catalog REST Api");
swagger.setDescription("REST Api for the Camel 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();
}
示例14: main
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// create dummy backend
DummyOrderService dummy = new DummyOrderService();
dummy.setupDummyOrders();
// create a Camel route that routes the REST services
OrderRoute route = new OrderRoute();
route.setOrderService(dummy);
// create CamelContext and add the route
CamelContext camel = new DefaultCamelContext();
camel.addRoutes(route);
// create a ProducerTemplate that the CXF REST service will use to integrate with Camel
ProducerTemplate producer = camel.createProducerTemplate();
// create CXF REST service and inject the Camel ProducerTemplate
// which we use to call the Camel route
RestOrderService rest = new RestOrderService();
rest.setProducerTemplate(producer);
// setup Apache CXF REST server on port 9000
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(RestOrderService.class);
sf.setResourceProvider(RestOrderService.class, new SingletonResourceProvider(rest));
// to use jackson for json
sf.setProvider(JacksonJsonProvider.class);
sf.setAddress("http://localhost:9000/");
// create the CXF server
Server server = sf.create();
// start Camel and CXF (non blocking)
camel.start();
server.start();
// keep the JVM running
Console console = System.console();
System.out.println("Server started on http://localhost:9000/");
System.out.println("");
// If you run the main class from IDEA/Eclipse then you may not have a console, which is null)
if (console != null) {
System.out.println(" Press ENTER to stop server");
console.readLine();
} else {
System.out.println(" Stopping after 5 minutes or press ctrl + C to stop");
Thread.sleep(5 * 60 * 1000);
}
// stop Camel and CXF server
camel.stop();
server.stop();
System.exit(0);
}
示例15: main
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// create dummy backend
DummyOrderService dummy = new DummyOrderService();
dummy.setupDummyOrders();
// create CXF REST service and inject the dummy backend
RestOrderService rest = new RestOrderService();
rest.setOrderService(dummy);
// setup Apache CXF REST server on port 9000
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(RestOrderService.class);
sf.setResourceProvider(RestOrderService.class, new SingletonResourceProvider(rest));
// to use jackson for json
sf.setProvider(JacksonJsonProvider.class);
sf.setAddress("http://localhost:9000/");
// create and start the CXF server (non blocking)
Server server = sf.create();
server.start();
// keep the JVM running
Console console = System.console();
System.out.println("Server started on http://localhost:9000/");
System.out.println("");
// If you run the main class from IDEA/Eclipse then you may not have a console, which is null)
if (console != null) {
System.out.println(" Press ENTER to stop server");
console.readLine();
} else {
System.out.println(" Stopping after 5 minutes or press ctrl + C to stop");
Thread.sleep(5 * 60 * 1000);
}
// stop CXF server
server.stop();
System.exit(0);
}