convert to Jersey 2 11/72311/5
authorTom Pantelis <tompantelis@gmail.com>
Fri, 25 May 2018 13:18:09 +0000 (09:18 -0400)
committerMichael Vorburger <vorburger@redhat.com>
Tue, 29 May 2018 10:54:55 +0000 (12:54 +0200)
Modified the WebInitializer to use the new AAA Servlet API based on Jersey 2.

JIRA: TSC-113
Change-Id: I1c495087c278debec6e04a6cf920ca10632dd3f7
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
integration/test-standalone/pom.xml
integration/test-standalone/src/test/java/org/opendaylight/neutron/e2etest/NeutronTestWiring.java
northbound-api/pom.xml
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/WebInitializer.java
northbound-api/src/main/resources/org/opendaylight/blueprint/blueprint.xml

index 3724848c6428313f1d8b2fc83ec778ca1a2642c1..1549f977f482c658d4f5c1ee3f078b8ab9dc2f5f 100644 (file)
       <artifactId>inject.guice.testutils</artifactId>
       <version>1.4.0-SNAPSHOT</version>
       <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>aopalliance</groupId>
+          <artifactId>aopalliance</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.aaa.web</groupId>
       <version>0.8.0-SNAPSHOT</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.aaa.web</groupId>
+      <artifactId>servlet-jersey2</artifactId>
+      <version>0.8.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.glassfish.jersey.bundles.repackaged</groupId>
+      <artifactId>jersey-guava</artifactId>
+      <version>2.6</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>
index 2b31d5594b159190e983cecb3fc11124f7398830..0201ac79803e1ce362fc311cb46921d0f81720d1 100644 (file)
@@ -11,6 +11,8 @@ import com.google.inject.AbstractModule;
 import org.opendaylight.aaa.web.WebContextSecurer;
 import org.opendaylight.aaa.web.WebServer;
 import org.opendaylight.aaa.web.jetty.JettyWebServer;
+import org.opendaylight.aaa.web.servlet.ServletSupport;
+import org.opendaylight.aaa.web.servlet.jersey2.JerseyServletSupport;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestModule;
 import org.opendaylight.neutron.northbound.api.WebInitializer;
