Search in sources :

Example 1 with Utils.getString

use of org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.getString in project aries-jax-rs-whiteboard by apache.

the class Whiteboard method getResourceProvider.

private static <T> OSGi<? extends ResourceProvider> getResourceProvider(ServiceTuple<T> serviceTuple) {
    CachingServiceReference<T> cachingServiceReference = serviceTuple.getCachingServiceReference();
    String scope = Utils.getString(cachingServiceReference.getProperty("service.scope"));
    if (Objects.equals(scope, "prototype")) {
        boolean applicationScoped = Boolean.parseBoolean(getString(cachingServiceReference.getProperty("org.apache.aries.jax.rs.whiteboard.application.scoped")));
        if (applicationScoped) {
            return just(serviceTuple.getServiceObjects().getService()).effects(__ -> {
            }, serviceTuple.getServiceObjects()::ungetService).map(service -> new SingletonServiceReferenceResourceProvider(cachingServiceReference, service));
        } else {
            return just(new PrototypeServiceReferenceResourceProvider(cachingServiceReference, serviceTuple.getService().getClass(), serviceTuple.getServiceObjects())).effects(__ -> {
            }, __ -> serviceTuple.dispose(), __ -> {
            }, __ -> {
            });
        }
    } else {
        return just(new SingletonServiceReferenceResourceProvider(serviceTuple.getCachingServiceReference(), serviceTuple.getService()));
    }
}
Also used : OSGi.serviceReferences(org.apache.aries.component.dsl.OSGi.serviceReferences) HTTP_WHITEBOARD_SERVLET_PATTERN(org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN) ServletContextHelper(org.osgi.service.http.context.ServletContextHelper) Utils.getApplicationProperties(org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.getApplicationProperties) ResourceProvider(org.apache.cxf.jaxrs.lifecycle.ResourceProvider) OSGi.effects(org.apache.aries.component.dsl.OSGi.effects) JAX_RS_RESOURCE(org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_RESOURCE) JAX_RS_EXTENSION(org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_EXTENSION) LoggerFactory(org.slf4j.LoggerFactory) ExceptionMapper(javax.ws.rs.ext.ExceptionMapper) MessageBodyWriter(javax.ws.rs.ext.MessageBodyWriter) Application(javax.ws.rs.core.Application) ContainerRequestFilter(javax.ws.rs.container.ContainerRequestFilter) ContainerResponseFilter(javax.ws.rs.container.ContainerResponseFilter) CxfJaxrsServiceRegistrator(org.apache.aries.jax.rs.whiteboard.internal.cxf.CxfJaxrsServiceRegistrator) JAX_RS_WHITEBOARD_TARGET(org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_WHITEBOARD_TARGET) ContextResolver(javax.ws.rs.ext.ContextResolver) CachingServiceReference(org.apache.aries.component.dsl.CachingServiceReference) Collectors.toMap(java.util.stream.Collectors.toMap) OSGiResult(org.apache.aries.component.dsl.OSGiResult) ReaderInterceptor(javax.ws.rs.ext.ReaderInterceptor) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) JAX_RS_DEFAULT_APPLICATION(org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_DEFAULT_APPLICATION) OSGi.just(org.apache.aries.component.dsl.OSGi.just) HTTP_WHITEBOARD_CONTEXT_SELECT(org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT) ParamConverterProvider(javax.ws.rs.ext.ParamConverterProvider) JaxrsServiceRuntime(org.osgi.service.jaxrs.runtime.JaxrsServiceRuntime) HTTP_WHITEBOARD_CONTEXT_PATH(org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH) HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED(org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED) HTTP_WHITEBOARD_SERVLET_NAME(org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME) LogUtils.ifErrorEnabled(org.apache.aries.jax.rs.whiteboard.internal.utils.LogUtils.ifErrorEnabled) Utils.onlyGettables(org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.onlyGettables) LogUtils.ifDebugEnabled(org.apache.aries.jax.rs.whiteboard.internal.utils.LogUtils.ifDebugEnabled) OSGi.register(org.apache.aries.component.dsl.OSGi.register) Utils.highest(org.apache.aries.component.dsl.Utils.highest) Servlet(javax.servlet.Servlet) SingletonServiceReferenceResourceProvider(org.apache.aries.jax.rs.whiteboard.internal.cxf.SingletonServiceReferenceResourceProvider) JAX_RS_APPLICATION_BASE(org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_APPLICATION_BASE) HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME(org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME) OSGi.changeContext(org.apache.aries.component.dsl.OSGi.changeContext) OSGi(org.apache.aries.component.dsl.OSGi) OSGi.once(org.apache.aries.component.dsl.OSGi.once) String.format(java.lang.String.format) Utils.getString(org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.getString) OSGi.all(org.apache.aries.component.dsl.OSGi.all) org.osgi.framework(org.osgi.framework) Utils.canonicalizeAddress(org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.canonicalizeAddress) DynamicFeature(javax.ws.rs.container.DynamicFeature) Stream(java.util.stream.Stream) HTTP_WHITEBOARD_TARGET(org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_TARGET) JAX_RS_SERVICE_ENDPOINT(org.osgi.service.jaxrs.runtime.JaxrsServiceRuntimeConstants.JAX_RS_SERVICE_ENDPOINT) ServiceTuple(org.apache.aries.jax.rs.whiteboard.internal.utils.ServiceTuple) OSGi.nothing(org.apache.aries.component.dsl.OSGi.nothing) SERVICE_PID(org.osgi.framework.Constants.SERVICE_PID) Utils(org.apache.aries.jax.rs.whiteboard.internal.utils.Utils) Bus(org.apache.cxf.Bus) Feature(javax.ws.rs.core.Feature) java.util(java.util) Utils.highestPer(org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.highestPer) JAX_RS_APPLICATION_SELECT(org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_APPLICATION_SELECT) AriesJaxrsServiceRuntime.getServiceName(org.apache.aries.jax.rs.whiteboard.internal.AriesJaxrsServiceRuntime.getServiceName) Function(java.util.function.Function) Supplier(java.util.function.Supplier) Utils.mergePropertyMaps(org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.mergePropertyMaps) Utils.updateProperty(org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.updateProperty) PropertyHolder(org.apache.aries.jax.rs.whiteboard.internal.utils.PropertyHolder) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) CXFNonSpringServlet(org.apache.cxf.transport.servlet.CXFNonSpringServlet) WriterInterceptor(javax.ws.rs.ext.WriterInterceptor) BundleWiring(org.osgi.framework.wiring.BundleWiring) PrototypeServiceReferenceResourceProvider(org.apache.aries.jax.rs.whiteboard.internal.cxf.PrototypeServiceReferenceResourceProvider) Logger(org.slf4j.Logger) Consumer(java.util.function.Consumer) HTTP_WHITEBOARD_CONTEXT_NAME(org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME) AtomicLong(java.util.concurrent.atomic.AtomicLong) JAX_RS_EXTENSION_SELECT(org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_EXTENSION_SELECT) Utils.canonicalize(org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.canonicalize) JAX_RS_NAME(org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_NAME) NOOP(org.apache.aries.component.dsl.OSGi.NOOP) Utils.accumulateInMap(org.apache.aries.component.dsl.Utils.accumulateInMap) MessageBodyReader(javax.ws.rs.ext.MessageBodyReader) OSGi.ignore(org.apache.aries.component.dsl.OSGi.ignore) SingletonServiceReferenceResourceProvider(org.apache.aries.jax.rs.whiteboard.internal.cxf.SingletonServiceReferenceResourceProvider) JAX_RS_WHITEBOARD_TARGET(org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_WHITEBOARD_TARGET) HTTP_WHITEBOARD_CONTEXT_SELECT(org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT) HTTP_WHITEBOARD_TARGET(org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_TARGET) JAX_RS_SERVICE_ENDPOINT(org.osgi.service.jaxrs.runtime.JaxrsServiceRuntimeConstants.JAX_RS_SERVICE_ENDPOINT) JAX_RS_APPLICATION_SELECT(org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_APPLICATION_SELECT) JAX_RS_EXTENSION_SELECT(org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.JAX_RS_EXTENSION_SELECT) PrototypeServiceReferenceResourceProvider(org.apache.aries.jax.rs.whiteboard.internal.cxf.PrototypeServiceReferenceResourceProvider) Utils.getString(org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.getString)

Aggregations

String.format (java.lang.String.format)1 java.util (java.util)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Supplier (java.util.function.Supplier)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 Stream (java.util.stream.Stream)1 Servlet (javax.servlet.Servlet)1 ContainerRequestFilter (javax.ws.rs.container.ContainerRequestFilter)1 ContainerResponseFilter (javax.ws.rs.container.ContainerResponseFilter)1 DynamicFeature (javax.ws.rs.container.DynamicFeature)1 Application (javax.ws.rs.core.Application)1 Feature (javax.ws.rs.core.Feature)1 ContextResolver (javax.ws.rs.ext.ContextResolver)1 ExceptionMapper (javax.ws.rs.ext.ExceptionMapper)1 MessageBodyReader (javax.ws.rs.ext.MessageBodyReader)1 MessageBodyWriter (javax.ws.rs.ext.MessageBodyWriter)1 ParamConverterProvider (javax.ws.rs.ext.ParamConverterProvider)1