Skip to content

Commit

Permalink
Automatic registration of AASs & submodels with registry (#828)
Browse files Browse the repository at this point in the history
Automatic registration of AASs & submodels with registry (#828)
---------

Co-authored-by: fvolz <volz.fr@gmail.com>
  • Loading branch information
mjacoby and fvolz committed Jul 17, 2024
1 parent 4ed60dd commit 7ccf501
Show file tree
Hide file tree
Showing 24 changed files with 1,429 additions and 60 deletions.
6 changes: 6 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
<artifactId>json-patch</artifactId>
<version>${json-patch.version}</version>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<version>${wiremock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import de.fraunhofer.iosb.ilt.faaast.service.persistence.ConceptDescriptionSearchCriteria;
import de.fraunhofer.iosb.ilt.faaast.service.persistence.Persistence;
import de.fraunhofer.iosb.ilt.faaast.service.persistence.SubmodelSearchCriteria;
import de.fraunhofer.iosb.ilt.faaast.service.registry.RegistrySynchronization;
import de.fraunhofer.iosb.ilt.faaast.service.request.RequestHandlerManager;
import de.fraunhofer.iosb.ilt.faaast.service.request.handler.RequestExecutionContext;
import de.fraunhofer.iosb.ilt.faaast.service.typing.TypeExtractor;
Expand Down Expand Up @@ -71,6 +72,8 @@ public class Service implements ServiceContext {
private MessageBus messageBus;
private Persistence persistence;
private FileStorage fileStorage;

private RegistrySynchronization registrySynchronization;
private RequestHandlerManager requestHandler;

/**
Expand Down Expand Up @@ -120,6 +123,7 @@ public Service(CoreConfig coreConfig,
fileStorage,
messageBus,
assetConnectionManager));
this.registrySynchronization = new RegistrySynchronization(config.getCore(), persistence, messageBus, endpoints);
}


Expand Down Expand Up @@ -251,6 +255,7 @@ public void start() throws MessageBusException, EndpointException {
LOGGER.debug("Starting endpoint {}", endpoint.getClass().getSimpleName());
endpoint.start();
}
registrySynchronization.start();
assetConnectionManager.start();
LOGGER.debug("FA³ST Service is running!");
}
Expand All @@ -264,6 +269,7 @@ public void stop() {
LOGGER.debug("Get command for stopping FA³ST Service");
messageBus.stop();
assetConnectionManager.stop();
registrySynchronization.stop();
endpoints.forEach(Endpoint::stop);
}

Expand Down Expand Up @@ -298,5 +304,6 @@ private void init() throws ConfigurationException {
this.fileStorage,
this.messageBus,
this.assetConnectionManager));
this.registrySynchronization = new RegistrySynchronization(config.getCore(), persistence, messageBus, endpoints);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package de.fraunhofer.iosb.ilt.faaast.service.config;

import de.fraunhofer.iosb.ilt.faaast.service.model.validation.ModelValidatorConfig;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.eclipse.digitaltwin.aas4j.v3.model.builder.ExtendableBuilder;

Expand All @@ -35,6 +37,8 @@ public class CoreConfig {
private ModelValidatorConfig validationOnLoad;
private ModelValidatorConfig validationOnCreate;
private ModelValidatorConfig validationOnUpdate;
private List<String> aasRegistries;
private List<String> submodelRegistries;

public CoreConfig() {
this.assetConnectionRetryInterval = DEFAULT_ASSET_CONNECTION_RETRY_INTERVAL;
Expand All @@ -54,6 +58,8 @@ public CoreConfig() {
.validateIdShortUniqueness(true)
.validateIdentifierUniqueness(true)
.build();
this.aasRegistries = new ArrayList<>();
this.submodelRegistries = new ArrayList<>();
}


Expand Down Expand Up @@ -112,13 +118,35 @@ public void setRequestHandlerThreadPoolSize(int requestHandlerThreadPoolSize) {
}


public List<String> getAasRegistries() {
return aasRegistries;
}


public void setAasRegistries(List<String> aasRegistries) {
this.aasRegistries = aasRegistries;
}


public List<String> getSubmodelRegistries() {
return submodelRegistries;
}


public void setSubmodelRegistries(List<String> submodelRegistries) {
this.submodelRegistries = submodelRegistries;
}


@Override
public int hashCode() {
return Objects.hash(assetConnectionRetryInterval,
requestHandlerThreadPoolSize,
validationOnLoad,
validationOnCreate,
validationOnUpdate);
validationOnUpdate,
aasRegistries,
submodelRegistries);
}


Expand All @@ -138,7 +166,9 @@ public boolean equals(Object obj) {
&& Objects.equals(this.requestHandlerThreadPoolSize, other.requestHandlerThreadPoolSize)
&& Objects.equals(this.validationOnLoad, other.validationOnLoad)
&& Objects.equals(this.validationOnCreate, other.validationOnCreate)
&& Objects.equals(this.validationOnUpdate, other.validationOnUpdate);
&& Objects.equals(this.validationOnUpdate, other.validationOnUpdate)
&& Objects.equals(this.aasRegistries, other.aasRegistries)
&& Objects.equals(this.submodelRegistries, other.submodelRegistries);
}

public static class Builder extends ExtendableBuilder<CoreConfig, Builder> {
Expand Down Expand Up @@ -167,6 +197,30 @@ public Builder validationOnCreate(ModelValidatorConfig value) {
}


public Builder aasRegistries(List<String> value) {
getBuildingInstance().setAasRegistries(value);
return getSelf();
}


public Builder aasRegistry(String value) {
getBuildingInstance().getAasRegistries().add(value);
return getSelf();
}


public Builder submodelRegistries(List<String> value) {
getBuildingInstance().setSubmodelRegistries(value);
return getSelf();
}


public Builder submodelRegistry(String value) {
getBuildingInstance().getSubmodelRegistries().add(value);
return getSelf();
}


public Builder validationOnUpdate(ModelValidatorConfig value) {
getBuildingInstance().setValidationOnUpdate(value);
return getSelf();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import de.fraunhofer.iosb.ilt.faaast.service.config.Configurable;
import de.fraunhofer.iosb.ilt.faaast.service.exception.EndpointException;
import java.util.List;


/**
Expand All @@ -39,4 +40,27 @@ public interface Endpoint<T extends EndpointConfig> extends Configurable<T> {
*/
public void stop();


/**
* Gets endpoint information for an AAS. This is used for automatic registration with a registry. The returned result
* may include multiple endpoints, e.g. with different interfaces like AAS-REPOSITORY and AAS.
*
* @param aasId the id of the AAS
* @return a list of endpoint information where this AAS can be accessed
*/
public default List<de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.Endpoint> getAasEndpointInformation(String aasId) {
return List.of();
}


/**
* Gets endpoint information for a submodel. This is used for automatic registration with a registry. The returned
* result may include multiple endpoints, e.g. with different interfaces like SUBMODEL-REPOSITORY and SUBMODEL.
*
* @param submodelId the id of the submodel
* @return a list of endpoint information where this submodel can be accessed
*/
public default List<de.fraunhofer.iosb.ilt.faaast.service.model.descriptor.Endpoint> getSubmodelEndpointInformation(String submodelId) {
return List.of();
}
}
Loading

0 comments on commit 7ccf501

Please sign in to comment.