Signalling of dependent services Also proper signalling of default application
Project: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/repo Commit: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/commit/3b810136 Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/3b810136 Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/3b810136 Branch: refs/heads/master Commit: 3b810136d4855cad655836e497854c516b74b6c2 Parents: b05a86a Author: Carlos Sierra <[email protected]> Authored: Thu Aug 24 18:58:35 2017 +0200 Committer: Carlos Sierra <[email protected]> Committed: Thu Aug 24 18:58:35 2017 +0200 ---------------------------------------------------------------------- jax-rs.itests/src/main/java/test/JaxrsTest.java | 95 +++++++++++++++----- .../internal/AriesJaxRSServiceRuntime.java | 55 +++++++++--- .../aries/jax/rs/whiteboard/internal/Utils.java | 4 - .../jax/rs/whiteboard/internal/Whiteboard.java | 68 ++++++++++---- 4 files changed, 165 insertions(+), 57 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/3b810136/jax-rs.itests/src/main/java/test/JaxrsTest.java ---------------------------------------------------------------------- diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java b/jax-rs.itests/src/main/java/test/JaxrsTest.java index 6491ec3..1ed4a6c 100644 --- a/jax-rs.itests/src/main/java/test/JaxrsTest.java +++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java @@ -25,7 +25,6 @@ import java.util.Hashtable; import java.util.Set; import org.junit.After; -import org.junit.Ignore; import org.junit.Test; import org.osgi.framework.Bundle; import org.osgi.framework.PrototypeServiceFactory; @@ -74,12 +73,12 @@ public class JaxrsTest extends TestHelper { assertNotNull(runtime); - assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length); serviceRegistration = registerApplication( new TestApplication()); - assertEquals(2, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); Client client = createClient(); @@ -107,7 +106,7 @@ public class JaxrsTest extends TestHelper { RuntimeDTO runtimeDTO = runtime.getRuntimeDTO(); - assertEquals(1, runtimeDTO.applicationDTOs.length); + assertEquals(0, runtimeDTO.applicationDTOs.length); assertEquals(0, runtimeDTO.failedExtensionDTOs.length); ServiceRegistration<?> serviceRegistration = registerApplication( @@ -122,7 +121,7 @@ public class JaxrsTest extends TestHelper { runtimeDTO = runtime.getRuntimeDTO(); - assertEquals(1, runtimeDTO.applicationDTOs.length); + assertEquals(0, runtimeDTO.applicationDTOs.length); assertEquals(1, runtimeDTO.failedApplicationDTOs.length); assertEquals( DTOConstants.FAILURE_REASON_UNKNOWN, @@ -140,7 +139,7 @@ public class JaxrsTest extends TestHelper { runtimeDTO = runtime.getRuntimeDTO(); - assertEquals(1, runtimeDTO.applicationDTOs.length); + assertEquals(0, runtimeDTO.applicationDTOs.length); assertEquals(0, runtimeDTO.failedApplicationDTOs.length); } @@ -287,12 +286,12 @@ public class JaxrsTest extends TestHelper { ServiceRegistration<?> serviceRegistration2; try { - assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length); assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length); serviceRegistration = registerApplication(new TestApplication()); - assertEquals(2, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length); Response response = webTarget.request().get(); @@ -304,7 +303,7 @@ public class JaxrsTest extends TestHelper { serviceRegistration2 = registerApplication( new TestApplicationConflict(), "service.ranking", 1); - assertEquals(2, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); assertEquals(1, runtime.getRuntimeDTO().failedApplicationDTOs.length); response = webTarget.request().get(); @@ -319,7 +318,7 @@ public class JaxrsTest extends TestHelper { serviceRegistration2.unregister(); - assertEquals(2, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length); response = webTarget.request().get(); @@ -531,13 +530,13 @@ public class JaxrsTest extends TestHelper { JaxRSServiceRuntime runtime = getJaxRSServiceRuntime(); - assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length); assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length); ServiceRegistration<Application> serviceRegistration = registerApplication(new TestApplication()); - assertEquals(2, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length); assertEquals( @@ -547,7 +546,7 @@ public class JaxrsTest extends TestHelper { ServiceRegistration<Application> ungettableServiceRegistration = registerUngettableApplication("service.ranking", 1); - assertEquals(2, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); assertEquals(1, runtime.getRuntimeDTO().failedApplicationDTOs.length); assertEquals( @@ -560,14 +559,14 @@ public class JaxrsTest extends TestHelper { serviceRegistration.unregister(); - assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length); assertEquals(1, runtime.getRuntimeDTO().failedApplicationDTOs.length); assertEquals(404, webTarget.request().get().getStatus()); ungettableServiceRegistration.unregister(); - assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length); assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length); } @@ -583,13 +582,13 @@ public class JaxrsTest extends TestHelper { JaxRSServiceRuntime runtime = getJaxRSServiceRuntime(); - assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length); assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length); ServiceRegistration<Application> serviceRegistration = registerApplication(new TestApplication()); - assertEquals(2, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length); assertEquals( @@ -599,7 +598,7 @@ public class JaxrsTest extends TestHelper { ServiceRegistration<Application> ungettableServiceRegistration = registerUngettableApplication("service.ranking", -1); - assertEquals(2, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); assertEquals(1, runtime.getRuntimeDTO().failedApplicationDTOs.length); assertEquals( @@ -612,14 +611,14 @@ public class JaxrsTest extends TestHelper { serviceRegistration.unregister(); - assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length); assertEquals(1, runtime.getRuntimeDTO().failedApplicationDTOs.length); assertEquals(404, webTarget.request().get().getStatus()); ungettableServiceRegistration.unregister(); - assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length); assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length); } @@ -627,13 +626,13 @@ public class JaxrsTest extends TestHelper { public void testNotGettableApplication() throws InterruptedException { JaxRSServiceRuntime runtime = getJaxRSServiceRuntime(); - assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length); assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length); ServiceRegistration<Application> serviceRegistration = registerUngettableApplication(); - assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length); assertEquals(1, runtime.getRuntimeDTO().failedApplicationDTOs.length); assertEquals( @@ -642,7 +641,7 @@ public class JaxrsTest extends TestHelper { serviceRegistration.unregister(); - assertEquals(1, runtime.getRuntimeDTO().applicationDTOs.length); + assertEquals(0, runtime.getRuntimeDTO().applicationDTOs.length); assertEquals(0, runtime.getRuntimeDTO().failedApplicationDTOs.length); } @@ -763,13 +762,17 @@ public class JaxrsTest extends TestHelper { } @Test - public void testStandaloneEndpointWithExtensionsDependencies() { + public void testStandaloneEndpointWithExtensionsDependencies() + throws InterruptedException { + Client client = createClient(); WebTarget webTarget = client. target("http://localhost:8080"). path("test"); + JaxRSServiceRuntime runtime = getJaxRSServiceRuntime(); + ServiceRegistration<?> serviceRegistration = null; ServiceRegistration<?> extensionRegistration1; ServiceRegistration<?> extensionRegistration2; @@ -782,16 +785,36 @@ public class JaxrsTest extends TestHelper { "(property two=two)", }); + RuntimeDTO runtimeDTO = runtime.getRuntimeDTO(); + + assertEquals(1, runtimeDTO.failedResourceDTOs.length); + assertEquals( + (long)serviceRegistration.getReference().getProperty( + "service.id"), + runtimeDTO.failedResourceDTOs[0].serviceId); + assertEquals(404, webTarget.request().get().getStatus()); extensionRegistration1 = registerExtension( "aExtension", "property one", "one"); + runtimeDTO = runtime.getRuntimeDTO(); + + assertEquals(1, runtimeDTO.failedResourceDTOs.length); + assertEquals( + (long)serviceRegistration.getReference().getProperty( + "service.id"), + runtimeDTO.failedResourceDTOs[0].serviceId); + assertEquals(404, webTarget.request().get().getStatus()); extensionRegistration2 = registerExtension( "anotherExtension", "property two", "two"); + runtimeDTO = runtime.getRuntimeDTO(); + + assertEquals(0, runtimeDTO.failedResourceDTOs.length); + Response response = webTarget.request().get(); assertEquals( @@ -800,20 +823,44 @@ public class JaxrsTest extends TestHelper { extensionRegistration1.unregister(); + runtimeDTO = runtime.getRuntimeDTO(); + assertEquals(1, runtimeDTO.failedResourceDTOs.length); + assertEquals( + (long)serviceRegistration.getReference().getProperty( + "service.id"), + runtimeDTO.failedResourceDTOs[0].serviceId); + assertEquals(404, webTarget.request().get().getStatus()); extensionRegistration1 = registerExtension( "aExtension", "property one", "one"); + runtimeDTO = runtime.getRuntimeDTO(); + assertEquals(0, runtimeDTO.failedResourceDTOs.length); + assertEquals( "This should say hello", "Hello test", response.readEntity(String.class)); extensionRegistration2.unregister(); + runtimeDTO = runtime.getRuntimeDTO(); + assertEquals(1, runtimeDTO.failedResourceDTOs.length); + assertEquals( + (long)serviceRegistration.getReference().getProperty( + "service.id"), + runtimeDTO.failedResourceDTOs[0].serviceId); + assertEquals(404, webTarget.request().get().getStatus()); extensionRegistration1.unregister(); + + runtimeDTO = runtime.getRuntimeDTO(); + assertEquals(1, runtimeDTO.failedResourceDTOs.length); + assertEquals( + (long)serviceRegistration.getReference().getProperty( + "service.id"), + runtimeDTO.failedResourceDTOs[0].serviceId); } finally { if (serviceRegistration != null) { http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/3b810136/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java ---------------------------------------------------------------------- diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java index c680f3c..a098f82 100644 --- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java +++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AriesJaxRSServiceRuntime.java @@ -32,6 +32,7 @@ import org.osgi.service.jaxrs.runtime.dto.RuntimeDTO; import org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants; import javax.ws.rs.core.Application; +import java.util.Collections; import java.util.Map; import java.util.Set; import java.util.TreeSet; @@ -39,6 +40,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; import static org.apache.aries.jax.rs.whiteboard.internal.Utils.generateApplicationName; +import static org.apache.aries.jax.rs.whiteboard.internal.Whiteboard.getApplicationBase; import static org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants.JAX_RS_NAME; public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime { @@ -66,6 +68,21 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime { private TreeSet<ServiceReference<?>> _ungettableEndpoints = new TreeSet<>(); private TreeSet<ServiceReference<?>> _ungettableExtensions = new TreeSet<>(); + private TreeSet<ServiceReference<?>> _dependentServices = new TreeSet<>(); + private Map<String, Object> _defaultApplicationProperties; + + public void addDependentService(ServiceReference<?> serviceReference) { + _dependentServices.add(serviceReference); + } + + public void clearDefaultApplication() { + _defaultApplicationProperties = Collections.emptyMap(); + } + + public void removeDependentService(ServiceReference<?> serviceReference) { + _dependentServices.remove(serviceReference); + } + public void addErroredApplication( ServiceReference<Application> serviceReference) { @@ -120,6 +137,12 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime { return _applications.put(path, properties); } + public void setDefaultApplication(Map<String, Object> properties) { + _defaultApplicationProperties = properties; + + _applications.put(getApplicationBase(properties::get), properties); + } + public Map<String, Object> unsetApplicationForPath(String path) { return _applications.remove(path); } @@ -200,6 +223,9 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime { public RuntimeDTO getRuntimeDTO() { RuntimeDTO runtimeDTO = new RuntimeDTO(); + runtimeDTO.defaultApplication = buildApplicationDTO( + _defaultApplicationProperties); + runtimeDTO.applicationDTOs = applicationDTOStream(). toArray( ApplicationDTO[]::new @@ -214,12 +240,12 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime { FailedApplicationDTO[]::new ); - runtimeDTO.failedResourceDTOs = unreferenciableEndpointsDTOStream().map( - sr -> buildFailedResourceDTO( - DTOConstants.FAILURE_REASON_SERVICE_NOT_GETTABLE, sr) - ).toArray( - FailedResourceDTO[]::new - ); + runtimeDTO.failedResourceDTOs = + Stream.concat( + unreferenciableEndpointsDTOStream(), dependentServiceStreamDTO() + ).toArray( + FailedResourceDTO[]::new + ); runtimeDTO.failedExtensionDTOs = unreferenciableExtensionsDTOStream().map( sr -> buildFailedExtensionDTO( @@ -231,6 +257,12 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime { return runtimeDTO; } + private Stream<FailedResourceDTO> dependentServiceStreamDTO() { + return _dependentServices.stream().map( + sr -> buildFailedResourceDTO( + DTOConstants.FAILURE_REASON_REQUIRED_EXTENSIONS_UNAVAILABLE, sr)); + } + private Stream<FailedApplicationDTO> erroredApplicationsDTOStream() { return _erroredApplications.stream().map( sr -> buildFailedApplicationDTO( @@ -266,12 +298,15 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime { return failedResourceDTO; } - private Stream<ServiceReference<?>> unreferenciableEndpointsDTOStream() { - return _ungettableEndpoints.stream(); + private Stream<FailedResourceDTO> unreferenciableEndpointsDTOStream() { + return _ungettableEndpoints.stream().map( + sr -> buildFailedResourceDTO( + DTOConstants.FAILURE_REASON_SERVICE_NOT_GETTABLE, sr)); } private Stream<ApplicationDTO> applicationDTOStream() { return _applications.values().stream(). + filter(p -> !(".default".equals(p.get(JAX_RS_NAME)))). map( this::buildApplicationDTO ); @@ -300,7 +335,7 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime { ApplicationDTO applicationDTO = new ApplicationDTO(){}; applicationDTO.name = getApplicationName(properties::get); - applicationDTO.base = Whiteboard.getApplicationBase(properties::get); + applicationDTO.base = getApplicationBase(properties::get); applicationDTO.serviceId = (Long)properties.get("service.id"); applicationDTO.resourceDTOs = getApplicationEndpointsStream( @@ -335,7 +370,7 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime { private Stream<ExtensionDTO> getApplicationExtensionsStream(String name) { Set<ServiceReference<?>> applicationExtensions = - _applicationEndpoints.get(name); + _applicationExtensions.get(name); Stream<ServiceReference<?>> applicationExtensionStream = applicationExtensions != null ? http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/3b810136/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java ---------------------------------------------------------------------- diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java index dd7530b..058c1a8 100644 --- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java +++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java @@ -36,7 +36,6 @@ import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; import java.util.function.Function; -import java.util.function.Supplier; import static org.apache.aries.osgi.functional.OSGi.bundleContext; import static org.apache.aries.osgi.functional.OSGi.just; @@ -149,9 +148,6 @@ public class Utils { "original.objectClass", serviceReference.getProperty("objectClass")); - properties.remove(JaxRSWhiteboardConstants.JAX_RS_EXTENSION); - properties.remove(JaxRSWhiteboardConstants.JAX_RS_RESOURCE); - return onlyGettables( just(serviceReference), http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/3b810136/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java ---------------------------------------------------------------------- diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java index b0968cb..5a586fc 100644 --- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java +++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java @@ -54,6 +54,7 @@ import static org.apache.aries.jax.rs.whiteboard.internal.Utils.highestPer; import static org.apache.aries.jax.rs.whiteboard.internal.Utils.onlyGettables; import static org.apache.aries.jax.rs.whiteboard.internal.Utils.safeRegisterGeneric; import static org.apache.aries.jax.rs.whiteboard.internal.Utils.service; +import static org.apache.aries.osgi.functional.OSGi.NOOP; import static org.apache.aries.osgi.functional.OSGi.all; import static org.apache.aries.osgi.functional.OSGi.bundleContext; import static org.apache.aries.osgi.functional.OSGi.just; @@ -100,11 +101,12 @@ public class Whiteboard { all( countChanges( whiteboardApplications( - runtimeReference, runtime, Maps.from(configuration)), + runtimeReference, runtime, configurationMap), counter), countChanges( whiteBoardApplicationSingletons( - runtimeReference, defaultApplicationReference, runtime), + bundleContext, runtimeReference, + defaultApplicationReference, runtime), counter) )))))); } @@ -125,14 +127,6 @@ public class Whiteboard { ); } - private static String buildExtensionFilter(String filter) { - filter = filter.replace("(objectClass=", "(original.objectClass="); - - return String.format( - "(&(objectClass=%s)%s)", - ApplicationExtensionRegistration.class.getName(), filter); - } - private static String[] canonicalize(Object propertyValue) { if (propertyValue == null) { return new String[0]; @@ -176,8 +170,8 @@ public class Whiteboard { bundleContext().flatMap(bundleContext -> just(createBus(bundleContext, configuration)).flatMap(bus -> registerCXFServletService(bus, "", configuration).foreach( - __ -> runtime.setApplicationForPath("/", properties), - __ -> runtime.unsetApplicationForPath("/")).then( + __ -> runtime.setDefaultApplication(properties), + __ -> runtime.clearDefaultApplication()).then( just(new CXFJaxRsServiceRegistrator(bus, new DefaultApplication())). flatMap(registrator -> just(new ApplicationReference(DEFAULT_NAME, registrator)) @@ -233,22 +227,54 @@ public class Whiteboard { } private static OSGi<?> waitForExtensionDependencies( - ServiceReference<?> serviceReference, AriesJaxRSServiceRuntime runtime, - OSGi<?> program) { + BundleContext bundleContext, + ServiceReference<?> serviceReference, + ApplicationReference applicationReference, + AriesJaxRSServiceRuntime runtime, OSGi<?> program) { String[] extensionDependencies = canonicalize( serviceReference.getProperty(JAX_RS_EXTENSION_SELECT)); + if (extensionDependencies.length > 0) { + runtime.addDependentService(serviceReference); + } + for (String extensionDependency : extensionDependencies) { - program = - serviceReferences(buildExtensionFilter(extensionDependency)). - then(program); + try { + extensionDependency = extensionDependency.replace( + "(objectClass=", "(original.objectClass="); + + Filter extensionFilter = bundleContext.createFilter( + extensionDependency); + + program = + serviceReferences(ApplicationExtensionRegistration.class). + filter( + sr -> getApplicationName(sr::getProperty).equals( + applicationReference.getApplicationName()) + ). + filter( + extensionFilter::match + ).foreach( + __ -> {}, + __ -> runtime.addDependentService(serviceReference) + ). + then(program); + } + catch (InvalidSyntaxException e) { + + } } + program = program.foreach( + __ -> runtime.removeDependentService(serviceReference) + ); + return program; } private static OSGi<?> whiteBoardApplicationSingletons( + BundleContext bundleContext, ServiceReference<?> jaxRsRuntimeServiceReference, ApplicationReference defaultApplicationReference, AriesJaxRSServiceRuntime runtime) { @@ -258,7 +284,8 @@ public class Whiteboard { flatMap(endpointReference -> chooseApplication(endpointReference, defaultApplicationReference). flatMap(applicationReference -> - waitForExtensionDependencies(endpointReference, runtime, + waitForExtensionDependencies( + bundleContext, endpointReference, applicationReference, runtime, safeRegisterGeneric( endpointReference, applicationReference.getApplicationName(), @@ -290,7 +317,10 @@ public class Whiteboard { } private static String getApplicationSingletonsFilter() { - return format("(|%s%s)", getExtensionsFilter(), getResourcesFilter()); + return format( + "(&(!(objectClass=%s))(|%s%s))", + ApplicationExtensionRegistration.class.getName(), + getExtensionsFilter(), getResourcesFilter()); } private static OSGi<?> whiteboardApplications(
