changeset 2706:088eb9e6923c

Refactor common plugin code to new common-plugin module This patch moves common code (PluginConfiguration and PluginDAOBase) to the new module common-plugin. Several plugins needed updating because the package name changed from c.r.t.common.plugins to c.r.t.common.plugin. Reviewed-by: sgehwolf, neugens Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-June/023788.html Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-June/023858.html
author Simon Tooke <stooke@redhat.com>
date Wed, 21 Jun 2017 17:46:44 -0400
parents e06cb0c117d9
children 00feaa00f469
files common/core/pom.xml common/core/src/main/java/com/redhat/thermostat/common/plugins/PluginConfiguration.java common/core/src/test/java/com/redhat/thermostat/common/plugins/PluginConfigurationTest.java common/plugin/pom.xml common/plugin/src/main/java/com/redhat/thermostat/common/plugin/PluginConfiguration.java common/plugin/src/main/java/com/redhat/thermostat/common/plugin/PluginDAOBase.java common/plugin/src/main/java/com/redhat/thermostat/common/plugin/SystemIDImpl.java common/plugin/src/test/java/com/redhat/thermostat/common/plugin/PluginConfigurationTest.java plugins/commands/agent/pom.xml plugins/commands/agent/src/main/java/com/redhat/thermostat/commands/agent/internal/CommandsBackend.java plugins/commands/agent/src/test/java/com/redhat/thermostat/commands/agent/internal/CommandsBackendTest.java plugins/host-overview/agent/pom.xml plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/HostInfoTypeAdapter.java plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/HostOverviewBackend.java plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/common/PluginDAOBase.java plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/models/HostInfoDAO.java plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/models/HostInfoDAOImpl.java plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/model/HostInfoTypeAdapter.java plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/internal/HostInfoTypeAdapterTest.java plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/internal/HostOverviewBackendTest.java plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/internal/models/HostInfoDAOImplTest.java plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/internal/models/HostInfoDAOTest.java plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/model/HostInfoTypeAdapterTest.java plugins/vm-gc/agent/pom.xml plugins/vm-gc/agent/src/main/java/com/redhat/thermostat/vm/gc/agent/internal/models/VmGcStatDAOImpl.java plugins/vm-gc/agent/src/test/java/com/redhat/thermostat/vm/gc/agent/internal/models/VmGcStatDAOImplTest.java plugins/vm-memory/common/pom.xml plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatDAOImpl.java plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/internal/VmTlabStatDAOImpl.java plugins/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatDAOImplTest.java plugins/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/VmTlabStatDAOTest.java
diffstat 31 files changed, 624 insertions(+), 584 deletions(-) [+]
line wrap: on
line diff
--- a/common/core/pom.xml	Fri Jun 23 11:45:40 2017 -0400
+++ b/common/core/pom.xml	Wed Jun 21 17:46:44 2017 -0400
@@ -93,8 +93,7 @@
               com.redhat.thermostat.common.config.experimental,
               com.redhat.thermostat.common.utils,
               com.redhat.thermostat.common.ssl,
-              com.redhat.thermostat.common.model,
-              com.redhat.thermostat.common.plugins,
+              com.redhat.thermostat.common.model
             </Export-Package>
             <Private-Package>
               com.redhat.thermostat.common.internal.test,
--- a/common/core/src/main/java/com/redhat/thermostat/common/plugins/PluginConfiguration.java	Fri Jun 23 11:45:40 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.common.plugins;
-
-import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Map;
-
-public class PluginConfiguration {
-
-    private static final String CONFIG_FILE = "gateway.properties";
-    private static final String URL_PROP = "gatewayURL";
-
-    private final ConfigurationInfoSource source;
-    private final String pluginId;
-
-    public PluginConfiguration(ConfigurationInfoSource source, final String pluginId) {
-        this.source = source;
-        this.pluginId = pluginId;
-    }
-
-    public String getGatewayURL() throws IOException {
-        Map<String, String> props = source.getConfiguration(pluginId, CONFIG_FILE);
-        String url = props.get(URL_PROP);
-        if (url == null) {
-            throw new IOException("No gateway URL found for " + pluginId + " in " + getConfigFilePath());
-        }
-        return url;
-    }
-
-    private String getConfigFilePath() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("$THERMOSTAT_HOME").append(File.separator).append("etc").append(File.separator)
-                .append("plugins.d").append(File.separator).append(pluginId).append(File.separator)
-                .append(CONFIG_FILE);
-        return builder.toString();
-    }
-}
\ No newline at end of file
--- a/common/core/src/test/java/com/redhat/thermostat/common/plugins/PluginConfigurationTest.java	Fri Jun 23 11:45:40 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.common.plugins;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Test;
-
-import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
-
-public class PluginConfigurationTest {
-
-    private static final String PLUGIN_ID = "vm-gc";
-    private static final String CONFIG_FILE = "gateway.properties";
-    private static final String URL_PROP = "gatewayURL";
-
-    @Test
-    public void testGetGatewayURL() throws Exception {
-        ConfigurationInfoSource source = mock(ConfigurationInfoSource.class);
-        Map<String, String> props = new HashMap<>();
-        props.put(URL_PROP, "urlToGateway");
-        when(source.getConfiguration(PLUGIN_ID, CONFIG_FILE)).thenReturn(props);
-        PluginConfiguration config = new PluginConfiguration(source, PLUGIN_ID);
-
-        assertEquals("urlToGateway", config.getGatewayURL());
-    }
-
-    @Test(expected=IOException.class)
-    public void testGetGatewayURLMissing() throws Exception {
-        ConfigurationInfoSource source = mock(ConfigurationInfoSource.class);
-        Map<String, String> props = new HashMap<>();
-        when(source.getConfiguration(PLUGIN_ID, CONFIG_FILE)).thenReturn(props);
-        PluginConfiguration config = new PluginConfiguration(source, PLUGIN_ID);
-        config.getGatewayURL();
-    }
-}
--- a/common/plugin/pom.xml	Fri Jun 23 11:45:40 2017 -0400
+++ b/common/plugin/pom.xml	Wed Jun 21 17:46:44 2017 -0400
@@ -71,6 +71,19 @@
           </instructions>
         </configuration>
       </plugin>
