-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initialize broker on startup (#28)
- Loading branch information
1 parent
303c9f2
commit d944e50
Showing
6 changed files
with
68 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...server/src/main/java/de/sovity/edc/ext/brokerserver/services/BrokerServerInitializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2023 sovity GmbH | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* sovity GmbH - initial API and implementation | ||
* | ||
*/ | ||
|
||
package de.sovity.edc.ext.brokerserver.services; | ||
|
||
import de.sovity.edc.ext.brokerserver.BrokerServerExtension; | ||
import de.sovity.edc.ext.brokerserver.dao.models.ConnectorRecord; | ||
import de.sovity.edc.ext.brokerserver.dao.stores.ConnectorStore; | ||
import lombok.RequiredArgsConstructor; | ||
import org.eclipse.edc.spi.system.configuration.Config; | ||
|
||
import java.time.OffsetDateTime; | ||
import java.util.Arrays; | ||
|
||
@RequiredArgsConstructor | ||
public class BrokerServerInitializer { | ||
private final ConnectorStore connectorStore; | ||
private final Config config; | ||
|
||
public void initializeConnectorList() { | ||
var knownConnectors = config.getString(BrokerServerExtension.KNOWN_CONNECTORS).split(","); | ||
|
||
Arrays.stream(knownConnectors).forEach(connectorId -> { | ||
connectorId = connectorId.trim(); | ||
|
||
var connectorRecord = ConnectorRecord.builder() | ||
.id(connectorId) | ||
.idsId(connectorId) | ||
.endpoint(connectorId) | ||
.createdAt(OffsetDateTime.now()) | ||
.build(); | ||
|
||
connectorStore.save(connectorRecord); | ||
}); | ||
} | ||
} |