You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cs...@apache.org on 2021/01/27 07:51:43 UTC
[aries-jax-rs-whiteboard] branch master updated: [ARIES-2032] Not
needed until we can pair converters to OpenAPI instances
This is an automated email from the ASF dual-hosted git repository.
csierra pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-jax-rs-whiteboard.git
The following commit(s) were added to refs/heads/master by this push:
new 9445244 [ARIES-2032] Not needed until we can pair converters to OpenAPI instances
9445244 is described below
commit 94452449af8f1c5e82f625ee6c3886c9aade487e
Author: Carlos Sierra Andrés <ca...@liferay.com>
AuthorDate: Wed Jan 27 08:50:42 2021 +0100
[ARIES-2032] Not needed until we can pair converters to OpenAPI instances
---
.../jax/rs/openapi/OpenApiBundleActivator.java | 103 ++-------------------
1 file changed, 10 insertions(+), 93 deletions(-)
diff --git a/integrations/openapi/openapi-resource/src/main/java/org/apache/aries/jax/rs/openapi/OpenApiBundleActivator.java b/integrations/openapi/openapi-resource/src/main/java/org/apache/aries/jax/rs/openapi/OpenApiBundleActivator.java
index df46287..4b8540d 100644
--- a/integrations/openapi/openapi-resource/src/main/java/org/apache/aries/jax/rs/openapi/OpenApiBundleActivator.java
+++ b/integrations/openapi/openapi-resource/src/main/java/org/apache/aries/jax/rs/openapi/OpenApiBundleActivator.java
@@ -27,7 +27,6 @@ import org.osgi.annotation.bundle.Header;
import org.osgi.framework.*;
import java.util.*;
-import java.util.stream.Collectors;
import static org.apache.aries.component.dsl.OSGi.*;
import static org.apache.aries.component.dsl.Utils.accumulate;
@@ -40,80 +39,9 @@ public class OpenApiBundleActivator implements BundleActivator {
private OSGiResult result;
- private static <T> OSGi<Set<T>> sequence(Set<OSGi<T>> list) {
- Set<T> objects = new HashSet<>();
-
- OSGi<Set<T>> result = just(() -> objects);
-
- for (OSGi<T> osgi : list) {
- result = osgi.effects(objects::add, objects::remove).then(result);
- }
-
- return result;
- }
-
- private static OpenAPIWithModelResolvers pairModelConverterWithOpenAPI(
- CachingServiceReference<OpenAPI> oasr, List<CachingServiceReference<ModelConverter>> mcsrs) {
-
- return new OpenAPIWithModelResolvers(
- oasr,
- mcsrs.stream().filter(
- mcsr -> filterModelConverter(oasr, mcsr)
- ).collect(
- Collectors.toSet()
- )
- );
- }
-
- private static boolean filterModelConverter(
- CachingServiceReference<OpenAPI> oasr,
- CachingServiceReference<ModelConverter> mcsr) {
-
- final String[] propertyValues = canonicalize(
- mcsr.getProperty("osgi.jaxrs.openapi.select"));
-
- for (String propertyValue : propertyValues) {
- if (propertyValue == null || propertyValue.isEmpty()) {
- continue;
- }
- try {
- Filter filter = FrameworkUtil.createFilter(propertyValue);
-
- if (filter.match(oasr.getServiceReference())) {
- return true;
- }
- } catch (InvalidSyntaxException ise) {
- //log
- continue;
- }
- }
-
- return false;
- }
-
- private static String[] canonicalize(Object propertyValue) {
- if (propertyValue == null) {
- return new String[0];
- }
- if (propertyValue instanceof String[]) {
- return (String[]) propertyValue;
- }
- if (propertyValue instanceof Collection) {
- return
- ((Collection<?>) propertyValue).stream().
- map(
- Object::toString
- ).toArray(
- String[]::new
- );
- }
-
- return new String[]{propertyValue.toString()};
- }
-
@Override
public void start(BundleContext bundleContext) throws Exception {
- final OSGi<?> modelConverters = services(
+ OSGi<?> modelConverters = services(
ModelConverter.class
).effects(
ModelConverters.getInstance()::addConverter,
@@ -124,31 +52,20 @@ public class OpenApiBundleActivator implements BundleActivator {
(openAPI, __) -> openAPI,
serviceReferences(OpenAPI.class),
accumulate(modelConverters)
- ).
- flatMap(openAPICachingServiceReference ->
- service(openAPICachingServiceReference).flatMap(openAPI ->
- register(
- Object.class,
- new OpenApiPrototypeServiceFactory(
- new PropertyWrapper(openAPICachingServiceReference), openAPI),
- () -> getProperties(openAPICachingServiceReference)
- )
+ ).flatMap(openAPICachingServiceReference ->
+ service(openAPICachingServiceReference).flatMap(openAPI ->
+ register(
+ Object.class,
+ new OpenApiPrototypeServiceFactory(
+ new PropertyWrapper(openAPICachingServiceReference), openAPI),
+ () -> getProperties(openAPICachingServiceReference)
)
- );
+ )
+ );
result = program.run(bundleContext);
}
- private Set<OSGi<ModelConverter>> lazilyGetModelConverters(
- OpenAPIWithModelResolvers openAPIWithModelConverters) {
-
- return openAPIWithModelConverters.
- getModelConverters().
- stream().
- map(OSGi::service).
- collect(Collectors.toSet());
- }
-
@Override
public void stop(BundleContext bundleContext) throws Exception {
result.close();