Skip to content

Commit

Permalink
Comentario
Browse files Browse the repository at this point in the history
  • Loading branch information
GRUPOGMV\ssis committed Jul 18, 2024
1 parent 36f32ea commit bf385e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,28 @@ public class FromRegistrationServiceParticipantsExtension implements ServiceExte
public void initialize(ServiceExtensionContext context) {
var periodSeconds = context.getSetting(EXECUTION_PLAN_PERIOD_SECONDS, DEFAULT_EXECUTION_PERIOD_SECONDS);
var monitor = context.getMonitor();
var participantConfig = new ParticipantConfiguration(monitor, new ObjectMapper());
var participantRegistrationService = new ParticipantRegistrationService(monitor, new ObjectMapper());

// Initial update
updateTargetNodeDirectory(context, participantConfig);
updateTargetNodeDirectory(context, participantRegistrationService);

// Schedule periodic updates
scheduler.scheduleAtFixedRate(() -> {
try {
updateTargetNodeDirectory(context, participantConfig);
updateTargetNodeDirectory(context, participantRegistrationService);
} catch (Exception e) {
monitor.severe("Error updating TargetNodeDirectory", e);
}
}, periodSeconds, periodSeconds, TimeUnit.SECONDS);
}

private void updateTargetNodeDirectory(ServiceExtensionContext context, ParticipantConfiguration participantConfig) {
private void updateTargetNodeDirectory(ServiceExtensionContext context, ParticipantRegistrationService participantRegistrationService) {
var newDir = new InMemoryNodeDirectory();

Result<TokenRepresentation> tokenRepresentationResult = identityService.obtainClientCredentials(
TokenParameters.Builder.newInstance().build());

for (var target : participantConfig.getTargetNodes(context.getConfig(), tokenRepresentationResult)) {
for (var target : participantRegistrationService.getTargetNodes(context.getConfig(), tokenRepresentationResult)) {
// skipping null target nodes
if (target != null){
newDir.insert(target);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* Handles participants in configuration and transforms them into TargetNodes
*/
public class ParticipantConfiguration {
public class ParticipantRegistrationService {

public static final List<String> SUPPORTED_PROTOCOLS = List.of("dataspace-protocol-http");

Expand All @@ -42,7 +42,7 @@ public class ParticipantConfiguration {
* @param monitor monitor
* @param objectMapper mapper
*/
public ParticipantConfiguration(Monitor monitor, ObjectMapper objectMapper) {
public ParticipantRegistrationService(Monitor monitor, ObjectMapper objectMapper) {
this.monitor = monitor;
this.objectMapper = objectMapper;
}
Expand Down

0 comments on commit bf385e9

Please sign in to comment.