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/07/19 11:37:38 UTC
[2/2] aries-jax-rs-whiteboard git commit: Move new features to
component DSL
Move new features to component DSL
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/9e8dc5db
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/9e8dc5db
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/9e8dc5db
Branch: refs/heads/master
Commit: 9e8dc5db3d34ef2bc22fbadf4e22ca95ccddee88
Parents: 80aec38
Author: Carlos Sierra <cs...@apache.org>
Authored: Tue Jul 18 16:50:01 2017 +0200
Committer: Carlos Sierra <cs...@apache.org>
Committed: Wed Jul 19 13:36:46 2017 +0200
----------------------------------------------------------------------
.../activator/CXFJaxRsBundleActivator.java | 67 ++--
.../jax/rs/whiteboard/internal/Whiteboard.java | 364 ++++++++-----------
.../internal/WhiteboardServiceFactory.java | 66 ----
3 files changed, 200 insertions(+), 297 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/9e8dc5db/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 4fa17c8..72d7dd8 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
@@ -19,21 +19,30 @@ package org.apache.aries.jax.rs.whiteboard.activator;
import java.util.Dictionary;
import java.util.Hashtable;
-import java.util.concurrent.Executors;
import javax.ws.rs.ext.RuntimeDelegate;
-import org.apache.aries.jax.rs.whiteboard.internal.WhiteboardServiceFactory;
+import org.apache.aries.jax.rs.whiteboard.internal.DefaultWeb;
+import org.apache.aries.jax.rs.whiteboard.internal.Maps;
+import org.apache.aries.jax.rs.whiteboard.internal.Whiteboard;
+import org.apache.aries.osgi.functional.OSGi;
+import org.apache.aries.osgi.functional.OSGiResult;
import org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedServiceFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static java.lang.String.format;
+import static org.apache.aries.jax.rs.whiteboard.internal.Whiteboard.createWhiteboard;
+import static org.apache.aries.osgi.functional.OSGi.configurations;
+import static org.apache.aries.osgi.functional.OSGi.register;
+import static org.apache.aries.osgi.functional.OSGi.serviceReferences;
+import static org.apache.aries.osgi.functional.OSGi.services;
+import static org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants.JAX_RS_APPLICATION_SELECT;
+import static org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants.JAX_RS_RESOURCE;
+
public class CXFJaxRsBundleActivator implements BundleActivator {
private static final Logger _log = LoggerFactory.getLogger(CXFJaxRsBundleActivator.class);
@@ -42,9 +51,8 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
RuntimeDelegate.setInstance(new RuntimeDelegateImpl());
}
- private ServiceRegistration<ManagedServiceFactory> _serviceRegistration;
- private WhiteboardServiceFactory _whiteboardServiceFactory;
- private String _defaultName;
+ private OSGiResult<?> _defaultOSGiResult;
+ private OSGiResult<?> _whiteboardsResult;
@Override
public void start(BundleContext bundleContext) throws Exception {
@@ -52,31 +60,27 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
_log.debug("Starting the whiteboard factory");
}
- _whiteboardServiceFactory = new WhiteboardServiceFactory(bundleContext);
-
- _defaultName = _whiteboardServiceFactory.getName() + ".default";
-
- Dictionary<String, Object> properties = new Hashtable<>();
- properties.put(Constants.SERVICE_PID, _whiteboardServiceFactory.getName());
+ OSGi<?> whiteboards =
+ configurations("org.apache.aries.jax.rs.whiteboard").flatMap(configuration ->
+ createWhiteboard(configuration).then(
+ registerDefaultWeb())
+ );
- _serviceRegistration = bundleContext.registerService(
- ManagedServiceFactory.class, _whiteboardServiceFactory, properties);
+ _whiteboardsResult = whiteboards.run(bundleContext);
if (_log.isDebugEnabled()) {
_log.debug("Whiteboard factory started");
}
- Executors.newSingleThreadExecutor().submit(() -> {
- try {
- Dictionary<String, Object> defaultConfiguration = new Hashtable<>();
+ Dictionary<String, Object> defaultConfiguration = new Hashtable<>();
- defaultConfiguration.put(Constants.SERVICE_PID, _defaultName);
+ defaultConfiguration.put(
+ Constants.SERVICE_PID, "org.apache.aries.jax.rs.whiteboard.default");
- _whiteboardServiceFactory.updated(_defaultName, defaultConfiguration);
- } catch (ConfigurationException ce) {
- _log.error("Configuration error", ce);
- }
- });
+ _defaultOSGiResult =
+ createWhiteboard(defaultConfiguration).then(
+ registerDefaultWeb()
+ ).run(bundleContext);
}
@Override
@@ -85,13 +89,22 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
_log.debug("Stopping whiteboard factory");
}
- _serviceRegistration.unregister();
+ _defaultOSGiResult.close();
- _whiteboardServiceFactory.deleted(_defaultName);
+ _whiteboardsResult.close();
if (_log.isDebugEnabled()) {
_log.debug("Stopped whiteboard factory");
}
}
+ private static OSGi<?> registerDefaultWeb() {
+ Dictionary<String, Object> dictionary = new Hashtable<>();
+ dictionary.put(JAX_RS_APPLICATION_SELECT, "(osgi.jaxrs.name=.default)");
+ dictionary.put(JAX_RS_RESOURCE, "true");
+ dictionary.put(Constants.SERVICE_RANKING, -1);
+
+ return register(DefaultWeb.class, new DefaultWeb(), Maps.from(dictionary));
+ }
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/9e8dc5db/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 a15b07f..d7a4a11 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
@@ -17,6 +17,27 @@
package org.apache.aries.jax.rs.whiteboard.internal;
+import org.apache.aries.osgi.functional.OSGi;
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.extension.ExtensionManagerBus;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.wiring.BundleWiring;
+import org.osgi.service.http.runtime.HttpServiceRuntime;
+import org.osgi.service.jaxrs.runtime.JaxRSServiceRuntime;
+
+import javax.servlet.Servlet;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.core.Application;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Map;
+
import static java.lang.String.format;
import static org.apache.aries.jax.rs.whiteboard.internal.Utils.cxfRegistrator;
import static org.apache.aries.jax.rs.whiteboard.internal.Utils.repeatInOrder;
@@ -24,7 +45,10 @@ import static org.apache.aries.jax.rs.whiteboard.internal.Utils.safeRegisterEndp
import static org.apache.aries.jax.rs.whiteboard.internal.Utils.safeRegisterExtension;
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.all;
+import static org.apache.aries.osgi.functional.OSGi.bundleContext;
import static org.apache.aries.osgi.functional.OSGi.just;
+import static org.apache.aries.osgi.functional.OSGi.register;
import static org.apache.aries.osgi.functional.OSGi.serviceReferences;
import static org.apache.aries.osgi.functional.OSGi.services;
import static org.osgi.service.http.runtime.HttpServiceRuntimeConstants.HTTP_SERVICE_ENDPOINT;
@@ -41,177 +65,38 @@ import static org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants.JAX_RS_
import static org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants.JAX_RS_NAME;
import static org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants.JAX_RS_RESOURCE;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Optional;
-
-import javax.servlet.Servlet;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.core.Application;
-
-import org.apache.aries.osgi.functional.OSGi;
-import org.apache.aries.osgi.functional.OSGiResult;
-import org.apache.cxf.Bus;
-import org.apache.cxf.bus.extension.ExtensionManagerBus;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.framework.wiring.BundleWiring;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.http.runtime.HttpServiceRuntime;
-import org.osgi.service.jaxrs.runtime.JaxRSServiceRuntime;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class Whiteboard implements AutoCloseable {
-
- public Whiteboard(
- BundleContext bundleContext, Map<String, Object> configuration)
- throws ConfigurationException {
-
- BundleWiring wiring = bundleContext.getBundle().adapt(BundleWiring.class);
-
- configuration.put(_ID, configuration.get(Constants.SERVICE_PID));
-
- ExtensionManagerBus bus = new ExtensionManagerBus(null, configuration, wiring.getClassLoader());
-
- bus.initialize();
-
- _runtimeRegistration = registerJaxRSServiceRuntime(bundleContext, bus, configuration);
-
- OSGi<?> applications =
- repeatInOrder(
- serviceReferences(Application.class, getApplicationFilter())).
- flatMap(ref ->
- just(
- CXFJaxRsServiceRegistrator.getProperties(
- ref, JAX_RS_APPLICATION_BASE)).
- flatMap(properties ->
- service(ref).flatMap(application ->
- cxfRegistrator(bus, application, properties)
- )));
-
- _applicationsResult = applications.run(bundleContext);
-
- OSGi<?> applicationSingletons =
- serviceReferences(format("(%s=*)", JAX_RS_APPLICATION_SELECT)).
- flatMap(ref ->
- just(ref.getProperty(JAX_RS_APPLICATION_SELECT).toString()).
- flatMap(applicationFilter ->
- services(CXFJaxRsServiceRegistrator.class, applicationFilter).
- flatMap(registrator ->
- safeRegisterGeneric(ref, registrator)
- )));
-
- _applicationSingletonsResult = applicationSingletons.run(bundleContext);
-
- Map<String, Object> properties = new HashMap<>();
- properties.put(JAX_RS_APPLICATION_BASE, "/");
- properties.put(JAX_RS_NAME, ".default");
-
- CXFJaxRsServiceRegistrator defaultServiceRegistrator =
- new CXFJaxRsServiceRegistrator(
- bus, new DefaultApplication(), properties);
-
- OSGi<?> extensions =
- serviceReferences(getExtensionFilter()).flatMap(ref ->
- waitForExtensionDependencies(ref,
- safeRegisterExtension(ref, defaultServiceRegistrator)
- )
- );
-
- _extensionsResult = extensions.run(bundleContext);
-
- OSGi<?> singletons =
- serviceReferences(getSingletonsFilter()).
- flatMap(serviceReference ->
- waitForExtensionDependencies(serviceReference,
- safeRegisterEndpoint(
- serviceReference, defaultServiceRegistrator)
- )
- );
-
- _singletonsResult = singletons.run(bundleContext);
-
- Dictionary<String, Object> dictionary = new Hashtable<>();
- dictionary.put(JAX_RS_APPLICATION_SELECT, "(osgi.jaxrs.name=.default)");
- dictionary.put(JAX_RS_RESOURCE, "true");
- dictionary.put(Constants.SERVICE_RANKING, -1);
-
- _defaultWeb = bundleContext.registerService(
- DefaultWeb.class, new DefaultWeb(), dictionary);
- _clientBuilder = bundleContext.registerService(
- ClientBuilder.class, new ClientBuilderFactory(), null);
- }
-
- @Override
- public void close() {
- _clientBuilder.unregister();
- _defaultWeb.unregister();
- _applicationsResult.close();
- _applicationSingletonsResult.close();
- _extensionsResult.close();
- _singletonsResult.close();
- _runtimeRegistration.unregister();
+/**
+ * @author Carlos Sierra Andrés
+ */
+public class Whiteboard {
+ public static OSGi<Void> createWhiteboard(Dictionary<String, ?> configuration) {
+ return
+ bundleContext().flatMap(bundleContext ->
+ just(createBus(bundleContext, configuration)).flatMap(bus ->
+ just(createDefaultJaxRsServiceRegistrator(bus)).flatMap(defaultServiceRegistrator ->
+ all(
+ registerJaxRSServiceRuntime(bundleContext, bus, Maps.from(configuration)),
+ whiteboardApplications(bus),
+ whiteBoardApplicationSingletons(),
+ whiteboardExtensions(defaultServiceRegistrator),
+ whiteboardSingletons(defaultServiceRegistrator),
+ register(ClientBuilder.class, new ClientBuilderFactory(), null)
+ ))));
}
- private void bestEffortCalculationOfEnpoints(
- Dictionary<String, Object> properties, BundleContext bundleContext)
- throws ConfigurationException {
-
- String targetFilter = (String)properties.get(HTTP_WHITEBOARD_TARGET);
-
- Filter filter;
-
- try {
- filter = bundleContext.createFilter(format(
- "(&(objectClass=%s)%s)",
- HttpServiceRuntime.class.getName(),
- targetFilter));
- }
- catch (InvalidSyntaxException ise) {
- throw new ConfigurationException(
- HTTP_WHITEBOARD_TARGET, format("Invalid syntax for filter {}", targetFilter));
- }
-
- ServiceTracker<HttpServiceRuntime, HttpServiceRuntime> httpRuntimeTracker =
- new ServiceTracker<>(bundleContext, filter, null);
-
- httpRuntimeTracker.open();
-
- try {
- httpRuntimeTracker.waitForService(1000);
- }
- catch (InterruptedException ie) {
- }
-
- Optional.ofNullable(
- httpRuntimeTracker.getServiceReferences()
- ).ifPresent(
- array -> {
- Collection<String> endPoints = new ArrayList<>();
-
- Arrays.stream(array).forEach(
- reference -> Strings.stringPlus(
- reference.getProperty(HTTP_SERVICE_ENDPOINT)
- ).ifPresent(
- values -> values.stream().forEach(
- value -> {
- endPoints.add(value);
- }
- )
- )
- );
-
- properties.put(JAX_RS_SERVICE_ENDPOINT, endPoints);
- }
+ private static OSGi<Collection<String>> bestEffortCalculationOfEnpoints(Filter filter) {
+ Collection<String> endPoints = new ArrayList<>();
+
+ return
+ serviceReferences(HttpServiceRuntime.class, filter.toString()).
+ foreach(
+ reference -> Strings.stringPlus(reference.getProperty(HTTP_SERVICE_ENDPOINT)).
+ ifPresent(endPoints::addAll)
+ ,
+ reference -> Strings.stringPlus(reference.getProperty(HTTP_SERVICE_ENDPOINT)).
+ ifPresent(values -> values.forEach(endPoints::remove))
+ ).then(
+ just(endPoints)
);
}
@@ -229,6 +114,31 @@ public class Whiteboard implements AutoCloseable {
return new String[]{propertyValue.toString()};
}
+ private static ExtensionManagerBus createBus(BundleContext bundleContext, Dictionary<String, ?> configuration) {
+ BundleWiring wiring = bundleContext.getBundle().adapt(BundleWiring.class);
+
+ Map<String, Object> properties = Maps.from((Dictionary<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 CXFJaxRsServiceRegistrator createDefaultJaxRsServiceRegistrator(
+ ExtensionManagerBus bus) {
+
+ Map<String, Object> properties = new HashMap<>();
+ properties.put(JAX_RS_APPLICATION_BASE, "/");
+ properties.put(JAX_RS_NAME, ".default");
+
+ return new CXFJaxRsServiceRegistrator(
+ bus, new DefaultApplication(), properties);
+ }
+
private static String getApplicationFilter() {
return format("(%s=*)", JAX_RS_APPLICATION_BASE);
}
@@ -241,40 +151,49 @@ public class Whiteboard implements AutoCloseable {
return format("(%s=true)", JAX_RS_RESOURCE);
}
- private ServiceRegistration<?> registerJaxRSServiceRuntime(
- BundleContext bundleContext, Bus bus, Map<String, Object> configuration)
- throws ConfigurationException {
+ private static OSGi<?> registerJaxRSServiceRuntime(
+ BundleContext bundleContext, Bus bus, Map<String, ?> configuration) {
- Dictionary<String, Object> properties = new Hashtable<>(configuration);
+ Map<String, Object> properties = new HashMap<>(configuration);
- properties.put(
- HTTP_WHITEBOARD_TARGET,
- configuration.computeIfAbsent(
- HTTP_WHITEBOARD_TARGET,
- k -> "(osgi.http.endpoint=*)"));
+ properties.putIfAbsent(
+ HTTP_WHITEBOARD_TARGET, "(osgi.http.endpoint=*)");
- properties.put(
+ properties.putIfAbsent(
HTTP_WHITEBOARD_CONTEXT_SELECT,
- configuration.computeIfAbsent(
- HTTP_WHITEBOARD_CONTEXT_SELECT,
- k -> format(
- "(%s=%s)",
- HTTP_WHITEBOARD_CONTEXT_NAME,
- HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME)));
-
- properties.put(
- HTTP_WHITEBOARD_SERVLET_PATTERN,
- configuration.computeIfAbsent(
- HTTP_WHITEBOARD_SERVLET_PATTERN,
- k -> "/*"));
+ format(
+ "(%s=%s)",
+ HTTP_WHITEBOARD_CONTEXT_NAME,
+ HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME));
+
+ properties.putIfAbsent(HTTP_WHITEBOARD_SERVLET_PATTERN, "/*");
properties.put(Constants.SERVICE_RANKING, -1);
- bestEffortCalculationOfEnpoints(properties, bundleContext);
+ String targetFilter = (String)properties.get(HTTP_WHITEBOARD_TARGET);
- return bundleContext.registerService(
- new String[] {JaxRSServiceRuntime.class.getName(), Servlet.class.getName()},
- new AriesJaxRSServiceRuntime(bus), properties);
+ Filter filter;
+
+ try {
+ filter = bundleContext.createFilter(
+ format(
+ "(&(objectClass=%s)%s)", HttpServiceRuntime.class.getName(),
+ targetFilter));
+ }
+ catch (InvalidSyntaxException ise) {
+ throw new IllegalArgumentException(
+ format("Invalid syntax for filter %s", targetFilter));
+ }
+
+ return
+ bestEffortCalculationOfEnpoints(filter).flatMap(endpoints -> {
+ properties.put(JAX_RS_SERVICE_ENDPOINT, endpoints);
+
+ return register(
+ new String[]{JaxRSServiceRuntime.class.getName(), Servlet.class.getName()},
+ new AriesJaxRSServiceRuntime(bus), properties);
+ }
+ );
}
private static OSGi<?> waitForExtensionDependencies(
@@ -286,20 +205,57 @@ public class Whiteboard implements AutoCloseable {
for (String extensionDependency : extensionDependencies) {
program =
serviceReferences(buildExtensionFilter(extensionDependency)).
- then(program);
+ then(program);
}
return program;
}
- private static final String _ID = "org.apache.cxf.bus.id";
+ private static OSGi<?> whiteBoardApplicationSingletons() {
+ return
+ serviceReferences(format("(%s=*)", JAX_RS_APPLICATION_SELECT)).
+ flatMap(ref ->
+ just(ref.getProperty(JAX_RS_APPLICATION_SELECT).toString()).
+ flatMap(applicationFilter ->
+ services(CXFJaxRsServiceRegistrator.class, applicationFilter).
+ flatMap(registrator ->
+ safeRegisterGeneric(ref, registrator)
+ )));
+ }
- private final OSGiResult<?> _applicationsResult;
- private final OSGiResult<?> _applicationSingletonsResult;
- private final ServiceRegistration<ClientBuilder> _clientBuilder;
- private final ServiceRegistration<DefaultWeb> _defaultWeb;
- private final OSGiResult<?> _extensionsResult;
- private final ServiceRegistration<?> _runtimeRegistration;
- private final OSGiResult<?> _singletonsResult;
+ private static OSGi<?> whiteboardApplications(ExtensionManagerBus bus) {
+ return
+ repeatInOrder(
+ serviceReferences(Application.class, getApplicationFilter())).
+ flatMap(ref ->
+ just(CXFJaxRsServiceRegistrator.getProperties(ref, JAX_RS_APPLICATION_BASE)).
+ flatMap(properties ->
+ service(ref).flatMap(application ->
+ cxfRegistrator(bus, application, properties)
+ )));
+ }
+
+ private static OSGi<?> whiteboardExtensions(
+ CXFJaxRsServiceRegistrator defaultServiceRegistrator) {
+ return
+ serviceReferences(getExtensionFilter()).flatMap(ref ->
+ waitForExtensionDependencies(ref,
+ safeRegisterExtension(ref, defaultServiceRegistrator)
+ )
+ );
+ }
+
+ private static OSGi<?> whiteboardSingletons(
+ CXFJaxRsServiceRegistrator defaultServiceRegistrator) {
+
+ return
+ serviceReferences(getSingletonsFilter()).
+ flatMap(serviceReference ->
+ waitForExtensionDependencies(serviceReference,
+ safeRegisterEndpoint(
+ serviceReference, defaultServiceRegistrator)
+ )
+ );
+ }
}
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/9e8dc5db/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/WhiteboardServiceFactory.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/WhiteboardServiceFactory.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/WhiteboardServiceFactory.java
deleted file mode 100644
index 8b41700..0000000
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/WhiteboardServiceFactory.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.aries.jax.rs.whiteboard.internal;
-
-import java.util.Dictionary;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-public class WhiteboardServiceFactory implements ManagedServiceFactory {
-
- public WhiteboardServiceFactory(BundleContext bundleContext) {
- _bundleContext = bundleContext;
- }
-
- @Override
- public String getName() {
- return "org.apache.aries.jax.rs.whiteboard";
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void updated(String pid, Dictionary<String, ?> configuration)
- throws ConfigurationException {
-
- Whiteboard whiteboard = _whiteboards.remove(pid);
-
- if (whiteboard != null) {
- whiteboard.close();
- }
-
- _whiteboards.put(
- pid, new Whiteboard(_bundleContext, (Map<String, Object>)Maps.from(configuration)));
- }
-
- @Override
- public void deleted(String pid) {
- Whiteboard whiteboard = _whiteboards.remove(pid);
-
- if (whiteboard != null) {
- whiteboard.close();
- }
- }
-
- private final BundleContext _bundleContext;
- private final Map<String, Whiteboard> _whiteboards = new ConcurrentHashMap<>();
-
-}
\ No newline at end of file