+
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-scr-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>generate-scr-scrdescriptor</id>
+            <goals>
+              <goal>scr</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
 
   </build>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/plugin/src/main/java/com/redhat/thermostat/common/plugin/PluginConfiguration.java	Wed Jun 21 17:46:44 2017 -0400
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2012-2017 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.plugin;
+
+import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+public class PluginConfiguration {
+
+    private static final String CONFIG_FILE = "gateway.properties";
+    private static final String URL_PROP = "gatewayURL";
+
+    private final ConfigurationInfoSource source;
+    private final String pluginId;
+
+    public PluginConfiguration(ConfigurationInfoSource source, final String pluginId) {
+        this.source = source;
+        this.pluginId = pluginId;
+    }
+
+    public String getGatewayURL() throws IOException {
+        Map<String, String> props = source.getConfiguration(pluginId, CONFIG_FILE);
+        String url = props.get(URL_PROP);
+        if (url == null) {
+            throw new IOException("No gateway URL found for " + pluginId + " in " + getConfigFilePath());
+        }
+        return url;
+    }
+
+    private String getConfigFilePath() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("$THERMOSTAT_HOME").append(File.separator).append("etc").append(File.separator)
+                .append("plugins.d").append(File.separator).append(pluginId).append(File.separator)
+                .append(CONFIG_FILE);
+        return builder.toString();
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/plugin/src/main/java/com/redhat/thermostat/common/plugin/PluginDAOBase.java	Wed Jun 21 17:46:44 2017 -0400
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2012-2017 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.plugin;
+
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.api.ContentResponse;
+import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.client.util.StringContentProvider;
+import org.eclipse.jetty.http.HttpHeader;
+import org.eclipse.jetty.http.HttpMethod;
+import org.eclipse.jetty.http.HttpStatus;
+
+abstract public class PluginDAOBase<Tobj,Tdao> {
+
+    private static final String CONTENT_TYPE = "application/json";
+
+    protected final HttpClient httpClient;
+
+    public PluginDAOBase(HttpClient client) {
+        this.httpClient = client;
+    }
+
+    protected abstract String toJsonString(Tobj obj) throws IOException;
+    protected abstract PluginConfiguration getConfig();
+    protected abstract String getURL(final String basepath);
+    protected abstract Logger getLogger();
+
+    public void put(final Tobj obj) {
+        try {
+            final String gatewayURL = getConfig().getGatewayURL();
+            final String json = toJsonString(obj);
+            final StringContentProvider provider =  new StringContentProvider(json);
+            final String url = getURL(gatewayURL);
+            final Request httpRequest = httpClient.newRequest(url);
+            httpRequest.method(HttpMethod.POST);
+            httpRequest.content(provider);
+            httpRequest.header(HttpHeader.CONTENT_TYPE, CONTENT_TYPE);
+            sendRequest(httpRequest);
+        } catch (IOException | InterruptedException | TimeoutException | ExecutionException e) {
+            getLogger().log(Level.WARNING, "Failed to send " + obj.getClass().getName() + " to web gateway", e);
+        }
+    }
+
+    private void sendRequest(Request httpRequest)
+            throws InterruptedException, TimeoutException, ExecutionException, IOException {
+        final ContentResponse resp = httpRequest.send();
+        final int status = resp.getStatus();
+        if (status != HttpStatus.OK_200) {
+            throw new IOException("Gateway returned HTTP status " + String.valueOf(status) + " - " + resp.getReason());
+        }
+    }
+}
+
--- a/common/plugin/src/main/java/com/redhat/thermostat/common/plugin/SystemIDImpl.java	Fri Jun 23 11:45:40 2017 -0400
+++ b/common/plugin/src/main/java/com/redhat/thermostat/common/plugin/SystemIDImpl.java	Wed Jun 21 17:46:44 2017 -0400
@@ -60,7 +60,8 @@
             return System.getenv("COMPUTERNAME");
         }
         else {
-            return System.getenv("HOSTNAME");
+            final String env = System.getenv("HOSTNAME");
+            return env != null ? env : "localhost";
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/plugin/src/test/java/com/redhat/thermostat/common/plugin/PluginConfigurationTest.java	Wed Jun 21 17:46:44 2017 -0400
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2012-2017 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.plugin;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
+
+public class PluginConfigurationTest {
+
+    private static final String PLUGIN_ID = "vm-gc";
+    private static final String CONFIG_FILE = "gateway.properties";
+    private static final String URL_PROP = "gatewayURL";
+
+    @Test
+    public void testGetGatewayURL() throws Exception {
+        ConfigurationInfoSource source = mock(ConfigurationInfoSource.class);
+        Map<String, String> props = new HashMap<>();
+        props.put(URL_PROP, "urlToGateway");
+        when(source.getConfiguration(PLUGIN_ID, CONFIG_FILE)).thenReturn(props);
+        PluginConfiguration config = new PluginConfiguration(source, PLUGIN_ID);
+
+        assertEquals("urlToGateway", config.getGatewayURL());
+    }
+
+    @Test(expected=IOException.class)
+    public void testGetGatewayURLMissing() throws Exception {
+        ConfigurationInfoSource source = mock(ConfigurationInfoSource.class);
+        Map<String, String> props = new HashMap<>();
+        when(source.getConfiguration(PLUGIN_ID, CONFIG_FILE)).thenReturn(props);
+        PluginConfiguration config = new PluginConfiguration(source, PLUGIN_ID);
+        config.getGatewayURL();
+    }
+}
--- a/plugins/commands/agent/pom.xml	Fri Jun 23 11:45:40 2017 -0400
+++ b/plugins/commands/agent/pom.xml	Wed Jun 21 17:46:44 2017 -0400
@@ -118,6 +118,11 @@
     </dependency>
     <dependency>
       <groupId>com.redhat.thermostat</groupId>
+      <artifactId>thermostat-common-plugin</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.redhat.thermostat</groupId>
       <artifactId>thermostat-agent-core</artifactId>
       <version>${project.version}</version>
     </dependency>
@@ -139,6 +144,6 @@
       <artifactId>websocket-client</artifactId>
       <version>${jetty.version}</version>
     </dependency>
-    
+
   </dependencies>
 </project>
--- a/plugins/commands/agent/src/main/java/com/redhat/thermostat/commands/agent/internal/CommandsBackend.java	Fri Jun 23 11:45:40 2017 -0400
+++ b/plugins/commands/agent/src/main/java/com/redhat/thermostat/commands/agent/internal/CommandsBackend.java	Wed Jun 21 17:46:44 2017 -0400
@@ -61,7 +61,7 @@
 import com.redhat.thermostat.common.Ordered;
 import com.redhat.thermostat.common.Version;
 import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
-import com.redhat.thermostat.common.plugins.PluginConfiguration;
+import com.redhat.thermostat.common.plugin.PluginConfiguration;
 import com.redhat.thermostat.common.utils.LoggingUtils;
 import com.redhat.thermostat.shared.config.CommonPaths;
 import com.redhat.thermostat.storage.config.FileStorageCredentials;
--- a/plugins/commands/agent/src/test/java/com/redhat/thermostat/commands/agent/internal/CommandsBackendTest.java	Fri Jun 23 11:45:40 2017 -0400
+++ b/plugins/commands/agent/src/test/java/com/redhat/thermostat/commands/agent/internal/CommandsBackendTest.java	Wed Jun 21 17:46:44 2017 -0400
@@ -63,7 +63,7 @@
 import com.redhat.thermostat.commands.agent.internal.CommandsBackend.WsClientCreator;
 import com.redhat.thermostat.commands.agent.internal.socket.CmdChannelAgentSocket;
 import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
-import com.redhat.thermostat.common.plugins.PluginConfiguration;
+import com.redhat.thermostat.common.plugin.PluginConfiguration;
 import com.redhat.thermostat.shared.config.CommonPaths;
 import com.redhat.thermostat.storage.core.StorageCredentials;
 
--- a/plugins/host-overview/agent/pom.xml	Fri Jun 23 11:45:40 2017 -0400
+++ b/plugins/host-overview/agent/pom.xml	Wed Jun 21 17:46:44 2017 -0400
@@ -62,7 +62,6 @@
             <Export-Package>com.redhat.thermostat.host.overview.model</Export-Package>
             <Private-Package>
               com.redhat.thermostat.host.overview.internal,
-              com.redhat.thermostat.host.overview.internal.common,
               com.redhat.thermostat.host.overview.internal.models
             </Private-Package>
             <!-- Do not autogenerate uses clauses in Manifests -->
@@ -151,6 +150,11 @@
     </dependency>
     <dependency>
       <groupId>com.redhat.thermostat</groupId>
+      <artifactId>thermostat-common-plugin</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.redhat.thermostat</groupId>
       <artifactId>thermostat-common-portability</artifactId>
       <version>${project.version}</version>
     </dependency>
--- a/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/HostInfoTypeAdapter.java	Fri Jun 23 11:45:40 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.host.overview.internal;
-
-import java.io.IOException;
-import java.util.List;
-
-import com.google.gson.TypeAdapter;
-import com.google.gson.stream.JsonReader;
-import com.google.gson.stream.JsonWriter;
-import com.redhat.thermostat.host.overview.model.HostInfo;
-
-public class HostInfoTypeAdapter extends TypeAdapter<List<HostInfo>> {
-    
-    private static final String AGENT_ID = "agentId";
-    private static final String HOSTNAME = "hostname";
-    private static final String OS_NAME = "osName";
-    private static final String OS_KERNEL = "osKernel";
-    private static final String CPU_MODEL = "cpuModel";
-    private static final String CPU_COUNT = "cpuCount";
-    private static final String TOTAL_MEMORY = "totalMemory";
-    private static final String TYPE_LONG = "$numberLong";
-
-    @Override
-    public void write(JsonWriter out, List<HostInfo> value) throws IOException {
-        // Request is an array of HostInfo objects
-        out.beginArray();
-        
-        for (HostInfo info : value) {
-            writeHostInfo(out, info);
-        }
-        
-        out.endArray();
-    }
-
-    private void writeHostInfo(JsonWriter out, HostInfo info) throws IOException {
-        out.beginObject();
-        
-        // Write each field of HostInfo as part of a JSON object
-        out.name(AGENT_ID);
-        out.value(info.getAgentId());
-        out.name(HOSTNAME);
-        out.value(info.getHostname());
-        out.name(OS_NAME);
-        out.value(info.getOsName());
-        out.name(OS_KERNEL);
-        out.value(info.getOsKernel());
-        out.name(CPU_MODEL);
-        out.value(info.getCpuModel());
-        out.name(CPU_COUNT);
-        out.value(info.getCpuCount());
-        out.name(TOTAL_MEMORY);
-        writeLong(out, info.getTotalMemory());
-        
-        out.endObject();
-    }
-
-    private void writeLong(JsonWriter out, long totalMemory) throws IOException {
-        // Write MongoDB representation of a Long
-        out.beginObject();
-        out.name(TYPE_LONG);
-        out.value(String.valueOf(totalMemory));
-        out.endObject();
-    }
-
-    @Override
-    public List<HostInfo> read(JsonReader in) throws IOException {
-        throw new UnsupportedOperationException();
-    }
-
-}
--- a/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/HostOverviewBackend.java	Fri Jun 23 11:45:40 2017 -0400
+++ b/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/HostOverviewBackend.java	Wed Jun 21 17:46:44 2017 -0400
@@ -78,7 +78,7 @@
     public boolean activate() {
         HostInfoBuilder builder = builderCreator.create(writerID);
         HostInfo hostInfo = builder.build();
-        hostInfoDAO.put(hostInfo.getHostname(), hostInfo);
+        hostInfoDAO.put(hostInfo);
         started = true;
         return true;
     }
--- a/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/common/PluginDAOBase.java	Fri Jun 23 11:45:40 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.host.overview.internal.common;
-
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.client.api.ContentResponse;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.client.util.StringContentProvider;
-import org.eclipse.jetty.http.HttpHeader;
-import org.eclipse.jetty.http.HttpMethod;
-import org.eclipse.jetty.http.HttpStatus;
-
-import com.redhat.thermostat.common.plugins.PluginConfiguration;
-import com.redhat.thermostat.common.utils.LoggingUtils;
-
-abstract public class PluginDAOBase<Tobj,Tdao> {
-
-    private static final Logger logger = LoggingUtils.getLogger(PluginDAOBase.class);
-
-    private static final String CONTENT_TYPE = "application/json";
-
-    protected final HttpClient httpClient;
-
-    public PluginDAOBase(HttpClient client) {
-        this.httpClient = client;
-    }
-
-    protected abstract String toJsonString(Tobj obj) throws IOException;
-    protected abstract PluginConfiguration getConfig();
-
-    public void put(String systemid, final Tobj obj) {
-        try {
-            final String gatewayURL = getConfig().getGatewayURL();
-            final String json = toJsonString(obj);
-            final StringContentProvider provider =  new StringContentProvider(json);
-            final String url = gatewayURL + "/systems/" + systemid;
-            final Request httpRequest = httpClient.newRequest(url);
-            httpRequest.method(HttpMethod.POST);
-            httpRequest.content(provider);
-            httpRequest.header(HttpHeader.CONTENT_TYPE, CONTENT_TYPE);
-            sendRequest(httpRequest);
-        } catch (IOException | InterruptedException | TimeoutException | ExecutionException e) {
-            logger.log(Level.WARNING, "Failed to send " + obj.getClass().getName() + " to web gateway", e);
-        }
-    }
-
-    private void sendRequest(Request httpRequest)
-            throws InterruptedException, TimeoutException, ExecutionException, IOException {
-        final ContentResponse resp = httpRequest.send();
-        final int status = resp.getStatus();
-        if (status != HttpStatus.OK_200) {
-            throw new IOException("Gateway returned HTTP status " + String.valueOf(status) + " - " + resp.getReason());
-        }
-    }
-}
-
--- a/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/models/HostInfoDAO.java	Fri Jun 23 11:45:40 2017 -0400
+++ b/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/models/HostInfoDAO.java	Wed Jun 21 17:46:44 2017 -0400
@@ -42,7 +42,7 @@
 @Service
 public interface HostInfoDAO {
 
-    void put(String systemid, HostInfo info);
+    void put(HostInfo info);
 
 }
 
--- a/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/models/HostInfoDAOImpl.java	Fri Jun 23 11:45:40 2017 -0400
+++ b/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/models/HostInfoDAOImpl.java	Wed Jun 21 17:46:44 2017 -0400
@@ -41,6 +41,7 @@
 import java.util.List;
 import java.util.logging.Logger;
 
+import com.redhat.thermostat.common.plugin.SystemID;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Reference;
@@ -49,10 +50,11 @@
 import org.eclipse.jetty.client.util.StringContentProvider;
 
 import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
-import com.redhat.thermostat.common.plugins.PluginConfiguration;
+import com.redhat.thermostat.common.plugin.PluginConfiguration;
+import com.redhat.thermostat.common.plugin.PluginDAOBase;
 import com.redhat.thermostat.common.utils.LoggingUtils;
-import com.redhat.thermostat.host.overview.internal.HostInfoTypeAdapter;
-import com.redhat.thermostat.host.overview.internal.common.PluginDAOBase;
+
+import com.redhat.thermostat.host.overview.model.HostInfoTypeAdapter;
 import com.redhat.thermostat.host.overview.model.HostInfo;
 
 @Component
@@ -70,8 +72,12 @@
     
     @Reference
     private ConfigurationInfoSource configInfoSource;
+
     private PluginConfiguration config;
 
+    @Reference
+    private SystemID systemID;
+
     public HostInfoDAOImpl() {
         this(new HttpClient(), new JsonHelper(new HostInfoTypeAdapter()), new HttpHelper(), 
                 new ConfigurationCreator(), null);
@@ -92,6 +98,9 @@
         httpHelper.startClient(httpClient);
     }
 
+    public String getURL(final String base) {
+        return base + "/systems/" + systemID.getSystemID();
+    }
 
     public String getPluginId() {
         return PLUGIN_ID;
@@ -111,7 +120,11 @@
     	return config;
     }
 
-    // For testing purposes
+    // DS bind method
+    protected void bindSystemID(SystemID systemid) {
+        this.systemID = systemid;
+    }
+
     static class JsonHelper {
         
         private final HostInfoTypeAdapter typeAdapter;
@@ -123,7 +136,6 @@
         String toJson(List<HostInfo> infos) throws IOException {
             return typeAdapter.toJson(infos);
         }
-        
     }
     
     // For testing purposes
@@ -136,7 +148,6 @@
         StringContentProvider createContentProvider(String content) {
             return new StringContentProvider(content);
         }
-        
     }
     
     // For Testing purposes
