org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider Java Examples
The following examples show how to use
org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JAXRSClientServerTikaTest.java From cxf with Apache License 2.0 | 6 votes |
protected void run() { JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); final Map< String, Object > properties = new HashMap<>(); properties.put("search.query.parameter.name", "$filter"); properties.put("search.parser", new FiqlParser< SearchBean >(SearchBean.class)); properties.put(SearchUtils.DATE_FORMAT_PROPERTY, "yyyy/MM/dd"); sf.setResourceClasses(BookCatalog.class); sf.setResourceProvider(BookCatalog.class, new SingletonResourceProvider(new BookCatalog())); sf.setAddress("http://localhost:" + PORT + "/"); sf.setProperties(properties); sf.setProvider(new MultipartProvider()); sf.setProvider(new SearchContextProvider()); sf.setProvider(new JacksonJsonProvider()); sf.create(); }
Example #2
Source File: JAXRSLocalTransportTest.java From cxf with Apache License 2.0 | 6 votes |
@Before public void setUp() { JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStore.class, BookStoreSpring.class); sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore(), true)); sf.setResourceProvider(BookStoreSpring.class, new SingletonResourceProvider(new BookStoreSpring(), true)); sf.setProvider(new JacksonJsonProvider()); List<Interceptor<? extends Message>> outInts = new ArrayList<>(); outInts.add(new CustomOutInterceptor()); sf.setOutInterceptors(outInts); List<Interceptor<? extends Message>> inInts = new ArrayList<>(); inInts.add(new CustomInFaultyInterceptor()); sf.setInInterceptors(inInts); sf.setTransportId(LocalTransportFactory.TRANSPORT_ID); sf.setAddress("local://books"); localServer = sf.create(); }
Example #3
Source File: BookKerberosServer.java From cxf with Apache License 2.0 | 6 votes |
protected void run() { JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStore.class); //default lifecycle is per-request, change it to singleton sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStoreImpl())); KerberosAuthenticationFilter filter = new KerberosAuthenticationFilter(); filter.setLoginContextName("bob"); filter.setCallbackHandler(getCallbackHandler("bob", "bob")); //filter.setLoginContextName("KerberosServerKeyTab"); //filter.setServicePrincipalName("HTTP/ktab"); sf.setProvider(filter); sf.setAddress("http://localhost:" + PORT + "/"); sf.create(); }
Example #4
Source File: OpenTracingTracingTest.java From cxf with Apache License 2.0 | 6 votes |
@Override protected void run() { final Tracer tracer = new JaegerTracer.Builder("tracer-jaxrs") .withSampler(new ConstSampler(true)) .withReporter(REPORTER) .build(); final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStore.class); sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore<Scope>())); sf.setAddress("http://localhost:" + PORT); sf.setProvider(new JacksonJsonProvider()); sf.setProvider(new OpenTracingFeature(tracer)); sf.setProvider(new NullPointerExceptionMapper()); server = sf.create(); }
Example #5
Source File: MultipartServer.java From cxf with Apache License 2.0 | 6 votes |
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(); }
Example #6
Source File: BraveTracingTest.java From cxf with Apache License 2.0 | 6 votes |
@Override protected void run() { final Tracing brave = Tracing .newBuilder() .spanReporter(new TestSpanReporter()) .build(); final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStore.class); sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore<TraceScope>())); sf.setAddress("http://localhost:" + PORT); sf.setProvider(new JacksonJsonProvider()); sf.setProvider(new BraveFeature(brave)); sf.setProvider(new NullPointerExceptionMapper()); server = sf.create(); }
Example #7
Source File: Swagger2NonAnnotatedServiceDescriptionTest.java From cxf with Apache License 2.0 | 6 votes |
@Override protected void run() { final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStore.class); sf.setResourceClasses(BookStoreStylesheetsSwagger2.class); sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore())); sf.setProvider(new JacksonJsonProvider()); final Swagger2Feature feature = createSwagger2Feature(); //FIXME swagger-jaxrs 1.5.3 can't handle a self-recursive subresource like Book // so we need to exclude "org.apache.cxf.systest.jaxrs" for now. feature.setResourcePackage("org.apache.cxf.systest.jaxrs.description.group1"); feature.setScanAllResources(true); sf.setFeatures(Arrays.asList(feature)); sf.setAddress("http://localhost:" + port + "/"); sf.create(); }
Example #8
Source File: CXFNonSpringJaxrsServlet.java From cxf with Apache License 2.0 | 6 votes |
protected Map<Class<?>, ResourceProvider> getResourceProviders(ServletConfig servletConfig, Map<Class<?>, Map<String, List<String>>> resourceClasses) throws ServletException { String scope = servletConfig.getInitParameter(SERVICE_SCOPE_PARAM); if (scope != null && !SERVICE_SCOPE_SINGLETON.equals(scope) && !SERVICE_SCOPE_REQUEST.equals(scope)) { throw new ServletException("Only singleton and prototype scopes are supported"); } boolean isPrototype = SERVICE_SCOPE_REQUEST.equals(scope); Map<Class<?>, ResourceProvider> map = new HashMap<>(); for (Map.Entry<Class<?>, Map<String, List<String>>> entry : resourceClasses.entrySet()) { Class<?> c = entry.getKey(); map.put(c, isPrototype ? new PerRequestResourceProvider(c) : new SingletonResourceProvider( createSingletonInstance(c, entry.getValue(), servletConfig), true)); } return map; }
Example #9
Source File: JAXRSClientServerStreamingTest.java From cxf with Apache License 2.0 | 6 votes |
protected void run() { JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStore.class); sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore())); JAXBElementProvider<?> p1 = new JAXBElementProvider<>(); p1.setEnableBuffering(true); p1.setEnableStreaming(true); JAXBElementProvider<?> p2 = new CustomJaxbProvider(); p2.setProduceMediaTypes(Collections.singletonList("text/xml")); List<Object> providers = new ArrayList<>(); providers.add(p1); providers.add(p2); sf.setProviders(providers); sf.setAddress("http://localhost:" + PORT + "/"); Map<String, Object> properties = new HashMap<>(); properties.put("org.apache.cxf.serviceloader-context", "true"); sf.setProperties(properties); sf.create(); }
Example #10
Source File: AbstractCXFTest.java From sakai with Educational Community License v2.0 | 6 votes |
/** * 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(); }
Example #11
Source File: SyncopeCoreTestingServer.java From syncope with Apache License 2.0 | 6 votes |
@Override public void onApplicationEvent(final ContextRefreshedEvent event) { if (AbstractTest.available(9080)) { // 1. start (mocked) Core as embedded CXF JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setAddress(ADDRESS); sf.setResourceClasses(SRARouteService.class); sf.setResourceProvider(SRARouteService.class, new SingletonResourceProvider(new StubSRARouteService(), true)); sf.setProviders(List.of(new JacksonJsonProvider())); sf.create(); // 2. register Core in Keymaster NetworkService core = new NetworkService(); core.setType(NetworkService.Type.CORE); core.setAddress(ADDRESS); serviceOps.register(core); } }
Example #12
Source File: SyncopeCoreTestingServer.java From syncope with Apache License 2.0 | 6 votes |
@Override public void onApplicationEvent(final ContextRefreshedEvent event) { synchronized (ADDRESS) { if (serviceOps.list(NetworkService.Type.CORE).isEmpty()) { // 1. start (mocked) Core as embedded CXF JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setAddress(ADDRESS); sf.setResourceClasses(WAClientAppService.class, GoogleMfaAuthTokenService.class); sf.setResourceProvider( WAClientAppService.class, new SingletonResourceProvider(new StubWAClientAppService(), true)); sf.setResourceProvider( GoogleMfaAuthTokenService.class, new SingletonResourceProvider(new StubGoogleMfaAuthTokenService(), true)); sf.setProviders(List.of(new JacksonJsonProvider())); sf.create(); // 2. register Core in Keymaster NetworkService core = new NetworkService(); core.setType(NetworkService.Type.CORE); core.setAddress(ADDRESS); serviceOps.register(core); } } }
Example #13
Source File: JAXRSUtilsTest.java From cxf with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void testContextAnnotationOnMethod() throws Exception { ClassResourceInfo cri = new ClassResourceInfo(Customer.class, true); Customer c = new Customer(); cri.setResourceProvider(new SingletonResourceProvider(c)); InjectionUtils.injectContextProxies(cri, cri.getResourceProvider().getInstance(null)); OperationResourceInfo ori = new OperationResourceInfo(Customer.class.getMethods()[0], cri); Message message = createMessage(); InjectionUtils.injectContextMethods(c, ori.getClassResourceInfo(), message); assertNotNull(c.getUriInfo()); assertSame(ThreadLocalUriInfo.class, c.getUriInfo().getClass()); assertSame(UriInfoImpl.class, ((ThreadLocalProxy<UriInfo>)c.getUriInfo()).get().getClass()); assertSame(ThreadLocalServletConfig.class, c.getSuperServletConfig().getClass()); assertSame(ThreadLocalHttpServletRequest.class, c.getHttpServletRequest().getClass()); }
Example #14
Source File: CXFNonSpringJaxrsServlet.java From JaxRSProviders with Apache License 2.0 | 6 votes |
protected Map<Class<?>, ResourceProvider> getResourceProviders(ServletConfig servletConfig, Map<Class<?>, Map<String, List<String>>> resourceClasses) throws ServletException { String scope = servletConfig.getInitParameter(SERVICE_SCOPE_PARAM); if (scope != null && !SERVICE_SCOPE_SINGLETON.equals(scope) && !SERVICE_SCOPE_REQUEST.equals(scope)) { throw new ServletException("Only singleton and prototype scopes are supported"); } boolean isPrototype = SERVICE_SCOPE_REQUEST.equals(scope); Map<Class<?>, ResourceProvider> map = new HashMap<>(); for (Map.Entry<Class<?>, Map<String, List<String>>> entry : resourceClasses.entrySet()) { Class<?> c = entry.getKey(); map.put(c, isPrototype ? new PerRequestResourceProvider(c) : new SingletonResourceProvider( createSingletonInstance(c, entry.getValue(), servletConfig), true)); } return map; }
Example #15
Source File: JAXRSClientServerValidationTest.java From cxf with Apache License 2.0 | 6 votes |
protected void run() { JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStoreWithValidation.class); sf.setResourceProvider(BookStoreWithValidation.class, new SingletonResourceProvider(new BookStoreWithValidation())); sf.setProvider(new ValidationExceptionMapper() { @Override public Response toResponse(ValidationException exception) { Response r = super.toResponse(exception); return JAXRSUtils.toResponseBuilder( r.getStatus()).type("application/xml").entity(new Book("Validation", 123L)).build(); } }); sf.setAddress("http://localhost:" + PORT + "/"); BeanValidationInInterceptor in = new JAXRSBeanValidationInInterceptor(); in.setProvider(new BeanValidationProvider(new JAXRSParameterNameProvider())); sf.setInInterceptors(Arrays.< Interceptor< ? extends Message > >asList( in)); sf.setOutInterceptors(Arrays.< Interceptor< ? extends Message > >asList( new JAXRSBeanValidationOutInterceptor())); sf.create(); }
Example #16
Source File: AbstractCXFTest.java From sakai with Educational Community License v2.0 | 6 votes |
/** * 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(); }
Example #17
Source File: TileServer.java From osmdroid with Apache License 2.0 | 6 votes |
/** * 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(); }
Example #18
Source File: ClassResourceInfoProxyHelper.java From HotswapAgent with GNU General Public License v2.0 | 6 votes |
public Object invoke(Object self, Method method, Method proceed, Object[] args) throws Throwable { // simple delegate to delegate object if (method.getName() == "setResourceProvider" && args != null && args[0] != null && args[0] instanceof SingletonResourceProvider) { try { SingletonResourceProvider resourceProvider = (SingletonResourceProvider) args[0]; ClassLoader pluginClassLoader = delegate.getServiceClass().getClassLoader(); Object pluginInstance = PluginManager.getInstance().getPlugin(CxfJAXRSPlugin.class.getName(), pluginClassLoader); if (pluginInstance != null) { ReflectionHelper.invoke(pluginInstance, pluginInstance.getClass(), "registerServiceInstance", new Class[] {Object.class}, resourceProvider.getInstance(null)); } else { LOGGER.error("registerServiceInstance() CxfJAXRSPlugin not found in classLoader {}", pluginClassLoader); } } catch (Exception e) { LOGGER.error("registerServiceInstance() exception {}", e); } } return method.invoke(delegate, args); }
Example #19
Source File: JAXRSUtilsTest.java From cxf with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Test public void testSingletonHttpResourceFields() throws Exception { ClassResourceInfo cri = new ClassResourceInfo(Customer.class, true); Customer c = new Customer(); cri.setResourceProvider(new SingletonResourceProvider(c)); Message m = createMessage(); ServletContext servletContextMock = EasyMock.createNiceMock(ServletContext.class); m.put(AbstractHTTPDestination.HTTP_CONTEXT, servletContextMock); HttpServletRequest httpRequest = EasyMock.createNiceMock(HttpServletRequest.class); m.put(AbstractHTTPDestination.HTTP_REQUEST, httpRequest); HttpServletResponse httpResponse = EasyMock.createMock(HttpServletResponse.class); m.put(AbstractHTTPDestination.HTTP_RESPONSE, httpResponse); InjectionUtils.injectContextProxies(cri, cri.getResourceProvider().getInstance(null)); InjectionUtils.injectContextFields(c, cri, m); assertSame(servletContextMock, ((ThreadLocalProxy<ServletContext>)c.getServletContextResource()).get()); HttpServletRequest currentReq = ((ThreadLocalProxy<HttpServletRequest>)c.getServletRequestResource()).get(); assertSame(httpRequest, ((HttpServletRequestFilter)currentReq).getRequest()); HttpServletResponseFilter filter = ( HttpServletResponseFilter)((ThreadLocalProxy<HttpServletResponse>)c.getServletResponseResource()) .get(); assertSame(httpResponse, filter.getResponse()); }
Example #20
Source File: OpenApiCustomizerTest.java From cxf with Apache License 2.0 | 5 votes |
@Override protected void run() { final JAXRSServerFactoryBean sf = RuntimeDelegate .getInstance() .createEndpoint(new BookStoreApplication(), JAXRSServerFactoryBean.class); sf.setResourceClasses(BookStoreOpenApi.class); sf.setResourceClasses(BookStoreStylesheetsOpenApi.class); sf.setResourceProvider(BookStoreOpenApi.class, new SingletonResourceProvider(new BookStoreOpenApi())); sf.setProvider(new JacksonJsonProvider()); final OpenApiFeature feature = createOpenApiFeature(); sf.setFeatures(Arrays.asList(feature)); sf.setAddress("http://localhost:" + port + "/api"); sf.create(); }
Example #21
Source File: JAXRSServerFactoryBean.java From cxf with Apache License 2.0 | 5 votes |
protected void updateClassResourceProviders(Endpoint ep) { for (ClassResourceInfo cri : serviceFactory.getClassResourceInfo()) { if (cri.getResourceProvider() == null) { ResourceProvider rp = resourceProviders.get(cri.getResourceClass()); if (rp != null) { cri.setResourceProvider(rp); } else { setDefaultResourceProvider(cri); } } if (cri.getResourceProvider() instanceof SingletonResourceProvider) { ((SingletonResourceProvider)cri.getResourceProvider()).init(ep); } } }
Example #22
Source File: RxJava2FlowableServer.java From cxf with Apache License 2.0 | 5 votes |
private JAXRSServerFactoryBean createFactoryBean(Bus bus, boolean useStreamingSubscriber, String relAddress) { JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.getProperties(true).put("useStreamingSubscriber", useStreamingSubscriber); sf.setProvider(new JacksonJsonProvider()); new ReactiveIOCustomizer().customize(sf); sf.getOutInterceptors().add(new LoggingOutInterceptor()); sf.setResourceClasses(RxJava2FlowableService.class); sf.setResourceProvider(RxJava2FlowableService.class, new SingletonResourceProvider(new RxJava2FlowableService(), true)); sf.setAddress("http://localhost:" + PORT + relAddress); return sf; }
Example #23
Source File: OpenApiCustomizerSubclassTest.java From cxf with Apache License 2.0 | 5 votes |
@Override protected void run() { final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStoreOpenApi.class); sf.setResourceClasses(BookStoreStylesheetsOpenApi.class); sf.setResourceProvider(BookStoreOpenApi.class, new SingletonResourceProvider(new BookStoreOpenApi())); sf.setProvider(new JacksonJsonProvider()); final OpenApiFeature feature = createOpenApiFeature(); sf.setFeatures(Arrays.asList(feature)); sf.setAddress("http://localhost:" + port + "/"); sf.create(); }
Example #24
Source File: AbstractOpenApiServiceDescriptionTest.java From cxf with Apache License 2.0 | 5 votes |
@Override protected void run() { final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStoreOpenApi.class); sf.setResourceClasses(BookStoreStylesheetsOpenApi.class); sf.setResourceProvider(BookStoreOpenApi.class, new SingletonResourceProvider(new BookStoreOpenApi())); sf.setProvider(new JacksonJsonProvider()); final OpenApiFeature feature = createOpenApiFeature(); sf.setFeatures(Arrays.asList(feature)); sf.setAddress("http://localhost:" + port + "/"); sf.create(); }
Example #25
Source File: SwaggerToOpenApiConversionTest.java From cxf with Apache License 2.0 | 5 votes |
@Override protected void run() { final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStoreSwagger2.class); sf.setResourceProvider(BookStoreSwagger2.class, new SingletonResourceProvider(new BookStoreSwagger2())); sf.setProvider(new SwaggerToOpenApiConversionFilter()); final Swagger2Feature feature = createSwagger2Feature(); sf.setFeatures(Arrays.asList(feature)); sf.setAddress("http://localhost:" + PORT + "/"); sf.create(); }
Example #26
Source File: SwaggerUiConfigurationTest.java From cxf with Apache License 2.0 | 5 votes |
@Override protected void run() { final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStoreSwagger2.class); sf.setResourceProvider(BookStoreSwagger2.class, new SingletonResourceProvider(new BookStoreSwagger2())); sf.setProvider(new JacksonJsonProvider()); final Swagger2Feature feature = new Swagger2Feature(); feature.setRunAsFilter(false); feature.setSwaggerUiConfig(new SwaggerUiConfig().url("/swagger.json")); sf.setFeatures(Arrays.asList(feature)); sf.setAddress("http://localhost:" + PORT + "/"); sf.create(); }
Example #27
Source File: AbstractSwagger2ServiceDescriptionTest.java From cxf with Apache License 2.0 | 5 votes |
@Override protected void run() { final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStoreSwagger2.class); sf.setResourceClasses(BookStoreStylesheetsSwagger2.class); sf.setResourceProvider(BookStoreSwagger2.class, new SingletonResourceProvider(new BookStoreSwagger2())); sf.setProvider(new JacksonJsonProvider()); final Swagger2Feature feature = createSwagger2Feature(); sf.setFeatures(Arrays.asList(feature)); sf.setAddress("http://localhost:" + port + "/"); sf.setExtensionMappings( Collections.singletonMap("json", "application/json;charset=UTF-8")); sf.create(); }
Example #28
Source File: JsrJsonpProviderTest.java From cxf with Apache License 2.0 | 5 votes |
protected void run() { final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookJsonStore.class); sf.setResourceProvider(BookJsonStore.class, new SingletonResourceProvider(new BookJsonStore())); sf.setProvider(new JsrJsonpProvider()); sf.setAddress("http://localhost:" + PORT + "/"); sf.create(); }
Example #29
Source File: Server.java From cxf with Apache License 2.0 | 5 votes |
private void createEndpoint(String address) { JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStore.class); sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore(), false)); sf.setAddress(address); servers.add(sf.create()); }
Example #30
Source File: CompletableFutureServer.java From cxf with Apache License 2.0 | 5 votes |
protected void run() { Bus bus = BusFactory.getDefaultBus(); setBus(bus); JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setBus(bus); sf.setResourceClasses(CompletableFutureService.class); sf.setResourceProvider(CompletableFutureService.class, new SingletonResourceProvider(new CompletableFutureService(), true)); sf.setAddress("http://localhost:" + PORT + "/"); sf.setProvider(new MappedExceptionMapper()); server = sf.create(); BusFactory.setDefaultBus(null); BusFactory.setThreadDefaultBus(null); }