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/08/18 14:01:58 UTC

[09/14] aries-jax-rs-whiteboard git commit: No longer need the properties or workaround

No longer need the properties or workaround


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

Branch: refs/heads/master
Commit: d7c8ad4a207728375da3c92386cef07589439154
Parents: 0e631d5
Author: Carlos Sierra <cs...@apache.org>
Authored: Mon Aug 14 14:20:54 2017 +0200
Committer: Carlos Sierra <cs...@apache.org>
Committed: Fri Aug 18 15:59:21 2017 +0200

----------------------------------------------------------------------
 .../internal/CXFJaxRsServiceRegistrator.java    | 71 +-------------------
 1 file changed, 1 insertion(+), 70 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/d7c8ad4a/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 8d6ee29..91c70f8 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
@@ -17,13 +17,10 @@
 
 package org.apache.aries.jax.rs.whiteboard.internal;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import javax.ws.rs.core.Application;
 
@@ -38,32 +35,22 @@ import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.provider.json.JSONProvider;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.apache.cxf.message.Message;
-import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.transport.Destination;
-import org.apache.cxf.transport.DestinationFactory;
-import org.apache.cxf.transport.DestinationFactoryManager;
 import org.osgi.framework.ServiceReference;
 
-import static org.apache.aries.jax.rs.whiteboard.internal.Utils.safeToString;
-
 public class CXFJaxRsServiceRegistrator {
 
     private volatile boolean _closed = false;
     private final Application _application;
     private final Bus _bus;
-    private final Map<String, Object> _properties;
     private final Collection<Object> _providers = new ArrayList<>();
     private Server _server;
     private final Collection<ResourceProvider> _services = new ArrayList<>();
 
     private static final String CXF_ENDPOINT_ADDRESS = "CXF_ENDPOINT_ADDRESS";
 
-    public CXFJaxRsServiceRegistrator(
-        Bus bus, Application application, Map<String, Object> properties) {
-
+    public CXFJaxRsServiceRegistrator(Bus bus, Application application) {
         _bus = bus;
         _application = application;
-        _properties = properties;
 
         rewire();
     }
@@ -189,17 +176,6 @@ public class CXFJaxRsServiceRegistrator {
             _application, JAXRSServerFactoryBean.class);
 
         jaxRsServerFactoryBean.setBus(_bus);
-        jaxRsServerFactoryBean.setProperties(_properties);
-
-        String address = safeToString(_properties.get(CXF_ENDPOINT_ADDRESS));
-
-        DestinationFactoryManager dfm = _bus.getExtension(
-            DestinationFactoryManager.class);
-        DestinationFactory destinationFactory = dfm.getDestinationFactoryForUri(
-            address);
-
-        jaxRsServerFactoryBean.setDestinationFactory(
-            new CXF7409DestinationFactory(destinationFactory));
 
         JSONProvider<Object> jsonProvider = new JSONProvider<>();
 
@@ -218,8 +194,6 @@ public class CXFJaxRsServiceRegistrator {
             jaxRsServerFactoryBean.setResourceProvider(resourceProvider);
         }
 
-        jaxRsServerFactoryBean.setAddress(address);
-
         jaxRsServerFactoryBean.setResourceComparator(
             new ComparableResourceComparator());
 
@@ -238,47 +212,4 @@ public class CXFJaxRsServiceRegistrator {
         return endpointType.cast(server);
     }
 
-    /**
-     * This class exists as a workaround for
-     * https://issues.apache.org/jira/browse/CXF-7409
-     */
-    private static class CXF7409DestinationFactory
-        implements DestinationFactory {
-
-        private final DestinationFactory _destinationFactory;
-
-        public CXF7409DestinationFactory(
-            DestinationFactory destinationFactory) {
-
-            _destinationFactory = destinationFactory;
-        }
-
-        @Override
-        public Destination getDestination(
-            EndpointInfo endpointInfo, Bus bus) throws IOException {
-
-            Destination destination = _destinationFactory.getDestination(
-                endpointInfo, bus);
-
-            if (destination.getMessageObserver() != null) {
-                throw new RuntimeException(
-                    "There is already an application running at " +
-                        endpointInfo.getAddress());
-            }
-
-            return destination;
-        }
-
-        @Override
-        public Set<String> getUriPrefixes() {
-            return _destinationFactory.getUriPrefixes();
-        }
-
-        @Override
-        public List<String> getTransportIds() {
-            return _destinationFactory.getTransportIds();
-        }
-
-    }
-
 }