<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}.web</groupId>
+ <artifactId>web-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}.web</groupId>
+ <artifactId>web-osgi-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}.web</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}.web</groupId>
+ <artifactId>servlet-jersey2</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>features-aaa</artifactId>
<name>ODL :: aaa :: ${project.artifactId}</name>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>aaa-artifacts</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey</groupId>
+ <artifactId>jersey-bom</artifactId>
+ <version>2.25.1</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
<dependencies>
<dependency>
<groupId>org.opendaylight.odlparent</groupId>
<dependency>
<groupId>${project.groupId}.web</groupId>
<artifactId>web-osgi-impl</artifactId>
- <version>${project.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>${project.groupId}.web</groupId>
+ <artifactId>servlet-jersey2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.bundles.repackaged</groupId>
+ <artifactId>jersey-guava</artifactId>
+ <version>2.25.1</version>
+ </dependency>
+
<dependency>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odl-karaf-feat-jetty</artifactId>
<module>api</module>
<module>impl-osgi</module>
<module>impl-jetty</module>
+ <module>servlet-api</module>
+ <module>servlet-jersey2</module>
</modules>
</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright © 2018 Pantheon Technologies, s.r.o. and others. All rights reserved.
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.opendaylight.aaa</groupId>
+ <artifactId>aaa-parent</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <groupId>org.opendaylight.aaa.web</groupId>
+ <artifactId>servlet-api</artifactId>
+ <name>ODL :: aaa :: ${project.artifactId}</name>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>concepts</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
--- /dev/null
+/*
+ * Copyright (c) 2018 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.aaa.web.servlet;
+
+import com.google.common.annotations.Beta;
+import javax.annotation.concurrent.NotThreadSafe;
+import javax.servlet.http.HttpServlet;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Configurable;
+import org.opendaylight.yangtools.concepts.Builder;
+
+/**
+ * Utility methods for instantiating {@link HttpServlet}s from {@link Application}s, abstracting the servlet
+ * implementation from application developers.
+ *
+ * @author Robert Varga
+ */
+@Beta
+@NotThreadSafe
+public interface HttpServletBuilder extends Builder<HttpServlet>, Configurable<HttpServletBuilder> {
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.aaa.web.servlet;
+
+import com.google.common.annotations.Beta;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.core.Application;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+
+/**
+ * Main API entry point. An implementation of this interface is injected in the application.
+ *
+ * @author Robert Varga
+ */
+@Beta
+@NonNullByDefault
+public interface ServletSupport {
+ /**
+ * Create a new {@link ClientBuilder}.
+ *
+ * @return A new ClientBuilder.
+ */
+ ClientBuilder newClientBuilder();
+
+ /**
+ * Create a new {@link HttpServletBuilder} for an {@link Application}.
+ *
+ * @return A new HttpServletBuilder.
+ */
+ HttpServletBuilder createHttpServletBuilder(Application application);
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright © 2018 Pantheon Technologies, s.r.o. and others. All rights reserved.
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.opendaylight.aaa</groupId>
+ <artifactId>aaa-parent</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <groupId>org.opendaylight.aaa.web</groupId>
+ <artifactId>servlet-jersey2</artifactId>
+ <name>ODL :: aaa :: ${project.artifactId}</name>
+ <packaging>bundle</packaging>
+
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.glassfish.jersey</groupId>
+ <artifactId>jersey-bom</artifactId>
+ <version>2.25.1</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.aaa.web</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.containers</groupId>
+ <artifactId>jersey-container-servlet</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.kohsuke.metainf-services</groupId>
+ <artifactId>metainf-services</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Include-Resource>{META-INF/services=${project.build.directory}/classes/META-INF/services}</Include-Resource>
+ <Bundle-Activator>org.opendaylight.aaa.web.servlet.jersey2.osgi.Activator</Bundle-Activator>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+/*
+ * Copyright (c) 2018 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.aaa.web.servlet.jersey2;
+
+import java.util.Map;
+import javax.servlet.http.HttpServlet;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Configuration;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.servlet.ServletContainer;
+import org.opendaylight.aaa.web.servlet.HttpServletBuilder;
+
+/**
+ * Jersey-based implementation of {@link HttpServletBuilder}.
+ *
+ * @author Robert Varga
+ */
+final class JerseyHttpServletBuilder implements HttpServletBuilder {
+ private ResourceConfig config;
+
+ JerseyHttpServletBuilder(final Application application) {
+ config = ResourceConfig.forApplication(application);
+ }
+
+ @Override
+ public HttpServlet build() {
+ return new ServletContainer(config);
+ }
+
+ @Override
+ public Configuration getConfiguration() {
+ return config;
+ }
+
+ @Override
+ public HttpServletBuilder property(final String name, final Object value) {
+ config = config.property(name, value);
+ return this;
+ }
+
+ @Override
+ public HttpServletBuilder register(final Class<?> componentClass) {
+ config = config.register(componentClass);
+ return this;
+ }
+
+ @Override
+ public HttpServletBuilder register(final Class<?> componentClass, final int priority) {
+ config = config.register(componentClass, priority);
+ return this;
+ }
+
+ @Override
+ public HttpServletBuilder register(final Class<?> componentClass, final Class<?>... contracts) {
+ config = config.register(componentClass, contracts);
+ return this;
+ }
+
+ @Override
+ public HttpServletBuilder register(final Class<?> componentClass, final Map<Class<?>, Integer> contracts) {
+ config = config.register(componentClass, contracts);
+ return this;
+ }
+
+ @Override
+ public HttpServletBuilder register(final Object component) {
+ config = config.register(component);
+ return this;
+ }
+
+ @Override
+ public HttpServletBuilder register(final Object component, final int priority) {
+ config = config.register(component, priority);
+ return this;
+ }
+
+ @Override
+ public HttpServletBuilder register(final Object component, final Class<?>... contracts) {
+ config = config.register(component, contracts);
+ return this;
+ }
+
+ @Override
+ public HttpServletBuilder register(final Object component, final Map<Class<?>, Integer> contracts) {
+ config = config.register(component, contracts);
+ return this;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.aaa.web.servlet.jersey2;
+
+import com.google.common.annotations.Beta;
+import javax.annotation.concurrent.ThreadSafe;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.core.Application;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.glassfish.jersey.client.JerseyClientBuilder;
+import org.kohsuke.MetaInfServices;
+import org.opendaylight.aaa.web.servlet.HttpServletBuilder;
+import org.opendaylight.aaa.web.servlet.ServletSupport;
+
+@Beta
+@MetaInfServices
+@NonNullByDefault
+@ThreadSafe
+public final class JerseyServletSupport implements ServletSupport {
+ @Override
+ public HttpServletBuilder createHttpServletBuilder(final Application application) {
+ return new JerseyHttpServletBuilder(application);
+ }
+
+ @Override
+ public ClientBuilder newClientBuilder() {
+ return new JerseyClientBuilder();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.aaa.web.servlet.jersey2.osgi;
+
+import org.opendaylight.aaa.web.servlet.ServletSupport;
+import org.opendaylight.aaa.web.servlet.jersey2.JerseyServletSupport;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class Activator implements BundleActivator {
+ private ServiceRegistration<ServletSupport> reg;
+
+ @Override
+ public void start(final BundleContext context) {
+ reg = context.registerService(ServletSupport.class, new JerseyServletSupport(), null);
+ }
+
+ @Override
+ public void stop(final BundleContext context) {
+ if (reg != null) {
+ reg.unregister();
+ reg = null;
+ }
+ }
+}