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/09/14 07:29:26 UTC
[1/4] aries-jax-rs-whiteboard git commit: Source format
Repository: aries-jax-rs-whiteboard
Updated Branches:
refs/heads/master afbf0e4b6 -> e63d50e53
Source format
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/63ccf0be
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/63ccf0be
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/63ccf0be
Branch: refs/heads/master
Commit: 63ccf0bea1f959ac0117006aa10aaad98650c239
Parents: afbf0e4
Author: Carlos Sierra <cs...@apache.org>
Authored: Tue Sep 12 09:26:19 2017 +0200
Committer: Carlos Sierra <cs...@apache.org>
Committed: Tue Sep 12 09:26:19 2017 +0200
----------------------------------------------------------------------
jax-rs.itests/src/main/java/test/WhiteboardFactoryTest.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/63ccf0be/jax-rs.itests/src/main/java/test/WhiteboardFactoryTest.java
----------------------------------------------------------------------
diff --git a/jax-rs.itests/src/main/java/test/WhiteboardFactoryTest.java b/jax-rs.itests/src/main/java/test/WhiteboardFactoryTest.java
index 0f1bb86..a50c0bf 100644
--- a/jax-rs.itests/src/main/java/test/WhiteboardFactoryTest.java
+++ b/jax-rs.itests/src/main/java/test/WhiteboardFactoryTest.java
@@ -102,9 +102,9 @@ public class WhiteboardFactoryTest extends TestHelper {
}
}
+
+
private BundleContext bundleContext =
- FrameworkUtil.
- getBundle(getClass()).
- getBundleContext();
+ FrameworkUtil.getBundle(getClass()).getBundleContext();
}
\ No newline at end of file
[3/4] aries-jax-rs-whiteboard git commit: These are independent
Posted by cs...@apache.org.
These are independent
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/a7c3e429
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/a7c3e429
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/a7c3e429
Branch: refs/heads/master
Commit: a7c3e4293e5b2d2b1d89c01c57fb675e80afd156
Parents: 421697c
Author: Carlos Sierra <cs...@apache.org>
Authored: Tue Sep 12 09:27:23 2017 +0200
Committer: Carlos Sierra <cs...@apache.org>
Committed: Tue Sep 12 09:27:23 2017 +0200
----------------------------------------------------------------------
.../whiteboard/activator/CXFJaxRsBundleActivator.java | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/a7c3e429/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
index effd182..3c4359e 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
@@ -24,6 +24,7 @@ import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.ext.RuntimeDelegate;
import org.apache.aries.jax.rs.whiteboard.internal.ClientBuilderFactory;
+import org.apache.aries.jax.rs.whiteboard.internal.Utils;
import org.apache.aries.jax.rs.whiteboard.internal.Whiteboard;
import org.apache.aries.osgi.functional.OSGi;
import org.apache.aries.osgi.functional.OSGiResult;
@@ -34,7 +35,9 @@ import org.osgi.framework.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.apache.aries.jax.rs.whiteboard.internal.Utils.ignoreResult;
import static org.apache.aries.jax.rs.whiteboard.internal.Whiteboard.createWhiteboard;
+import static org.apache.aries.osgi.functional.OSGi.all;
import static org.apache.aries.osgi.functional.OSGi.configurations;
import static org.apache.aries.osgi.functional.OSGi.just;
import static org.apache.aries.osgi.functional.OSGi.onClose;
@@ -72,9 +75,12 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
"org.apache.aries.jax.rs.whiteboard.default");
_defaultOSGiResult =
- register(
- ClientBuilder.class, new ClientBuilderFactory(), null).then(
- runWhiteboard(bundleContext, defaultConfiguration))
+ all(
+ ignoreResult(
+ register(
+ ClientBuilder.class, new ClientBuilderFactory(), null)),
+ ignoreResult(runWhiteboard(bundleContext, defaultConfiguration))
+ )
.run(bundleContext);
if (_log.isDebugEnabled()) {
[2/4] aries-jax-rs-whiteboard git commit: This can be static
Posted by cs...@apache.org.
This can be static
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/421697c1
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/421697c1
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/421697c1
Branch: refs/heads/master
Commit: 421697c1cf763202e1bece97c9aa04d412b1e210
Parents: 63ccf0b
Author: Carlos Sierra <cs...@apache.org>
Authored: Tue Sep 12 09:26:42 2017 +0200
Committer: Carlos Sierra <cs...@apache.org>
Committed: Tue Sep 12 09:26:42 2017 +0200
----------------------------------------------------------------------
.../java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/421697c1/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 d278e4e..c4967cc 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
@@ -186,7 +186,7 @@ public class Utils {
serviceRegistration.setProperties(properties);
}
- static OSGi<Void> ignoreResult(OSGi<?> program) {
+ public static OSGi<Void> ignoreResult(OSGi<?> program) {
return program.map(t -> null);
}
[4/4] aries-jax-rs-whiteboard git commit: Apply lazyness
Posted by cs...@apache.org.
Apply lazyness
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/e63d50e5
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/e63d50e5
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/e63d50e5
Branch: refs/heads/master
Commit: e63d50e5364668b6546276b98baf3fa6f7d5de70
Parents: a7c3e42
Author: Carlos Sierra <cs...@apache.org>
Authored: Tue Sep 12 09:28:36 2017 +0200
Committer: Carlos Sierra <cs...@apache.org>
Committed: Tue Sep 12 09:28:36 2017 +0200
----------------------------------------------------------------------
.../jax/rs/whiteboard/internal/Whiteboard.java | 192 ++++++++++---------
1 file changed, 101 insertions(+), 91 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/e63d50e5/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 76b3d89..279d2ae 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
@@ -79,6 +79,7 @@ import static org.apache.aries.jax.rs.whiteboard.internal.Utils.service;
import static org.apache.aries.jax.rs.whiteboard.internal.Utils.serviceObjects;
import static org.apache.aries.jax.rs.whiteboard.internal.Utils.updateProperty;
import static org.apache.aries.osgi.functional.OSGi.all;
+import static org.apache.aries.osgi.functional.OSGi.join;
import static org.apache.aries.osgi.functional.OSGi.just;
import static org.apache.aries.osgi.functional.OSGi.nothing;
import static org.apache.aries.osgi.functional.OSGi.onClose;
@@ -248,8 +249,7 @@ public class Whiteboard {
return
highestRankedPerPath.flatMap(
- tuple -> deployApplication(
- _configurationMap, _bundleContext, tuple, _runtime)
+ this::deployApplication
).map(
ServiceTuple::getServiceReference
).map(
@@ -296,6 +296,21 @@ public class Whiteboard {
);
}
+ private ExtensionManagerBus createBus() {
+ BundleWiring wiring = _bundleContext.getBundle().adapt(
+ BundleWiring.class);
+
+ @SuppressWarnings("unchecked")
+ Map<String, Object> properties = new HashMap<>(_configurationMap);
+
+ ExtensionManagerBus bus = new ExtensionManagerBus(
+ null, properties, wiring.getClassLoader());
+
+ bus.initialize();
+
+ return bus;
+ }
+
private OSGi<ServiceReference<CXFJaxRsServiceRegistrator>>
defaultApplication() {
@@ -311,6 +326,63 @@ public class Whiteboard {
);
}
+ private OSGi<ServiceTuple<Application>> deployApplication(
+ ServiceTuple<Application> tuple) {
+
+ return
+ just(this::createBus).flatMap(bus ->
+ just(() -> {
+ ServiceReference<Application> serviceReference =
+ tuple.getServiceReference();
+
+ Map<String, Object> properties = getProperties(
+ serviceReference);
+
+ properties.computeIfAbsent(
+ JAX_RS_NAME, (__) -> generateApplicationName(
+ serviceReference::getProperty));
+
+ return properties;
+ }).flatMap(properties ->
+ deployRegistrator(bus, tuple, properties).then(
+ registerCXFServletService(
+ bus, getApplicationBase(properties::get), properties)).then(
+ just(tuple)
+ )));
+ }
+
+ private OSGi<?> deployRegistrator(
+ Bus bus, ServiceTuple<Application> tuple, Map<String, Object> props) {
+
+ return
+ join(just(() -> {
+ try {
+ CXFJaxRsServiceRegistrator registrator =
+ new CXFJaxRsServiceRegistrator(bus, tuple.getService());
+
+ return
+ onClose(registrator::close).then(
+ register(
+ CXFJaxRsServiceRegistrator.class, registrator,
+ props)
+ );
+ }
+ catch (RuntimeException e) {
+ ServiceReference<Application> serviceReference =
+ tuple.getServiceReference();
+
+ _runtime.addErroredApplication(serviceReference);
+
+ return onClose(
+ () ->
+ _runtime.removeErroredApplication(serviceReference)
+ ).then(
+ nothing()
+ );
+ }
+ }));
+ }
+
private OSGi<ServiceReference<Object>>
getApplicationExtensionsForWhiteboard() {
@@ -335,13 +407,18 @@ public class Whiteboard {
private OSGi<ServiceRegistration<Application>>
registerDefaultApplication() {
- Map<String, Object> properties = new HashMap<>(_configurationMap);
- properties.put(JAX_RS_NAME, DEFAULT_NAME);
- properties.put(JAX_RS_APPLICATION_BASE, "/");
- properties.put("service.ranking", Integer.MIN_VALUE);
+ return
+ just(() -> {
+ Map<String, Object> properties = new HashMap<>(
+ _configurationMap);
+ properties.put(JAX_RS_NAME, DEFAULT_NAME);
+ properties.put(JAX_RS_APPLICATION_BASE, "/");
+ properties.put("service.ranking", Integer.MIN_VALUE);
- return register(
- Application.class, new DefaultApplication(), properties);
+ return properties;
+ }).flatMap(properties ->
+ register(
+ Application.class, new DefaultApplication(), properties));
}
private ServiceRegistration<?>
@@ -398,17 +475,20 @@ public class Whiteboard {
ServiceReference<?> serviceReference,
ServiceReference<CXFJaxRsServiceRegistrator> registratorReference) {
- Map<String, Object> properties = getProperties(serviceReference);
-
- String applicationName = getApplicationName(
- registratorReference::getProperty);
-
- properties.put(JAX_RS_NAME, applicationName);
- properties.put(
- "original.objectClass",
- serviceReference.getProperty("objectClass"));
-
return
+ just(() -> getApplicationName(registratorReference::getProperty)).
+ flatMap(applicationName ->
+ just(() ->{
+ Map<String, Object> properties = getProperties(
+ serviceReference);
+
+ properties.put(JAX_RS_NAME, applicationName);
+ properties.put(
+ "original.objectClass",
+ serviceReference.getProperty("objectClass"));
+
+ return properties;
+ }).flatMap(properties ->
service(registratorReference).flatMap(registrator ->
onlyGettables(
just(serviceReference),
@@ -426,7 +506,7 @@ public class Whiteboard {
register(
ApplicationExtensionRegistration.class,
new ApplicationExtensionRegistration(){}, properties)
- ));
+ ))));
}
private OSGi<ServiceReference<Application>>
@@ -591,82 +671,12 @@ public class Whiteboard {
return program.map(t -> {counter.inc(); return t;});
}
- private static ExtensionManagerBus createBus(
- BundleContext bundleContext, Map<String, ?> configuration) {
-
- BundleWiring wiring = bundleContext.getBundle().adapt(
- BundleWiring.class);
-
- @SuppressWarnings("unchecked")
- Map<String, Object> properties = (Map<String, Object>)configuration;
-
- properties.put("org.apache.cxf.bus.id", configuration.get(
- Constants.SERVICE_PID));
-
- ExtensionManagerBus bus = new ExtensionManagerBus(
- null, properties, wiring.getClassLoader());
-
- bus.initialize();
-
- return bus;
- }
-
private static CXFNonSpringServlet createCXFServlet(Bus bus) {
CXFNonSpringServlet cxfNonSpringServlet = new CXFNonSpringServlet();
cxfNonSpringServlet.setBus(bus);
return cxfNonSpringServlet;
}
- private static OSGi<ServiceTuple<Application>> deployApplication(
- Map<String, ?> configuration, BundleContext bundleContext,
- ServiceTuple<Application> tuple, AriesJaxRSServiceRuntime runtime) {
-
- ExtensionManagerBus bus = createBus(bundleContext, configuration);
-
- ServiceReference<Application> serviceReference =
- tuple.getServiceReference();
-
- Map<String, Object> properties = getProperties(serviceReference);
-
- properties.computeIfAbsent(
- JAX_RS_NAME, (__) -> generateApplicationName(
- serviceReference::getProperty));
-
- return
- deployRegistrator(bus, tuple, properties, runtime).then(
- registerCXFServletService(
- bus, getApplicationBase(properties::get), properties)).then(
- just(tuple)
- );
- }
-
- private static OSGi<?> deployRegistrator(
- Bus bus, ServiceTuple<Application> tuple, Map<String, Object> props,
- AriesJaxRSServiceRuntime runtime) {
-
- try {
- CXFJaxRsServiceRegistrator registrator =
- new CXFJaxRsServiceRegistrator(bus, tuple.getService());
-
- return
- onClose(registrator::close).then(
- register(CXFJaxRsServiceRegistrator.class, registrator, props)
- );
- }
- catch (RuntimeException e) {
- ServiceReference<Application> serviceReference =
- tuple.getServiceReference();
-
- runtime.addErroredApplication(serviceReference);
-
- return onClose(
- () -> runtime.removeErroredApplication(serviceReference)
- ).then(
- nothing()
- );
- }
- }
-
private static String getApplicationExtensionsFilter() {
return format(
"(&(!(objectClass=%s))(%s=%s)%s)",
@@ -729,13 +739,13 @@ public class Whiteboard {
return register(Servlet.class, cxfNonSpringServlet, properties);
}
- private static <T> OSGi<ResourceProvider>
- registerEndpoint(
+ private static <T> OSGi<ResourceProvider> registerEndpoint(
CXFJaxRsServiceRegistrator registrator,
ServiceObjects<T> serviceObjects) {
ResourceProvider resourceProvider = getResourceProvider(serviceObjects);
registrator.add(resourceProvider);
+
return just(resourceProvider);
}