aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From csie...@apache.org
Subject [4/4] aries-jax-rs-whiteboard git commit: Satisfy Find Security Bugs
Date Mon, 04 Sep 2017 13:52:21 GMT
Satisfy Find Security Bugs


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/2cf7f7f0
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/2cf7f7f0
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/2cf7f7f0

Branch: refs/heads/master
Commit: 2cf7f7f0e05fc52d99258d5092b7c5b1ee927f99
Parents: e6fa583
Author: Carlos Sierra <csierra@apache.org>
Authored: Mon Sep 4 13:47:07 2017 +0200
Committer: Carlos Sierra <csierra@apache.org>
Committed: Mon Sep 4 14:05:11 2017 +0200

----------------------------------------------------------------------
 .../internal/AriesJaxRSServiceRuntime.java      |  42 +++---
 .../internal/CXFJaxRsServiceRegistrator.java    |  47 ++++---
 .../jax/rs/whiteboard/internal/Strings.java     |  44 ------
 .../aries/jax/rs/whiteboard/internal/Utils.java |  46 ++++---
 .../jax/rs/whiteboard/internal/Whiteboard.java  | 138 +++++++++----------
 5 files changed, 144 insertions(+), 173 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/2cf7f7f0/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 a3c53c9..c44773f 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
@@ -30,6 +30,8 @@ import org.osgi.service.jaxrs.runtime.dto.RequestInfoDTO;
 import org.osgi.service.jaxrs.runtime.dto.ResourceDTO;
 import org.osgi.service.jaxrs.runtime.dto.RuntimeDTO;
 import org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.ws.rs.core.Application;
 import java.util.ArrayList;
