brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [27/34] brooklyn-server git commit: REST API optional Jersey compatibility
Date Thu, 18 Feb 2016 15:47:45 GMT
REST API optional Jersey compatibility


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/abd2d5f3
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/abd2d5f3
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/abd2d5f3

Branch: refs/heads/master
Commit: abd2d5f3b2a5584c639ca233acd474d2bc972035
Parents: 6f624c7
Author: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Authored: Tue Feb 9 19:30:17 2016 +0200
Committer: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Committed: Tue Feb 16 11:43:48 2016 +0200

----------------------------------------------------------------------
 camp/camp-server-jersey/pom.xml                 | 225 ++++++
 .../brooklyn/camp/server/RestApiSetup.java      |  53 ++
 .../rest/resource/ApiListingResource.java       | 260 +++++++
 .../rest/resource/ApidocRestResource.java       |  32 +
 .../src/main/webapp/WEB-INF/web.xml             | 142 ++++
 .../brooklyn/camp/server/RestApiSetup.java      |   4 +-
 .../brooklyn/camp/server/rest/CampServer.java   |   2 +-
 .../rest/resource/ApidocRestResource.java       |   2 +-
 camp/pom.xml                                    |   1 +
 launcher/pom.xml                                |  36 +-
 .../brooklyn/launcher/BrooklynWebServer.java    |   8 +-
 .../BrooklynJavascriptGuiLauncherTest.java      |   2 +-
 parent/pom.xml                                  |  28 +-
 pom.xml                                         |   3 +-
 .../rest/client/BrooklynApiUtilTest.java        |   2 +-
 .../brooklyn/rest/resources/ApidocResource.java |   3 +-
 .../rest/util/ManagementContextProvider.java    |   6 +-
 .../rest/util/ShutdownHandlerProvider.java      |   6 +-
 .../util/json/BrooklynJacksonJsonProvider.java  |  42 +-
 .../src/main/resources/not-a-jar-file.txt       |  18 -
 .../src/main/resources/reset-catalog.xml        |  37 -
 .../src/test/resources/not-a-jar-file.txt       |  18 +
 .../src/test/resources/reset-catalog.xml        |  37 +
 rest/rest-server-jersey/pom.xml                 | 317 +++++++++
 .../org/apache/brooklyn/rest/RestApiSetup.java  |  78 +++
 .../rest/filter/HaHotCheckResourceFilter.java   | 163 +++++
 .../brooklyn/rest/filter/NoCacheFilter.java     |  40 ++
 .../brooklyn/rest/filter/SwaggerFilter.java     |  79 +++
 .../rest/resources/ApiListingResource.java      | 260 +++++++
 .../brooklyn/rest/resources/ApidocResource.java |  33 +
 .../brooklyn/rest/util/FormMapProvider.java     |  81 +++
 .../main/resources/build-metadata.properties    |  18 +
 .../src/main/webapp/WEB-INF/web.xml             | 144 ++++
 .../BrooklynPropertiesSecurityFilterTest.java   | 151 ++++
 .../brooklyn/rest/BrooklynRestApiLauncher.java  | 499 +++++++++++++
 .../rest/BrooklynRestApiLauncherTest.java       |  77 ++
 .../BrooklynRestApiLauncherTestFixture.java     | 109 +++
 .../apache/brooklyn/rest/HaHotCheckTest.java    | 130 ++++
 .../brooklyn/rest/HaMasterCheckFilterTest.java  | 218 ++++++
 .../rest/domain/AbstractDomainTest.java         |  44 ++
 .../brooklyn/rest/domain/ApiErrorTest.java      |  71 ++
 .../rest/domain/ApplicationSpecTest.java        |  40 ++
 .../brooklyn/rest/domain/ApplicationTest.java   |  87 +++
 .../rest/domain/EffectorSummaryTest.java        |  44 ++
 .../brooklyn/rest/domain/EntitySpecTest.java    |  48 ++
 .../brooklyn/rest/domain/EntitySummaryTest.java |  48 ++
 .../brooklyn/rest/domain/LocationSpecTest.java  |  58 ++
 .../rest/domain/LocationSummaryTest.java        |  41 ++
 .../brooklyn/rest/domain/SensorSummaryTest.java | 103 +++
 .../rest/domain/VersionSummaryTest.java         |  49 ++
 .../AbstractRestApiEntitlementsTest.java        | 111 +++
 .../ActivityApiEntitlementsTest.java            | 123 ++++
 .../AuthenticateAnyoneSecurityProvider.java     |  41 ++
 .../EntityConfigApiEntitlementsTest.java        | 103 +++
 .../entitlement/SensorApiEntitlementsTest.java  | 108 +++
 .../entitlement/ServerApiEntitlementsTest.java  |  34 +
 .../StaticDelegatingEntitlementManager.java     |  37 +
 .../rest/resources/AccessResourceTest.java      |  68 ++
 .../rest/resources/ApidocResourceTest.java      | 177 +++++
 .../ApplicationResourceIntegrationTest.java     | 133 ++++
 .../rest/resources/ApplicationResourceTest.java | 701 +++++++++++++++++++
 .../rest/resources/CatalogResetTest.java        | 113 +++
 .../rest/resources/CatalogResourceTest.java     | 513 ++++++++++++++
 .../rest/resources/DelegatingPrintStream.java   | 183 +++++
 .../rest/resources/DescendantsTest.java         | 130 ++++
 .../resources/EntityConfigResourceTest.java     | 172 +++++
 .../rest/resources/EntityResourceTest.java      | 189 +++++
 .../rest/resources/ErrorResponseTest.java       |  98 +++
 .../rest/resources/LocationResourceTest.java    | 188 +++++
 .../rest/resources/PolicyResourceTest.java      | 145 ++++
 .../rest/resources/ScriptResourceTest.java      |  54 ++
 .../SensorResourceIntegrationTest.java          |  82 +++
 .../rest/resources/SensorResourceTest.java      | 271 +++++++
 .../ServerResourceIntegrationTest.java          | 125 ++++
 .../rest/resources/ServerResourceTest.java      | 168 +++++
 .../rest/resources/ServerShutdownTest.java      | 185 +++++
 .../rest/resources/UsageResourceTest.java       | 443 ++++++++++++
 .../rest/resources/VersionResourceTest.java     |  52 ++
 .../rest/security/PasswordHasherTest.java       |  37 +
 .../security/provider/TestSecurityProvider.java |  46 ++
 .../test/config/render/TestRendererHints.java   |  36 +
 .../brooklynnode/DeployBlueprintTest.java       |  89 +++
 .../rest/testing/BrooklynRestApiTest.java       | 223 ++++++
 .../rest/testing/BrooklynRestResourceTest.java  | 154 ++++
 .../rest/testing/mocks/CapitalizePolicy.java    |  33 +
 .../rest/testing/mocks/EverythingGroup.java     |  27 +
 .../rest/testing/mocks/EverythingGroupImpl.java |  32 +
 .../rest/testing/mocks/NameMatcherGroup.java    |  30 +
 .../testing/mocks/NameMatcherGroupImpl.java     |  33 +
 .../rest/testing/mocks/RestMockApp.java         |  24 +
 .../rest/testing/mocks/RestMockAppBuilder.java  |  39 ++
 .../testing/mocks/RestMockSimpleEntity.java     | 103 +++
 .../testing/mocks/RestMockSimplePolicy.java     |  64 ++
 .../util/BrooklynRestResourceUtilsTest.java     | 213 ++++++
 .../rest/util/EntityLocationUtilsTest.java      |  72 ++
 .../rest/util/HaHotStateCheckClassResource.java |  38 +
 .../rest/util/HaHotStateCheckResource.java      |  44 ++
 .../rest/util/NoOpRecordingShutdownHandler.java |  39 ++
 .../util/NullHttpServletRequestProvider.java    |  46 ++
 .../rest/util/NullServletConfigProvider.java    |  51 ++
 .../brooklyn/rest/util/RestApiTestUtils.java    |  58 ++
 .../util/ServerStoppingShutdownHandler.java     |  75 ++
 .../json/BrooklynJacksonSerializerTest.java     | 399 +++++++++++
 .../resources/brooklyn/scanning.catalog.bom     |  19 +
 .../resources/fixtures/api-error-basic.json     |   4 +
 .../fixtures/api-error-no-details.json          |   3 +
 .../resources/fixtures/application-list.json    |  44 ++
 .../resources/fixtures/application-spec.json    |  16 +
 .../resources/fixtures/application-tree.json    |  43 ++
 .../test/resources/fixtures/application.json    |  22 +
 .../fixtures/catalog-application-list.json      |  29 +
 .../resources/fixtures/catalog-application.json |   9 +
 .../fixtures/effector-summary-list.json         |  47 ++
 .../resources/fixtures/effector-summary.json    |   9 +
 .../resources/fixtures/entity-only-type.json    |   3 +
 .../resources/fixtures/entity-summary-list.json |  14 +
 .../test/resources/fixtures/entity-summary.json |  13 +
 .../src/test/resources/fixtures/entity.json     |   7 +
 .../src/test/resources/fixtures/ha-summary.json |  19 +
 .../test/resources/fixtures/location-list.json  |  10 +
 .../resources/fixtures/location-summary.json    |   8 +
 .../fixtures/location-without-credential.json   |   5 +
 .../src/test/resources/fixtures/location.json   |   4 +
 .../fixtures/sensor-current-state.json          |   6 +
 .../resources/fixtures/sensor-summary-list.json |  42 ++
 .../test/resources/fixtures/sensor-summary.json |   8 +
 .../test/resources/fixtures/server-version.json |  14 +
 .../test/resources/fixtures/service-state.json  |   1 +
 .../resources/fixtures/task-summary-list.json   |  15 +
 .../org/apache/brooklyn/rest/RestApiSetup.java  |  12 +-
 .../src/main/resources/not-a-jar-file.txt       |  18 -
 .../src/main/resources/reset-catalog.xml        |  37 -
 .../brooklyn/rest/BrooklynRestApiLauncher.java  |  61 +-
 .../rest/apidoc/ApiListingResource.java         |  20 -
 134 files changed, 11051 insertions(+), 260 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/camp/camp-server-jersey/pom.xml