@@ -145,7 +156,6 @@
         PluginConfiguration create(ConfigurationInfoSource source) {
             return new PluginConfiguration(source, PLUGIN_ID);
         }
-        
     }
     
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/model/HostInfoTypeAdapter.java	Wed Jun 21 17:46:44 2017 -0400
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2012-2017 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.host.overview.model;
+
+import java.io.IOException;
+import java.util.List;
+
+import com.google.gson.TypeAdapter;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonWriter;
+
+public class HostInfoTypeAdapter extends TypeAdapter<List<HostInfo>> {
+    
+    private static final String AGENT_ID = "agentId";
+    private static final String HOSTNAME = "hostname";
+    private static final String OS_NAME = "osName";
+    private static final String OS_KERNEL = "osKernel";
+    private static final String CPU_MODEL = "cpuModel";
+    private static final String CPU_COUNT = "cpuCount";
+    private static final String TOTAL_MEMORY = "totalMemory";
+    private static final String TYPE_LONG = "$numberLong";
+
+    @Override
+    public void write(JsonWriter out, List<HostInfo> value) throws IOException {
+        // Request is an array of HostInfo objects
+        out.beginArray();
+        
+        for (HostInfo info : value) {
+            writeHostInfo(out, info);
+        }
+        
+        out.endArray();
+    }
+
+    private void writeHostInfo(JsonWriter out, HostInfo info) throws IOException {
+        out.beginObject();
+        
+        // Write each field of HostInfo as part of a JSON object
+        out.name(AGENT_ID);
+        out.value(info.getAgentId());
+        out.name(HOSTNAME);
+        out.value(info.getHostname());
+        out.name(OS_NAME);
+        out.value(info.getOsName());
+        out.name(OS_KERNEL);
+        out.value(info.getOsKernel());
+        out.name(CPU_MODEL);
+        out.value(info.getCpuModel());
+        out.name(CPU_COUNT);
+        out.value(info.getCpuCount());
+        out.name(TOTAL_MEMORY);
+        writeLong(out, info.getTotalMemory());
+        
+        out.endObject();
+    }
+
+    private void writeLong(JsonWriter out, long totalMemory) throws IOException {
+        // Write MongoDB representation of a Long
+        out.beginObject();
+        out.name(TYPE_LONG);
+        out.value(String.valueOf(totalMemory));
+        out.endObject();
+    }
+
+    @Override
+    public List<HostInfo> read(JsonReader in) throws IOException {
+        throw new UnsupportedOperationException();
+    }
+
+}
--- a/plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/internal/HostInfoTypeAdapterTest.java	Fri Jun 23 11:45:40 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.host.overview.internal;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.redhat.thermostat.host.overview.model.HostInfo;
-
-public class HostInfoTypeAdapterTest {
-    
-    private HostInfoTypeAdapter adapter;
-    
-    @Before
-    public void setup() {
-        adapter = new HostInfoTypeAdapter();
-    }
-
-    @Test
-    public void testWrite() throws Exception {
-        final String expected = "[{\"agentId\":\"myAgent1\",\"hostname\":\"myHost1\"," 
-                + "\"osName\":\"myOS1\",\"osKernel\":\"myKernel1\",\"cpuModel\":\"myCPU1\"," 
-                + "\"cpuCount\":4,\"totalMemory\":{\"$numberLong\":\"400000000\"}}," 
-                + "{\"agentId\":\"myAgent2\",\"hostname\":\"myHost2\",\"osName\":\"myOS2\"," 
-                + "\"osKernel\":\"myKernel2\",\"cpuModel\":\"myCPU2\",\"cpuCount\":2," 
-                + "\"totalMemory\":{\"$numberLong\":\"800000000\"}}]";
-        
-        HostInfo first = new HostInfo("myAgent1", "myHost1", "myOS1", "myKernel1", "myCPU1", 4, 400000000L);
-        HostInfo second = new HostInfo("myAgent2", "myHost2", "myOS2", "myKernel2", "myCPU2", 2, 800000000L);
-        List<HostInfo> infos = Arrays.asList(first, second);
-        
-        String json = adapter.toJson(infos);
-        assertEquals(expected, json);
-    }
-
-}
--- a/plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/internal/HostOverviewBackendTest.java	Fri Jun 23 11:45:40 2017 -0400
+++ b/plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/internal/HostOverviewBackendTest.java	Wed Jun 21 17:46:44 2017 -0400
@@ -86,7 +86,7 @@
         
         verify(builderCreator).create(writerID);
         verify(builder).build();