@@ -56,42 +58,32 @@ import static org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants.JAX_RS_
 public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime {
 
     private static final long serialVersionUID = 1L;
-
+    private static final Logger _LOGGER = LoggerFactory.getLogger(
+        Whiteboard.class);
     private ConcurrentHashMap<String, Map<String, Object>>
         _applications = new ConcurrentHashMap<>();
-
     private ConcurrentHashMap<String, Collection<ServiceReference<?>>>
         _applicationEndpoints = new ConcurrentHashMap<>();
-
     private ConcurrentHashMap<String, Collection<ServiceReference<?>>>
         _applicationExtensions = new ConcurrentHashMap<>();
-
     private Collection<ServiceReference<Application>>
         _ungettableApplications = new CopyOnWriteArrayList<>();
-
     private Collection<ServiceReference<Application>> _shadowedApplications =
         new CopyOnWriteArrayList<>();
-
     private Set<ServiceReference<Application>> _dependentApplications =
         ConcurrentHashMap.newKeySet();
-
     private Collection<ServiceReference<Application>> _clashingApplications =
         new CopyOnWriteArrayList<>();
-
     private Collection<ServiceReference<Application>> _erroredApplications =
         new CopyOnWriteArrayList<>();
-
     private Collection<ServiceReference<?>> _ungettableEndpoints =
         new CopyOnWriteArrayList<>();
     private Collection<ServiceReference<?>> _ungettableExtensions =
         new CopyOnWriteArrayList<>();
-
     private Set<ServiceReference<?>> _dependentServices =
         ConcurrentHashMap.newKeySet();
-
     private Collection<ServiceReference<?>> _invalidExtensions =
         new CopyOnWriteArrayList<>();
-
     private volatile Map<String, Object> _defaultApplicationProperties;
 
     public void addApplicationEndpoint(
@@ -138,18 +130,36 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime
{
     public boolean addNotGettableApplication(
         ServiceReference<Application> serviceReference) {
 
+        if (_LOGGER.isWarnEnabled()) {
+            _LOGGER.warn(
+                "Application from reference " + serviceReference +
+                    " can't be got");
+        }
+
         return _ungettableApplications.add(serviceReference);
     }
 
     public <T> boolean addNotGettableEndpoint(
         ServiceReference<T> serviceReference) {
 
+        if (_LOGGER.isWarnEnabled()) {
+            _LOGGER.warn(
+                "Resource from reference " + serviceReference +
+                    " can't be got");
+        }
+
         return _ungettableEndpoints.add(serviceReference);
     }
 
     public <T> void addNotGettableExtension(
         ServiceReference<T> serviceReference) {
 
+        if (_LOGGER.isWarnEnabled()) {
+            _LOGGER.warn(
+                "Extension from reference " + serviceReference +
+                    " can't be got");
+        }
+
         _ungettableExtensions.add(serviceReference);
     }
 
@@ -296,14 +306,6 @@ public class AriesJaxRSServiceRuntime implements JaxRSServiceRuntime
{
             });
     }
 
-    /*public void setDefaultApplication(Map<String, Object> properties) {
-        _applications.compute(DEFAULT_NAME, (__, ___) -> {
-            _defaultApplicationProperties = properties;
-
-            return properties;
-        });
-    }*/
-
     public Map<String, Object> unsetApplicationForPath(String path) {
         return _applications.remove(path);
     }

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/2cf7f7f0/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
index e06a907..d73e1ee 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
@@ -20,12 +20,13 @@ package org.apache.aries.jax.rs.whiteboard.internal;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Comparator;
 import java.util.stream.Stream;
 
 import javax.ws.rs.core.Application;
 import javax.ws.rs.core.Feature;
 
-import org.apache.aries.jax.rs.whiteboard.internal.Utils.ComparableResourceProvider;
+import org.apache.aries.jax.rs.whiteboard.internal.Utils.ServiceReferenceResourceProvider;
 import org.apache.aries.jax.rs.whiteboard.internal.Utils.ServiceTuple;
 import org.apache.cxf.Bus;
 import org.apache.cxf.endpoint.Server;
@@ -43,12 +44,12 @@ import static org.apache.aries.jax.rs.whiteboard.internal.Utils.canonicalize;
 
 public class CXFJaxRsServiceRegistrator {
 
-    private volatile boolean _closed = false;
     private final Application _application;
     private final Bus _bus;
     private final Collection<ServiceTuple<?>> _providers = new ArrayList<>();
-    private Server _server;
     private final Collection<ResourceProvider> _services = new ArrayList<>();
+    private volatile boolean _closed = false;
+    private Server _server;
 
     public CXFJaxRsServiceRegistrator(Bus bus, Application application) {
         _bus = bus;
@@ -89,6 +90,16 @@ public class CXFJaxRsServiceRegistrator {
         _closed = true;
     }
 
+    public <T> T createEndpoint(Application app, Class<T> endpointType) {
+        JAXRSServerFactoryBean bean = ResourceUtils.createApplication(app, false);
+        if (JAXRSServerFactoryBean.class.isAssignableFrom(endpointType)) {
+            return endpointType.cast(bean);
+        }
+        bean.setStart(false);
+        Server server = bean.create();
+        return endpointType.cast(server);
+    }
+
     public void remove(ResourceProvider resourceProvider) {
         if (_closed) {
             return;
@@ -112,6 +123,13 @@ public class CXFJaxRsServiceRegistrator {
     private static class ComparableResourceComparator
         implements ResourceComparator {
 
+        private static Comparator<ServiceReferenceResourceProvider> comparator;
+
+        static {
+            comparator = Comparator.comparing(
+                ServiceReferenceResourceProvider::getServiceReference);
+        }
+
         @Override
         public int compare(
             ClassResourceInfo cri1, ClassResourceInfo cri2, Message message) {
@@ -119,18 +137,19 @@ public class CXFJaxRsServiceRegistrator {
             ResourceProvider rp1 = cri1.getResourceProvider();
             ResourceProvider rp2 = cri2.getResourceProvider();
 
-            if (rp1 instanceof ComparableResourceProvider &&
-                rp2 instanceof ComparableResourceProvider) {
+            if (rp1 instanceof ServiceReferenceResourceProvider &&
+                rp2 instanceof ServiceReferenceResourceProvider) {
 
-                return -((ComparableResourceProvider) rp1).compareTo(
-                    (ComparableResourceProvider) rp2);
+                return comparator.compare(
+                    (ServiceReferenceResourceProvider)rp2,
+                    (ServiceReferenceResourceProvider)rp1);
             }
 
-            if (rp1 instanceof ComparableResourceProvider) {
+            if (rp1 instanceof ServiceReferenceResourceProvider) {
                 return 1;
             }
 
-            if (rp2 instanceof ComparableResourceProvider) {
+            if (rp2 instanceof ServiceReferenceResourceProvider) {
                 return -1;
             }
 
@@ -213,14 +232,4 @@ public class CXFJaxRsServiceRegistrator {
         _server.start();
     }
 
-    public <T> T createEndpoint(Application app, Class<T> endpointType) {
-        JAXRSServerFactoryBean bean = ResourceUtils.createApplication(app, false);
-        if (JAXRSServerFactoryBean.class.isAssignableFrom(endpointType)) {
-            return endpointType.cast(bean);
-        }
-        bean.setStart(false);
-        Server server = bean.create();
-        return endpointType.cast(server);
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/2cf7f7f0/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Strings.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Strings.java
b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Strings.java
deleted file mode 100644
index 7fc2ac5..0000000
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Strings.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.apache.aries.jax.rs.whiteboard.internal;
-
-import java.lang.reflect.ParameterizedType;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Optional;
-
-public class Strings {
-
-    @SuppressWarnings({"unchecked" })
-    public static Optional<List<String>> stringPlus(Object obj) {
-        if (obj == null) {
-            return Optional.empty();
-        }
-
-        List<String> strings = new ArrayList<>();
-
-        if (obj instanceof String) {
-            strings.add((String)obj);
-        }
-        else if (Collection.class.isInstance(obj) &&
-                (ParameterizedType.class.isAssignableFrom(obj.getClass())) &&
-                ((ParameterizedType)obj).getActualTypeArguments()[0].equals(String.class))
{
-
-            for (String item : (Collection<String>)obj) {
-                strings.add(item);
-            }
-        }
-        else if (obj.getClass().isArray() &&
-                String.class.isAssignableFrom(obj.getClass().getComponentType())) {
-
-            for (String item : (String[])obj) {
-                strings.add(item);
-            }
-        }
-        else {
-            return Optional.empty();
-        }
-
-        return Optional.of(strings);
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/2cf7f7f0/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 637353a..8bee358 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
@@ -23,6 +23,7 @@ import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
 import org.apache.cxf.message.Message;
 import org.osgi.framework.ServiceObjects;
 import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
 
 import java.util.Collection;
 import java.util.Comparator;
@@ -52,8 +53,15 @@ public class Utils {
             return (String[]) propertyValue;
         }
         if (propertyValue instanceof Collection) {
-            return ((Collection<String>) propertyValue).toArray(new String[0]);
+            return
+                ((Collection<?>)propertyValue).stream().
+                    map(
+                        Object::toString
+                    ).toArray(
+                        String[]::new
+                    );
         }
+
         return new String[]{propertyValue.toString()};
     }
 
@@ -80,7 +88,8 @@ public class Utils {
         ServiceReference<T> serviceReference =
             serviceObjects.getServiceReference();
 
-        return new ComparableResourceProvider(serviceReference, serviceObjects);
+        return new ServiceReferenceResourceProvider(
+            serviceReference, serviceObjects);
     }
 
     public static <K, T extends Comparable<? super T>> OSGi<T> highestPer(
@@ -166,13 +175,13 @@ public class Utils {
 
     public interface ApplicationExtensionRegistration {}
 
-    public static class ComparableResourceProvider
-        implements ResourceProvider, Comparable<ComparableResourceProvider> {
+    public static class ServiceReferenceResourceProvider
+        implements ResourceProvider {
 
         private final ServiceObjects<?> _serviceObjects;
         private ServiceReference<?> _serviceReference;
 
-        public ComparableResourceProvider(
+        ServiceReferenceResourceProvider(
             ServiceReference<?> serviceReference,
             ServiceObjects<?> serviceObjects) {
             _serviceReference = serviceReference;
@@ -181,11 +190,6 @@ public class Utils {
         }
 
         @Override
-        public int compareTo(ComparableResourceProvider o) {
-            return _serviceReference.compareTo(o._serviceReference);
-        }
-
-        @Override
         public Object getInstance(Message m) {
             return _serviceObjects.getService();
         }
@@ -214,6 +218,10 @@ public class Utils {
             return false;
         }
 
+        ServiceReference<?> getServiceReference() {
+            return _serviceReference;
+        }
+
     }
 
     public static class ServiceTuple<T> implements Comparable<ServiceTuple<T>>
{
@@ -221,22 +229,25 @@ public class Utils {
         private final ServiceReference<T> _serviceReference;
         private final T _service;
 
-        public ServiceTuple(ServiceReference<T> a, T service) {
+        ServiceTuple(ServiceReference<T> a, T service) {
             _serviceReference = a;
             _service = service;
         }
 
+        @Override
+        public int compareTo(ServiceTuple<T> o) {
+            return _serviceReference.compareTo(o._serviceReference);
+        }
+
         public T getService() {
             return _service;
         }
 
-        public ServiceReference<T> getServiceReference() {
-            return _serviceReference;
-        }
         @Override
         public int hashCode() {
             return _serviceReference.hashCode();
         }
+
         @Override
         public boolean equals(Object o) {
             if (this == o) return true;
@@ -245,9 +256,10 @@ public class Utils {
             ServiceTuple<?> that = (ServiceTuple<?>) o;
 
             return _serviceReference.equals(that._serviceReference);
-        }@Override
-        public int compareTo(ServiceTuple<T> o) {
-            return _serviceReference.compareTo(o._serviceReference);
+        }
+
+        ServiceReference<T> getServiceReference() {
+            return _serviceReference;
         }
 
 

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/2cf7f7f0/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 9caf49f..7668c6a 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
@@ -51,12 +51,12 @@ import javax.ws.rs.ext.ReaderInterceptor;
 import javax.ws.rs.ext.WriterInterceptor;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Map;
-import java.util.Optional;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.function.Consumer;
@@ -101,21 +101,9 @@ import static org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants.JAX_RS_
  */
 public class Whiteboard {
 
-    public static final Function<ServiceTuple<Application>, String>
-        APPLICATION_BASE =
-        ((Function<ServiceTuple<Application>, ServiceReference<Application>>)
-            ServiceTuple::getServiceReference).andThen(
-                sr -> getApplicationBase(sr::getProperty));
-
-    public static final Function<ServiceTuple<Application>, String>
-        APPLICATION_NAME =
-        ((Function<ServiceTuple<Application>, ServiceReference<Application>>)
-            ServiceTuple::getServiceReference).andThen(
-            sr -> getApplicationName(sr::getProperty));
-
-    public static final Collection<String> SUPPORTED_EXTENSION_INTERFACES =
-        new HashSet<>(
-            Arrays.asList(
+    static final Collection<String> SUPPORTED_EXTENSION_INTERFACES =
+        Collections.unmodifiableSet(
+            new HashSet<>(Arrays.asList(
                 ContainerRequestFilter.class.getName(),
                 ContainerResponseFilter.class.getName(),
                 ReaderInterceptor.class.getName(),
@@ -127,15 +115,18 @@ public class Whiteboard {
                 ParamConverterProvider.class.getName(),
                 Feature.class.getName(),
                 DynamicFeature.class.getName()
-            ));
-
-    public static final String DEFAULT_NAME = ".default";
-
-    public static OSGi<ServiceReference<CXFJaxRsServiceRegistrator>>
-        allApplicationReferences() {
-
-        return serviceReferences(CXFJaxRsServiceRegistrator.class);
-    }
+        )));
+    static final String DEFAULT_NAME = ".default";
+    private static final Function<ServiceTuple<Application>, String>
+        APPLICATION_BASE =
+        ((Function<ServiceTuple<Application>, ServiceReference<Application>>)
+            ServiceTuple::getServiceReference).andThen(
+                sr -> getApplicationBase(sr::getProperty));
+    private static final Function<ServiceTuple<Application>, String>
+        APPLICATION_NAME =
+        ((Function<ServiceTuple<Application>, ServiceReference<Application>>)
+            ServiceTuple::getServiceReference).andThen(
+            sr -> getApplicationName(sr::getProperty));
 
     public static OSGi<?> createWhiteboard(
         Dictionary<String, ?> configuration) {
@@ -167,46 +158,6 @@ public class Whiteboard {
             )))))));
     }
 
-    public static OSGi<ServiceReference<CXFJaxRsServiceRegistrator>>
-        defaultApplication() {
-
-        return
-            repeatInOrder(
-                serviceReferences(
-                    CXFJaxRsServiceRegistrator.class,
-                    String.format(
-                        "(%s=%s)", JAX_RS_NAME, DEFAULT_NAME)
-                )
-            );
-    }
-
-    public 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 (Exception e) {
-            ServiceReference<Application> serviceReference =
-                tuple.getServiceReference();
-
-            runtime.addErroredApplication(serviceReference);
-
-            return onClose(
-                () -> runtime.removeErroredApplication(serviceReference)
-            ).then(
-                nothing()
-            );
-        }
-    }
-
     public static String getApplicationBase(PropertyHolder properties) {
         return properties.get(JAX_RS_APPLICATION_BASE).toString();
     }
@@ -290,6 +241,12 @@ public class Whiteboard {
             ));
     }
 
+    private static OSGi<ServiceReference<CXFJaxRsServiceRegistrator>>
+        allApplicationReferences() {
+
+        return serviceReferences(CXFJaxRsServiceRegistrator.class);
+    }
+
     private static OSGi<Collection<String>> bestEffortCalculationOfEnpoints(
         Filter filter) {
 
@@ -298,14 +255,9 @@ public class Whiteboard {
         return
             serviceReferences(HttpServiceRuntime.class, filter.toString()).
                 map(
-                    r -> Strings.stringPlus(
-                        r.getProperty(HTTP_SERVICE_ENDPOINT))
-                ).
-                filter(
-                    Optional::isPresent
-                ).
-                map(
-                    Optional::get
+                    r -> Arrays.asList(
+                        canonicalize(
+                            r.getProperty(HTTP_SERVICE_ENDPOINT)))
                 ).
                 foreach(
                     endPoints::addAll,
@@ -365,6 +317,19 @@ public class Whiteboard {
         return cxfNonSpringServlet;
     }
 
+    private static OSGi<ServiceReference<CXFJaxRsServiceRegistrator>>
+        defaultApplication() {
+
+        return
+            repeatInOrder(
+                serviceReferences(
+                    CXFJaxRsServiceRegistrator.class,
+                    String.format(
+                        "(%s=%s)", JAX_RS_NAME, DEFAULT_NAME)
+                )
+            );
+    }
+
     private static OSGi<ServiceTuple<Application>> deployApplication(
         Map<String, ?> configuration, BundleContext bundleContext,
         ServiceTuple<Application> tuple, AriesJaxRSServiceRuntime runtime) {
@@ -388,6 +353,33 @@ public class Whiteboard {
         );
     }
 
+    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)",


Mime
View raw message