|
|
Here, I'll walk you through the java source code, responsible for starting the [AAS Registry](What-am-I-looking-at-here#registry). Additional startup procedures are explained in the documentation for the [`start_component.sh`](start_component.sh) and the [`run_demo.sh`](run_demo.sh) scripts.
|
|
|
|
|
|
The discussed file can be found [here](https://gitlab.hrz.tu-chemnitz.de/s6869070--tu-dresden.de/vws-spielwiese/-/blob/b1802bdd98650bdb666f03483f1e13c7f99bf4b8/basyx.lichterkette/src/main/java/de/olipar/basyx/lichterkette/RegistryServer.java).
|
|
|
|
|
|
This is very similar to the [AAS Server starter](AAS-Server-starter-walkthrough).
|
|
|
|
|
|
We'll skip the license header, imports and comments, as they are either pretty much self explanatory or not the product of conscious development effort.
|
|
|
|
|
|
```java
|
|
|
public class RegistryServer {
|
|
|
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(RegistryServer.class);
|
|
|
|
|
|
```
|
|
|
At the start of the `RegistryServer`-class, we aquire a logger object, to which all console output will be passed. This is not only used internally by BaSyx too, but allows us to easily utilize different loglevels, such as `INFO`, `WARN` and `ERROR`, indicating severity.
|
|
|
|
|
|
```java
|
|
|
public static void main(String[] args) {
|
|
|
```
|
|
|
We then define a `main`-method, as this class is executable. It will be called to startup the AAS Registry.
|
|
|
|
|
|
```java
|
|
|
final int HOSTPORT = Common.getHostPort();
|
|
|
logger.info("Local host port is set to " + HOSTPORT);
|
|
|
```
|
|
|
Here, we invoke the static method `getHostPort()` of the [`Common`-class](Common-class-walkthrough). The port on which to host the AAS Registry is grabbed from an environment variable, if present and set to a fallback value if not. The set port is then logged via the `Logger` object acquired above.
|
|
|
|
|
|
```java
|
|
|
startRegistry(HOSTPORT);
|
|
|
```
|
|
|
Lastly, we startup the AAS Registry by invoking the method defined next:
|
|
|
|
|
|
```java
|
|
|
private static void startRegistry(final int HOSTPORT) {
|
|
|
```
|
|
|
This method is used to handle the actual startup of an AAS Registry instance, given the port to host it on.
|
|
|
It is based on the startup method given by the BaSyx documentation in [this example](https://wiki.eclipse.org/BaSyx_/_Introductory_Examples_/_Java_/_Example_6), only the port to host it on was parametrized.
|
|
|
|
|
|
```java
|
|
|
BaSyxContextConfiguration contextConfig = new BaSyxContextConfiguration(HOSTPORT, "/registry");
|
|
|
```
|
|
|
Here, we create a `BaSyxContextConfiguration`-object, storing the port to host the new AAS Registry instance on and the path prefix.
|
|
|
|
|
|
```java
|
|
|
BaSyxRegistryConfiguration registryConfig = new BaSyxRegistryConfiguration(RegistryBackend.INMEMORY);
|
|
|
```
|
|
|
Here, we create a `BaSyxRegistryConfiguration`-object, setting the backend of the registry to use the RAM.
|
|
|
|
|
|
```java
|
|
|
RegistryComponent registry = new RegistryComponent(contextConfig, registryConfig);
|
|
|
```
|
|
|
Creates a new AAS registry Component, passing the configuration objects created above
|
|
|
|
|
|
```java
|
|
|
registry.startComponent();
|
|
|
```
|
|
|
Actually starts the AAS Registry.
|
|
|
|
|
|
After startup, the AAS Registry can be reached locally on `http://localhost:<HOSTPORT>/registry/api/v1/registry`. |
|
|
\ No newline at end of file |