Adds startComponent method to components
- Allows separate start and configuration
Change-Id: I7aa76d4c59201a5e285618493ad78ca363edfc6f
Signed-off-by: Frank Schnicke <frank.schnicke@iese.fraunhofer.de>
diff --git a/components/basys.components/basyx.components.docker/basyx.components.AASX/src/main/java/org/eclipse/basyx/components/executable/AASXExecutable.java b/components/basys.components/basyx.components.docker/basyx.components.AASX/src/main/java/org/eclipse/basyx/components/executable/AASXExecutable.java
index e566c35..11e728b 100644
--- a/components/basys.components/basyx.components.docker/basyx.components.AASX/src/main/java/org/eclipse/basyx/components/executable/AASXExecutable.java
+++ b/components/basys.components/basyx.components.docker/basyx.components.AASX/src/main/java/org/eclipse/basyx/components/executable/AASXExecutable.java
@@ -42,12 +42,25 @@
BaSyxContextConfiguration config = new BaSyxContextConfiguration();
config.loadFromResource(BaSyxContextConfiguration.DEFAULT_CONFIG_PATH);
+ startComponent(config.getHostname(), config.getPort(), config.getContextPath(), config.getDocBasePath(), config.getProperty("aasxPath"));
+ }
+
+ /**
+ * Starts the AASX component at http://${hostName}:${port}/${path}
+ *
+ * @param hostName
+ * @param port
+ * @param path
+ * @param docBasePath
+ * @throws IOException
+ * @throws SAXException
+ * @throws ParserConfigurationException
+ */
+ public static void startComponent(String hostName, int port, String path, String docBasePath, String aasxPath) throws ParserConfigurationException, SAXException, IOException {
// Init HTTP context and add an XMLAAServlet according to the configuration
- BaSyxContext context = new BaSyxContext(config.getContextPath(), config.getDocBasePath(), config.getHostname(), config.getPort());
+ BaSyxContext context = new BaSyxContext(path, docBasePath, hostName, port);
// Create the Servlet for aas
- String aasxPath = config.getProperty("aasxPath");
-
context.addServletMapping(SERVLET_MAPPING, new AASXAASServlet(aasxPath));
// Create and start server
@@ -57,7 +70,6 @@
// 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 cefb994..6501fa7 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
@@ -35,9 +35,21 @@
// Load configuration
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(config.getContextPath(), config.getDocBasePath(), config.getHostname(),
- config.getPort());
+ BaSyxContext context = new BaSyxContext(path, docBasePath, hostName, port);
context.addServletMapping(SERVLET_MAPPING + "*", new InMemoryRegistryServlet());
// Create and start server
@@ -45,5 +57,4 @@
logger.info("Starting server...");
server.start();
}
-
}
\ 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/executable/SQLRegistryExecutable.java b/components/basys.components/basyx.components.docker/basyx.components.sqlregistry/src/main/java/org/eclipse/basyx/components/executable/SQLRegistryExecutable.java
index d51f2ed..832441a 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
@@ -34,12 +34,22 @@
// Load configuration
BaSyxContextConfiguration config = new BaSyxContextConfiguration();
config.loadFromResource(BaSyxContextConfiguration.DEFAULT_CONFIG_PATH);
+ startComponent(config.getHostname(), config.getPort(), config.getContextPath(), config.getDocBasePath(), "dockerRegistry.properties");
+ }
+ /**
+ * 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(config.getContextPath(), config.getDocBasePath(), config.getHostname(),
- config.getPort());
- context.addServletMapping(SERVLET_MAPPING, new SQLRegistryServlet("dockerRegistry.properties"));
+ BaSyxContext context = new BaSyxContext(path, docBasePath, hostName, port);
+ context.addServletMapping(SERVLET_MAPPING, new SQLRegistryServlet(sqlPropertyPath));
// Create and start server
server = new AASHTTPServer(context);
diff --git a/components/basys.components/basyx.components.docker/basyx.components.xmlAAS/src/main/java/org/eclipse/basyx/components/executable/XMLExecutable.java b/components/basys.components/basyx.components.docker/basyx.components.xmlAAS/src/main/java/org/eclipse/basyx/components/executable/XMLExecutable.java
index bad8a53..90ba9dd 100644
--- a/components/basys.components/basyx.components.docker/basyx.components.xmlAAS/src/main/java/org/eclipse/basyx/components/executable/XMLExecutable.java
+++ b/components/basys.components/basyx.components.docker/basyx.components.xmlAAS/src/main/java/org/eclipse/basyx/components/executable/XMLExecutable.java
@@ -44,11 +44,26 @@
BaSyxContextConfiguration config = new BaSyxContextConfiguration();
config.loadFromResource(BaSyxContextConfiguration.DEFAULT_CONFIG_PATH);
- // Init HTTP context and add an XMLAAServlet according to the configuration
- BaSyxContext context = new BaSyxContext(config.getContextPath(), config.getDocBasePath(), config.getHostname(), config.getPort());
+ startComponent(config.getHostname(), config.getPort(), config.getContextPath(), config.getDocBasePath(), config.getProperty("xmlPath"));
+ }
+
+ /**
+ * Starts the XML-AAS at http://${hostName}:${port}/${path}
+ *
+ * @param hostName
+ * @param port
+ * @param path
+ * @param docBasePath
+ * @throws IOException
+ * @throws SAXException
+ * @throws ParserConfigurationException
+ */
+ public static void startComponent(String hostName, int port, String path, String docBasePath, String xmlPath) throws IOException, ParserConfigurationException, SAXException {
+ // Init HTTP context and add an XMLAAServlet according to the configuration
+ BaSyxContext context = new BaSyxContext(path, docBasePath, hostName, port);
// Load xml content from file
- String xmlContent = BaSyxConfiguration.getResourceString(config.getProperty("xmlPath"));
+ String xmlContent = BaSyxConfiguration.getResourceString(xmlPath);
context.addServletMapping(SERVLET_MAPPING, new XMLAASServlet(xmlContent));
// Create and start server