Modifies registry components to harmonize structure
Change-Id: I6be92d28b5b00bb863789bc3f0b46ff3390e34f2
Signed-off-by: Daniel Espen <daniel.espen@iese.fraunhofer.de>
diff --git a/components/basys.components/basyx.components.docker/basyx.components.simple/src/main/java/org/eclipse/basyx/components/InMemoryRegistryComponent.java b/components/basys.components/basyx.components.docker/basyx.components.simple/src/main/java/org/eclipse/basyx/components/InMemoryRegistryComponent.java
new file mode 100644
index 0000000..972d21e
--- /dev/null
+++ b/components/basys.components/basyx.components.docker/basyx.components.simple/src/main/java/org/eclipse/basyx/components/InMemoryRegistryComponent.java
@@ -0,0 +1,49 @@
+package org.eclipse.basyx.components;
+
+import org.eclipse.basyx.components.servlets.InMemoryRegistryServlet;
+import org.eclipse.basyx.vab.protocol.http.server.AASHTTPServer;
+import org.eclipse.basyx.vab.protocol.http.server.BaSyxContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A Registry component based on an InMemory Registry.
+ *
+ * Do not use this registry in a productive environment - the entries are not persistent!
+ *
+ * @author espen
+ */
+public class InMemoryRegistryComponent {
+ private static Logger logger = LoggerFactory.getLogger(InMemoryRegistryComponent.class);
+
+ // BaSyx context information
+ private String hostName;
+ private int port;
+ private String path;
+ private String docBasePath;
+
+ // The server with the servlet that will be created
+ private AASHTTPServer server;
+
+ public InMemoryRegistryComponent(String hostName, int port, String path, String docBasePath) {
+ // Sets the server context
+ this.hostName = hostName;
+ this.port = port;
+ this.path = path;
+ this.docBasePath = docBasePath;
+ }
+
+ /**
+ * Starts the InMemoryRegistry at http://${hostName}:${port}/${path}
+ */
+ public void startComponent() {
+ logger.info("Create the server...");
+ // Init HTTP context and add an InMemoryRegistryServlet according to the configuration
+ BaSyxContext context = new BaSyxContext(path, docBasePath, hostName, port);
+ context.addServletMapping("/*", new InMemoryRegistryServlet());
+ server = new AASHTTPServer(context);
+
+ logger.info("Start the server...");
+ server.start();
+ }
+}
diff --git a/components/basys.components/basyx.components.docker/basyx.components.simple/src/main/java/org/eclipse/basyx/components/executable/InMemoryRegistryExecutable.java b/components/basys.components/basyx.components.docker/basyx.components.simple/src/main/java/org/eclipse/basyx/components/executable/InMemoryRegistryExecutable.java
index 6501fa7..e62c6bb 100644
--- a/components/basys.components/basyx.components.docker/basyx.components.simple/src/main/java/org/eclipse/basyx/components/executable/InMemoryRegistryExecutable.java
+++ b/components/basys.components/basyx.components.docker/basyx.components.simple/src/main/java/org/eclipse/basyx/components/executable/InMemoryRegistryExecutable.java
@@ -1,9 +1,7 @@
package org.eclipse.basyx.components.executable;
+import org.eclipse.basyx.components.InMemoryRegistryComponent;
import org.eclipse.basyx.components.configuration.BaSyxContextConfiguration;
-import org.eclipse.basyx.components.servlets.InMemoryRegistryServlet;
-import org.eclipse.basyx.vab.protocol.http.server.AASHTTPServer;
-import org.eclipse.basyx.vab.protocol.http.server.BaSyxContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -18,14 +16,6 @@
public class InMemoryRegistryExecutable {
private static Logger logger = LoggerFactory.getLogger(InMemoryRegistryExecutable.class);
-
-
- // The path the created servlet is mapped to
- public static final String SERVLET_MAPPING = "/";
-
- // The server with the servlet that will be created
- private static AASHTTPServer server;
-
private InMemoryRegistryExecutable() {
}
@@ -36,25 +26,8 @@
BaSyxContextConfiguration config = new BaSyxContextConfiguration();
config.loadFromResource(BaSyxContextConfiguration.DEFAULT_CONFIG_PATH);
- startComponent(config.getHostname(), config.getPort(), config.getContextPath(), config.getDocBasePath());
- }
-
- /**
- * Starts the InMemoryRegistry at http://${hostName}:${port}/${path}
- *
- * @param hostName
- * @param port
- * @param path
- * @param docBasePath
- */
- public static void startComponent(String hostName, int port, String path, String docBasePath) {
- // Init HTTP context and add an InMemoryRegistryServlet according to the configuration
- BaSyxContext context = new BaSyxContext(path, docBasePath, hostName, port);
- context.addServletMapping(SERVLET_MAPPING + "*", new InMemoryRegistryServlet());
-
- // Create and start server
- server = new AASHTTPServer(context);
- logger.info("Starting server...");
- server.start();
+ InMemoryRegistryComponent component = new InMemoryRegistryComponent(config.getHostname(), config.getPort(),
+ config.getContextPath(), config.getDocBasePath());
+ component.startComponent();
}
}
\ No newline at end of file
diff --git a/components/basys.components/basyx.components.docker/basyx.components.sqlregistry/src/main/java/org/eclipse/basyx/components/SQLRegistryComponent.java b/components/basys.components/basyx.components.docker/basyx.components.sqlregistry/src/main/java/org/eclipse/basyx/components/SQLRegistryComponent.java
new file mode 100644
index 0000000..3f70a6e
--- /dev/null
+++ b/components/basys.components/basyx.components.docker/basyx.components.sqlregistry/src/main/java/org/eclipse/basyx/components/SQLRegistryComponent.java
@@ -0,0 +1,49 @@
+package org.eclipse.basyx.components;
+
+import org.eclipse.basyx.components.servlet.SQLRegistryServlet;
+import org.eclipse.basyx.vab.protocol.http.server.AASHTTPServer;
+import org.eclipse.basyx.vab.protocol.http.server.BaSyxContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A registry component based on an SQL database.
+ *
+ * @author espen
+ */
+public class SQLRegistryComponent {
+ private static Logger logger = LoggerFactory.getLogger(SQLRegistryComponent.class);
+
+ // BaSyx context information
+ private String hostName;
+ private int port;
+ private String path;
+ private String docBasePath;
+ private String sqlPropertyPath;
+
+ // The server with the servlet that will be created
+ private AASHTTPServer server;
+
+ public SQLRegistryComponent(String hostName, int port, String path, String docBasePath, String sqlPropertyPath) {
+ this.sqlPropertyPath = sqlPropertyPath;
+ // Sets the server context
+ this.hostName = hostName;
+ this.port = port;
+ this.path = path;
+ this.docBasePath = docBasePath;
+ }
+
+ /**
+ * Starts the SQLRegistry at http://${hostName}:${port}/${path}
+ */
+ public void startComponent() {
+ logger.info("Create the server...");
+ // Init HTTP context and add an InMemoryRegistryServlet according to the configuration
+ BaSyxContext context = new BaSyxContext(path, docBasePath, hostName, port);
+ context.addServletMapping("/*", new SQLRegistryServlet(sqlPropertyPath));
+ server = new AASHTTPServer(context);
+
+ logger.info("Start the server...");
+ server.start();
+ }
+}
diff --git a/components/basys.components/basyx.components.docker/basyx.components.sqlregistry/src/main/java/org/eclipse/basyx/components/executable/SQLRegistryExecutable.java b/components/basys.components/basyx.components.docker/basyx.components.sqlregistry/src/main/java/org/eclipse/basyx/components/executable/SQLRegistryExecutable.java
index 832441a..69eab79 100644
--- a/components/basys.components/basyx.components.docker/basyx.components.sqlregistry/src/main/java/org/eclipse/basyx/components/executable/SQLRegistryExecutable.java
+++ b/components/basys.components/basyx.components.docker/basyx.components.sqlregistry/src/main/java/org/eclipse/basyx/components/executable/SQLRegistryExecutable.java
@@ -1,9 +1,7 @@
package org.eclipse.basyx.components.executable;
+import org.eclipse.basyx.components.SQLRegistryComponent;
import org.eclipse.basyx.components.configuration.BaSyxContextConfiguration;
-import org.eclipse.basyx.components.servlet.SQLRegistryServlet;
-import org.eclipse.basyx.vab.protocol.http.server.AASHTTPServer;
-import org.eclipse.basyx.vab.protocol.http.server.BaSyxContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -17,14 +15,6 @@
public class SQLRegistryExecutable {
private static Logger logger = LoggerFactory.getLogger(SQLRegistryExecutable.class);
-
-
- // The path the created servlet is mapped to
- public static final String SERVLET_MAPPING = "/*";
-
- // The server with the servlet that will be created
- private static AASHTTPServer server;
-
private SQLRegistryExecutable() {
}
@@ -34,27 +24,9 @@
// Load configuration
BaSyxContextConfiguration config = new BaSyxContextConfiguration();
config.loadFromResource(BaSyxContextConfiguration.DEFAULT_CONFIG_PATH);
- startComponent(config.getHostname(), config.getPort(), config.getContextPath(), config.getDocBasePath(), "dockerRegistry.properties");
+
+ SQLRegistryComponent component = new SQLRegistryComponent(config.getHostname(), config.getPort(),
+ config.getContextPath(), config.getDocBasePath(), "dockerRegistry.properties");
+ component.startComponent();
}
-
- /**
- * Starts the SQLRegistry at http://${hostName}:${port}/${path}
- *
- * @param hostName
- * @param port
- * @param path
- * @param docBasePath
- */
- public static void startComponent(String hostName, int port, String path, String docBasePath, String sqlPropertyPath) {
- // Init HTTP context and add an SQLRegistryServlet according to the
- // configuration
- BaSyxContext context = new BaSyxContext(path, docBasePath, hostName, port);
- context.addServletMapping(SERVLET_MAPPING, new SQLRegistryServlet(sqlPropertyPath));
-
- // Create and start server
- server = new AASHTTPServer(context);
- logger.info("Starting server...");
- server.start();
- }
-
}
\ No newline at end of file