@@ -88,6 +90,7 @@ public class NeutronTestWiring extends AbstractModule {
     protected void configure() {
         bind(WebServer.class).toInstance(new JettyWebServer(9090));
         bind(WebContextSecurer.class).toInstance((webContextBuilder, urlPatterns) -> { }); // NOOP
+        bind(ServletSupport.class).toInstance(new JerseyServletSupport());
         bind(WebInitializer.class);
 
         DataBrokerTestModule dataBrokerTestModule = new DataBrokerTestModule(true);
index 23987788db84ddcbb4eb9a8acd4ceedae3853ba1..a4a3985816d57788c51ae5a2ec6f7cce4e2b4b95 100644 (file)
        build failure. Please do not modify this unless you have a good reason. -->
   <name>ODL :: neutron :: ${project.artifactId}</name>
 
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.opendaylight.aaa</groupId>
+        <artifactId>aaa-artifacts</artifactId>
+        <version>0.8.0-SNAPSHOT</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
   <dependencies>
-    <dependency>
-      <groupId>com.sun.jersey</groupId>
-      <artifactId>jersey-core</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>com.sun.jersey</groupId>
-      <artifactId>jersey-server</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>com.sun.jersey</groupId>
-      <artifactId>jersey-servlet</artifactId>
-    </dependency>
     <dependency>
       <groupId>org.codehaus.enunciate</groupId>
       <artifactId>enunciate-core-annotations</artifactId>
     <dependency>
       <groupId>org.opendaylight.aaa.web</groupId>
       <artifactId>web-api</artifactId>
-      <version>0.8.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.aaa.web</groupId>
+      <artifactId>servlet-api</artifactId>
     </dependency>
   </dependencies>
   <build>
        <groupId>org.apache.aries.blueprint</groupId>
        <artifactId>blueprint-maven-plugin</artifactId>
       </plugin>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <extensions>true</extensions>
-        <configuration>
-          <instructions>
-            <Import-Package>
-              com.sun.jersey.spi.container.servlet,
-              !org.codehaus.enunciate.jaxrs,
-
-              com.sun.xml.bind;resolution:=optional,
-              com.sun.xml.bind.annotation;resolution:=optional,
-              com.sun.xml.bind.api;resolution:=optional,
-              com.sun.xml.bind.api.impl;resolution:=optional,
-              com.sun.codemodel;resolution:=optional,
-              com.sun.xml.xsom;resolution:=optional,
-              com.sun.xml.xsom.impl;resolution:=optional,
-              com.sun.xml.xsom.impl.parser;resolution:=optional,
-              com.sun.tools.xjc;resolution:=optional,
-              com.sun.tools.xjc.model;resolution:=optional,
-              com.sun.tools.xjc.outline;resolution:=optional,
-              javax.activation;resolution:=optional,
-              javax.json;resolution:=optional,
-              javax.json.stream;resolution:=optional,
-              javax.naming;resolution:=optional,
-              javax.validation;resolution:=optional,
-              javax.validation.constraints;resolution:=optional;
-              javax.validation.groups;resolution:=optional;
-              javax.ws.rs;resolution:=optional,
-              javax.ws.rs.core;resolution:=optional,
-              javax.ws.rs.ext;resolution:=optional,
-              javax.xml.namespace;resolution:=optional,
-              javax.xml.parsers;resolution:=optional,
-              javax.xml.stream;resolution:=optional,
-              javax.xml.transform;resolution:=optional,
-              javax.xml.transform.dom;resolution:=optional,
-              javax.xml.transform.sax;resolution:=optional,
-              javax.xml.transform.stax;resolution:=optional,
-              javax.xml.transform.stream;resolution:=optional,
-              javax.xml.validation;resolution:=optional,
-              org.eclipse.persistence.internal.libraries.asm;resolution:=optional,
-              *
-            </Import-Package>
-
-            <!-- Workaround for javax.ws.rs version mismatch with jackson/jersey/moxy -->
-            <Embed-Transitive>true</Embed-Transitive>
-            <Embed-Dependency>org.eclipse.persistence.moxy;inline</Embed-Dependency>
-          </instructions>
-        </configuration>
-      </plugin>
     </plugins>
   </build>
   <scm>
index 51e8ad99c891e28533f047f33719ec2ffaf97f7f..a615d02343505cef0d4cdd54b2f07f2a9fee9b75 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.aaa.web.WebContextBuilder;
 import org.opendaylight.aaa.web.WebContextRegistration;
 import org.opendaylight.aaa.web.WebContextSecurer;
 import org.opendaylight.aaa.web.WebServer;
+import org.opendaylight.aaa.web.servlet.ServletSupport;
 
 /**
  * Initializer for web components.
@@ -29,14 +30,14 @@ public class WebInitializer {
     private final WebContextRegistration registraton;
 
     @Inject
-    public WebInitializer(WebServer webServer, WebContextSecurer webContextSecurer, NeutronNorthboundRSApplication app)
-            throws ServletException {
+    public WebInitializer(WebServer webServer, WebContextSecurer webContextSecurer, ServletSupport servletSupport,
+            NeutronNorthboundRSApplication app) throws ServletException {
         WebContextBuilder webContextBuilder = WebContext.builder()
             .contextPath("/controller/nb/v2/neutron").supportsSessions(true)
             // TODO confirm through testing that Jersey & Neutron are fine without sessions, and false instead true
 
             .addServlet(ServletDetails.builder()
-                    .servlet(new com.sun.jersey.spi.container.servlet.ServletContainer(app))
+                    .servlet(servletSupport.createHttpServletBuilder(app).build())
                     .addUrlPattern("/*").build());
 
         webContextSecurer.requireAuthentication(webContextBuilder, "/*");
index 53bc0ad8fc0a2d489bfbd6cb53cc57a9d635783d..fab85014f1b1cb4f4cbc1cbce9bc178df513ba00 100644 (file)
@@ -6,4 +6,5 @@
 
   <reference id="webContextSecurer" interface="org.opendaylight.aaa.web.WebContextSecurer" />
 
+  <reference id="servletSupport" interface="org.opendaylight.aaa.web.servlet.ServletSupport" />
 </blueprint>