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 2018/02/20 09:51:52 UTC
[2/3] aries-jax-rs-whiteboard git commit: Source formatting
Source formatting
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/1194bafd
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/1194bafd
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/1194bafd
Branch: refs/heads/master
Commit: 1194bafdc75565ba499f2666dc2adc834838f248
Parents: 0ab8db6
Author: Carlos Sierra <cs...@apache.org>
Authored: Tue Feb 20 09:44:17 2018 +0100
Committer: Carlos Sierra <cs...@apache.org>
Committed: Tue Feb 20 09:44:17 2018 +0100
----------------------------------------------------------------------
.../internal/AriesJaxrsServiceRuntime.java | 33 +++--
.../jax/rs/whiteboard/internal/Whiteboard.java | 136 ++++++++++---------
2 files changed, 91 insertions(+), 78 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/1194bafd/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 b40fedc..33638e1 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
@@ -710,7 +710,7 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
return failedExtensionDTO;
}
- private FailedResourceDTO buildFailedResourceDTO(
+ private static FailedResourceDTO buildFailedResourceDTO(
int reason, CachingServiceReference<?> serviceReference) {
FailedResourceDTO failedResourceDTO = new FailedResourceDTO();
@@ -849,6 +849,7 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
}
private static class EndpointRuntimeInformation {
+
public EndpointRuntimeInformation(
CachingServiceReference cachingServiceReference, Bus bus,
Class<?> aClass) {
@@ -862,7 +863,8 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
public int hashCode() {
return _cachingServiceReference.hashCode();
}
- CachingServiceReference _cachingServiceReference; Bus _bus;@Override
+
+ @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@@ -872,12 +874,15 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
return _cachingServiceReference.equals(
that._cachingServiceReference);
}
- Class<?> _class;
+ Bus _bus;
+ CachingServiceReference _cachingServiceReference;
+ Class<?> _class;
}
private static class ExtensionRuntimeInformation {
+
public ExtensionRuntimeInformation(
CachingServiceReference<?> cachingServiceReference,
Class<?> aClass) {
@@ -885,11 +890,13 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
_cachingServiceReference = cachingServiceReference;
_class = aClass;
}
- CachingServiceReference _cachingServiceReference; Class<?> _class;@Override
+
+ @Override
public int hashCode() {
return _cachingServiceReference.hashCode();
}
- @Override
+
+ @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@@ -900,11 +907,13 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
that._cachingServiceReference);
}
-
+ CachingServiceReference _cachingServiceReference;
+ Class<?> _class;
}
private static class ApplicationRuntimeInformation {
+
public ApplicationRuntimeInformation(
CachingServiceReference cachingServiceReference,
CxfJaxrsServiceRegistrator cxfJaxRsServiceRegistrator) {
@@ -912,11 +921,16 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
_cachingServiceReference = cachingServiceReference;
_cxfJaxRsServiceRegistrator = cxfJaxRsServiceRegistrator;
}
- CachingServiceReference _cachingServiceReference; CxfJaxrsServiceRegistrator _cxfJaxRsServiceRegistrator;@Override
+
+ CachingServiceReference _cachingServiceReference;
+ CxfJaxrsServiceRegistrator _cxfJaxRsServiceRegistrator;
+
+ @Override
public int hashCode() {
return _cachingServiceReference.hashCode();
}
- @Override
+
+ @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@@ -928,9 +942,6 @@ public class AriesJaxrsServiceRuntime implements JaxrsServiceRuntime {
that._cachingServiceReference);
}
-
-
-
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/1194bafd/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 b7e2433..ce38529 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
@@ -220,18 +220,21 @@ public class Whiteboard {
@SuppressWarnings("unchecked")
private OSGi<?> getAllServices() {
+ OSGi<CachingServiceReference<Object>> applicationsForWhiteboard =
+ (OSGi)getApplicationsForWhiteboard();
return
highestPer(
sr -> getApplicationName(sr::getProperty),
all(
countChanges(getResourcesForWhiteboard(), _counter),
- countChanges(getApplicationExtensionsForWhiteboard(), _counter),
- countChanges(getApplicationsForWhiteboard(), _counter)
+ countChanges(
+ getApplicationExtensionsForWhiteboard(), _counter),
+ countChanges(applicationsForWhiteboard, _counter)
),
this::registerShadowedService,
this::unregisterShadowedService
).distribute(
- p -> ignore(applications(p.filter(this::isApplication))),
+ p -> ignore(applications((OSGi)p.filter(this::isApplication))),
p -> ignore(applicationResources(p.filter(this::isResource))),
p -> ignore(applicationExtensions(p.filter(this::isExtension)))
);
@@ -274,12 +277,12 @@ public class Whiteboard {
}
private OSGi<?> applications(
- OSGi<CachingServiceReference<Object>> applications) {
+ OSGi<CachingServiceReference<Application>> applications) {
OSGi<CachingServiceReference<Application>> applicationsForWhiteboard =
- applications.flatMap(
- this::waitForApplicationDependencies
- );
+ waitForApplicationDependencies(
+ applications,
+ );
OSGi<CachingServiceReference<Application>> highestRankedPerPath =
highestPer(
@@ -394,11 +397,11 @@ public class Whiteboard {
filter(new TargetFilter<>(_runtimeReference));
}
- private OSGi<CachingServiceReference<Object>>
+ private OSGi<CachingServiceReference<Application>>
getApplicationsForWhiteboard() {
return
- serviceReferences(_applicationsFilter.toString()).
+ serviceReferences(Application.class, _applicationsFilter.toString()).
filter(new TargetFilter<>(_runtimeReference));
}
@@ -550,76 +553,75 @@ public class Whiteboard {
private OSGi<CachingServiceReference<Application>>
waitForApplicationDependencies(
- CachingServiceReference<?> objectReference) {
+ OSGi<CachingServiceReference<Application>> references) {
- String[] extensionDependencies = canonicalize(
- objectReference.getProperty(JAX_RS_EXTENSION_SELECT));
+ return references.flatMap(reference -> {
+ String[] extensionDependencies = canonicalize(
+ reference.getProperty(JAX_RS_EXTENSION_SELECT));
- CachingServiceReference<Application> applicationReference =
- (CachingServiceReference<Application>) objectReference;
+ OSGi<CachingServiceReference<Application>> program = just(
+ reference);
- OSGi<CachingServiceReference<Application>> program = just(
- applicationReference);
+ if (extensionDependencies.length > 0) {
+ program = effects(
+ () -> _runtime.addDependentApplication(reference),
+ () -> _runtime.removeDependentApplication(reference)
+ ).then(program);
+ }
+ else {
+ return program;
+ }
- if (extensionDependencies.length > 0) {
- program = effects(
- () -> _runtime.addDependentApplication(applicationReference),
- () -> _runtime.removeDependentApplication(applicationReference)
- ).then(program);
- }
- else {
- return program;
- }
+ for (String extensionDependency : extensionDependencies) {
+ extensionDependency = String.format(
+ "(&(!(objectClass=%s))%s)",
+ ApplicationExtensionRegistration.class.getName(),
+ extensionDependency);
- for (String extensionDependency : extensionDependencies) {
- extensionDependency = String.format(
- "(&(!(objectClass=%s))%s)",
- ApplicationExtensionRegistration.class.getName(),
- extensionDependency);
-
- program =
- once(serviceReferences(extensionDependency)).
- flatMap(
- sr -> {
- Object applicationSelectProperty =
- sr.getProperty(JAX_RS_APPLICATION_SELECT);
-
- if (applicationSelectProperty == null) {
- return just(applicationReference);
- }
+ program =
+ once(serviceReferences(extensionDependency)).
+ flatMap(
+ sr -> {
+ Object applicationSelectProperty =
+ sr.getProperty(JAX_RS_APPLICATION_SELECT);
- Filter filter;
+ if (applicationSelectProperty == null) {
+ return just(reference);
+ }
- try {
- filter = _bundleContext.createFilter(
- applicationSelectProperty.toString());
- }
- catch (InvalidSyntaxException e) {
- return nothing();
- }
+ Filter filter;
- if (filter.match(
- applicationReference.getServiceReference())) {
+ try {
+ filter = _bundleContext.createFilter(
+ applicationSelectProperty.toString());
+ }
+ catch (InvalidSyntaxException e) {
+ return nothing();
+ }
- return just(applicationReference);
- }
+ if (filter.match(
+ reference.getServiceReference())) {
- return nothing();
- }
- ).effects(
- __ -> {},
- __ -> _runtime.addDependentApplication(
- applicationReference)
- ).
- then(program);
- }
+ return just(reference);
+ }
- program = program.effects(
- __ -> _runtime.removeDependentApplication(applicationReference),
- __ -> {}
- );
+ return nothing();
+ }
+ ).effects(
+ __ -> {},
+ __ -> _runtime.addDependentApplication(
+ reference)
+ ).
+ then(program);
+ }
- return program;
+ program = program.effects(
+ __ -> _runtime.removeDependentApplication(reference),
+ __ -> {}
+ );
+
+ return program;
+ });
}
private OSGi<?> waitForExtensionDependencies(