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 2017/11/22 18:20:00 UTC
[1/2] aries-jax-rs-whiteboard git commit: Properly register dependent
extensions
Repository: aries-jax-rs-whiteboard
Updated Branches:
refs/heads/master c086a9287 -> ad5e86177
Properly register dependent extensions
Also refactor the waitingForExtension functions to not having to pass
the next value as parameter because it is not necessary and made
everything even harder to read.
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/98f26c27
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/98f26c27
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/98f26c27
Branch: refs/heads/master
Commit: 98f26c278a551e853b978b3d7129e1a9d0db519e
Parents: c086a92
Author: Carlos Sierra <cs...@apache.org>
Authored: Wed Nov 22 19:15:41 2017 +0100
Committer: Carlos Sierra <cs...@apache.org>
Committed: Wed Nov 22 19:15:41 2017 +0100
----------------------------------------------------------------------
.../internal/AriesJaxRSServiceRuntime.java | 32 ++++++++++++---
.../jax/rs/whiteboard/internal/Whiteboard.java | 42 ++++++++++++--------
2 files changed, 53 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/98f26c27/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 0e714dc..edc8e32 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
@@ -105,6 +105,12 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
_dependentApplications.add(applicationReference);
}
+ public void addDependentExtension(
+ CachingServiceReference<?> cachingServiceReference) {
+
+ _dependentExtensions.add(cachingServiceReference);
+ }
+
public void addDependentService(CachingServiceReference<?> serviceReference) {
_dependentServices.add(serviceReference);
}
@@ -218,7 +224,8 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
applicationDependentExtensionsDTOStream(),
Stream.concat(
erroredExtensionsDTOStream(),
- invalidExtensionsDTOStream()))
+ Stream.concat(dependentExtensionsStreamDTO(),
+ invalidExtensionsDTOStream())))
).toArray(
FailedExtensionDTO[]::new
);
@@ -264,6 +271,12 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
_dependentApplications.remove(applicationReference);
}
+ public void removeDependentExtension(
+ CachingServiceReference<?> cachingServiceReference) {
+
+ _dependentExtensions.add(cachingServiceReference);
+ }
+
public void removeDependentService(CachingServiceReference<?> serviceReference) {
_dependentServices.remove(serviceReference);
}
@@ -339,14 +352,18 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
_ungettableApplications = new CopyOnWriteArrayList<>();
private Collection<CachingServiceReference<Application>> _shadowedApplications =
new CopyOnWriteArrayList<>();
- private Set<CachingServiceReference<Application>> _dependentApplications =
- ConcurrentHashMap.newKeySet();
private Set<CachingServiceReference<?>> _applicationDependentExtensions =
ConcurrentHashMap.newKeySet();
private Set<CachingServiceReference<?>> _applicationDependentResources =
ConcurrentHashMap.newKeySet();
private Collection<CachingServiceReference<Application>> _clashingApplications =
new CopyOnWriteArrayList<>();
+ private Set<CachingServiceReference<Application>> _dependentApplications =
+ ConcurrentHashMap.newKeySet();
+ private Set<CachingServiceReference<?>> _dependentExtensions =
+ ConcurrentHashMap.newKeySet();
+ private Set<CachingServiceReference<?>> _dependentServices =
+ ConcurrentHashMap.newKeySet();
private Collection<CachingServiceReference<Application>> _erroredApplications =
new CopyOnWriteArrayList<>();
private Collection<CachingServiceReference<?>> _erroredEndpoints =
@@ -357,8 +374,6 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
new CopyOnWriteArrayList<>();
private Collection<CachingServiceReference<?>> _ungettableExtensions =
new CopyOnWriteArrayList<>();
- private Set<CachingServiceReference<?>> _dependentServices =
- ConcurrentHashMap.newKeySet();
private Collection<CachingServiceReference<?>> _invalidExtensions =
new CopyOnWriteArrayList<>();
private volatile Map<String, Object> _defaultApplicationProperties;
@@ -521,6 +536,13 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
);
}
+ private Stream<FailedExtensionDTO> dependentExtensionsStreamDTO() {
+ return _dependentExtensions.stream().map(
+ sr -> buildFailedExtensionDTO(
+ DTOConstants.FAILURE_REASON_REQUIRED_EXTENSIONS_UNAVAILABLE,
+ sr));
+ }
+
private Stream<FailedResourceDTO> dependentServiceStreamDTO() {
return _dependentServices.stream().map(
sr -> buildFailedResourceDTO(
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/98f26c27/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 961c468..9eed2be 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
@@ -196,8 +196,11 @@ public class Whiteboard {
_runtime::removeApplicationDependentExtension).
flatMap(registratorReference ->
waitForExtensionDependencies(
- resourceReference,
- getApplicationName(registratorReference::getProperty),
+ resourceReference,
+ getApplicationName(registratorReference::getProperty),
+ _runtime::addDependentExtension,
+ _runtime::removeDependentExtension).
+ then(
safeRegisterExtension(resourceReference, registratorReference)
)));
}
@@ -214,16 +217,18 @@ public class Whiteboard {
waitForExtensionDependencies(
resourceReference,
getApplicationName(registratorReference::getProperty),
- safeRegisterEndpoint(resourceReference, registratorReference)
- )));
+ _runtime::addDependentService,
+ _runtime::removeDependentService).
+ then(
+ safeRegisterEndpoint(resourceReference, registratorReference)
+ )));
}
private OSGi<?> applications() {
OSGi<CachingServiceReference<Application>> applicationsForWhiteboard =
- countChanges(
- getApplicationsForWhiteboard(), _counter).
- flatMap(
- sr -> waitForApplicationDependencies(sr, just(sr)));
+ countChanges(getApplicationsForWhiteboard(), _counter).flatMap(
+ this::waitForApplicationDependencies
+ );
OSGi<CachingServiceReference<Application>> highestRankedPerName =
highestPer(
@@ -495,12 +500,14 @@ public class Whiteboard {
private OSGi<CachingServiceReference<Application>>
waitForApplicationDependencies(
- CachingServiceReference<Application> applicationReference,
- OSGi<CachingServiceReference<Application>> program) {
+ CachingServiceReference<Application> applicationReference) {
String[] extensionDependencies = canonicalize(
applicationReference.getProperty(JAX_RS_EXTENSION_SELECT));
+ OSGi<CachingServiceReference<Application>> program = just(
+ applicationReference);
+
if (extensionDependencies.length > 0) {
program = effects(
() -> _runtime.addDependentApplication(applicationReference),
@@ -564,13 +571,16 @@ public class Whiteboard {
private OSGi<?> waitForExtensionDependencies(
CachingServiceReference<?> serviceReference, String applicationName,
- OSGi<?> program) {
+ Consumer<CachingServiceReference<?>> onAddingDependent,
+ Consumer<CachingServiceReference<?>> onRemovingDependent) {
String[] extensionDependencies = canonicalize(
serviceReference.getProperty(JAX_RS_EXTENSION_SELECT));
+ OSGi<CachingServiceReference<?>> program = just(serviceReference);
+
if (extensionDependencies.length > 0) {
- _runtime.addDependentService(serviceReference);
+ onAddingDependent.accept(serviceReference);
}
else {
return program;
@@ -596,7 +606,7 @@ public class Whiteboard {
)
).effects(
__ -> {},
- __ -> _runtime.addDependentService(serviceReference)
+ __ -> onAddingDependent.accept(serviceReference)
).
then(program);
}
@@ -606,11 +616,11 @@ public class Whiteboard {
}
program = onClose(
- () -> _runtime.removeDependentService(serviceReference)).
+ () -> onRemovingDependent.accept(serviceReference)).
then(program);
- program = program.foreach(
- __ -> _runtime.removeDependentService(serviceReference),
+ program = program.effects(
+ __ -> onRemovingDependent.accept(serviceReference),
__ -> {}
);
[2/2] aries-jax-rs-whiteboard git commit: Use only localhost for the
tests
Posted by cs...@apache.org.
Use only localhost for the tests
Also workarounds a bug that prevented the tests from working when no
other connection was available.
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/ad5e8617
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/ad5e8617
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/ad5e8617
Branch: refs/heads/master
Commit: ad5e861777836eb33fc95e3aa093763711d63f5b
Parents: 98f26c2
Author: Carlos Sierra <cs...@apache.org>
Authored: Wed Nov 22 19:16:47 2017 +0100
Committer: Carlos Sierra <cs...@apache.org>
Committed: Wed Nov 22 19:16:47 2017 +0100
----------------------------------------------------------------------
jax-rs.itests/itest.bndrun | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/ad5e8617/jax-rs.itests/itest.bndrun
----------------------------------------------------------------------
diff --git a/jax-rs.itests/itest.bndrun b/jax-rs.itests/itest.bndrun
index d1f4237..f55468a 100644
--- a/jax-rs.itests/itest.bndrun
+++ b/jax-rs.itests/itest.bndrun
@@ -17,6 +17,7 @@
logback.configurationFile=file:${.}/logback.xml,\
osgi.console.enable.builtin=false, \
osgi.console=, \
+ org.apache.felix.http.host=localhost,\
org.osgi.service.http.port=*
-runblacklist:\
osgi.identity;filter:='(osgi.identity=org.osgi.compendium)',\