----------------------------------------------------------------------
diff --git a/camp/camp-server-jersey/pom.xml b/camp/camp-server-jersey/pom.xml
new file mode 100644
index 0000000..5bb2517
--- /dev/null
+++ b/camp/camp-server-jersey/pom.xml
@@ -0,0 +1,225 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<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>
+    <artifactId>camp-server-jersey</artifactId>
+    <packaging>jar</packaging>
+    <name>CAMP Server Jersey</name>
+    <description>
+        REST Server classes for CAMP server implementation, using Jersey dependencies
+    </description>
+
+    <parent>
+        <groupId>org.apache.brooklyn.camp</groupId>
+        <artifactId>camp-parent</artifactId>
+        <version>0.9.0-SNAPSHOT</version>  <!-- BROOKLYN_VERSION -->
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.brooklyn.camp</groupId>
+            <artifactId>camp-base</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-utils-test-support</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn.camp</groupId>
+            <artifactId>camp-base</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <scope>test</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <!-- jackson-core and jackson-annotations are pulled in from this, with the right version -->
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.jaxrs</groupId>
+            <artifactId>jackson-jaxrs-json-provider</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>com.sun.jersey</groupId>
+            <artifactId>jersey-json</artifactId>
+              <exclusions>
+                <exclusion>
+                    <groupId>com.sun.xml.bind</groupId>
+                    <artifactId>jaxb-impl</artifactId>
+                </exclusion>
+            </exclusions>               
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-core</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.validation</groupId>
+            <artifactId>validation-api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-webapp</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-server</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-servlet</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-util</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-utils-rest-swagger</artifactId>
+            <version>${project.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>javax.ws.rs</groupId>
+                    <artifactId>javax.ws.rs-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-utils-common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        
+        <!-- TODO have a camp.log / logging module -->
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-logback-xml</artifactId>
+            <version>${project.version}</version>
+            <!-- optional so that this project has logging; dependencies may redeclare or supply their own -->
+            <optional>true</optional>
+        </dependency>
+        
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-resources-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>copy-rest-sources</id>
+                        <phase>generate-sources</phase>
+                        <goals><goal>copy-resources</goal></goals>
+                        <configuration>
+                          <outputDirectory>target/generated-sources/rest-deps</outputDirectory>
+                          <resources>
+                            <resource>
+                              <directory>../camp-server/src/main/java</directory>
+                              <excludes>
+                                <exclude>**/RestApiSetup.java</exclude>
+                                <exclude>**/ApidocRestResource.java</exclude>
+                              </excludes>
+                            </resource>
+                          </resources>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>copy-test-rest-sources</id>
+                        <phase>generate-sources</phase>
+                        <goals><goal>copy-resources</goal></goals>
+                        <configuration>
+                          <outputDirectory>target/generated-sources/test-rest-deps</outputDirectory>
+                          <resources>
+                            <resource>
+                              <directory>../camp-server/src/test/java</directory>
+                            </resource>
+                          </resources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>rest-sources</id>
+                        <phase>generate-sources</phase>
+                        <goals><goal>add-source</goal></goals>
+                        <configuration>
+                          <sources>
+                            <source>target/generated-sources/rest-deps</source>
+                          </sources>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>test-rest-sources</id>
+                        <phase>generate-sources</phase>
+                        <goals><goal>add-test-source</goal></goals>
+                        <configuration>
+                          <sources>
+                            <source>target/generated-sources/test-rest-deps</source>
+                          </sources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+         </plugins>
+    </build>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/RestApiSetup.java
----------------------------------------------------------------------
diff --git a/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/RestApiSetup.java b/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/RestApiSetup.java
new file mode 100644
index 0000000..60a44e0
--- /dev/null
+++ b/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/RestApiSetup.java
@@ -0,0 +1,53 @@
+/*
+ * 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.brooklyn.camp.server;
+
+import java.util.EnumSet;
+
+import javax.servlet.DispatcherType;
+
+import org.apache.brooklyn.camp.server.rest.CampRestResources;
+import org.eclipse.jetty.servlet.FilterHolder;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+
+import com.sun.jersey.api.core.DefaultResourceConfig;
+import com.sun.jersey.api.core.ResourceConfig;
+import com.sun.jersey.spi.container.servlet.ServletContainer;
+
+public class RestApiSetup {
+
+    public static void install(ServletContextHandler context) {
+        ResourceConfig config = new DefaultResourceConfig();
+        // load all our REST API modules, JSON, and Swagger
+        for (Object r: CampRestResources.getAllResources())
+            config.getSingletons().add(r);
+
+        // configure to match empty path, or any thing which looks like a file path with /assets/ and extension html, css, js, or png
+        // and treat that as static content
+        config.getProperties().put(ServletContainer.PROPERTY_WEB_PAGE_CONTENT_REGEX, "(/?|[^?]*/assets/[^?]+\\.[A-Za-z0-9_]+)");
+
+        // and anything which is not matched as a servlet also falls through (but more expensive than a regex check?)
+        config.getFeatures().put(ServletContainer.FEATURE_FILTER_FORWARD_ON_404, true);
+
+        // finally create this as a _filter_ which falls through to a web app or something (optionally)
+        FilterHolder filterHolder = new FilterHolder(new ServletContainer(config));
+        context.addFilter(filterHolder, "/*", EnumSet.allOf(DispatcherType.class));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApiListingResource.java
----------------------------------------------------------------------
diff --git a/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApiListingResource.java b/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApiListingResource.java
new file mode 100644
index 0000000..af656cc
--- /dev/null
+++ b/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApiListingResource.java
@@ -0,0 +1,260 @@
+/*
+ * Copyright 2015 The Apache Software Foundation.
+ *
+ * Licensed 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.brooklyn.camp.server.rest.resource;
+
+import com.sun.jersey.spi.container.servlet.WebConfig;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.config.FilterFactory;
+import io.swagger.config.Scanner;
+import io.swagger.config.ScannerFactory;
+import io.swagger.config.SwaggerConfig;
+import io.swagger.core.filter.SpecFilter;
+import io.swagger.core.filter.SwaggerSpecFilter;
+import io.swagger.jaxrs.Reader;
+import io.swagger.jaxrs.config.JaxrsScanner;
+import io.swagger.jaxrs.config.ReaderConfigUtils;
+import io.swagger.jaxrs.listing.SwaggerSerializers;
+import io.swagger.models.Swagger;
+import io.swagger.util.Yaml;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Cookie;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.brooklyn.util.text.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ApiListingResource usable within a jersey servlet filter.
+ *
+ * Taken from io.swagger:swagger-jaxrs, class
+ * io.swagger.jaxrs.listing.ApiListingResource, which can only be used within a
+ * servlet context. We are here using a filter, but jersey has a WebConfig class
+ * that can substitute ServletConfig and FilterConfig.
+ *
+ * @todo Remove when the rest-server is no longer running within a filter (e.g.
+ * as a standalone OSGi http service)
+ *
+ * @author Ciprian Ciubotariu <cheepeero@gmx.net>
+ */
+public class ApiListingResource {
+
+    static Logger LOGGER = LoggerFactory.getLogger(ApiListingResource.class);
+
+    @Context
+    ServletContext context;
+
+    boolean initialized = false;
+
+    private static class ServletConfigAdapter implements ServletConfig {
+
+        private final WebConfig webConfig;
+
+        private ServletConfigAdapter(WebConfig webConfig) {
+            this.webConfig = webConfig;
+        }
+
+        @Override
+        public String getServletName() {
+            return webConfig.getName();
+        }
+
+        @Override
+        public ServletContext getServletContext() {
+            return webConfig.getServletContext();
+        }
+
+        @Override
+        public String getInitParameter(String name) {
+            return webConfig.getInitParameter(name);
+        }
+
+        @Override
+        public Enumeration<String> getInitParameterNames() {
+            return webConfig.getInitParameterNames();
+        }
+
+    }
+
+    protected synchronized Swagger scan(Application app, WebConfig sc) {
+        Swagger swagger = null;
+        Scanner scanner = ScannerFactory.getScanner();
+        LOGGER.debug("using scanner " + scanner);
+
+        if (scanner != null) {
+            SwaggerSerializers.setPrettyPrint(scanner.getPrettyPrint());
+            swagger = (Swagger) context.getAttribute("swagger");
+
+            Set<Class<?>> classes;
+            if (scanner instanceof JaxrsScanner) {
+                JaxrsScanner jaxrsScanner = (JaxrsScanner) scanner;
+                classes = jaxrsScanner.classesFromContext(app, new ServletConfigAdapter(sc));
+            } else {
+                classes = scanner.classes();
+            }
+            if (classes != null) {
+                Reader reader = new Reader(swagger, ReaderConfigUtils.getReaderConfig(context));
+                swagger = reader.read(classes);
+                if (scanner instanceof SwaggerConfig) {
+                    swagger = ((SwaggerConfig) scanner).configure(swagger);
+                } else {
+                    SwaggerConfig configurator = (SwaggerConfig) context.getAttribute("reader");
+                    if (configurator != null) {
+                        LOGGER.debug("configuring swagger with " + configurator);
+                        configurator.configure(swagger);
+                    } else {
+                        LOGGER.debug("no configurator");
+                    }
+                }
+                context.setAttribute("swagger", swagger);
+            }
+        }
+        initialized = true;
+        return swagger;
+    }
+
+    private Swagger process(
+            Application app,
+            WebConfig sc,
+            HttpHeaders headers,
+            UriInfo uriInfo) {
+        Swagger swagger = (Swagger) context.getAttribute("swagger");
+        if (!initialized) {
+            swagger = scan(app, sc);
+        }
+        if (swagger != null) {
+            SwaggerSpecFilter filterImpl = FilterFactory.getFilter();
+            if (filterImpl != null) {
+                SpecFilter f = new SpecFilter();
+                swagger = f.filter(swagger, filterImpl, getQueryParams(uriInfo.getQueryParameters()), getCookies(headers),
+                        getHeaders(headers));
+            }
+        }
+        return swagger;
+    }
+
+    @GET
+    @Produces({MediaType.APPLICATION_JSON, "application/yaml"})
+    @ApiOperation(value = "The swagger definition in either JSON or YAML", hidden = true)
+    @Path("/swagger.{type:json|yaml}")
+    public Response getListing(
+            @Context Application app,
+            @Context WebConfig sc,
+            @Context HttpHeaders headers,
+            @Context UriInfo uriInfo,
+            @PathParam("type") String type) {
+        if (Strings.isNonBlank(type) && type.trim().equalsIgnoreCase("yaml")) {
+            return getListingYaml(app, sc, headers, uriInfo);
+        } else {
+            return getListingJson(app, sc, headers, uriInfo);
+        }
+    }
+
+    @GET
+    @Produces({MediaType.APPLICATION_JSON})
+    @Path("/swagger")
+    @ApiOperation(value = "The swagger definition in JSON", hidden = true)
+    public Response getListingJson(
+            @Context Application app,
+            @Context WebConfig sc,
+            @Context HttpHeaders headers,
+            @Context UriInfo uriInfo) {
+        Swagger swagger = process(app, sc, headers, uriInfo);
+
+        if (swagger != null) {
+            return Response.ok().entity(swagger).build();
+        } else {
+            return Response.status(404).build();
+        }
+    }
+
+    @GET
+    @Produces("application/yaml")
+    @Path("/swagger")
+    @ApiOperation(value = "The swagger definition in YAML", hidden = true)
+    public Response getListingYaml(
+            @Context Application app,
+            @Context WebConfig sc,
+            @Context HttpHeaders headers,
+            @Context UriInfo uriInfo) {
+        Swagger swagger = process(app, sc, headers, uriInfo);
+        try {
+            if (swagger != null) {
+                String yaml = Yaml.mapper().writeValueAsString(swagger);
+                StringBuilder b = new StringBuilder();
+                String[] parts = yaml.split("\n");
+                for (String part : parts) {
+                    b.append(part);
+                    b.append("\n");
+                }
+                return Response.ok().entity(b.toString()).type("application/yaml").build();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Response.status(404).build();
+    }
+
+    protected Map<String, List<String>> getQueryParams(MultivaluedMap<String, String> params) {
+        Map<String, List<String>> output = new HashMap<>();
+        if (params != null) {
+            for (String key : params.keySet()) {
+                List<String> values = params.get(key);
+                output.put(key, values);
+            }
+        }
+        return output;
+    }
+
+    protected Map<String, String> getCookies(HttpHeaders headers) {
+        Map<String, String> output = new HashMap<>();
+        if (headers != null) {
+            for (String key : headers.getCookies().keySet()) {
+                Cookie cookie = headers.getCookies().get(key);
+                output.put(key, cookie.getValue());
+            }
+        }
+        return output;
+    }
+
+    protected Map<String, List<String>> getHeaders(HttpHeaders headers) {
+        Map<String, List<String>> output = new HashMap<>();
+        if (headers != null) {
+            for (String key : headers.getRequestHeaders().keySet()) {
+                List<String> values = headers.getRequestHeaders().get(key);
+                output.put(key, values);
+            }
+        }
+        return output;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApidocRestResource.java
----------------------------------------------------------------------
diff --git a/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApidocRestResource.java b/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApidocRestResource.java
new file mode 100644
index 0000000..1696855
--- /dev/null
+++ b/camp/camp-server-jersey/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApidocRestResource.java
@@ -0,0 +1,32 @@
+/*
+ * 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.brooklyn.camp.server.rest.resource;
+
+import javax.ws.rs.Path;
+
+import io.swagger.annotations.Api;
+
+
+@Path(ApidocRestResource.API_URI_PATH)
+@Api("Web API Documentation")
+public class ApidocRestResource extends ApiListingResource {
+
+    public static final String API_URI_PATH = PlatformRestResource.CAMP_URI_PATH + "/apidoc";
+
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/camp/camp-server-jersey/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/camp/camp-server-jersey/src/main/webapp/WEB-INF/web.xml b/camp/camp-server-jersey/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..0ea4373
--- /dev/null
+++ b/camp/camp-server-jersey/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,142 @@
+<!DOCTYPE web-app PUBLIC
+        "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+        "http://java.sun.com/dtd/web-app_2_3.dtd" >
+<!--
+    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.
+-->
+<web-app>
+    <display-name>Brooklyn REST API v1</display-name>
+
+    <filter>
+        <filter-name>Brooklyn Request Tagging Filter</filter-name>
+        <filter-class>org.apache.brooklyn.rest.filter.RequestTaggingFilter</filter-class>
+    </filter>
+    <filter-mapping>
+        <filter-name>Brooklyn Request Tagging Filter</filter-name>
+        <url-pattern>/*</url-pattern>
+    </filter-mapping>
+
+    <filter>
+        <filter-name>Brooklyn Properties Authentication Filter</filter-name>
+        <filter-class>org.apache.brooklyn.rest.filter.BrooklynPropertiesSecurityFilter</filter-class>
+    </filter>
+    <filter-mapping>
+        <filter-name>Brooklyn Properties Authentication Filter</filter-name>
+        <url-pattern>/*</url-pattern>
+    </filter-mapping>
+
+    <filter>
+        <filter-name>Brooklyn Logging Filter</filter-name>
+        <filter-class>org.apache.brooklyn.rest.filter.LoggingFilter</filter-class>
+    </filter>
+    <filter-mapping>
+        <filter-name>Brooklyn Logging Filter</filter-name>
+        <url-pattern>/*</url-pattern>
+    </filter-mapping>
+
+    <filter>
+        <filter-name>Brooklyn HA Master Filter</filter-name>
+        <filter-class>org.apache.brooklyn.rest.filter.HaMasterCheckFilter</filter-class>
+    </filter>
+    <filter-mapping>
+        <filter-name>Brooklyn HA Master Filter</filter-name>
+        <url-pattern>/*</url-pattern>
+    </filter-mapping>
+
+    <filter>
+        <filter-name>Brooklyn Swagger Bootstrap</filter-name>
+        <filter-class>org.apache.brooklyn.rest.filter.SwaggerFilter</filter-class>
+    </filter>
+    <filter-mapping>
+        <filter-name>Brooklyn Swagger Bootstrap</filter-name>
+        <url-pattern>/*</url-pattern>
+    </filter-mapping>
+
+    <!-- Brooklyn REST is usually run as a filter so static content can be placed in a webapp
+         to which this is added; to run as a servlet directly, replace the filter tags 
+         below (after the comment) with the servlet tags (commented out immediately below),
+         (and do the same for the matching tags at the bottom)
+        <servlet>
+            <servlet-name>Brooklyn REST API v1 Servlet</servlet-name>
+            <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
+     -->
+    <filter>
+        <filter-name>Brooklyn REST API v1 Filter</filter-name>
+        <filter-class>com.sun.jersey.spi.container.servlet.ServletContainer</filter-class>
+
+        <!-- load our REST API jersey resources explicitly 
+            (the package scanner will only pick up classes with @Path annotations - doesn't look at implemented interfaces) 
+        -->
+        <init-param>
+            <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
+            <param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
+        </init-param>
+        <init-param>
+            <param-name>com.sun.jersey.config.property.classnames</param-name>
+            <param-value>
+                io.swagger.jaxrs.listing.SwaggerSerializers;
+                org.apache.brooklyn.rest.util.FormMapProvider;
+                org.codehaus.jackson.jaxrs.JacksonJsonProvider;
+                org.apache.brooklyn.rest.resources.ActivityResource;
+                org.apache.brooklyn.rest.resources.ApidocResource;
+                org.apache.brooklyn.rest.resources.ApplicationResource;
+                org.apache.brooklyn.rest.resources.CatalogResource;
+                org.apache.brooklyn.rest.resources.EffectorResource;
+                org.apache.brooklyn.rest.resources.EntityConfigResource;
+                org.apache.brooklyn.rest.resources.EntityResource;
+                org.apache.brooklyn.rest.resources.LocationResource;
+                org.apache.brooklyn.rest.resources.PolicyConfigResource;
+                org.apache.brooklyn.rest.resources.PolicyResource;
+                org.apache.brooklyn.rest.resources.ScriptResource;
+                org.apache.brooklyn.rest.resources.SensorResource;
+                org.apache.brooklyn.rest.resources.UsageResource;
+                org.apache.brooklyn.rest.resources.VersionResource;
+            </param-value>
+        </init-param>
+
+        <init-param>
+            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
+            <param-value>true</param-value>
+        </init-param>
+
+        <!-- no need for WADL. of course you can turn it back on it you want. -->
+        <init-param>
+            <param-name>com.sun.jersey.config.feature.DisableWADL</param-name>
+            <param-value>true</param-value>
+        </init-param>
+
+        <init-param>
+            <param-name>com.sun.jersey.config.feature.FilterContextPath</param-name>
+            <param-value>/v1</param-value>
+        </init-param>
+
+    </filter>
+    <filter-mapping>
+        <filter-name>Brooklyn REST API v1 Filter</filter-name>
+        <url-pattern>/v1/*</url-pattern>
+    </filter-mapping>
+    <!-- Brooklyn REST as a filter above; replace above 5 lines with those commented out below,
+         to run it as a servlet (see note above) 
+            <load-on-startup>1</load-on-startup>
+        </servlet>
+        <servlet-mapping>
+            <servlet-name>Brooklyn REST API v1 Servlet</servlet-name>
+            <url-pattern>/*</url-pattern>
+        </servlet-mapping>
+    -->
+</web-app>

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/RestApiSetup.java
----------------------------------------------------------------------
diff --git a/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/RestApiSetup.java b/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/RestApiSetup.java
index 127b5bd..302dff8 100644
--- a/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/RestApiSetup.java
+++ b/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/RestApiSetup.java
@@ -20,7 +20,6 @@ package org.apache.brooklyn.camp.server;
 
 import org.apache.brooklyn.rest.apidoc.RestApiResourceScanner;
 import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet;
-import org.eclipse.jetty.server.handler.ContextHandler;
 import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.servlet.ServletHolder;
 
@@ -28,7 +27,7 @@ import io.swagger.config.ScannerFactory;
 
 public class RestApiSetup {
 
-    public static ContextHandler installRestServlet(ServletContextHandler context) {
+    public static void install(ServletContextHandler context) {
         ScannerFactory.setScanner(new RestApiResourceScanner());
 
         CampRestApp app = new CampRestApp();
@@ -37,7 +36,6 @@ public class RestApiSetup {
         final ServletHolder servletHolder = new ServletHolder(servlet);
 
         context.addServlet(servletHolder, "/*");
-        return context;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/CampServer.java
----------------------------------------------------------------------
diff --git a/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/CampServer.java b/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/CampServer.java
index 1274494..669342f 100644
--- a/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/CampServer.java
+++ b/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/CampServer.java
@@ -121,7 +121,7 @@ public class CampServer {
     public static class CampServerUtils {
 
         public static void installAsServletFilter(ServletContextHandler context) {
-            RestApiSetup.installRestServlet(context);
+            RestApiSetup.install(context);
         }
 
         public static Server startServer(ContextHandler context, String summary) {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApidocRestResource.java
----------------------------------------------------------------------
diff --git a/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApidocRestResource.java b/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApidocRestResource.java
index 3c5f96d..40061ea 100644
--- a/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApidocRestResource.java
+++ b/camp/camp-server/src/main/java/org/apache/brooklyn/camp/server/rest/resource/ApidocRestResource.java
@@ -24,7 +24,7 @@ import javax.ws.rs.Path;
 
 @Path(ApidocRestResource.API_URI_PATH)
 @Api("Web API Documentation")
-public class ApidocRestResource extends org.apache.brooklyn.rest.apidoc.ApiListingResource {
+public class ApidocRestResource extends io.swagger.jaxrs.listing.ApiListingResource {
 
     public static final String API_URI_PATH = PlatformRestResource.CAMP_URI_PATH + "/apidoc";
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/camp/pom.xml
----------------------------------------------------------------------
diff --git a/camp/pom.xml b/camp/pom.xml
index 579c473..3bbce4b 100644
--- a/camp/pom.xml
+++ b/camp/pom.xml
@@ -39,6 +39,7 @@
     <modules>
         <module>camp-base</module>
         <module>camp-server</module>
+        <module>camp-server-jersey</module>
         <module>camp-brooklyn</module>
     </modules>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/launcher/pom.xml
----------------------------------------------------------------------
diff --git a/launcher/pom.xml b/launcher/pom.xml
index a10af41..9247a51 100644
--- a/launcher/pom.xml
+++ b/launcher/pom.xml
@@ -48,7 +48,7 @@
         </dependency>
         <dependency>
             <groupId>org.apache.brooklyn</groupId>
-            <artifactId>brooklyn-rest-server</artifactId>
+            <artifactId>brooklyn-rest-server${rest-server-classifier}</artifactId>
             <version>${project.version}</version>
         </dependency>
         <dependency>
@@ -63,7 +63,7 @@
         </dependency>
         <dependency>
             <groupId>org.apache.brooklyn.camp</groupId>
-            <artifactId>camp-server</artifactId>
+            <artifactId>camp-server${rest-server-classifier}</artifactId>
             <version>${project.version}</version>
         </dependency>
         <dependency>
@@ -132,10 +132,6 @@
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.apache.cxf</groupId>
-            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
-        </dependency>
 
         <dependency>
             <groupId>org.apache.brooklyn</groupId>
@@ -186,14 +182,7 @@
         </dependency>
         <dependency>
             <groupId>org.apache.brooklyn</groupId>
-            <artifactId>brooklyn-rest-resources</artifactId>
-            <version>${project.version}</version>
-            <classifier>tests</classifier>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.brooklyn</groupId>
-            <artifactId>brooklyn-rest-server</artifactId>
+            <artifactId>brooklyn-rest-server${rest-server-classifier}</artifactId>
             <version>${project.version}</version>
             <classifier>tests</classifier>
             <scope>test</scope>
@@ -283,4 +272,23 @@
             </plugin>
         </plugins>
     </build>
+    <profiles>
+        <profile>
+            <id>jax-rs-jersey</id>
+            <activation>
+                <property>
+                    <name>!jar-rs</name>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.brooklyn</groupId>
+                    <artifactId>brooklyn-rest-resources</artifactId>
+                    <version>${project.version}</version>
+                    <classifier>tests</classifier>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
 </project>

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynWebServer.java
----------------------------------------------------------------------
diff --git a/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynWebServer.java b/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynWebServer.java
index f2760f2..75e9f3e 100644
--- a/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynWebServer.java
+++ b/launcher/src/main/java/org/apache/brooklyn/launcher/BrooklynWebServer.java
@@ -74,8 +74,6 @@ import org.apache.brooklyn.util.stream.Streams;
 import org.apache.brooklyn.util.text.Identifiers;
 import org.apache.brooklyn.util.text.Strings;
 import org.apache.brooklyn.util.web.ContextHandlerCollectionHotSwappable;
-import org.apache.cxf.transport.common.gzip.GZIPInInterceptor;
-import org.apache.cxf.transport.common.gzip.GZIPOutInterceptor;
 import org.eclipse.jetty.http.HttpVersion;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.HttpConfiguration;
@@ -421,13 +419,11 @@ public class BrooklynWebServer {
     }
 
     private WebAppContext deployRestApi(WebAppContext context) {
-        RestApiSetup.installRestServlet(context,
+        RestApiSetup.installRest(context,
                 new ManagementContextProvider(managementContext),
                 new ShutdownHandlerProvider(shutdownHandler),
                 new NoCacheFilter(),
-                new HaHotCheckResourceFilter(),
-                new GZIPInInterceptor(),
-                new GZIPOutInterceptor());
+                new HaHotCheckResourceFilter());
         RestApiSetup.installServletFilters(context,
                 RequestTaggingFilter.class,
                 LoggingFilter.class,

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/launcher/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java
----------------------------------------------------------------------
diff --git a/launcher/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java b/launcher/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java
index 2896239..77adb2e 100644
--- a/launcher/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java
+++ b/launcher/src/test/java/org/apache/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java
@@ -84,7 +84,7 @@ public class BrooklynJavascriptGuiLauncherTest {
      *
      * @todo Remove after transition to karaf launcher.
      */
-    private static ManagementContext getManagementContext(ContextHandler jettyServerHandler) {
+    public static ManagementContext getManagementContext(ContextHandler jettyServerHandler) {
         ManagementContext managementContext = Compat.getInstance().getManagementContext();
         if (managementContext == null && jettyServerHandler != null) {
             managementContext = (ManagementContext) jettyServerHandler.getAttribute(BrooklynServiceAttributes.BROOKLYN_MANAGEMENT_CONTEXT);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index d87baae..308bb32 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -52,6 +52,10 @@
       http://stackoverflow.com/questions/5309379/how-to-keep-maven-profiles-which-are-activebydefault-active-even-if-another-prof )
     -->
 
+    <properties>
+        <rest-server-classifier />
+    </properties>
+
     <dependencyManagement>
         <dependencies>
             <dependency>
@@ -127,16 +131,6 @@
                 <version>${slf4j.version}</version>
             </dependency>
             <dependency>
-                <groupId>org.eclipse.jetty</groupId>
-                <artifactId>jetty-http</artifactId>
-                <version>${jetty.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.eclipse.jetty</groupId>
-                <artifactId>jetty-io</artifactId>
-                <version>${jetty.version}</version>
-            </dependency>
-            <dependency>
                 <groupId>org.apache.commons</groupId>
                 <artifactId>commons-lang3</artifactId>
                 <version>${commons-lang3.version}</version>
@@ -1841,6 +1835,18 @@
               </pluginManagement>
             </build>
         </profile>
-    </profiles>
 
+        <profile>
+            <id>jersey-deps</id>
+            <activation>
+              <property>
+                  <name>jax-rs</name>
+                  <value>jersey</value>
+              </property>
+            </activation>
+            <properties>
+              <rest-server-classifier>-jersey</rest-server-classifier>
+            </properties>
+        </profile>
+    </profiles>
 </project>

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 588198a..f710b91 100644
--- a/pom.xml
+++ b/pom.xml
@@ -208,8 +208,9 @@
         <module>logging/logback-xml</module>
         <module>rest/rest-api</module>
         <module>rest/rest-client</module>
-	<module>rest/rest-resources</module>
+        <module>rest/rest-resources</module>
         <module>rest/rest-server</module>
+        <module>rest/rest-server-jersey</module>
         <module>test-framework</module>
         <module>test-support</module>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-client/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiUtilTest.java
----------------------------------------------------------------------
diff --git a/rest/rest-client/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiUtilTest.java b/rest/rest-client/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiUtilTest.java
index eae9b6d..2543238 100644
--- a/rest/rest-client/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiUtilTest.java
+++ b/rest/rest-client/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiUtilTest.java
@@ -65,7 +65,7 @@ public class BrooklynApiUtilTest {
         BrooklynApiUtil.deployBlueprint(api, YAML);
 
         RecordedRequest request = server.takeRequest();
-        assertEquals("/v1/applications", request.getPath());
+        assertEquals("/applications", request.getPath());
         assertEquals("POST", request.getMethod());
         assertEquals(YAML, new String(request.getBody()));
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ApidocResource.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ApidocResource.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ApidocResource.java
index 220e4e3..7372288 100644
--- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ApidocResource.java
+++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/ApidocResource.java
@@ -21,9 +21,8 @@ package org.apache.brooklyn.rest.resources;
 
 import javax.ws.rs.Path;
 
-import org.apache.brooklyn.rest.apidoc.ApiListingResource;
-
 import io.swagger.annotations.Api;
+import io.swagger.jaxrs.listing.ApiListingResource;
 
 /**
  * @author Ciprian Ciubotariu <cheepeero@gmx.net>

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/ManagementContextProvider.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/ManagementContextProvider.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/ManagementContextProvider.java
index ae90d0e..cbe5d91 100644
--- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/ManagementContextProvider.java
+++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/ManagementContextProvider.java
@@ -35,7 +35,11 @@ public class ManagementContextProvider implements ContextResolver<ManagementCont
 
     @Override
     public ManagementContext getContext(Class<?> type) {
-        return mgmt;
+        if (type == ManagementContext.class) {
+            return mgmt;
+        } else {
+            return null;
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/ShutdownHandlerProvider.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/ShutdownHandlerProvider.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/ShutdownHandlerProvider.java
index bae2922..dd0ad21 100644
--- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/ShutdownHandlerProvider.java
+++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/ShutdownHandlerProvider.java
@@ -34,7 +34,11 @@ public class ShutdownHandlerProvider implements ContextResolver<ShutdownHandler>
 
     @Override
     public ShutdownHandler getContext(Class<?> type) {
-        return shutdownHandler;
+        if (type == ShutdownHandler.class) {
+            return shutdownHandler;
+        } else {
+            return null;
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonJsonProvider.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonJsonProvider.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonJsonProvider.java
index 5568208..9c6704d 100644
--- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonJsonProvider.java
+++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/util/json/BrooklynJacksonJsonProvider.java
@@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
 import javax.servlet.ServletContext;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.MessageBodyReader;
 import javax.ws.rs.ext.MessageBodyWriter;
 
@@ -31,7 +32,6 @@ import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.config.ConfigKeys;
 import org.apache.brooklyn.core.internal.BrooklynProperties;
 import org.apache.brooklyn.core.server.BrooklynServiceAttributes;
-import org.apache.brooklyn.rest.util.OsgiCompat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -48,12 +48,14 @@ public class BrooklynJacksonJsonProvider extends JacksonJsonProvider implements
 
     public static final String BROOKLYN_REST_OBJECT_MAPPER = BrooklynServiceAttributes.BROOKLYN_REST_OBJECT_MAPPER;
 
-    @Context protected ServletContext servletContext;
+    @Context
+    private ServletContext servletContext;
 
     protected ObjectMapper ourMapper;
     protected boolean notFound = false;
 
-    private ManagementContext mgmt;
+    @Context
+    private ContextResolver<ManagementContext> mgmt;
 
     @Override
     public ObjectMapper locateMapper(Class<?> type, MediaType mediaType) {
@@ -77,7 +79,7 @@ public class BrooklynJacksonJsonProvider extends JacksonJsonProvider implements
         if (ourMapper != null || notFound)
             return ourMapper;
 
-        ourMapper = findSharedObjectMapper(servletContext, mgmt);
+        ourMapper = findSharedObjectMapper(servletContext, mgmt());
         if (ourMapper == null) return null;
 
         if (notFound) {
@@ -88,6 +90,10 @@ public class BrooklynJacksonJsonProvider extends JacksonJsonProvider implements
         return ourMapper;
     }
 
+    private ManagementContext mgmt() {
+        return mgmt.getContext(ManagementContext.class);
+    }
+
     /**
      * Finds a shared {@link ObjectMapper} or makes a new one, stored against the servlet context;
      * returns null if a shared instance cannot be created.
@@ -113,19 +119,16 @@ public class BrooklynJacksonJsonProvider extends JacksonJsonProvider implements
                 }
             }
         }
-        if (mgmt != null) {
-            synchronized (mgmt) {
-                ConfigKey<ObjectMapper> key = ConfigKeys.newConfigKey(ObjectMapper.class, BROOKLYN_REST_OBJECT_MAPPER);
-                ObjectMapper mapper = mgmt.getConfig().getConfig(key);
-                if (mapper != null) return mapper;
-
-                mapper = newPrivateObjectMapper(mgmt);
-                log.debug("Storing new ObjectMapper against "+mgmt+" because no ServletContext available: "+mapper);
-                ((BrooklynProperties)mgmt.getConfig()).put(key, mapper);
-                return mapper;
-            }
+        synchronized (mgmt) {
+            ConfigKey<ObjectMapper> key = ConfigKeys.newConfigKey(ObjectMapper.class, BROOKLYN_REST_OBJECT_MAPPER);
+            ObjectMapper mapper = mgmt.getConfig().getConfig(key);
+            if (mapper != null) return mapper;
+
+            mapper = newPrivateObjectMapper(mgmt);
+            log.debug("Storing new ObjectMapper against "+mgmt+" because no ServletContext available: "+mapper);
+            ((BrooklynProperties)mgmt.getConfig()).put(key, mapper);
+            return mapper;
         }
-        return null;
     }
 
     /**
@@ -136,9 +139,6 @@ public class BrooklynJacksonJsonProvider extends JacksonJsonProvider implements
         ObjectMapper mapper = findSharedObjectMapper(servletContext, mgmt);
         if (mapper != null) return mapper;
 
-        if (mgmt == null && servletContext != null) {
-            mgmt = getManagementContext(servletContext);
-        }
         return newPrivateObjectMapper(mgmt);
     }
 
@@ -170,8 +170,4 @@ public class BrooklynJacksonJsonProvider extends JacksonJsonProvider implements
         return mapper;
     }
 
-    public static ManagementContext getManagementContext(ServletContext servletContext) {
-        return OsgiCompat.getManagementContext(servletContext);
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-resources/src/main/resources/not-a-jar-file.txt
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/main/resources/not-a-jar-file.txt b/rest/rest-resources/src/main/resources/not-a-jar-file.txt
deleted file mode 100644
index fbc22fe..0000000
--- a/rest/rest-resources/src/main/resources/not-a-jar-file.txt
+++ /dev/null
@@ -1,18 +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.
-
-Test loading of malformed jar file
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-resources/src/main/resources/reset-catalog.xml
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/main/resources/reset-catalog.xml b/rest/rest-resources/src/main/resources/reset-catalog.xml
deleted file mode 100644
index adef40a..0000000
--- a/rest/rest-resources/src/main/resources/reset-catalog.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-    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.
--->
-<catalog>
-    <name>Brooklyn Demos</name>
-
-    <template type="org.apache.brooklyn.entity.stock.BasicApplication" name="Basic application" />
-    <template type="org.apache.brooklyn.test.osgi.entities.SimpleApplication" name="Simple OSGi application">
-        <libraries>
-            <bundle>${bundle-location}</bundle>
-        </libraries>
-    </template>
-    <catalog>
-        <name>Nested catalog</name>
-        <template type="org.apache.brooklyn.test.osgi.entities.SimpleApplication" name="Simple OSGi application">
-            <libraries>
-                <bundle>${bundle-location}</bundle>
-            </libraries>
-        </template>
-    </catalog>
-</catalog>

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-resources/src/test/resources/not-a-jar-file.txt
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/test/resources/not-a-jar-file.txt b/rest/rest-resources/src/test/resources/not-a-jar-file.txt
new file mode 100644
index 0000000..fbc22fe
--- /dev/null
+++ b/rest/rest-resources/src/test/resources/not-a-jar-file.txt
@@ -0,0 +1,18 @@
+# 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.
+
+Test loading of malformed jar file
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-resources/src/test/resources/reset-catalog.xml
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/test/resources/reset-catalog.xml b/rest/rest-resources/src/test/resources/reset-catalog.xml
new file mode 100644
index 0000000..adef40a
--- /dev/null
+++ b/rest/rest-resources/src/test/resources/reset-catalog.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<catalog>
+    <name>Brooklyn Demos</name>
+
+    <template type="org.apache.brooklyn.entity.stock.BasicApplication" name="Basic application" />
+    <template type="org.apache.brooklyn.test.osgi.entities.SimpleApplication" name="Simple OSGi application">
+        <libraries>
+            <bundle>${bundle-location}</bundle>
+        </libraries>
+    </template>
+    <catalog>
+        <name>Nested catalog</name>
+        <template type="org.apache.brooklyn.test.osgi.entities.SimpleApplication" name="Simple OSGi application">
+            <libraries>
+                <bundle>${bundle-location}</bundle>
+            </libraries>
+        </template>
+    </catalog>
+</catalog>

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/pom.xml
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/pom.xml b/rest/rest-server-jersey/pom.xml
new file mode 100644
index 0000000..bf5e2c2
--- /dev/null
+++ b/rest/rest-server-jersey/pom.xml
@@ -0,0 +1,317 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<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>
+    <artifactId>brooklyn-rest-server-jersey</artifactId>
+    <packaging>jar</packaging>
+    <name>Brooklyn REST Server with Jersey dependencies</name>
+    <description>
+        Brooklyn REST Endpoint, using Jersey as the JAR-RS implementation
+    </description>
+
+    <parent>
+        <groupId>org.apache.brooklyn</groupId>
+        <artifactId>brooklyn-parent</artifactId>
+        <version>0.9.0-SNAPSHOT</version><!-- BROOKLYN_VERSION -->
+        <relativePath>../../parent/pom.xml</relativePath>
+    </parent>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-annotations</artifactId>
+            <version>${fasterxml.jackson.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>${fasterxml.jackson.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.validation</groupId>
+            <artifactId>validation-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.findbugs</groupId>
+            <artifactId>jsr305</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-core</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-utils-common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.swagger</groupId>
+            <artifactId>swagger-annotations</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-test-support</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-camp</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn.camp</groupId>
+            <artifactId>camp-base</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-software-base</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-utils-rest-swagger</artifactId>
+            <version>${project.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>javax.ws.rs</groupId>
+                    <artifactId>javax.ws.rs-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.yaml</groupId>
+            <artifactId>snakeyaml</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.reflections</groupId>
+            <artifactId>reflections</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.ws.rs</groupId>
+            <artifactId>jsr311-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.jaxrs</groupId>
+            <artifactId>jackson-jaxrs-json-provider</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.eclipse.jetty</groupId>
+            <artifactId>jetty-webapp</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-server</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-servlet</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-policy</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-core</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-software-base</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-locations-jclouds</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-all</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-client</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey.jersey-test-framework</groupId>
+            <artifactId>jersey-test-framework-inmemory</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey.jersey-test-framework</groupId>
+            <artifactId>jersey-test-framework-grizzly2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-rt-osgi</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <resources>
+            <resource>
+                <directory>../rest-server/src/main/resources</directory>
+                <!-- Required to set values in build-metadata.properties -->
+                <filtering>true</filtering>
+            </resource>
+            <resource>
+                <directory>src/main/webapp</directory>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <artifactId>maven-resources-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>copy-rest-sources</id>
+                        <phase>generate-sources</phase>
+                        <goals><goal>copy-resources</goal></goals>
+                        <configuration>
+                          <outputDirectory>target/generated-sources/rest-deps</outputDirectory>
+                          <resources>
+                            <resource>
+                              <directory>../rest-api/src/main/java</directory>
+                            </resource>
+                            <resource>
+                              <directory>../rest-resources/src/main/java</directory>
+                              <excludes>
+                                <exclude>**/NoCacheFilter.java</exclude>
+                                <exclude>**/HaHotCheckResourceFilter.java</exclude>
+                                <exclude>**/FormMapProvider.java</exclude>
+                                <exclude>**/ApidocResource.java</exclude>
+                              </excludes>
+                            </resource>
+                            <resource>
+                              <directory>../rest-server/src/main/java</directory>
+                              <excludes>
+                                <exclude>**/RestApiSetup.java</exclude>
+                              </excludes>
+                            </resource>
+                          </resources>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>copy-rest-test-resources</id>
+                        <phase>generate-test-resources</phase>
+                        <goals><goal>copy-resources</goal></goals>
+                        <configuration>
+                          <outputDirectory>target/generated-test-resources/rest-deps</outputDirectory>
+                          <resources>
+                            <resource>
+                              <directory>../rest-resources/src/test/resources</directory>
+                            </resource>
+                            <resource>
+                              <directory>../rest-server/src/test/resources</directory>
+                            </resource>
+                          </resources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>rest-sources</id>
+                        <phase>generate-sources</phase>
+                        <goals><goal>add-source</goal></goals>
+                        <configuration>
+                          <sources>
+                            <source>target/generated-sources/rest-deps</source>
+                          </sources>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>rest-resources</id>
+                        <phase>generate-test-resources</phase>
+                        <goals><goal>add-test-resource</goal></goals>
+                        <configuration>
+                          <resources>
+                            <resource>
+                                <directory>target/generated-test-resources/rest-deps</directory>
+                            </resource>
+                          </resources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+         </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/abd2d5f3/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/RestApiSetup.java
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/RestApiSetup.java b/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/RestApiSetup.java
new file mode 100644
index 0000000..9084756
--- /dev/null
+++ b/rest/rest-server-jersey/src/main/java/org/apache/brooklyn/rest/RestApiSetup.java
@@ -0,0 +1,78 @@
+/*
+ * 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.brooklyn.rest;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.EnumSet;
+
+import javax.servlet.DispatcherType;
+import javax.servlet.Filter;
+
+import org.apache.brooklyn.rest.filter.HaHotCheckResourceFilter;
+import org.apache.brooklyn.rest.filter.SwaggerFilter;
+import org.eclipse.jetty.servlet.FilterHolder;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+
+import com.google.common.collect.ImmutableList;
+import com.sun.jersey.api.container.filter.GZIPContentEncodingFilter;
+import com.sun.jersey.api.core.DefaultResourceConfig;
+import com.sun.jersey.api.core.ResourceConfig;
+import com.sun.jersey.spi.container.servlet.ServletContainer;
+
+public class RestApiSetup {
+
+    public static void installRest(ServletContextHandler context, Object... providers) {
+        ResourceConfig config = new DefaultResourceConfig();
+        // load all our REST API modules, JSON, and Swagger
+        for (Object r: BrooklynRestApi.getAllResources())
+            config.getSingletons().add(r);
+        for (Object o: providers)
+            config.getSingletons().add(o);
+
+        // Accept gzipped requests and responses, disable caching for dynamic content
+        config.getProperties().put(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS, GZIPContentEncodingFilter.class.getName());
+        config.getProperties().put(ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS, ImmutableList.of(GZIPContentEncodingFilter.class/*, NoCacheFilter.class*/));
+        // Checks if appropriate request given HA status
+        config.getProperties().put(ResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES, HaHotCheckResourceFilter.class.getName());
+        // configure to match empty path, or any thing which looks like a file path with /assets/ and extension html, css, js, or png
+        // and treat that as static content
+        config.getProperties().put(ServletContainer.PROPERTY_WEB_PAGE_CONTENT_REGEX, "(/?|[^?]*/assets/[^?]+\\.[A-Za-z0-9_]+)");
+        // and anything which is not matched as a servlet also falls through (but more expensive than a regex check?)
+        config.getFeatures().put(ServletContainer.FEATURE_FILTER_FORWARD_ON_404, true);
+        // finally create this as a _filter_ which falls through to a web app or something (optionally)
+        FilterHolder filterHolder = new FilterHolder(new ServletContainer(config));
+
+        filterHolder.setInitParameter(ServletContainer.PROPERTY_FILTER_CONTEXT_PATH, "/v1");
+        context.addFilter(filterHolder, "/v1/*", EnumSet.allOf(DispatcherType.class));
+
+        installServletFilters(context, SwaggerFilter.class);
+    }
+
+    @SafeVarargs
+    public static void installServletFilters(ServletContextHandler context, Class<? extends Filter>... filters) {
+        installServletFilters(context, Arrays.asList(filters));
+    }
+
+    public static void installServletFilters(ServletContextHandler context, Collection<Class<? extends Filter>> filters) {
+        for (Class<? extends Filter> filter : filters) {
+            context.addFilter(filter, "/*", EnumSet.allOf(DispatcherType.class));
+        }
+    }
+}


Mime
View raw message