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()));
}
}
Aggregations