diff --git a/src/main/java/org/eclipse/basyx/aas/aggregator/observing/ObservableAASAggregator.java b/src/main/java/org/eclipse/basyx/aas/aggregator/observing/ObservableAASAggregator.java index 43b5a1dd..54f0de56 100644 --- a/src/main/java/org/eclipse/basyx/aas/aggregator/observing/ObservableAASAggregator.java +++ b/src/main/java/org/eclipse/basyx/aas/aggregator/observing/ObservableAASAggregator.java @@ -70,18 +70,18 @@ public IModelProvider getAASProvider(IIdentifier aasId) throws ResourceNotFoundE @Override public void createAAS(AssetAdministrationShell aas) { aasAggregator.createAAS(aas); - observers.stream().forEach(o -> o.aasCreated(aas.getIdentification().getId())); + notifyAll(o -> o.aasCreated(aas.getIdentification().getId())); } @Override public void updateAAS(AssetAdministrationShell aas) throws ResourceNotFoundException { aasAggregator.updateAAS(aas); - observers.stream().forEach(o -> o.aasUpdated(aas.getIdentification().getId())); + notifyAll(o -> o.aasUpdated(aas.getIdentification().getId())); } @Override public void deleteAAS(IIdentifier aasId) { aasAggregator.deleteAAS(aasId); - observers.stream().forEach(o -> o.aasDeleted(aasId.getId())); + notifyAll(o -> o.aasDeleted(aasId.getId())); } } diff --git a/src/main/java/org/eclipse/basyx/aas/aggregator/observing/ObservableAASAggregatorV2.java b/src/main/java/org/eclipse/basyx/aas/aggregator/observing/ObservableAASAggregatorV2.java index 9af84ecb..6e3b0385 100644 --- a/src/main/java/org/eclipse/basyx/aas/aggregator/observing/ObservableAASAggregatorV2.java +++ b/src/main/java/org/eclipse/basyx/aas/aggregator/observing/ObservableAASAggregatorV2.java @@ -77,19 +77,19 @@ public IModelProvider getAASProvider(IIdentifier aasId) throws ResourceNotFoundE @Override public void createAAS(AssetAdministrationShell aas) { aasAggregator.createAAS(aas); - observers.stream().forEach(o -> o.aasCreated(aas, this.aasServerId)); + notifyAll(o -> o.aasCreated(aas, this.aasServerId)); } @Override public void updateAAS(AssetAdministrationShell aas) throws ResourceNotFoundException { aasAggregator.updateAAS(aas); - observers.stream().forEach(o -> o.aasUpdated(aas, this.aasServerId)); + notifyAll(o -> o.aasUpdated(aas, this.aasServerId)); } @Override public void deleteAAS(IIdentifier aasId) { IAssetAdministrationShell aas = aasAggregator.getAAS(aasId); aasAggregator.deleteAAS(aasId); - observers.stream().forEach(o -> o.aasDeleted(aas, this.aasServerId)); + notifyAll(o -> o.aasDeleted(aas, this.aasServerId)); } } diff --git a/src/main/java/org/eclipse/basyx/aas/registration/observing/ObservableAASRegistryService.java b/src/main/java/org/eclipse/basyx/aas/registration/observing/ObservableAASRegistryService.java index 0acec83c..25b51595 100644 --- a/src/main/java/org/eclipse/basyx/aas/registration/observing/ObservableAASRegistryService.java +++ b/src/main/java/org/eclipse/basyx/aas/registration/observing/ObservableAASRegistryService.java @@ -54,25 +54,25 @@ public ObservableAASRegistryService(IAASRegistry registry) { @Override public void register(AASDescriptor deviceAASDescriptor) throws ProviderException { aasRegistry.register(deviceAASDescriptor); - observers.stream().forEach(o -> o.aasRegistered(deviceAASDescriptor.getIdentifier().getId())); + notifyAll(o -> o.aasRegistered(deviceAASDescriptor.getIdentifier().getId())); } @Override public void register(IIdentifier aas, SubmodelDescriptor smDescriptor) throws ProviderException { aasRegistry.register(aas, smDescriptor); - observers.stream().forEach(o -> o.submodelRegistered(aas, smDescriptor.getIdentifier())); + notifyAll(o -> o.submodelRegistered(aas, smDescriptor.getIdentifier())); } @Override public void delete(IIdentifier aasId) throws ProviderException { aasRegistry.delete(aasId); - observers.stream().forEach(o -> o.aasDeleted(aasId.getId())); + notifyAll(o -> o.aasDeleted(aasId.getId())); } @Override public void delete(IIdentifier aasId, IIdentifier smId) throws ProviderException { aasRegistry.delete(aasId, smId); - observers.stream().forEach(o -> o.submodelDeleted(aasId, smId)); + notifyAll(o -> o.submodelDeleted(aasId, smId)); } @Override diff --git a/src/main/java/org/eclipse/basyx/aas/registration/observing/ObservableAASRegistryServiceV2.java b/src/main/java/org/eclipse/basyx/aas/registration/observing/ObservableAASRegistryServiceV2.java index d6e09440..fe8a2a50 100644 --- a/src/main/java/org/eclipse/basyx/aas/registration/observing/ObservableAASRegistryServiceV2.java +++ b/src/main/java/org/eclipse/basyx/aas/registration/observing/ObservableAASRegistryServiceV2.java @@ -63,10 +63,10 @@ public void register(AASDescriptor deviceAASDescriptor) throws ProviderException try { aasRegistry.lookupAAS(deviceAASDescriptor.getIdentifier()); aasRegistry.register(deviceAASDescriptor); - observers.stream().forEach(o -> o.aasUpdated(deviceAASDescriptor, this.registryId)); + notifyAll(o -> o.aasUpdated(deviceAASDescriptor, this.registryId)); } catch(ResourceNotFoundException e) { aasRegistry.register(deviceAASDescriptor); - observers.stream().forEach(o -> o.aasRegistered(deviceAASDescriptor, this.registryId)); + notifyAll(o -> o.aasRegistered(deviceAASDescriptor, this.registryId)); } } @@ -76,10 +76,10 @@ public void register(IIdentifier aas, SubmodelDescriptor smDescriptor) throws Pr try { aasRegistry.lookupSubmodel(aas, smDescriptor.getIdentifier()); aasRegistry.register(aas, smDescriptor); - observers.stream().forEach(o -> o.submodelUpdated(aas, smDescriptor, this.registryId)); + notifyAll(o -> o.submodelUpdated(aas, smDescriptor, this.registryId)); } catch(ResourceNotFoundException e) { aasRegistry.register(aas, smDescriptor); - observers.stream().forEach(o -> o.submodelRegistered(aas, smDescriptor, this.registryId)); + notifyAll(o -> o.submodelRegistered(aas, smDescriptor, this.registryId)); } } @@ -87,14 +87,14 @@ public void register(IIdentifier aas, SubmodelDescriptor smDescriptor) throws Pr public void delete(IIdentifier aasId) throws ProviderException { AASDescriptor aasDescriptor = lookupAAS(aasId); aasRegistry.delete(aasId); - observers.stream().forEach(o -> o.aasDeleted(aasDescriptor, this.registryId)); + notifyAll(o -> o.aasDeleted(aasDescriptor, this.registryId)); } @Override public void delete(IIdentifier aasId, IIdentifier smId) throws ProviderException { SubmodelDescriptor smDescriptor = lookupSubmodel(aasId, smId); aasRegistry.delete(aasId, smId); - observers.stream().forEach(o -> o.submodelDeleted(aasId, smDescriptor, this.registryId)); + notifyAll(o -> o.submodelDeleted(aasId, smDescriptor, this.registryId)); } @Override diff --git a/src/main/java/org/eclipse/basyx/aas/restapi/observing/ObservableAASAPI.java b/src/main/java/org/eclipse/basyx/aas/restapi/observing/ObservableAASAPI.java index adba9153..fa65d419 100644 --- a/src/main/java/org/eclipse/basyx/aas/restapi/observing/ObservableAASAPI.java +++ b/src/main/java/org/eclipse/basyx/aas/restapi/observing/ObservableAASAPI.java @@ -60,13 +60,13 @@ public void addSubmodel(IReference submodel) { throw new MalformedRequestException("Reference has to contain a submodel"); aasAPI.addSubmodel(submodel); - observers.stream().forEach(o -> o.submodelAdded(submodel)); + notifyAll(o -> o.submodelAdded(submodel)); } @Override public void removeSubmodel(String id) { aasAPI.removeSubmodel(id); - observers.stream().forEach(o -> o.submodelRemoved(id)); + notifyAll(o -> o.submodelRemoved(id)); } private boolean containsSubmodelReference(IReference submodel) { diff --git a/src/main/java/org/eclipse/basyx/extensions/aas/directory/tagged/observing/ObservableAASTaggedDirectoryServiceV2.java b/src/main/java/org/eclipse/basyx/extensions/aas/directory/tagged/observing/ObservableAASTaggedDirectoryServiceV2.java index 3cb2347d..14b3f9e9 100644 --- a/src/main/java/org/eclipse/basyx/extensions/aas/directory/tagged/observing/ObservableAASTaggedDirectoryServiceV2.java +++ b/src/main/java/org/eclipse/basyx/extensions/aas/directory/tagged/observing/ObservableAASTaggedDirectoryServiceV2.java @@ -56,10 +56,10 @@ public void register(TaggedAASDescriptor descriptor) { try { taggedDirectory.lookupAAS(descriptor.getIdentifier()); taggedDirectory.register(descriptor); - observers.stream().forEach(o -> o.aasUpdated(descriptor, super.getRegistryId())); + notifyAll(o -> o.aasUpdated(descriptor, super.getRegistryId())); } catch(ResourceNotFoundException e) { taggedDirectory.register(descriptor); - observers.stream().forEach(o -> o.aasRegistered(descriptor, super.getRegistryId())); + notifyAll(o -> o.aasRegistered(descriptor, super.getRegistryId())); } } @@ -68,10 +68,10 @@ public void registerSubmodel(IIdentifier aas, TaggedSubmodelDescriptor descripto try { taggedDirectory.lookupSubmodel(aas, descriptor.getIdentifier()); taggedDirectory.register(aas, descriptor); - observers.stream().forEach(o -> o.submodelUpdated(aas, descriptor, super.getRegistryId())); + notifyAll(o -> o.submodelUpdated(aas, descriptor, super.getRegistryId())); } catch (ResourceNotFoundException e) { taggedDirectory.register(aas, descriptor); - observers.stream().forEach(o -> o.submodelRegistered(aas, descriptor, super.getRegistryId())); + notifyAll(o -> o.submodelRegistered(aas, descriptor, super.getRegistryId())); } } diff --git a/src/main/java/org/eclipse/basyx/submodel/aggregator/observing/ObservableSubmodelAggregator.java b/src/main/java/org/eclipse/basyx/submodel/aggregator/observing/ObservableSubmodelAggregator.java index d9349ac2..2169eec4 100644 --- a/src/main/java/org/eclipse/basyx/submodel/aggregator/observing/ObservableSubmodelAggregator.java +++ b/src/main/java/org/eclipse/basyx/submodel/aggregator/observing/ObservableSubmodelAggregator.java @@ -82,26 +82,26 @@ public ISubmodelAPI getSubmodelAPIByIdShort(String submodelIdShort) throws Resou @Override public void createSubmodel(Submodel submodel) { submodelAggregator.createSubmodel(submodel); - observers.stream().forEach(observer -> observer.submodelCreated(getParentAASId(submodel), submodel.getIdentification().getId())); + notifyAll(observer -> observer.submodelCreated(getParentAASId(submodel), submodel.getIdentification().getId())); } @Override public void createSubmodel(ISubmodelAPI submodelAPI) { submodelAggregator.createSubmodel(submodelAPI); - observers.stream().forEach(observer -> observer.submodelCreated(getParentAASId(submodelAPI.getSubmodel()), submodelAPI.getSubmodel().getIdentification().getId())); + notifyAll(observer -> observer.submodelCreated(getParentAASId(submodelAPI.getSubmodel()), submodelAPI.getSubmodel().getIdentification().getId())); } @Override public void updateSubmodel(Submodel submodel) throws ResourceNotFoundException { submodelAggregator.updateSubmodel(submodel); - observers.stream().forEach(observer -> observer.submodelUpdated(getParentAASId(submodel), submodel.getIdentification().getId())); + notifyAll(observer -> observer.submodelUpdated(getParentAASId(submodel), submodel.getIdentification().getId())); } @Override public void deleteSubmodelByIdentifier(IIdentifier submodelIdentifier) { String parentAASId = getParentAASId(submodelAggregator.getSubmodel(submodelIdentifier)); submodelAggregator.deleteSubmodelByIdentifier(submodelIdentifier); - observers.stream().forEach(observer -> observer.submodelDeleted(parentAASId, submodelIdentifier.getId())); + notifyAll(observer -> observer.submodelDeleted(parentAASId, submodelIdentifier.getId())); } @Override @@ -109,7 +109,7 @@ public void deleteSubmodelByIdShort(String submodelIdShort) { ISubmodel submodel = submodelAggregator.getSubmodelbyIdShort(submodelIdShort); String parentAASId = getParentAASId(submodel); submodelAggregator.deleteSubmodelByIdShort(submodelIdShort); - observers.stream().forEach(observer -> observer.submodelDeleted(parentAASId, submodel.getIdentification().getId())); + notifyAll(observer -> observer.submodelDeleted(parentAASId, submodel.getIdentification().getId())); } private String getParentAASId(ISubmodel submodel) { diff --git a/src/main/java/org/eclipse/basyx/submodel/aggregator/observing/ObservableSubmodelAggregatorV2.java b/src/main/java/org/eclipse/basyx/submodel/aggregator/observing/ObservableSubmodelAggregatorV2.java index da6183c8..07a84729 100644 --- a/src/main/java/org/eclipse/basyx/submodel/aggregator/observing/ObservableSubmodelAggregatorV2.java +++ b/src/main/java/org/eclipse/basyx/submodel/aggregator/observing/ObservableSubmodelAggregatorV2.java @@ -88,19 +88,19 @@ public ISubmodelAPI getSubmodelAPIByIdShort(String submodelIdShort) throws Resou @Override public void createSubmodel(Submodel submodel) { submodelAggregator.createSubmodel(submodel); - observers.stream().forEach(observer -> observer.submodelCreated(getParentAASId(submodel), submodel, this.aasServerId)); + notifyAll(observer -> observer.submodelCreated(getParentAASId(submodel), submodel, this.aasServerId)); } @Override public void createSubmodel(ISubmodelAPI submodelAPI) { submodelAggregator.createSubmodel(submodelAPI); - observers.stream().forEach(observer -> observer.submodelCreated(getParentAASId(submodelAPI.getSubmodel()), submodelAPI.getSubmodel(), this.aasServerId)); + notifyAll(observer -> observer.submodelCreated(getParentAASId(submodelAPI.getSubmodel()), submodelAPI.getSubmodel(), this.aasServerId)); } @Override public void updateSubmodel(Submodel submodel) throws ResourceNotFoundException { submodelAggregator.updateSubmodel(submodel); - observers.stream().forEach(observer -> observer.submodelUpdated(getParentAASId(submodel), submodel, this.aasServerId)); + notifyAll(observer -> observer.submodelUpdated(getParentAASId(submodel), submodel, this.aasServerId)); } @Override @@ -108,7 +108,7 @@ public void deleteSubmodelByIdentifier(IIdentifier submodelIdentifier) { ISubmodel submodel = submodelAggregator.getSubmodel(submodelIdentifier); String parentAASId = getParentAASId(submodel); submodelAggregator.deleteSubmodelByIdentifier(submodelIdentifier); - observers.stream().forEach(observer -> observer.submodelDeleted(parentAASId, submodel, this.aasServerId)); + notifyAll(observer -> observer.submodelDeleted(parentAASId, submodel, this.aasServerId)); } @Override @@ -116,7 +116,7 @@ public void deleteSubmodelByIdShort(String submodelIdShort) { ISubmodel submodel = submodelAggregator.getSubmodelbyIdShort(submodelIdShort); String parentAASId = getParentAASId(submodel); submodelAggregator.deleteSubmodelByIdShort(submodelIdShort); - observers.stream().forEach(observer -> observer.submodelDeleted(parentAASId, submodel, this.aasServerId)); + notifyAll(observer -> observer.submodelDeleted(parentAASId, submodel, this.aasServerId)); } private String getParentAASId(ISubmodel submodel) { diff --git a/src/main/java/org/eclipse/basyx/submodel/restapi/observing/ObservableSubmodelAPI.java b/src/main/java/org/eclipse/basyx/submodel/restapi/observing/ObservableSubmodelAPI.java index 72a10fad..b54d15dd 100644 --- a/src/main/java/org/eclipse/basyx/submodel/restapi/observing/ObservableSubmodelAPI.java +++ b/src/main/java/org/eclipse/basyx/submodel/restapi/observing/ObservableSubmodelAPI.java @@ -57,13 +57,13 @@ public ISubmodel getSubmodel() { @Override public void addSubmodelElement(ISubmodelElement elem) { submodelAPI.addSubmodelElement(elem); - observers.stream().forEach(o -> o.elementAdded(elem.getIdShort(), elem.getValue())); + notifyAll(o -> o.elementAdded(elem.getIdShort(), elem.getValue())); } @Override public void addSubmodelElement(String idShortPath, ISubmodelElement elem) { submodelAPI.addSubmodelElement(idShortPath, elem); - observers.stream().forEach(o -> o.elementAdded(idShortPath, elem.getValue())); + notifyAll(o -> o.elementAdded(idShortPath, elem.getValue())); } @Override @@ -74,7 +74,7 @@ public ISubmodelElement getSubmodelElement(String idShortPath) { @Override public void deleteSubmodelElement(String idShortPath) { submodelAPI.deleteSubmodelElement(idShortPath); - observers.stream().forEach(o -> o.elementDeleted(idShortPath)); + notifyAll(o -> o.elementDeleted(idShortPath)); } @Override @@ -90,7 +90,7 @@ public Collection getSubmodelElements() { @Override public void updateSubmodelElement(String idShortPath, Object newValue) { submodelAPI.updateSubmodelElement(idShortPath, newValue); - observers.stream().forEach(o -> o.elementUpdated(idShortPath, newValue)); + notifyAll(o -> o.elementUpdated(idShortPath, newValue)); } @Override diff --git a/src/main/java/org/eclipse/basyx/submodel/restapi/observing/ObservableSubmodelAPIV2.java b/src/main/java/org/eclipse/basyx/submodel/restapi/observing/ObservableSubmodelAPIV2.java index 68729354..677e4f7c 100644 --- a/src/main/java/org/eclipse/basyx/submodel/restapi/observing/ObservableSubmodelAPIV2.java +++ b/src/main/java/org/eclipse/basyx/submodel/restapi/observing/ObservableSubmodelAPIV2.java @@ -80,10 +80,10 @@ private void addOrReplaceSubmodelElement(String idShortPath, ISubmodelElement el try { submodelAPI.getSubmodelElement(idShortPath); submodelAPI.addSubmodelElement(idShortPath, elem); - observers.stream().forEach(o -> o.elementUpdated(idShortPath, elem, getParentAASId(getSubmodel()), getSubmodel().getIdentification().getId(), this.aasServerId)); + notifyAll(o -> o.elementUpdated(idShortPath, elem, getParentAASId(getSubmodel()), getSubmodel().getIdentification().getId(), this.aasServerId)); } catch (ResourceNotFoundException e) { submodelAPI.addSubmodelElement(idShortPath, elem); - observers.stream().forEach(o -> o.elementAdded(idShortPath, elem, getParentAASId(getSubmodel()), getSubmodel().getIdentification().getId(), this.aasServerId)); + notifyAll(o -> o.elementAdded(idShortPath, elem, getParentAASId(getSubmodel()), getSubmodel().getIdentification().getId(), this.aasServerId)); } } @@ -101,7 +101,7 @@ public ISubmodelElement getSubmodelElement(String idShortPath) { public void deleteSubmodelElement(String idShortPath) { ISubmodelElement submodelElement = submodelAPI.getSubmodelElement(idShortPath); submodelAPI.deleteSubmodelElement(idShortPath); - observers.stream().forEach(o -> o.elementDeleted(idShortPath, submodelElement, getParentAASId(getSubmodel()), getSubmodel().getIdentification().getId(), this.aasServerId)); + notifyAll(o -> o.elementDeleted(idShortPath, submodelElement, getParentAASId(getSubmodel()), getSubmodel().getIdentification().getId(), this.aasServerId)); } @Override @@ -127,7 +127,7 @@ public void updateSubmodelElement(String idShortPath, Object newValue) { valueToSend = newValue; } - observers.stream().forEach(o -> o.elementValue(idShortPath, valueToSend, getParentAASId(getSubmodel()), getSubmodel().getIdentification().getId(), this.aasServerId)); + notifyAll(o -> o.elementValue(idShortPath, valueToSend, getParentAASId(getSubmodel()), getSubmodel().getIdentification().getId(), this.aasServerId)); }