-        verify(hostInfoDAO).put(info.getHostname(), info);
+        verify(hostInfoDAO).put(info);
     }
     
     @Test
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/internal/models/HostInfoDAOImplTest.java	Wed Jun 21 17:46:44 2017 -0400
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2012-2017 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.host.overview.internal.models;
+
+import static org.mockito.Matchers.anyListOf;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.redhat.thermostat.common.plugin.SystemID;
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.api.ContentProvider;
+import org.eclipse.jetty.client.api.ContentResponse;
+import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.client.util.StringContentProvider;
+import org.eclipse.jetty.http.HttpHeader;
+import org.eclipse.jetty.http.HttpMethod;
+import org.eclipse.jetty.http.HttpStatus;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Matchers;
+
+import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
+import com.redhat.thermostat.common.plugin.PluginConfiguration;
+import com.redhat.thermostat.host.overview.internal.models.HostInfoDAOImpl.ConfigurationCreator;
+import com.redhat.thermostat.host.overview.model.HostInfo;
+
+public class HostInfoDAOImplTest {
+
+    private static final String URL = "http://localhost:26000/api/systems/v0.0.3";
+    private static final String SOME_JSON = "{\"some\" : \"json\"}";
+    private static final String HOST_NAME = "a host name";
+    private static final String OS_NAME = "some os";
+    private static final String OS_KERNEL = "some kernel";
+    private static final String CPU_MODEL = "some cpu that runs fast";
+    private static final int CPU_NUM = -1;
+    private static final long MEMORY_TOTAL = 0xCAFEBABEl;
+
+    private static final String URL_PROP = "gatewayURL";
+
+    private HostInfo info;
+    private HttpClient httpClient;
+    private HostInfoDAOImpl.JsonHelper jsonHelper;
+    private HostInfoDAOImpl.HttpHelper httpHelper;
+    private StringContentProvider contentProvider;
+    private Request request;
+    private ContentResponse response;
+    private ConfigurationInfoSource cfiSource;
+    private ConfigurationCreator configCreator;
+    
+    @Before
+    public void setup() throws Exception {
+        info = new HostInfo("foo-agent", HOST_NAME, OS_NAME, OS_KERNEL, CPU_MODEL, CPU_NUM, MEMORY_TOTAL);
+        
+        httpHelper = mock(HostInfoDAOImpl.HttpHelper.class);
+        contentProvider = mock(StringContentProvider.class);
+        when(httpHelper.createContentProvider(anyString())).thenReturn(contentProvider);
+        request = mock(Request.class);
+        httpClient = mock(HttpClient.class);
+        request = mock(Request.class);
+        when(httpClient.newRequest(anyString())).thenReturn(request);
+        response = mock(ContentResponse.class);
+        when(response.getStatus()).thenReturn(HttpStatus.OK_200);
+        when(request.send()).thenReturn(response);
+        
+        jsonHelper = mock(HostInfoDAOImpl.JsonHelper.class);
+        when(jsonHelper.toJson(anyListOf(HostInfo.class))).thenReturn(SOME_JSON);
+
+        cfiSource = mock(ConfigurationInfoSource.class);
+        Map<String,String> map = new HashMap<>();
+        map.put(URL_PROP, URL);
+        when(cfiSource.getConfiguration(anyString(),anyString())).thenReturn(map);
+        configCreator = mock(ConfigurationCreator.class);
+        when(configCreator.create(eq(cfiSource))).thenReturn(new PluginConfiguration(cfiSource, HostInfoDAOImpl.PLUGIN_ID));
+    }
+
+    @Test
+    public void testPutHostInfo() throws Exception {
+
+        HostInfoDAOImpl dao = new HostInfoDAOImpl(httpClient, jsonHelper, httpHelper, configCreator, cfiSource);
+        SystemID idservice = mock(SystemID.class);
+        when(idservice.getSystemID()).thenReturn(HOST_NAME);
+        dao.bindSystemID(idservice);
+        dao.activate();
+        
+        dao.put(info);
+        
+        verify(httpClient).newRequest(URL + "/systems/" + HOST_NAME);
+        verify(request).method(HttpMethod.POST);
+        verify(jsonHelper).toJson(eq(Arrays.asList(info)));
+        verify(request).content(Matchers.any(ContentProvider.class));
+        verify(request).header(HttpHeader.CONTENT_TYPE, "application/json");
+        verify(request).send();
+        verify(response).getStatus();
+    }
+
+}
+
--- a/plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/internal/models/HostInfoDAOTest.java	Fri Jun 23 11:45:40 2017 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-/*
- * Copyright 2012-2017 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.host.overview.internal.models;
-
-import static org.mockito.Matchers.anyListOf;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.client.api.ContentProvider;
-import org.eclipse.jetty.client.api.ContentResponse;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.client.util.StringContentProvider;
-import org.eclipse.jetty.http.HttpHeader;
-import org.eclipse.jetty.http.HttpMethod;
-import org.eclipse.jetty.http.HttpStatus;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Matchers;
-
-import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
-import com.redhat.thermostat.common.plugins.PluginConfiguration;
-import com.redhat.thermostat.host.overview.internal.models.HostInfoDAOImpl.ConfigurationCreator;
-import com.redhat.thermostat.host.overview.model.HostInfo;
-
-public class HostInfoDAOTest {
-
-    private static final String URL = "http://localhost:26000/api/systems/v0.0.3";
-    private static final String SOME_JSON = "{\"some\" : \"json\"}";
-    private static final String HOST_NAME = "a host name";
-    private static final String OS_NAME = "some os";
-    private static final String OS_KERNEL = "some kernel";
-    private static final String CPU_MODEL = "some cpu that runs fast";
-    private static final int CPU_NUM = -1;
-    private static final long MEMORY_TOTAL = 0xCAFEBABEl;
-
-    private static final String URL_PROP = "gatewayURL";
-
-    private HostInfo info;
-    private HttpClient httpClient;
-    private HostInfoDAOImpl.JsonHelper jsonHelper;
-    private HostInfoDAOImpl.HttpHelper httpHelper;
-    private StringContentProvider contentProvider;
-    private Request request;
-    private ContentResponse response;
-    private ConfigurationInfoSource cfiSource;
-    private ConfigurationCreator configCreator;
-    
-    @Before
-    public void setup() throws Exception {
-        info = new HostInfo("foo-agent", HOST_NAME, OS_NAME, OS_KERNEL, CPU_MODEL, CPU_NUM, MEMORY_TOTAL);
-        
-        httpHelper = mock(HostInfoDAOImpl.HttpHelper.class);
-        contentProvider = mock(StringContentProvider.class);
-        when(httpHelper.createContentProvider(anyString())).thenReturn(contentProvider);
-        request = mock(Request.class);
-        httpClient = mock(HttpClient.class);
-        request = mock(Request.class);
-        when(httpClient.newRequest(anyString())).thenReturn(request);
-        response = mock(ContentResponse.class);
-        when(response.getStatus()).thenReturn(HttpStatus.OK_200);
-        when(request.send()).thenReturn(response);
-        
-        jsonHelper = mock(HostInfoDAOImpl.JsonHelper.class);
-        when(jsonHelper.toJson(anyListOf(HostInfo.class))).thenReturn(SOME_JSON);
-
-        cfiSource = mock(ConfigurationInfoSource.class);
-        Map<String,String> map = new HashMap<>();
-        map.put(URL_PROP, URL);
-        when(cfiSource.getConfiguration(anyString(),anyString())).thenReturn(map);
-        configCreator = mock(ConfigurationCreator.class);
-        when(configCreator.create(eq(cfiSource))).thenReturn(new PluginConfiguration(cfiSource, HostInfoDAOImpl.PLUGIN_ID));
-    }
-
-    @Test
-    public void testPutHostInfo() throws Exception {
-
-        HostInfoDAOImpl dao = new HostInfoDAOImpl(httpClient, jsonHelper, httpHelper, configCreator, cfiSource);
-        dao.activate();
-        
-        dao.put(info.getAgentId(), info);
-        
-        verify(httpClient).newRequest(URL + "/systems/" + info.getAgentId());
-        verify(request).method(HttpMethod.POST);
-        verify(jsonHelper).toJson(eq(Arrays.asList(info)));
-        verify(request).content(Matchers.any(ContentProvider.class));
-        verify(request).header(HttpHeader.CONTENT_TYPE, "application/json");
-        verify(request).send();
-        verify(response).getStatus();
-    }
-
-}
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/model/HostInfoTypeAdapterTest.java	Wed Jun 21 17:46:44 2017 -0400
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2012-2017 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.host.overview.model;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class HostInfoTypeAdapterTest {
+    
+    private HostInfoTypeAdapter adapter;
+    
+    @Before
+    public void setup() {
+        adapter = new HostInfoTypeAdapter();
+    }
+
+    @Test
+    public void testWrite() throws Exception {
+        final String expected = "[{\"agentId\":\"myAgent1\",\"hostname\":\"myHost1\"," 
+                + "\"osName\":\"myOS1\",\"osKernel\":\"myKernel1\",\"cpuModel\":\"myCPU1\"," 
+                + "\"cpuCount\":4,\"totalMemory\":{\"$numberLong\":\"400000000\"}}," 
+                + "{\"agentId\":\"myAgent2\",\"hostname\":\"myHost2\",\"osName\":\"myOS2\"," 
+                + "\"osKernel\":\"myKernel2\",\"cpuModel\":\"myCPU2\",\"cpuCount\":2," 
+                + "\"totalMemory\":{\"$numberLong\":\"800000000\"}}]";
+        
+        HostInfo first = new HostInfo("myAgent1", "myHost1", "myOS1", "myKernel1", "myCPU1", 4, 400000000L);
+        HostInfo second = new HostInfo("myAgent2", "myHost2", "myOS2", "myKernel2", "myCPU2", 2, 800000000L);
+        List<HostInfo> infos = Arrays.asList(first, second);
+        
+        String json = adapter.toJson(infos);
+        assertEquals(expected, json);
+    }
+
+}
--- a/plugins/vm-gc/agent/pom.xml	Fri Jun 23 11:45:40 2017 -0400
+++ b/plugins/vm-gc/agent/pom.xml	Wed Jun 21 17:46:44 2017 -0400
@@ -132,6 +132,11 @@
     </dependency>
     <dependency>
       <groupId>com.redhat.thermostat</groupId>
+      <artifactId>thermostat-common-plugin</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.redhat.thermostat</groupId>
       <artifactId>thermostat-agent-core</artifactId>
       <version>${project.version}</version>
     </dependency>
--- a/plugins/vm-gc/agent/src/main/java/com/redhat/thermostat/vm/gc/agent/internal/models/VmGcStatDAOImpl.java	Fri Jun 23 11:45:40 2017 -0400
+++ b/plugins/vm-gc/agent/src/main/java/com/redhat/thermostat/vm/gc/agent/internal/models/VmGcStatDAOImpl.java	Wed Jun 21 17:46:44 2017 -0400
@@ -52,7 +52,7 @@
 
 import com.redhat.thermostat.agent.http.HttpRequestService;
 import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
-import com.redhat.thermostat.common.plugins.PluginConfiguration;
+import com.redhat.thermostat.common.plugin.PluginConfiguration;
 import com.redhat.thermostat.common.utils.LoggingUtils;
 import com.redhat.thermostat.vm.gc.agent.model.VmGcStat;
 
--- a/plugins/vm-gc/agent/src/test/java/com/redhat/thermostat/vm/gc/agent/internal/models/VmGcStatDAOImplTest.java	Fri Jun 23 11:45:40 2017 -0400
+++ b/plugins/vm-gc/agent/src/test/java/com/redhat/thermostat/vm/gc/agent/internal/models/VmGcStatDAOImplTest.java	Wed Jun 21 17:46:44 2017 -0400
@@ -55,7 +55,7 @@
 
 import com.redhat.thermostat.agent.http.HttpRequestService;
 import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
-import com.redhat.thermostat.common.plugins.PluginConfiguration;
+import com.redhat.thermostat.common.plugin.PluginConfiguration;
 import com.redhat.thermostat.vm.gc.agent.internal.models.VmGcStatDAOImpl.ConfigurationCreator;
 import com.redhat.thermostat.vm.gc.agent.internal.models.VmGcStatDAOImpl.JsonHelper;
 import com.redhat.thermostat.vm.gc.agent.model.VmGcStat;
@@ -65,7 +65,7 @@
     private static final String AGENT_ID = "some-agent";
     private static final String JSON = "{\"this\":\"is\",\"also\":\"JSON\"}";
     private static final String GATEWAY_URL = "http://example.com/jvm-gc";
-    
+
     private VmGcStat stat;
     private JsonHelper jsonHelper;
     private VmGcStatDAOImpl dao;
--- a/plugins/vm-memory/common/pom.xml	Fri Jun 23 11:45:40 2017 -0400
+++ b/plugins/vm-memory/common/pom.xml	Wed Jun 21 17:46:44 2017 -0400
@@ -126,6 +126,11 @@
     </dependency>
     <dependency>
       <groupId>com.redhat.thermostat</groupId>
+      <artifactId>thermostat-common-plugin</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.redhat.thermostat</groupId>
       <artifactId>thermostat-storage-core</artifactId>
       <version>${project.version}</version>
     </dependency>
--- a/plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatDAOImpl.java	Fri Jun 23 11:45:40 2017 -0400
+++ b/plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatDAOImpl.java	Wed Jun 21 17:46:44 2017 -0400
@@ -45,7 +45,7 @@
 import java.util.logging.Logger;
 
 import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
-import com.redhat.thermostat.common.plugins.PluginConfiguration;
+import com.redhat.thermostat.common.plugin.PluginConfiguration;
 import com.redhat.thermostat.common.utils.LoggingUtils;
 import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO;
 import com.redhat.thermostat.vm.memory.common.model.VmMemoryStat;
--- a/plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/internal/VmTlabStatDAOImpl.java	Fri Jun 23 11:45:40 2017 -0400
+++ b/plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/internal/VmTlabStatDAOImpl.java	Wed Jun 21 17:46:44 2017 -0400
@@ -43,7 +43,7 @@
 import java.util.logging.Logger;
 
 import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
-import com.redhat.thermostat.common.plugins.PluginConfiguration;
+import com.redhat.thermostat.common.plugin.PluginConfiguration;
 import com.redhat.thermostat.common.utils.LoggingUtils;
 import com.redhat.thermostat.vm.memory.common.VmTlabStatDAO;
 import com.redhat.thermostat.vm.memory.common.model.VmTlabStat;
--- a/plugins/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatDAOImplTest.java	Fri Jun 23 11:45:40 2017 -0400
+++ b/plugins/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatDAOImplTest.java	Wed Jun 21 17:46:44 2017 -0400
@@ -56,7 +56,7 @@
 import org.junit.Test;
 
 import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
-import com.redhat.thermostat.common.plugins.PluginConfiguration;
+import com.redhat.thermostat.common.plugin.PluginConfiguration;
 import com.redhat.thermostat.vm.memory.common.internal.VmMemoryStatDAOImpl.HttpHelper;
 import com.redhat.thermostat.vm.memory.common.internal.VmMemoryStatDAOImpl.JsonHelper;
 import com.redhat.thermostat.vm.memory.common.model.VmMemoryStat;
--- a/plugins/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/VmTlabStatDAOTest.java	Fri Jun 23 11:45:40 2017 -0400
+++ b/plugins/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/VmTlabStatDAOTest.java	Wed Jun 21 17:46:44 2017 -0400
@@ -48,7 +48,7 @@
 import java.util.Arrays;
 
 import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
-import com.redhat.thermostat.common.plugins.PluginConfiguration;
+import com.redhat.thermostat.common.plugin.PluginConfiguration;
 import com.redhat.thermostat.vm.memory.common.VmTlabStatDAO;
 import com.redhat.thermostat.vm.memory.common.model.VmTlabStat;
 import org.eclipse.jetty.client.HttpClient;