You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2014/09/10 00:49:11 UTC

[08/19] add support for setting and deleting sensors, with tests, and setting config on entities dynamically; also major version changes and removal of old dependencies: * remove dropwizard as it had buggy treatment of string return values from jersey me

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/ExecutorConfiguration.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/ExecutorConfiguration.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/ExecutorConfiguration.java
deleted file mode 100644
index 86ac7fd..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/ExecutorConfiguration.java
+++ /dev/null
@@ -1,40 +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.
- */
-package brooklyn.rest;
-
-public class ExecutorConfiguration {
-
-  private int corePoolSize = 2;
-
-  private int maximumPoolSize = 16;
-
-  private int keepAliveTimeInSeconds = 120;
-
-  public int getCorePoolSize() {
-    return corePoolSize;
-  }
-
-  public int getMaximumPoolSize() {
-    return maximumPoolSize;
-  }
-
-  public int getKeepAliveTimeInSeconds() {
-    return keepAliveTimeInSeconds;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/auth/BasicAuthFilter.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/auth/BasicAuthFilter.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/auth/BasicAuthFilter.java
deleted file mode 100644
index 3f013c1..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/auth/BasicAuthFilter.java
+++ /dev/null
@@ -1,120 +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.
- */
-package brooklyn.rest.auth;
-
-import com.google.common.base.Optional;
-import static com.google.common.base.Preconditions.checkNotNull;
-import com.yammer.dropwizard.auth.AuthenticationException;
-import com.yammer.dropwizard.auth.Authenticator;
-import com.yammer.dropwizard.auth.basic.BasicCredentials;
-import com.yammer.dropwizard.logging.Log;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import org.eclipse.jetty.util.B64Code;
-import org.eclipse.jetty.util.StringUtil;
-
-public class BasicAuthFilter<T> implements Filter {
-
-  private static final Log LOG = Log.forClass(BasicAuthFilter.class);
-
-  private static final String PREFIX = "Basic";
-  private static final String HEADER_NAME = "WWW-Authenticate";
-  private static final String HEADER_VALUE = PREFIX + " realm=\"%s\"";
-
-  private final Authenticator<BasicCredentials, T> authenticator;
-  private final String realm;
-
-  public BasicAuthFilter(Authenticator<BasicCredentials, T> authenticator, String realm) {
-    this.authenticator = checkNotNull(authenticator, "authenticator");
-    this.realm = checkNotNull(realm, "realm");
-  }
-
-  @Override
-  public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain)
-      throws IOException, ServletException {
-
-    HttpServletRequest request = (HttpServletRequest) servletRequest;
-    HttpServletResponse response = (HttpServletResponse) servletResponse;
-
-    final String header = request.getHeader(HttpHeaders.AUTHORIZATION);
-    try {
-      if (header != null) {
-        final int space = header.indexOf(' ');
-        if (space > 0) {
-          final String method = header.substring(0, space);
-          if (PREFIX.equalsIgnoreCase(method)) {
-            final String decoded = B64Code.decode(header.substring(space + 1),
-                StringUtil.__ISO_8859_1);
-            final int i = decoded.indexOf(':');
-            if (i > 0) {
-              final String username = decoded.substring(0, i);
-              final String password = decoded.substring(i + 1);
-
-              final BasicCredentials credentials = new BasicCredentials(username, password);
-              final Optional<T> result = authenticator.authenticate(credentials);
-
-              if (result.isPresent()) {
-                chain.doFilter(servletRequest, servletResponse);
-                return;
-              }
-            }
-          }
-        }
-      }
-    } catch (UnsupportedEncodingException e) {
-      LOG.debug(e, "Error decoding credentials");
-
-    } catch (IllegalArgumentException e) {
-      LOG.debug(e, "Error decoding credentials");
-
-    } catch (AuthenticationException e) {
-      LOG.warn(e, "Error authentication credentials");
-
-      response.sendError(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
-      return;
-    }
-
-    response.setHeader(HEADER_NAME, String.format(HEADER_VALUE, realm));
-    response.setContentType(MediaType.TEXT_PLAIN);
-    response.sendError(Response.Status.UNAUTHORIZED.getStatusCode(),
-        "Credentials are required to access this resource.");
-  }
-
-  @Override
-  public void init(FilterConfig config) throws ServletException {
-    /* not used */
-  }
-
-  @Override
-  public void destroy() {
-    /* not used */
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/auth/ConfigBasedAuthenticator.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/auth/ConfigBasedAuthenticator.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/auth/ConfigBasedAuthenticator.java
deleted file mode 100644
index 32cb1f3..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/auth/ConfigBasedAuthenticator.java
+++ /dev/null
@@ -1,54 +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.
- */
-package brooklyn.rest.auth;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
-import com.yammer.dropwizard.auth.AuthenticationException;
-import com.yammer.dropwizard.auth.Authenticator;
-import com.yammer.dropwizard.auth.basic.BasicCredentials;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * An authenticator that's using a list of accounts defined
- * in the application configuration file
- */
-public class ConfigBasedAuthenticator implements Authenticator<BasicCredentials, User> {
-
-  private final Map<String, User> userByNameIndex;
-
-  public ConfigBasedAuthenticator(Set<User> users) {
-    ImmutableMap.Builder<String, User> builder = ImmutableMap.builder();
-    for (User user : users) {
-      builder.put(user.getName(), user);
-    }
-    userByNameIndex = builder.build();
-  }
-
-  @Override
-  public Optional<User> authenticate(BasicCredentials credentials)
-      throws AuthenticationException {
-    User user = userByNameIndex.get(credentials.getUsername());
-    if (user == null || !user.getClearTextPassword().equals(credentials.getPassword())) {
-      return Optional.absent();
-    }
-    return Optional.of(user);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/auth/User.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/auth/User.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/auth/User.java
deleted file mode 100644
index a0b62c6..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/auth/User.java
+++ /dev/null
@@ -1,84 +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.
- */
-package brooklyn.rest.auth;
-
-import java.util.Set;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-public class User {
-
-  private final String name;
-
-  private final String clearTextPassword;
-
-  private final Set<String> roles;
-
-  public User(
-      @JsonProperty("name") String name,
-      @JsonProperty("password") String clearTextPassword,
-      @JsonProperty("roles") Set<String> roles
-  ) {
-    this.name = name;
-    this.clearTextPassword = clearTextPassword;
-    this.roles = roles;
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  public String getClearTextPassword() {
-    return clearTextPassword;
-  }
-
-  public Set<String> getRoles() {
-    return roles;
-  }
-
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
-
-    User user = (User) o;
-
-    if (clearTextPassword != null ? !clearTextPassword.equals(user.clearTextPassword) : user.clearTextPassword != null)
-      return false;
-    if (name != null ? !name.equals(user.name) : user.name != null) return false;
-    if (roles != null ? !roles.equals(user.roles) : user.roles != null) return false;
-
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    int result = name != null ? name.hashCode() : 0;
-    result = 31 * result + (clearTextPassword != null ? clearTextPassword.hashCode() : 0);
-    result = 31 * result + (roles != null ? roles.hashCode() : 0);
-    return result;
-  }
-
-  @Override
-  public String toString() {
-    return "User{" +
-        "name='" + name + '\'' +
-        ", roles=" + roles +
-        '}';
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/BrooklynCommand.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/BrooklynCommand.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/BrooklynCommand.java
deleted file mode 100644
index 388f018..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/BrooklynCommand.java
+++ /dev/null
@@ -1,190 +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.
- */
-package brooklyn.rest.commands;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Throwables;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.filter.GZIPContentEncodingFilter;
-import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
-import com.sun.jersey.client.apache4.ApacheHttpClient4Handler;
-import com.sun.jersey.client.apache4.config.ApacheHttpClient4Config;
-import com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config;
-import com.yammer.dropwizard.AbstractService;
-import com.yammer.dropwizard.cli.Command;
-import com.yammer.dropwizard.client.HttpClientFactory;
-import com.yammer.dropwizard.client.JerseyClient;
-import com.yammer.dropwizard.client.JerseyClientConfiguration;
-import com.yammer.dropwizard.jersey.JacksonMessageBodyProvider;
-import com.yammer.dropwizard.json.Json;
-import com.yammer.dropwizard.util.Duration;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Options;
-import org.apache.http.client.HttpClient;
-
-import java.io.PrintStream;
-import java.net.URI;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.SynchronousQueue;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-public abstract class BrooklynCommand extends Command {
-
-  private String endpoint;
-
-  private String user;
-  private String password;
-
-  /**
-   * Create a new {@link BrooklynCommand} instance.
-   *
-   * @param name        the command name (must be unique for the service)
-   * @param description the description of the command
-   */
-  protected BrooklynCommand(String name, String description) {
-    super(name, description);
-  }
-
-  @Override
-  public Options getOptions() {
-    return super.getOptions()
-        .addOption(null, "endpoint", true, "Server endpoint")
-        .addOption(null, "user", true, "User name")
-        .addOption(null, "password", true, "User password");
-  }
-
-  @Override
-  protected void run(AbstractService<?> service, CommandLine params) throws Exception {
-    try {
-      buildJerseyClientAndRun(System.out, System.err, service.getJson(), params);
-
-    } catch (Exception e) {
-      System.exit(-1);
-    }
-  }
-
-  protected void buildJerseyClientAndRun(PrintStream out, PrintStream err,
-                                         Json json, CommandLine params) throws Exception {
-    try {
-      JerseyClientConfiguration jerseyConfig = new JerseyClientConfiguration();
-      jerseyConfig.setTimeout(Duration.seconds(2));
-
-      setEndpointFromCommandLineOrEnvironment(params);
-      setLoginCredentialsFromCommandLineOrEnvironment(params);
-
-      run(out, err, json, buildJerseyClient(json, jerseyConfig), params);
-
-    } catch (Exception e) {
-      err.println(e.getMessage());
-
-      throw Throwables.propagate(e);
-    }
-  }
-
-  @VisibleForTesting
-  void runAsATest(PrintStream out, PrintStream err,
-                  Client client, CommandLine params) throws Exception {
-    try {
-      setEndpointFromCommandLineOrEnvironment(params);
-      run(out, err, new Json(), client, params);
-
-    } catch (Exception e) {
-      err.println(e.getMessage());
-    }
-  }
-
-  /**
-   * Override this method to implement command functionality
-   */
-  protected abstract void run(PrintStream out, PrintStream err, Json json,
-                              Client client, CommandLine params) throws Exception;
-
-  /**
-   * Get a value from the command line params or from environment
-   */
-  private String getFromCliOrEnv(CommandLine params, String environmentVariableName,
-                                 String optionName, String defaultValue) {
-    String fromEnv = System.getenv(environmentVariableName);
-
-    /* the command line has precedence over the environment */
-    return params.getOptionValue(optionName, (fromEnv != null) ? fromEnv : defaultValue);
-  }
-
-  private void setEndpointFromCommandLineOrEnvironment(CommandLine params) {
-    this.endpoint = getFromCliOrEnv(params, "BROOKLYN_ENDPOINT", "endpoint", "http://localhost:8080");
-  }
-
-  private void setLoginCredentialsFromCommandLineOrEnvironment(CommandLine params) {
-    this.user = getFromCliOrEnv(params, "BROOKLYN_USER", "user", null);
-    this.password = getFromCliOrEnv(params, "BROOKLYN_PASSWORD", "password", null);
-  }
-
-  protected String getEndpoint() {
-    return endpoint;
-  }
-
-  protected URI uriFor(String resource) {
-    return URI.create(getEndpoint() + resource);
-  }
-
-  protected URI expandIfRelative(URI uri) {
-    if (uri.getHost() != null) {
-      return uri;
-    }
-    return URI.create(getEndpoint() + uri.getPath());
-  }
-
-  private JerseyClient buildJerseyClient(Json json, JerseyClientConfiguration configuration) {
-
-    final HttpClient client = new HttpClientFactory(configuration).build();
-    final ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(client, null, true);
-
-    final ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
-    config.getSingletons().add(new JacksonMessageBodyProvider(json));
-
-    final JerseyClient jerseyClient = new JerseyClient(handler, config);
-    jerseyClient.setExecutorService(buildThreadPool(configuration));
-
-    if (user != null && password != null) {
-      jerseyClient.addFilter(new HTTPBasicAuthFilter(user, password));
-    }
-
-    if (configuration.isGzipEnabled()) {
-      jerseyClient.addFilter(new GZIPContentEncodingFilter());
-    }
-
-    return jerseyClient;
-  }
-
-  private ExecutorService buildThreadPool(JerseyClientConfiguration configuration) {
-    final ThreadFactory threadFactory = new ThreadFactoryBuilder().setDaemon(true)
-        .setNameFormat("jersey-client-%d")
-        .build();
-
-    return new ThreadPoolExecutor(configuration.getMinThreads(),
-        configuration.getMaxThreads(),
-        60, TimeUnit.SECONDS,
-        new SynchronousQueue<Runnable>(),
-        threadFactory);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/DeleteApplicationCommand.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/DeleteApplicationCommand.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/DeleteApplicationCommand.java
deleted file mode 100644
index 180de82..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/DeleteApplicationCommand.java
+++ /dev/null
@@ -1,53 +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.
- */
-package brooklyn.rest.commands.applications;
-
-import brooklyn.rest.commands.BrooklynCommand;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.yammer.dropwizard.json.Json;
-import org.apache.commons.cli.CommandLine;
-
-import java.io.PrintStream;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-public class DeleteApplicationCommand extends BrooklynCommand {
-
-  public DeleteApplicationCommand() {
-    super("delete-application", "Delete application by name");
-  }
-
-  @Override
-  public String getSyntax() {
-    return "[options] <application name>";
-  }
-
-  @Override
-  protected void run(PrintStream out, PrintStream err, Json json,
-                     Client client, CommandLine params) throws Exception {
-    checkArgument(params.getArgList().size() >= 1, "Application name is mandatory");
-
-    String name = (String) params.getArgList().get(0);
-    ClientResponse response = client.resource(uriFor("/v1/applications/" + name))
-        .delete(ClientResponse.class);
-
-    out.println("Ok, status: " + response.getStatus());
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/InvokeEffectorCommand.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/InvokeEffectorCommand.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/InvokeEffectorCommand.java
deleted file mode 100644
index d207c73..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/InvokeEffectorCommand.java
+++ /dev/null
@@ -1,62 +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.
- */
-package brooklyn.rest.commands.applications;
-
-
-import brooklyn.rest.commands.BrooklynCommand;
-import com.google.common.collect.ImmutableMap;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.yammer.dropwizard.json.Json;
-import org.apache.commons.cli.CommandLine;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.PrintStream;
-import java.net.URI;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkState;
-
-public class InvokeEffectorCommand extends BrooklynCommand {
-
-  public InvokeEffectorCommand() {
-    super("invoke-effector", "Invoke entity effector (no arguments)");
-  }
-
-  @Override
-  public String getSyntax() {
-    return "[options] <effector uri>";
-  }
-
-  @Override
-  protected void run(PrintStream out, PrintStream err, Json json,
-                     Client client, CommandLine params) throws Exception {
-    checkArgument(params.getArgList().size() >= 1, "Effector URI is mandatory");
-
-    URI effectorUri = uriFor((String) params.getArgList().get(0));
-    ClientResponse response = client.resource(effectorUri)
-        .type(MediaType.APPLICATION_JSON_TYPE)
-        .entity(ImmutableMap.<String, String>of())
-        .post(ClientResponse.class);
-
-    checkState(response.getStatus() == Response.Status.ACCEPTED.getStatusCode(),
-        "Got unexpected response: " + response.toString());
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/ListApplicationsCommand.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/ListApplicationsCommand.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/ListApplicationsCommand.java
deleted file mode 100644
index 55e5cd8..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/ListApplicationsCommand.java
+++ /dev/null
@@ -1,53 +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.
- */
-package brooklyn.rest.commands.applications;
-
-import brooklyn.rest.commands.BrooklynCommand;
-import brooklyn.rest.domain.ApplicationSummary;
-
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.GenericType;
-import com.yammer.dropwizard.json.Json;
-import org.apache.commons.cli.CommandLine;
-
-import javax.ws.rs.core.MediaType;
-import java.io.PrintStream;
-import java.util.List;
-
-public class ListApplicationsCommand extends BrooklynCommand {
-
-  public ListApplicationsCommand() {
-    super("list-applications", "List all registered applications");
-  }
-
-  @Override
-  protected void run(PrintStream out, PrintStream err, Json json,
-                     Client client, CommandLine params) throws Exception {
-    List<ApplicationSummary> applications = client.resource(uriFor("/v1/applications"))
-        .type(MediaType.APPLICATION_JSON_TYPE).get(new GenericType<List<ApplicationSummary>>() {
-        });
-
-    String tableFormat = "%20s %10s\n";
-    out.printf(tableFormat, "Application", "Status");
-
-    for (ApplicationSummary application : applications) {
-      out.printf(tableFormat, application.getSpec().getName(), application.getStatus());
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/ListEffectorsCommand.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/ListEffectorsCommand.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/ListEffectorsCommand.java
deleted file mode 100644
index f0cdeee..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/ListEffectorsCommand.java
+++ /dev/null
@@ -1,83 +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.
- */
-package brooklyn.rest.commands.applications;
-
-import brooklyn.rest.commands.BrooklynCommand;
-import brooklyn.rest.domain.ApplicationSummary;
-import brooklyn.rest.domain.EffectorSummary;
-import brooklyn.rest.domain.EntitySummary;
-
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.GenericType;
-import com.yammer.dropwizard.json.Json;
-import org.apache.commons.cli.CommandLine;
-
-import javax.ws.rs.core.MediaType;
-import java.io.PrintStream;
-import java.net.URI;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-public class ListEffectorsCommand extends BrooklynCommand {
-
-  public ListEffectorsCommand() {
-    super("list-effectors", "List all effectors for all entities for a given application");
-  }
-
-  @Override
-  public String getSyntax() {
-    return "[options] <application name>";
-  }
-
-  @Override
-  protected void run(PrintStream out, PrintStream err, Json json,
-                     Client client, CommandLine params) throws Exception {
-    checkArgument(params.getArgList().size() >= 1, "Application name is mandatory");
-
-    String name = (String) params.getArgList().get(0);
-    ApplicationSummary application = client.resource(uriFor("/v1/applications/" + name))
-        .type(MediaType.APPLICATION_JSON_TYPE).get(ApplicationSummary.class);
-
-    queryAllEntities(out, client, application.getLinks().get("entities"));
-  }
-
-  private void queryAllEntities(PrintStream out, Client client, URI resource) {
-    Set<EntitySummary> entities = client.resource(expandIfRelative(resource))
-        .type(MediaType.APPLICATION_JSON_TYPE).get(new GenericType<Set<EntitySummary>>() {
-        });
-
-    for (EntitySummary summary : entities) {
-      out.println(summary.getLinks().get("self") + " #" + summary.getType());
-      queryListOfEffectors(out, client, summary.getLinks().get("effectors"));
-      queryAllEntities(out, client, summary.getLinks().get("children"));
-    }
-  }
-
-  private void queryListOfEffectors(PrintStream out, Client client, URI effectorsUri) {
-    Set<EffectorSummary> effectors = client.resource(expandIfRelative(effectorsUri))
-        .type(MediaType.APPLICATION_JSON_TYPE).get(new GenericType<Set<EffectorSummary>>() {
-        });
-    for (EffectorSummary summary : effectors) {
-      out.println("\t" + summary.getReturnType() + " " +
-          summary.getName() + " " + summary.getParameters());
-      out.println("\t" + summary.getLinks().get("self") + "\n");
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/QuerySensorsCommand.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/QuerySensorsCommand.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/QuerySensorsCommand.java
deleted file mode 100644
index 0955593..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/QuerySensorsCommand.java
+++ /dev/null
@@ -1,84 +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.
- */
-package brooklyn.rest.commands.applications;
-
-import brooklyn.rest.commands.BrooklynCommand;
-import brooklyn.rest.domain.ApplicationSummary;
-import brooklyn.rest.domain.EntitySummary;
-import brooklyn.rest.domain.SensorSummary;
-
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.GenericType;
-import com.yammer.dropwizard.json.Json;
-import org.apache.commons.cli.CommandLine;
-
-import javax.ws.rs.core.MediaType;
-import java.io.PrintStream;
-import java.net.URI;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-public class QuerySensorsCommand extends BrooklynCommand {
-
-  public QuerySensorsCommand() {
-    super("query-sensors", "Query all application sensors for all entities");
-  }
-
-  @Override
-  public String getSyntax() {
-    return "[options] <application name>";
-  }
-
-  @Override
-  protected void run(PrintStream out, PrintStream err, Json json,
-                     Client client, CommandLine params) throws Exception {
-    checkArgument(params.getArgList().size() >= 1, "Application name is mandatory");
-
-    String name = (String) params.getArgList().get(0);
-    ApplicationSummary application = client.resource(uriFor("/v1/applications/" + name))
-        .type(MediaType.APPLICATION_JSON_TYPE).get(ApplicationSummary.class);
-
-    queryAllEntities(out, client, application.getLinks().get("entities"));
-  }
-
-  private void queryAllEntities(PrintStream out, Client client, URI resource) {
-    Set<EntitySummary> entities = client.resource(expandIfRelative(resource))
-        .type(MediaType.APPLICATION_JSON_TYPE).get(new GenericType<Set<EntitySummary>>() {
-        });
-
-    for (EntitySummary summary : entities) {
-      out.println(summary.getLinks().get("self") + " #" + summary.getType());
-      queryAllSensors(out, client, summary.getLinks().get("sensors"));
-      queryAllEntities(out, client, summary.getLinks().get("children"));
-    }
-  }
-
-  private void queryAllSensors(PrintStream out, Client client, URI sensorsUri) {
-    Set<SensorSummary> sensors = client.resource(expandIfRelative(sensorsUri))
-        .type(MediaType.APPLICATION_JSON_TYPE).get(new GenericType<Set<SensorSummary>>() {
-        });
-    for (SensorSummary summary : sensors) {
-      String value = client.resource(expandIfRelative(summary.getLinks().get("self")))
-          .type(MediaType.APPLICATION_JSON_TYPE).get(String.class);
-      out.println("\t" + summary.getName() + " = " + value);
-    }
-    out.println();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/StartApplicationCommand.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/StartApplicationCommand.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/StartApplicationCommand.java
deleted file mode 100644
index 9fcaf83..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/applications/StartApplicationCommand.java
+++ /dev/null
@@ -1,101 +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.
- */
-package brooklyn.rest.commands.applications;
-
-import brooklyn.rest.commands.BrooklynCommand;
-import brooklyn.rest.domain.ApiError;
-import brooklyn.rest.domain.ApplicationSpec;
-import brooklyn.rest.domain.ApplicationSummary;
-import brooklyn.rest.domain.Status;
-
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.yammer.dropwizard.json.Json;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Options;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.File;
-import java.io.PrintStream;
-import java.net.URI;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-public class StartApplicationCommand extends BrooklynCommand {
-
-  public StartApplicationCommand() {
-    super("start-application", "Start a new application from a JSON spec file.");
-  }
-
-  @Override
-  public String getSyntax() {
-    return "[options] <json file>";
-  }
-
-  @Override
-  public Options getOptions() {
-    return super.getOptions()
-        .addOption("n", "name", true, "Override application name");
-  }
-
-  @Override
-  protected void run(PrintStream out, PrintStream err, Json json,
-                     Client client, CommandLine params) throws Exception {
-    checkArgument(params.getArgList().size() >= 1, "Path to JSON file is mandatory");
-
-    String jsonFileName = (String) params.getArgList().get(0);
-    ApplicationSpec spec = json.readValue(new File(jsonFileName), ApplicationSpec.class);
-
-    if (params.hasOption("name")) {
-      spec = ApplicationSpec.builder().from(spec).name(params.getOptionValue("name")).build();
-    }
-
-    ClientResponse response = client.resource(uriFor("/v1/applications"))
-        .type(MediaType.APPLICATION_JSON).post(ClientResponse.class, spec);
-
-    if (response.getStatus() != Response.Status.CREATED.getStatusCode()) {
-      ApiError error = response.getEntity(ApiError.class);
-      throw new RuntimeException(error.getMessage());
-    }
-
-    out.println("Starting at " + response.getLocation());
-
-    Status status;
-    do {
-      out.print(".");
-      out.flush();
-      Thread.sleep(1000);
-
-      status = getApplicationStatus(client, response.getLocation());
-    } while (status != Status.RUNNING && status != Status.ERROR);
-
-    if (status == Status.RUNNING) {
-      out.println("Done.");
-    } else {
-      err.println("Error.");
-    }
-  }
-
-  private Status getApplicationStatus(Client client, URI uri) {
-    ApplicationSummary application = client.resource(uri)
-        .type(MediaType.APPLICATION_JSON_TYPE).get(ApplicationSummary.class);
-    return application.getStatus();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/catalog/CatalogEntityDetailsCommand.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/catalog/CatalogEntityDetailsCommand.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/catalog/CatalogEntityDetailsCommand.java
deleted file mode 100644
index 74a70aa..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/catalog/CatalogEntityDetailsCommand.java
+++ /dev/null
@@ -1,56 +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.
- */
-package brooklyn.rest.commands.catalog;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import java.io.PrintStream;
-
-import javax.ws.rs.core.MediaType;
-
-import org.apache.commons.cli.CommandLine;
-
-import brooklyn.rest.commands.BrooklynCommand;
-import brooklyn.rest.domain.CatalogEntitySummary;
-
-import com.sun.jersey.api.client.Client;
-import com.yammer.dropwizard.json.Json;
-
-public class CatalogEntityDetailsCommand extends BrooklynCommand {
-
-  public CatalogEntityDetailsCommand() {
-    super("catalog-entity", "Show details of entity type");
-  }
-
-  @Override
-  public String getSyntax() {
-    return "[options] <entity type>";
-  }
-
-  @Override
-  protected void run(PrintStream out, PrintStream err, Json json,
-                     Client client, CommandLine params) throws Exception {
-    checkArgument(params.getArgList().size() >= 1, "The type of the entity is mandatory");
-
-    String type = (String) params.getArgList().get(0);
-    CatalogEntitySummary catalogEntity = client.resource(uriFor("/v1/catalog/entities/" + type))
-            .type(MediaType.APPLICATION_JSON_TYPE).get(CatalogEntitySummary.class);
-    out.println(catalogEntity);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/catalog/ListCatalogEntitiesCommand.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/catalog/ListCatalogEntitiesCommand.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/catalog/ListCatalogEntitiesCommand.java
deleted file mode 100644
index 4e80d72..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/catalog/ListCatalogEntitiesCommand.java
+++ /dev/null
@@ -1,48 +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.
- */
-package brooklyn.rest.commands.catalog;
-
-import brooklyn.rest.commands.BrooklynCommand;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.GenericType;
-import com.yammer.dropwizard.json.Json;
-import org.apache.commons.cli.CommandLine;
-
-import javax.ws.rs.core.MediaType;
-import java.io.PrintStream;
-import java.util.List;
-
-public class ListCatalogEntitiesCommand extends BrooklynCommand {
-
-  public ListCatalogEntitiesCommand() {
-    super("catalog-entities", "List all the entities from the catalog");
-  }
-
-  @Override
-  protected void run(PrintStream out, PrintStream err, Json json,
-                     Client client, CommandLine params
-  ) throws Exception {
-    List<String> entities = client.resource(uriFor("/v1/catalog/entities"))
-        .type(MediaType.APPLICATION_JSON_TYPE).get(new GenericType<List<String>>() {
-        });
-    for (String entity : entities) {
-      out.println(entity);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/catalog/ListCatalogPoliciesCommand.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/catalog/ListCatalogPoliciesCommand.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/catalog/ListCatalogPoliciesCommand.java
deleted file mode 100644
index 6b7f55a..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/catalog/ListCatalogPoliciesCommand.java
+++ /dev/null
@@ -1,47 +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.
- */
-package brooklyn.rest.commands.catalog;
-
-import brooklyn.rest.commands.BrooklynCommand;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.GenericType;
-import com.yammer.dropwizard.json.Json;
-import org.apache.commons.cli.CommandLine;
-
-import javax.ws.rs.core.MediaType;
-import java.io.PrintStream;
-import java.util.List;
-
-public class ListCatalogPoliciesCommand extends BrooklynCommand {
-
-  public ListCatalogPoliciesCommand() {
-    super("catalog-policies", "List all the policies from the catalog");
-  }
-
-  @Override
-  protected void run(PrintStream out, PrintStream err, Json json,
-                     Client client, CommandLine params) throws Exception {
-    List<String> policies = client.resource(uriFor("/v1/catalog/policies"))
-        .type(MediaType.APPLICATION_JSON_TYPE).get(new GenericType<List<String>>() {
-        });
-    for (String policy : policies) {
-      out.println(policy);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/catalog/LoadClassCommand.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/catalog/LoadClassCommand.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/catalog/LoadClassCommand.java
deleted file mode 100644
index b542673..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/catalog/LoadClassCommand.java
+++ /dev/null
@@ -1,61 +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.
- */
-package brooklyn.rest.commands.catalog;
-
-import brooklyn.rest.commands.BrooklynCommand;
-import com.google.common.base.Joiner;
-import com.google.common.io.Files;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.yammer.dropwizard.json.Json;
-import org.apache.commons.cli.CommandLine;
-
-import javax.ws.rs.core.MediaType;
-import java.io.File;
-import java.io.PrintStream;
-import java.nio.charset.Charset;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-public class LoadClassCommand extends BrooklynCommand {
-
-  public LoadClassCommand() {
-    super("load-class", "Load code from external groovy files.");
-  }
-
-  @Override
-  public String getSyntax() {
-    return "[options] <groovy file>";
-  }
-
-  @Override
-  protected void run(PrintStream out, PrintStream err, Json json,
-                     Client client, CommandLine params) throws Exception {
-    checkArgument(params.getArgList().size() >= 1, "Path to Groovy file is mandatory.");
-
-    String scriptFileName = (String) params.getArgList().get(0);
-    String groovyScript = Joiner.on("\n").join(Files.readLines(new File(scriptFileName),
-        Charset.forName("utf-8")));
-
-    ClientResponse response = client.resource(uriFor("/v1/catalog"))
-        .type(MediaType.APPLICATION_JSON_TYPE).post(ClientResponse.class, groovyScript);
-
-    out.println("Ok, create: " + response.getLocation());
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/locations/AddLocationCommand.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/locations/AddLocationCommand.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/locations/AddLocationCommand.java
deleted file mode 100644
index c1c17b6..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/locations/AddLocationCommand.java
+++ /dev/null
@@ -1,59 +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.
- */
-package brooklyn.rest.commands.locations;
-
-import brooklyn.rest.commands.BrooklynCommand;
-import brooklyn.rest.domain.LocationSpec;
-
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.yammer.dropwizard.json.Json;
-import org.apache.commons.cli.CommandLine;
-
-import javax.ws.rs.core.MediaType;
-import java.io.File;
-import java.io.PrintStream;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-public class AddLocationCommand extends BrooklynCommand {
-
-  public AddLocationCommand() {
-    super("add-location", "Add a new location from JSON spec file.");
-  }
-
-  @Override
-  public String getSyntax() {
-    return "[options] <json file>";
-  }
-
-  @Override
-  protected void run(PrintStream out, PrintStream err, Json json,
-                     Client client, CommandLine params) throws Exception {
-    checkArgument(params.getArgList().size() >= 1, "Path to JSON file is mandatory");
-
-    String jsonFileName = (String) params.getArgList().get(0);
-    LocationSpec spec = json.readValue(new File(jsonFileName), LocationSpec.class);
-
-    ClientResponse response = client.resource(uriFor("/v1/locations"))
-        .type(MediaType.APPLICATION_JSON_TYPE).post(ClientResponse.class, spec);
-
-    out.println("Ok: " + response.getLocation());
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/locations/ListLocationsCommand.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/locations/ListLocationsCommand.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/locations/ListLocationsCommand.java
deleted file mode 100644
index f3ea9db..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/commands/locations/ListLocationsCommand.java
+++ /dev/null
@@ -1,49 +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.
- */
-package brooklyn.rest.commands.locations;
-
-import brooklyn.rest.commands.BrooklynCommand;
-import brooklyn.rest.domain.LocationSummary;
-
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.GenericType;
-import com.yammer.dropwizard.json.Json;
-import org.apache.commons.cli.CommandLine;
-
-import javax.ws.rs.core.MediaType;
-import java.io.PrintStream;
-import java.util.List;
-
-public class ListLocationsCommand extends BrooklynCommand {
-
-  public ListLocationsCommand() {
-    super("list-locations", "List all registered locations");
-  }
-
-  @Override
-  protected void run(PrintStream out, PrintStream err, Json json,
-                     Client client, CommandLine params) throws Exception {
-    List<LocationSummary> locations = client.resource(uriFor("/v1/locations"))
-        .type(MediaType.APPLICATION_JSON_TYPE).get(new GenericType<List<LocationSummary>>() {
-        });
-    for (LocationSummary summary : locations) {
-      out.println(summary.toString());
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/health/GeneralHealthCheck.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/health/GeneralHealthCheck.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/health/GeneralHealthCheck.java
deleted file mode 100644
index b190a16..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/health/GeneralHealthCheck.java
+++ /dev/null
@@ -1,33 +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.
- */
-package brooklyn.rest.health;
-
-import com.yammer.metrics.core.HealthCheck;
-
-public class GeneralHealthCheck extends HealthCheck {
-
-  public GeneralHealthCheck() {
-    super("general");
-  }
-
-  @Override
-  protected Result check() throws Exception {
-    return Result.healthy();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/views/SwaggerUiResource.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/views/SwaggerUiResource.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/views/SwaggerUiResource.java
deleted file mode 100644
index 8573853..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/views/SwaggerUiResource.java
+++ /dev/null
@@ -1,52 +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.
- */
-package brooklyn.rest.views;
-
-
-import com.sun.jersey.api.core.ResourceConfig;
-import com.wordnik.swagger.core.Api;
-import freemarker.template.TemplateException;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import java.io.IOException;
-import java.util.Set;
-
-@Path(SwaggerUiResource.RESOURCE_PATH)
-@Produces(MediaType.TEXT_HTML)
-public class SwaggerUiResource {
-
-  public static final String RESOURCE_PATH = "/v1/api/docs";
-
-  @GET
-  public SwaggerUiView showRestDocumentation(@Context ResourceConfig config)
-      throws IOException, TemplateException {
-    Set<Class<?>> classList = config.getRootResourceClasses();
-    for (Object singleton : config.getRootResourceSingletons()) {
-      if (singleton.getClass().isAnnotationPresent(Api.class)) {
-        classList.add(singleton.getClass());
-      }
-    }
-    return new SwaggerUiView(classList);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/views/SwaggerUiView.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/views/SwaggerUiView.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/views/SwaggerUiView.java
deleted file mode 100644
index 72f95ae..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/views/SwaggerUiView.java
+++ /dev/null
@@ -1,114 +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.
- */
-package brooklyn.rest.views;
-
-
-import com.google.common.collect.Lists;
-import com.wordnik.swagger.core.Api;
-import com.wordnik.swagger.core.Documentation;
-import com.wordnik.swagger.core.DocumentationEndPoint;
-import com.wordnik.swagger.jaxrs.JaxrsApiReader;
-import com.yammer.dropwizard.views.View;
-
-import javax.ws.rs.Path;
-import java.util.List;
-import java.util.Set;
-
-public class SwaggerUiView extends View {
-
-  private final Set<Class<?>> resourceList;
-  private final List<Documentation> apiList;
-  private final Documentation apiListing;
-
-  public final static String BASE_PATH = "api";
-  public final static String API_VERSION = "0.1";
-  public final static String SWAGGER_VERSION = "1.0";
-
-  public SwaggerUiView(Set<Class<?>> resourceClasses) {
-    super("swagger-ui.ftl");
-    resourceList = resourceClasses;
-    apiListing = readApiListing(resourceList);
-    apiList = readApis(resourceList);
-  }
-
-  public List<Documentation> getApiList() {
-    return apiList;
-  }
-
-  public Set<Class<?>> getResourceList() {
-    return resourceList;
-  }
-
-  public Documentation getApiListing() {
-    return apiListing;
-  }
-
-  /**
-   * Returns a {@link Documentation} object that contains just the list of resources.
-   *
-   * @param resourceList
-   * @return
-   */
-  public static Documentation readApiListing(Set<Class<?>> resourceList) {
-    Documentation doc = new Documentation();
-    doc.setSwaggerVersion(SWAGGER_VERSION);
-    doc.setApiVersion(API_VERSION);
-    doc.setBasePath(BASE_PATH);
-    doc.setResourcePath(SwaggerUiResource.RESOURCE_PATH);
-    for (Class<?> clazz : resourceList) {
-      if (clazz.isAnnotationPresent(Api.class)) {
-        Api apiAnnotation = clazz.getAnnotation(Api.class);
-        DocumentationEndPoint api = new DocumentationEndPoint(apiAnnotation.value(), apiAnnotation.description());
-        doc.addApi(api);
-      }
-    }
-    return doc;
-  }
-
-  public static List<Documentation> readApis(Set<Class<?>> resourceList) {
-    List<Documentation> apis = Lists.newArrayList();
-    for (Class<?> clazz : resourceList) {
-      apis.add(buildDocumentation(clazz));
-    }
-    return apis;
-  }
-
-  public static Documentation buildDocumentation(Class<?> clazz) {
-    return JaxrsApiReader.read(clazz, API_VERSION, SWAGGER_VERSION, BASE_PATH, readApiPath(clazz));
-  }
-
-  private static String readApiPath(Class<?> clazz) {
-    if (clazz.isAnnotationPresent(Api.class)) {
-      return clazz.getAnnotation(Api.class).value();
-    }
-    throw new IllegalStateException("Class is not decorated with " + Api.class.getCanonicalName());
-  }
-
-  public static String buildPath(Class<?> clazz) {
-    if (clazz.isAnnotationPresent(Path.class)) {
-      return clazz.getAnnotation(Path.class).value();
-    }
-    throw new IllegalStateException("Class is not decorated with " + Path.class.getCanonicalName());
-  }
-
-  public static String toString(Api apiAnnotation) {
-    return String.format("Value %s, description %s, listing class %s, listing path %s, open %b", apiAnnotation.value(),
-        apiAnnotation.description(), apiAnnotation.listingClass(), apiAnnotation.listingPath(), apiAnnotation.open());
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/brooklyn/rest/views/WebClientResource.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/brooklyn/rest/views/WebClientResource.java b/sandbox/dropwizard/src/main/java/brooklyn/rest/views/WebClientResource.java
deleted file mode 100644
index 92293ef..0000000
--- a/sandbox/dropwizard/src/main/java/brooklyn/rest/views/WebClientResource.java
+++ /dev/null
@@ -1,52 +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.
- */
-package brooklyn.rest.views;
-
-import com.google.common.base.Charsets;
-import com.google.common.io.Resources;
-import com.wordnik.swagger.core.Api;
-import com.wordnik.swagger.core.ApiOperation;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.IOException;
-import java.net.URL;
-
-@Path("/")
-@Api(value = "/", description = "Loads the javascript client for this web service")
-@Produces(MediaType.TEXT_HTML)
-public class WebClientResource {
-
-  @GET
-  @ApiOperation(value = "JavaScript client GUI page")
-  public Response backboneUi() {
-    String pageContent = "";
-    try {
-      URL clientPage = Resources.getResource("assets/index.html");
-      pageContent = Resources.toString(clientPage, Charsets.UTF_8);
-    } catch (IOException e) {
-      return Response.serverError().build();
-    }
-    return Response.ok(pageContent).build();
-  }
-  
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/java/com/yammer/dropwizard/logging/AsyncAppender.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/java/com/yammer/dropwizard/logging/AsyncAppender.java b/sandbox/dropwizard/src/main/java/com/yammer/dropwizard/logging/AsyncAppender.java
deleted file mode 100644
index bd345b2..0000000
--- a/sandbox/dropwizard/src/main/java/com/yammer/dropwizard/logging/AsyncAppender.java
+++ /dev/null
@@ -1,98 +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.
- */
-package com.yammer.dropwizard.logging;
-
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.Appender;
-import ch.qos.logback.core.AppenderBase;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Queues;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-
-import java.util.List;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ThreadFactory;
-
-public class AsyncAppender extends AppenderBase<ILoggingEvent> implements Runnable {
-    private static final int BATCH_SIZE = 1000;
-
-    public static Appender<ILoggingEvent> wrap(Appender<ILoggingEvent> delegate) {
-        final AsyncAppender appender = new AsyncAppender(delegate, BATCH_SIZE);
-        appender.start();
-        return appender;
-    }
-
-    private static final ThreadFactory THREAD_FACTORY =
-            new ThreadFactoryBuilder().setNameFormat("async-log-appender-%d")
-                                      .setDaemon(true)
-                                      .build();
-
-    private final Appender<ILoggingEvent> delegate;
-    private final BlockingQueue<ILoggingEvent> queue;
-    private final List<ILoggingEvent> batch;
-    private final Thread dispatcher;
-    private final int batchSize;
-    private volatile boolean running;
-
-    public AsyncAppender(Appender<ILoggingEvent> delegate, int batchSize) {
-        this.delegate = delegate;
-        this.queue = Queues.newLinkedBlockingQueue();
-        this.batch = Lists.newArrayListWithCapacity(batchSize);
-        this.batchSize = batchSize;
-        this.dispatcher = THREAD_FACTORY.newThread(this);
-        setContext(delegate.getContext());
-    }
-
-    @Override
-    protected void append(ILoggingEvent eventObject) {
-        queue.add(eventObject);
-    }
-
-    @Override
-    public void start() {
-        super.start();
-        this.running = true;
-        dispatcher.start();
-    }
-
-    @Override
-    public void stop() {
-        this.running = false;
-        dispatcher.interrupt();
-        super.stop();
-    }
-
-    @Override
-    public void run() {
-        while (running) {
-            try {
-                batch.add(queue.take());
-                queue.drainTo(batch, batchSize - 1);
-
-                for (ILoggingEvent event : batch) {
-                    delegate.doAppend(event);
-                }
-
-                batch.clear();
-            } catch (InterruptedException ignored) {
-                Thread.currentThread().interrupt();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/resources/banner.txt
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/resources/banner.txt b/sandbox/dropwizard/src/main/resources/banner.txt
deleted file mode 100644
index 7bdf604..0000000
--- a/sandbox/dropwizard/src/main/resources/banner.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-______                 _     _
-| ___ \               | |   | |
-| |_/ /_ __ ___   ___ | | __| |_   _ _ __
-| ___ \ '__/ _ \ / _ \| |/ /| | | | | '_ \
-| |_/ / | | (_) | (_) |   < | | |_| | | | |
-\____/|_|  \___/ \___/|_|\_\|_|\__, |_| |_|
-                                __/ |
-                               |___/

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/main/resources/brooklyn/rest/views/swagger-ui.ftl
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/main/resources/brooklyn/rest/views/swagger-ui.ftl b/sandbox/dropwizard/src/main/resources/brooklyn/rest/views/swagger-ui.ftl
deleted file mode 100644
index 299bec9..0000000
--- a/sandbox/dropwizard/src/main/resources/brooklyn/rest/views/swagger-ui.ftl
+++ /dev/null
@@ -1,192 +0,0 @@
-<#-- @ftlvariable name="" type="brooklyn.rest.views.SwaggerUiView" -->
-<!DOCTYPE html>
-
-<!--
-    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.
--->
-    
-<html>
-<head>
-    <meta charset='utf-8'/>
-    <!-- Always force latest IE rendering engine (even in intranet) and Chrome Frame -->
-    <meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'/>
-    <title>Brooklyn REST API Explorer</title>
-    <link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
-    <link href='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/smoothness/jquery-ui.css' media='screen'
-          rel='stylesheet' type='text/css'/>
-    <link href='/assets/css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
-
-    <script src='/assets/js/libs/jquery-1.7.2.js' type='text/javascript'></script>
-    <script type='text/javascript'>
-        function toggle(selector) {
-            jQuery(selector).toggle();
-            return false;
-        }
-    </script>
-</head>
-<body>
-<div id="header" style="background-color:#89BF04;">
-    <h2 style="padding-left: 20px; color: white;">Brooklyn REST API</h2>
-</div>
-<div class='container' id='resources_container'>
-    <ul id='resources'>
-    <@resourceTemplate resourceList = apiList/>
-    </ul>
-</div>
-<div id='content_message'></div>
-
-<#macro resourceTemplate resourceList>
-    <#list resourceList as resource>
-    <li class='resource' id='resource_${resource_index}'>
-        <div class='heading'>
-            <h2>
-                <a href='#!/${resource_index}'
-                   onclick="toggle('ul#endpoint_list_${resource_index}');">${resource.getResourcePath()}</a>
-            </h2>
-            <ul class='options'>
-                <li>
-                    <a href='#operations_list' onclick="toggle('ul#endpoint_list_${resource_index}');">Toggle Operations
-                        List</a>
-                </li>
-                <li>
-                    <a href='#parameters_list' onclick="toggle('.resource${resource_index}');">Toggle parameters</a>
-                </li>
-            </ul>
-        </div>
-        <ul class='endpoints' id='endpoint_list_${resource_index}' style='display:none'>
-            <#list resource.getApis() as documentationEndoint>
-                <@apiTemplate api= documentationEndoint apiIndex = documentationEndoint_index resourceIndex = resource_index/>
-            </#list>
-        </ul>
-    </li>
-    </#list>
-</#macro>
-
-<#macro apiTemplate api apiIndex resourceIndex>
-<li class='endpoint'>
-    <ul class='operations' id='endpoint_operations_${apiIndex}'>
-        <#list api.getOperations() as operation>
-        <@operationTemplate operation = operation endpoint= api apiIndex= apiIndex operationIndex = operation_index resourceIndex = resourceIndex/>
-        </#list>
-    </ul>
-</li>
-</#macro>
-
-<#macro operationTemplate operation endpoint apiIndex operationIndex resourceIndex>
-    <#assign pathWithoutFormat=endpoint.getPath()?replace(".{format}","")/>
-    <#assign lowercaseHttpMethd = operation.getHttpMethod()?lower_case/>
-
-<li class='${lowercaseHttpMethd} operation' id='${operation.getHttpMethod()}_${operationIndex}'>
-    <div class='heading'>
-        <h3>
-<span class='http_method'>
-    <a href='#!/${pathWithoutFormat}/${operation.getNickname()}_${operation.getHttpMethod()}'>${operation.getHttpMethod()}</a>
-</span>
-<span class='path'>
-<a href='#!/${pathWithoutFormat}/${operation.getNickname()}_${operation.getHttpMethod()}'
-   onclick="toggle('#content_${apiIndex}_${resourceIndex}_${operationIndex}')">${pathWithoutFormat}</a>
-</span>
-        </h3>
-        <ul class='options'>
-            <li><h2>
-            ${operation.getSummary()}
-            </h2></li>
-        </ul>
-    </div>
-    <div class='content resource${resourceIndex}' id='content_${apiIndex}_${resourceIndex}_${operationIndex}'
-         style='display:none'>
-        <#if operation.getNotes()??>
-            <h4>Implementation Notes</h4>
-
-            <p>${operation.getNotes()}</p>
-        </#if>
-
-        <#if operation.getParameters()??>
-            <#assign parameterList = operation.getParameters() />
-
-            <form accept-charset='UTF-8' action='#' class='sandbox'
-                  id='${operation.getHttpMethod()}_${operationIndex}_form'
-                  method='post'>
-                <div style='margin:0;padding:0;display:inline'></div>
-                <h4>Parameters</h4>
-                <table class='fullwidth'>
-                    <thead>
-                    <tr>
-                        <th>Parameter</th>
-                        <th id='${operation.getHttpMethod()}_${operationIndex}_value_header'>
-                            Required
-                        </th>
-                        <th>Description</th>
-                    </tr>
-                    </thead>
-                    <tbody id='${operation.getHttpMethod()}_${operationIndex}_params'>
-                        <#list parameterList as parameter>
-                        <@paramTemplate param = parameter/>
-                    </#list>
-                    </tbody>
-                </table>
-            </form>
-            <div class='response' id='${operation.getHttpMethod()}_${operationIndex}_content_sandbox_response'
-                 style='display:none'>
-                <h4>Request URL</h4>
-
-                <div class='block request_url'></div>
-                <h4>Response Body</h4>
-
-                <div class='block response_body'></div>
-                <h4>Response Code</h4>
-
-                <div class='block response_code'></div>
-                <h4>Response Headers</h4>
-
-                <div class='block response_headers'></div>
-            </div>
-        </#if>
-    </div>
-</li>
-</#macro>
-
-<#macro paramTemplate param>
-    <#attempt>
-        <#if param.getName()??>
-            <#assign paramName = param.getName() />
-        <#elseif param.getNickname()??>
-            <#assign paramName = param.getNickname() />
-        </#if>
-    <tr>
-        <td class='code'> ${paramName}</td>
-        <td>
-        <#if param.getRequired()??>
-            <#if param.getRequired()>
-                Required
-            <#else>
-                Optional
-            </#if>
-        </#if></td>
-        <td width='500'>${param.getDescription()}</td>
-    </tr>
-        <#recover>
-    </#attempt>
-</#macro>
-
-<p id='colophon'>
-    Sexy API documentation based on
-    <a href="http://swagger.wordnik.com">Swagger</a>.
-</p>
-</body>
-</html>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/test/java/brooklyn/cli/ClientNoAuthTest.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/test/java/brooklyn/cli/ClientNoAuthTest.java b/sandbox/dropwizard/src/test/java/brooklyn/cli/ClientNoAuthTest.java
deleted file mode 100644
index f069bc6..0000000
--- a/sandbox/dropwizard/src/test/java/brooklyn/cli/ClientNoAuthTest.java
+++ /dev/null
@@ -1,37 +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.
- */
-package brooklyn.cli;
-
-import org.testng.annotations.AfterSuite;
-import org.testng.annotations.BeforeSuite;
-import org.testng.annotations.Test;
-
-@Test(suiteName = "ClientNoAuthTest")
-public class ClientNoAuthTest extends ClientTest {
-
-  @BeforeSuite(alwaysRun = true)
-  public void beforeClass() throws Exception {
-    super.oneTimeSetUp("config/test-config.yml");
-  }
-
-  @AfterSuite(alwaysRun = true)
-  public void afterClass() throws Exception {
-    super.oneTimeTearDown();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/196122dc/sandbox/dropwizard/src/test/java/brooklyn/cli/ClientTest.java
----------------------------------------------------------------------
diff --git a/sandbox/dropwizard/src/test/java/brooklyn/cli/ClientTest.java b/sandbox/dropwizard/src/test/java/brooklyn/cli/ClientTest.java
deleted file mode 100644
index 1069279..0000000
--- a/sandbox/dropwizard/src/test/java/brooklyn/cli/ClientTest.java
+++ /dev/null
@@ -1,214 +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.
- */
-package brooklyn.cli;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.containsString;
-import static org.testng.Assert.assertEquals;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.InputStream;
-import java.io.PrintStream;
-import java.util.Arrays;
-import java.util.List;
-
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.cli.commands.CommandExecutionException;
-import brooklyn.entity.basic.BasicEntity;
-import brooklyn.management.ManagementContext;
-import brooklyn.policy.basic.GeneralPurposePolicy;
-import brooklyn.rest.BrooklynService;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.io.ByteStreams;
-import com.google.common.io.Files;
-import com.yammer.dropwizard.logging.Log;
-
-public abstract class ClientTest {
-
-  private final static Log LOG = Log.forClass(ClientTest.class);
-
-  protected BrooklynService brooklynServer;
-  protected ManagementContext managementContext;
-  protected Client brooklynClient;
-
-  private ByteArrayOutputStream outBytes;
-  private ByteArrayOutputStream errBytes;
-
-  File tempConfigFile;
-
-  protected String standardOut() {
-    return outBytes.toString();
-  }
-
-  protected String standardErr() {
-    return errBytes.toString();
-  }
-
-  public void oneTimeSetUp(String resourceConfigName) throws Exception {
-    // Create temporary config file
-    tempConfigFile = File.createTempFile("server-config", ".yml");
-    tempConfigFile.deleteOnExit();
-
-    InputStream configInputStream = getClass().getClassLoader()
-        .getResourceAsStream(resourceConfigName);
-    try {
-      Files.write(ByteStreams.toByteArray(configInputStream), tempConfigFile);
-    } finally {
-      configInputStream.close();
-    }
-
-    // Start the REST server
-    brooklynServer = BrooklynService.newBrooklynService();
-    String[] args = {"server", tempConfigFile.getAbsolutePath()};
-    brooklynServer.runAsync(args);
-
-    managementContext = brooklynServer.getManagementContext();
-  }
-
-  public void oneTimeTearDown() throws Exception {
-    brooklynServer.stop();
-    tempConfigFile.delete();
-  }
-
-  @BeforeMethod
-  public void setUp() throws Exception {
-    outBytes = new ByteArrayOutputStream();
-    errBytes = new ByteArrayOutputStream();
-
-    brooklynClient = new Client(new PrintStream(outBytes), new PrintStream(errBytes));
-  }
-
-  protected void runWithArgs(String... args) throws Exception {
-    List<String> argsWithEndpoint = Lists.newArrayList(
-        "--endpoint", "http://localhost:60180"
-    );
-    argsWithEndpoint.addAll(Arrays.asList(args));
-
-    brooklynClient.run(argsWithEndpoint.toArray(new String[argsWithEndpoint.size()]));
-  }
-
-  @Test
-  public void testCatalogEntitiesCommand() throws Exception {
-    try {
-      runWithArgs("catalog-entities");
-
-      // Check list of entity types includes one of the defaults
-      assertThat(standardOut(), containsString(BasicEntity.class.getName()));
-    } catch (Exception e) {
-      LOG.error(e, "stdout={}; stderr={}", standardOut(), standardErr());
-      throw e;
-    }
-  }
-
-  @Test
-  public void testCatalogPoliciesCommand() throws Exception {
-    try {
-      runWithArgs("catalog-policies");
-
-      // Check list of entity types includes one of the defaults
-      assertThat(standardOut(), containsString(GeneralPurposePolicy.class.getName()));
-    } catch (Exception e) {
-      LOG.error(e, "stdout={}; stderr={}", standardOut(), standardErr());
-      throw e;
-    }
-  }
-
-  @Test
-  public void testDeployCreatesApp() throws Exception {
-    try {
-      runWithArgs("deploy", "--format", "class", "brooklyn.cli.ExampleApp");
-
-      // We should only have 1 app in the server's registry
-      assertEquals(managementContext.getApplications().size(), 1);
-
-      // The name of that app should match what we have provided in the deploy command
-      assertEquals(Iterables.getOnlyElement(managementContext.getApplications()).getEntityType().getName(), ExampleApp.class.getName());
-
-    } catch (Exception e) {
-      LOG.error(e, "stdout={}; stderr={}", standardOut(), standardErr());
-      throw e;
-    }
-  }
-
-  @Test(dependsOnMethods = {"testDeployCreatesApp"})
-  public void testListApplicationsShowsRunningApp() throws Exception {
-    try {
-      runWithArgs("list-applications");
-      assertThat(standardOut(), containsString("brooklyn.cli.ExampleApp [RUNNING]"));
-
-    } catch (Exception e) {
-      LOG.error(e, "stdout={}; stderr={}", standardOut(), standardErr());
-      throw e;
-    }
-  }
-
-  @Test(dependsOnMethods = {"testDeployCreatesApp"})
-  public void testUndeployStopsRunningApp() throws Exception {
-    try {
-      runWithArgs("undeploy", "brooklyn.cli.ExampleApp");
-      assertThat(standardOut(), containsString("Application has been undeployed: brooklyn.cli.ExampleApp"));
-
-    } catch (Exception e) {
-      LOG.error(e, "stdout={}; stderr={}", standardOut(), standardErr());
-      throw e;
-    }
-  }
-
-  @Test(dependsOnMethods = {"testUndeployStopsRunningApp"}, expectedExceptions = {CommandExecutionException.class})
-  public void testUndeployFailsGracefulyIfNoAppRunning() throws Exception {
-    try {
-      runWithArgs("undeploy", "brooklyn.cli.ExampleApp");
-      assertThat(standardOut(), containsString("Application 'brooklyn.test.entity.TestApplication' not found"));
-
-    } catch (Exception e) {
-      LOG.error(e, "stdout={}; stderr={}", standardOut(), standardErr());
-      throw e;
-    }
-  }
-
-  @Test(dependsOnMethods = {"testUndeployStopsRunningApp"})
-  public void testListApplicationsNoRunningApp() throws Exception {
-    try {
-      runWithArgs("list-applications");
-      assertEquals(standardOut(), "");
-
-    } catch (Exception e) {
-      LOG.error(e, "stdout={}; stderr={}", standardOut(), standardErr());
-      throw e;
-    }
-  }
-
-  @Test
-  public void testVersionCommand() throws Exception {
-    try {
-      runWithArgs("version");
-      assertThat(standardOut(), containsString("Brooklyn version:"));
-
-    } catch (Exception e) {
-      LOG.error(e, "stdout={}; stderr={}", standardOut(), standardErr());
-      throw e;
-    }
-  }
-
-}