diff --git a/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-backend/src/main/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/backend/ThreadSafeAasDiscovery.java b/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-backend/src/main/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/backend/ThreadSafeAasDiscovery.java index d7cc46ece..a0c16600d 100644 --- a/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-backend/src/main/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/backend/ThreadSafeAasDiscovery.java +++ b/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-backend/src/main/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/backend/ThreadSafeAasDiscovery.java @@ -50,22 +50,22 @@ public ThreadSafeAasDiscovery(AasDiscoveryService decoratedAasDiscovery) { @Override public CursorResult> getAllAssetAdministrationShellIdsByAssetLink(PaginationInfo pInfo, List assetIds) { - return access.read(decoratedAasDiscovery::getAllAssetAdministrationShellIdsByAssetLink, pInfo, assetIds); + return access.read(() -> decoratedAasDiscovery.getAllAssetAdministrationShellIdsByAssetLink(pInfo, assetIds)); } @Override public List getAllAssetLinksById(String shellIdentifier) { - return access.read(decoratedAasDiscovery::getAllAssetLinksById, shellIdentifier); + return access.read(() -> decoratedAasDiscovery.getAllAssetLinksById(shellIdentifier)); } @Override public List createAllAssetLinksById(String shellIdentifier, List assetIds) { - return access.write(decoratedAasDiscovery::createAllAssetLinksById, shellIdentifier, assetIds); + return access.write(() -> decoratedAasDiscovery.createAllAssetLinksById(shellIdentifier, assetIds)); } @Override public void deleteAllAssetLinksById(String shellIdentifier) { - access.write(decoratedAasDiscovery::deleteAllAssetLinksById, shellIdentifier); + access.write(() -> decoratedAasDiscovery.deleteAllAssetLinksById(shellIdentifier)); } @Override diff --git a/basyx.aasregistry/basyx.aasregistry-service-inmemory-storage/src/main/java/org/eclipse/digitaltwin/basyx/aasregistry/service/storage/memory/ThreadSafeAasRegistryStorageDecorator.java b/basyx.aasregistry/basyx.aasregistry-service-inmemory-storage/src/main/java/org/eclipse/digitaltwin/basyx/aasregistry/service/storage/memory/ThreadSafeAasRegistryStorageDecorator.java index 116716da2..08a7041f2 100644 --- a/basyx.aasregistry/basyx.aasregistry-service-inmemory-storage/src/main/java/org/eclipse/digitaltwin/basyx/aasregistry/service/storage/memory/ThreadSafeAasRegistryStorageDecorator.java +++ b/basyx.aasregistry/basyx.aasregistry-service-inmemory-storage/src/main/java/org/eclipse/digitaltwin/basyx/aasregistry/service/storage/memory/ThreadSafeAasRegistryStorageDecorator.java @@ -51,37 +51,37 @@ public class ThreadSafeAasRegistryStorageDecorator implements AasRegistryStorage @Override public CursorResult> getAllAasDescriptors(@NonNull PaginationInfo pRequest, @NonNull DescriptorFilter filter) { - return access.read(storage::getAllAasDescriptors, pRequest, filter); + return access.read(() -> storage.getAllAasDescriptors(pRequest, filter)); } @Override public void removeAasDescriptor(@NonNull String aasDescriptorId) { - access.write(storage::removeAasDescriptor, aasDescriptorId); + access.write(() -> storage.removeAasDescriptor(aasDescriptorId)); } @Override public AssetAdministrationShellDescriptor getAasDescriptor(@NonNull String aasDescriptorId) throws AasDescriptorNotFoundException { - return access.read(storage::getAasDescriptor, aasDescriptorId); + return access.read(() -> storage.getAasDescriptor(aasDescriptorId)); } @Override public CursorResult> getAllSubmodels(@NonNull String aasDescriptorId, @NonNull PaginationInfo pRequest) throws AasDescriptorNotFoundException { - return access.read(storage::getAllSubmodels, aasDescriptorId, pRequest); + return access.read(() -> storage.getAllSubmodels(aasDescriptorId, pRequest)); } @Override public SubmodelDescriptor getSubmodel(@NonNull String aasDescriptorId, @NonNull String submodelId) { - return access.read(storage::getSubmodel, aasDescriptorId, submodelId); + return access.read(() -> storage.getSubmodel(aasDescriptorId, submodelId)); } @Override public void insertSubmodel(@NonNull String aasDescriptorId, @NonNull SubmodelDescriptor submodel) { - access.write(storage::insertSubmodel, aasDescriptorId, submodel); + access.write(() -> storage.insertSubmodel(aasDescriptorId, submodel)); } @Override public void removeSubmodel(@NonNull String aasDescrId, @NonNull String submodelId) { - access.write(storage::removeSubmodel, aasDescrId, submodelId); + access.write(() -> storage.removeSubmodel(aasDescrId, submodelId)); } @Override @@ -91,21 +91,21 @@ public Set clear() { @Override public ShellDescriptorSearchResponse searchAasDescriptors(ShellDescriptorSearchRequest request) { - return access.read(storage::searchAasDescriptors, request); + return access.read(() -> storage.searchAasDescriptors(request)); } @Override public void insertAasDescriptor(@Valid AssetAdministrationShellDescriptor descr) throws AasDescriptorAlreadyExistsException { - access.write(storage::insertAasDescriptor, descr); + access.write(() -> storage.insertAasDescriptor(descr)); } @Override public void replaceAasDescriptor(@NonNull String aasDescritorId, @NonNull AssetAdministrationShellDescriptor descriptor) throws AasDescriptorNotFoundException { - access.write(storage::replaceAasDescriptor, aasDescritorId, descriptor); + access.write(() -> storage.replaceAasDescriptor(aasDescritorId, descriptor)); } @Override public void replaceSubmodel(@NonNull String aasDescriptorId, @NonNull String submodelId, @NonNull SubmodelDescriptor submodel) throws AasDescriptorNotFoundException, SubmodelNotFoundException { - access.write(storage::replaceSubmodel, aasDescriptorId, submodelId, submodel); + access.write(() -> storage.replaceSubmodel(aasDescriptorId, submodelId, submodel)); } } diff --git a/basyx.aasrepository/basyx.aasrepository-backend/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/backend/ThreadSafeAasRepository.java b/basyx.aasrepository/basyx.aasrepository-backend/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/backend/ThreadSafeAasRepository.java index 0b5a40316..03d286c5d 100644 --- a/basyx.aasrepository/basyx.aasrepository-backend/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/backend/ThreadSafeAasRepository.java +++ b/basyx.aasrepository/basyx.aasrepository-backend/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/backend/ThreadSafeAasRepository.java @@ -56,67 +56,67 @@ public ThreadSafeAasRepository(AasRepository decoratedRepository) { @Override public CursorResult> getAllAas(PaginationInfo pInfo) { - return access.read(decoratedAasRepository::getAllAas, pInfo); + return access.read(() -> decoratedAasRepository.getAllAas(pInfo)); } @Override public AssetAdministrationShell getAas(String aasId) throws ElementDoesNotExistException { - return access.read(decoratedAasRepository::getAas, aasId); + return access.read(() -> decoratedAasRepository.getAas(aasId)); } @Override public void createAas(AssetAdministrationShell aas) throws CollidingIdentifierException, MissingIdentifierException { - access.write(decoratedAasRepository::createAas, aas); + access.write(() -> decoratedAasRepository.createAas(aas)); } @Override public void deleteAas(String aasId) { - access.write(decoratedAasRepository::deleteAas, aasId); + access.write(() -> decoratedAasRepository.deleteAas(aasId)); } @Override public void updateAas(String aasId, AssetAdministrationShell aas) { - access.write(decoratedAasRepository::updateAas, aasId, aas); + access.write(() -> decoratedAasRepository.updateAas(aasId, aas)); } @Override public CursorResult> getSubmodelReferences(String aasId, PaginationInfo pInfo) { - return access.read(decoratedAasRepository::getSubmodelReferences, aasId, pInfo); + return access.read(() -> decoratedAasRepository.getSubmodelReferences(aasId, pInfo)); } @Override public void addSubmodelReference(String aasId, Reference submodelReference) { - access.write(decoratedAasRepository::addSubmodelReference, aasId, submodelReference); + access.write(() -> decoratedAasRepository.addSubmodelReference(aasId, submodelReference)); } @Override public void removeSubmodelReference(String aasId, String submodelId) { - access.write(decoratedAasRepository::removeSubmodelReference, aasId, submodelId); + access.write(() -> decoratedAasRepository.removeSubmodelReference(aasId, submodelId)); } @Override public void setAssetInformation(String aasId, AssetInformation aasInfo) throws ElementDoesNotExistException { - access.write(decoratedAasRepository::setAssetInformation, aasId, aasInfo); + access.write(() -> decoratedAasRepository.setAssetInformation(aasId, aasInfo)); } @Override public AssetInformation getAssetInformation(String aasId) throws ElementDoesNotExistException { - return access.read(decoratedAasRepository::getAssetInformation, aasId); + return access.read(() -> decoratedAasRepository.getAssetInformation(aasId)); } @Override public File getThumbnail(String aasId) { - return access.read(decoratedAasRepository::getThumbnail, aasId); + return access.read(() -> decoratedAasRepository.getThumbnail(aasId)); } @Override public void setThumbnail(String aasId, String fileName, String contentType, InputStream inputStream) { - access.write(decoratedAasRepository::setThumbnail, aasId, fileName, contentType, inputStream); + access.write(() -> decoratedAasRepository.setThumbnail(aasId, fileName, contentType, inputStream)); } @Override public void deleteThumbnail(String aasId) { - access.write(decoratedAasRepository::deleteThumbnail, aasId); + access.write(() -> decoratedAasRepository.deleteThumbnail(aasId)); } @Override diff --git a/basyx.aasxfileserver/basyx.aasxfileserver-backend/src/main/java/org/eclipse/digitaltwin/basyx/aasxfileserver/backend/ThreadSafeAASXFileServer.java b/basyx.aasxfileserver/basyx.aasxfileserver-backend/src/main/java/org/eclipse/digitaltwin/basyx/aasxfileserver/backend/ThreadSafeAASXFileServer.java index d7057e650..9cc6ef4ee 100644 --- a/basyx.aasxfileserver/basyx.aasxfileserver-backend/src/main/java/org/eclipse/digitaltwin/basyx/aasxfileserver/backend/ThreadSafeAASXFileServer.java +++ b/basyx.aasxfileserver/basyx.aasxfileserver-backend/src/main/java/org/eclipse/digitaltwin/basyx/aasxfileserver/backend/ThreadSafeAASXFileServer.java @@ -43,41 +43,41 @@ */ public class ThreadSafeAASXFileServer implements AASXFileServer { - private final AASXFileServer decoreatedAasxFileServer; + private final AASXFileServer decoratedAasxFileServer; private final ThreadSafeAccess access = new ThreadSafeAccess(); public ThreadSafeAASXFileServer(AASXFileServer aasxFileServer) { - this.decoreatedAasxFileServer = aasxFileServer; + this.decoratedAasxFileServer = aasxFileServer; } @Override public CursorResult> getAllAASXPackageIds(String shellId, PaginationInfo pInfo) { - return access.read(decoreatedAasxFileServer::getAllAASXPackageIds, shellId, pInfo); + return access.read(() -> decoratedAasxFileServer.getAllAASXPackageIds(shellId, pInfo)); } @Override public InputStream getAASXByPackageId(String packageId) throws ElementDoesNotExistException { - return access.read(decoreatedAasxFileServer::getAASXByPackageId, packageId); + return access.read(() -> decoratedAasxFileServer.getAASXByPackageId(packageId)); } @Override public void updateAASXByPackageId(String packageId, List shellIds, InputStream file, String filename) throws ElementDoesNotExistException { - access.write(decoreatedAasxFileServer::updateAASXByPackageId, packageId, shellIds, file, filename); + access.write(() -> decoratedAasxFileServer.updateAASXByPackageId(packageId, shellIds, file, filename)); } @Override public PackageDescription createAASXPackage(List shellIds, InputStream file, String filename) { - return access.write(decoreatedAasxFileServer::createAASXPackage, shellIds, file, filename); + return access.write(() -> decoratedAasxFileServer.createAASXPackage(shellIds, file, filename)); } @Override public void deleteAASXByPackageId(String packageId) throws ElementDoesNotExistException { - access.write(decoreatedAasxFileServer::deleteAASXByPackageId, packageId); + access.write(() -> decoratedAasxFileServer.deleteAASXByPackageId(packageId)); } @Override public String getName() { - return decoreatedAasxFileServer.getName(); + return decoratedAasxFileServer.getName(); } } diff --git a/basyx.common/basyx.backend/src/main/java/org/eclipse/digitaltwin/basyx/common/backend/ThreadSafeAccess.java b/basyx.common/basyx.backend/src/main/java/org/eclipse/digitaltwin/basyx/common/backend/ThreadSafeAccess.java index 4c4d6378d..ec78fd955 100644 --- a/basyx.common/basyx.backend/src/main/java/org/eclipse/digitaltwin/basyx/common/backend/ThreadSafeAccess.java +++ b/basyx.common/basyx.backend/src/main/java/org/eclipse/digitaltwin/basyx/common/backend/ThreadSafeAccess.java @@ -26,63 +26,33 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock; -import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; -import java.util.function.Consumer; -import java.util.function.Function; import java.util.function.Supplier; /** * Utility class for thread-safe access * - * @author Gerhard Sonnenberg DFKI GmbH + * @author Gerhard Sonnenberg DFKI GmbH, mateusmolina */ public class ThreadSafeAccess { - private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - private final ReadLock readLock = lock.readLock(); - private final WriteLock writeLock = lock.writeLock(); + private final Lock readLock = lock.readLock(); + private final Lock writeLock = lock.writeLock(); public T write(Supplier supplier) { return runWithLock(supplier, writeLock); } - public void write(Consumer consumer, A arg1) { - runWithLock(consumer, arg1, readLock); - } - - public void write(BiConsumer consumer, A arg1, B arg2) { - runWithLock(consumer, arg1, arg2, writeLock); - } - - public T write(BiFunction function, A arg1, B arg2) { - return runWithLock(function, arg1, arg2, writeLock); - } - public void write(TriConsumer consumer, A arg1, B arg2, C arg3) { - runWithLock(consumer, arg1, arg2, arg3, writeLock); - } - - public T write(TriFunction function, A arg1, B arg2, C arg3) { - return runWithLock(function, arg1, arg2, arg3, writeLock); - } - public void write(TetraConsumer consumer, A arg1, B arg2, C arg3, D arg4) { - runWithLock(consumer, arg1, arg2, arg3, arg4, writeLock); - } - - public T read(Function func, A arg1) { - return runWithLock(func, arg1, readLock); + public void write(Runnable action) { + runWithLock(action, writeLock); } - public T read(BiFunction func, A arg1, B arg2) { - return runWithLock(func, arg1, arg2, readLock); + public T read(Supplier supplier) { + return runWithLock(supplier, readLock); } - public T read(TriFunction func, A arg1, B arg2, C arg3) { - return runWithLock(func, arg1, arg2, arg3, readLock); + public void read(Runnable action) { + runWithLock(action, readLock); } - private T runWithLock(Supplier supplier, Lock lock) { try { lock.lock(); @@ -92,83 +62,12 @@ private T runWithLock(Supplier supplier, Lock lock) { } } - private void runWithLock(Consumer consumer, A arg1, Lock lock) { - try { - lock.lock(); - consumer.accept(arg1); - } finally { - lock.unlock(); - } - } - - private T runWithLock(Function func, A arg1, Lock lock) { - try { - lock.lock(); - return func.apply(arg1); - } finally { - lock.unlock(); - } - } - - private T runWithLock(BiFunction func, A arg1, B arg2, Lock lock) { - try { - lock.lock(); - return func.apply(arg1, arg2); - } finally { - lock.unlock(); - } - } - - private T runWithLock(TriFunction func, A arg1, B arg2, C arg3, Lock lock) { - try { - lock.lock(); - return func.apply(arg1, arg2, arg3); - } finally { - lock.unlock(); - } - } - - private void runWithLock(BiConsumer consumer, A arg1, B arg2, Lock lock) { - try { - lock.lock(); - consumer.accept(arg1, arg2); - } finally { - lock.unlock(); - } - } - - private void runWithLock(TriConsumer consumer, A arg1, B arg2, C arg3, Lock lock) { + private void runWithLock(Runnable action, Lock lock) { try { lock.lock(); - consumer.accept(arg1, arg2, arg3); + action.run(); } finally { lock.unlock(); } } - - private void runWithLock(TetraConsumer consumer, A arg1, B arg2, C arg3, D arg4, Lock lock) { - try { - lock.lock(); - consumer.accept(arg1, arg2, arg3, arg4); - } finally { - lock.unlock(); - } - } - - @FunctionalInterface - public static interface TriConsumer { - - void accept(S s, T t, U u); - - } - - @FunctionalInterface - public static interface TetraConsumer { - void accept(S s, T t, U u, V v); - } - - @FunctionalInterface - public static interface TriFunction { - R apply(S s, T t, U u); - } } \ No newline at end of file diff --git a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/backend/ThreadSafeConceptDescriptionRepository.java b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/backend/ThreadSafeConceptDescriptionRepository.java index 41de61e59..5e3485f9a 100644 --- a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/backend/ThreadSafeConceptDescriptionRepository.java +++ b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/backend/ThreadSafeConceptDescriptionRepository.java @@ -53,42 +53,42 @@ public ThreadSafeConceptDescriptionRepository(ConceptDescriptionRepository decor @Override public CursorResult> getAllConceptDescriptions(PaginationInfo pInfo) { - return access.read(decoratedRepository::getAllConceptDescriptions, pInfo); + return access.read(() -> decoratedRepository.getAllConceptDescriptions(pInfo)); } @Override public CursorResult> getAllConceptDescriptionsByIdShort(String idShort, PaginationInfo pInfo) { - return access.read(decoratedRepository::getAllConceptDescriptionsByIdShort, idShort, pInfo); + return access.read(() -> decoratedRepository.getAllConceptDescriptionsByIdShort(idShort, pInfo)); } @Override public CursorResult> getAllConceptDescriptionsByIsCaseOf(Reference isCaseOf, PaginationInfo pInfo) { - return access.read(decoratedRepository::getAllConceptDescriptionsByIsCaseOf, isCaseOf, pInfo); + return access.read(() -> decoratedRepository.getAllConceptDescriptionsByIsCaseOf(isCaseOf, pInfo)); } @Override public CursorResult> getAllConceptDescriptionsByDataSpecificationReference(Reference dataSpecificationReference, PaginationInfo pInfo) { - return access.read(decoratedRepository::getAllConceptDescriptionsByDataSpecificationReference, dataSpecificationReference, pInfo); + return access.read(() -> decoratedRepository.getAllConceptDescriptionsByDataSpecificationReference(dataSpecificationReference, pInfo)); } @Override public ConceptDescription getConceptDescription(String conceptDescriptionId) throws ElementDoesNotExistException { - return access.read(decoratedRepository::getConceptDescription, conceptDescriptionId); + return access.read(() -> decoratedRepository.getConceptDescription(conceptDescriptionId)); } @Override public void updateConceptDescription(String conceptDescriptionId, ConceptDescription conceptDescription) throws ElementDoesNotExistException { - access.write(decoratedRepository::updateConceptDescription, conceptDescriptionId, conceptDescription); + access.write(() -> decoratedRepository.updateConceptDescription(conceptDescriptionId, conceptDescription)); } @Override public void createConceptDescription(ConceptDescription conceptDescription) throws CollidingIdentifierException, MissingIdentifierException { - access.write(decoratedRepository::createConceptDescription, conceptDescription); + access.write(() -> decoratedRepository.createConceptDescription(conceptDescription)); } @Override public void deleteConceptDescription(String conceptDescriptionId) throws ElementDoesNotExistException { - access.write(decoratedRepository::deleteConceptDescription, conceptDescriptionId); + access.write(() -> decoratedRepository.deleteConceptDescription(conceptDescriptionId)); } @Override diff --git a/basyx.submodelregistry/basyx.submodelregistry-service-inmemory-storage/src/main/java/org/eclipse/digitaltwin/basyx/submodelregistry/service/storage/memory/ThreadSafeSubmodelRegistryStorageDecorator.java b/basyx.submodelregistry/basyx.submodelregistry-service-inmemory-storage/src/main/java/org/eclipse/digitaltwin/basyx/submodelregistry/service/storage/memory/ThreadSafeSubmodelRegistryStorageDecorator.java index e16864ce6..94c76abe9 100644 --- a/basyx.submodelregistry/basyx.submodelregistry-service-inmemory-storage/src/main/java/org/eclipse/digitaltwin/basyx/submodelregistry/service/storage/memory/ThreadSafeSubmodelRegistryStorageDecorator.java +++ b/basyx.submodelregistry/basyx.submodelregistry-service-inmemory-storage/src/main/java/org/eclipse/digitaltwin/basyx/submodelregistry/service/storage/memory/ThreadSafeSubmodelRegistryStorageDecorator.java @@ -46,7 +46,7 @@ public class ThreadSafeSubmodelRegistryStorageDecorator implements SubmodelRegis @Override public CursorResult> getAllSubmodelDescriptors(PaginationInfo pRequest) { - return access.read(storage::getAllSubmodelDescriptors, pRequest); + return access.read(() -> storage.getAllSubmodelDescriptors(pRequest)); } @Override @@ -56,22 +56,22 @@ public Set clear() { @Override public SubmodelDescriptor getSubmodelDescriptor( String submodelId) throws SubmodelNotFoundException { - return access.read(storage::getSubmodelDescriptor, submodelId); + return access.read(() -> storage.getSubmodelDescriptor(submodelId)); } @Override public void insertSubmodelDescriptor(SubmodelDescriptor descr) throws SubmodelAlreadyExistsException { - access.write(storage::insertSubmodelDescriptor, descr); + access.write(() -> storage.insertSubmodelDescriptor(descr)); } @Override public void removeSubmodelDescriptor(String submodelId) throws SubmodelNotFoundException { - access.write(storage::removeSubmodelDescriptor, submodelId); + access.write(() -> storage.removeSubmodelDescriptor(submodelId)); } @Override public void replaceSubmodelDescriptor(String submodelId, SubmodelDescriptor descr) throws SubmodelNotFoundException { - access.write(storage::replaceSubmodelDescriptor, submodelId, descr); + access.write(() -> storage.replaceSubmodelDescriptor(submodelId, descr)); } } \ No newline at end of file diff --git a/basyx.submodelrepository/basyx.submodelrepository-backend/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/backend/ThreadSafeSubmodelRepository.java b/basyx.submodelrepository/basyx.submodelrepository-backend/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/backend/ThreadSafeSubmodelRepository.java index bc0b28b00..82dc59d15 100644 --- a/basyx.submodelrepository/basyx.submodelrepository-backend/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/backend/ThreadSafeSubmodelRepository.java +++ b/basyx.submodelrepository/basyx.submodelrepository-backend/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/backend/ThreadSafeSubmodelRepository.java @@ -60,112 +60,112 @@ public ThreadSafeSubmodelRepository(SubmodelRepository submodelRepository) { @Override public CursorResult> getAllSubmodels(PaginationInfo pInfo) { - return access.read(decoratedRepository::getAllSubmodels, pInfo); + return access.read(() -> decoratedRepository.getAllSubmodels(pInfo)); } @Override public CursorResult> getAllSubmodels(String semanticId, PaginationInfo pInfo) { - return access.read(decoratedRepository::getAllSubmodels, semanticId, pInfo); + return access.read(() -> decoratedRepository.getAllSubmodels(semanticId, pInfo)); } @Override public Submodel getSubmodel(String submodelId) throws ElementDoesNotExistException { - return access.read(decoratedRepository::getSubmodel, submodelId); + return access.read(() -> decoratedRepository.getSubmodel(submodelId)); } @Override public void updateSubmodel(String submodelId, Submodel submodel) throws ElementDoesNotExistException { - access.write(decoratedRepository::updateSubmodel, submodelId, submodel); + access.write(() -> decoratedRepository.updateSubmodel(submodelId, submodel)); } @Override public void createSubmodel(Submodel submodel) throws CollidingIdentifierException, MissingIdentifierException { - access.write(decoratedRepository::createSubmodel, submodel); + access.write(() -> decoratedRepository.createSubmodel(submodel)); } @Override public void updateSubmodelElement(String submodelIdentifier, String idShortPath, SubmodelElement submodelElement) throws ElementDoesNotExistException { - access.write(decoratedRepository::updateSubmodelElement, submodelIdentifier, idShortPath, submodelElement); + access.write(() -> decoratedRepository.updateSubmodelElement(submodelIdentifier, idShortPath, submodelElement)); } @Override public void deleteSubmodel(String submodelId) throws ElementDoesNotExistException { - access.write(decoratedRepository::deleteSubmodel, submodelId); + access.write(() -> decoratedRepository.deleteSubmodel(submodelId)); } @Override public CursorResult> getSubmodelElements(String submodelId, PaginationInfo pInfo) throws ElementDoesNotExistException { - return access.read(decoratedRepository::getSubmodelElements, submodelId, pInfo); + return access.read(() -> decoratedRepository.getSubmodelElements(submodelId, pInfo)); } @Override public SubmodelElement getSubmodelElement(String submodelId, String smeIdShort) throws ElementDoesNotExistException { - return access.read(decoratedRepository::getSubmodelElement, submodelId, smeIdShort); + return access.read(() -> decoratedRepository.getSubmodelElement(submodelId, smeIdShort)); } @Override public SubmodelElementValue getSubmodelElementValue(String submodelId, String smeIdShort) throws ElementDoesNotExistException { - return access.read(decoratedRepository::getSubmodelElementValue, submodelId, smeIdShort); + return access.read(() -> decoratedRepository.getSubmodelElementValue(submodelId, smeIdShort)); } @Override public void setSubmodelElementValue(String submodelId, String smeIdShort, SubmodelElementValue value) throws ElementDoesNotExistException { - access.write(decoratedRepository::setSubmodelElementValue, submodelId, smeIdShort, value); + access.write(() -> decoratedRepository.setSubmodelElementValue(submodelId, smeIdShort, value)); } @Override public void createSubmodelElement(String submodelId, SubmodelElement smElement) { - access.write(decoratedRepository::createSubmodelElement, submodelId, smElement); + access.write(() -> decoratedRepository.createSubmodelElement(submodelId, smElement)); } @Override public void createSubmodelElement(String submodelId, String idShortPath, SubmodelElement smElement) throws ElementDoesNotExistException { - access.write(decoratedRepository::createSubmodelElement, submodelId, idShortPath, smElement); + access.write(() -> decoratedRepository.createSubmodelElement(submodelId, idShortPath, smElement)); } @Override public void deleteSubmodelElement(String submodelId, String idShortPath) throws ElementDoesNotExistException { - access.write(decoratedRepository::deleteSubmodelElement, submodelId, idShortPath); + access.write(() -> decoratedRepository.deleteSubmodelElement(submodelId, idShortPath)); } @Override public OperationVariable[] invokeOperation(String submodelId, String idShortPath, OperationVariable[] input) throws ElementDoesNotExistException { - return access.read(decoratedRepository::invokeOperation, submodelId, idShortPath, input); + return decoratedRepository.invokeOperation(submodelId, idShortPath, input); } @Override public SubmodelValueOnly getSubmodelByIdValueOnly(String submodelId) throws ElementDoesNotExistException { - return access.read(decoratedRepository::getSubmodelByIdValueOnly, submodelId); + return access.read(() -> decoratedRepository.getSubmodelByIdValueOnly(submodelId)); } @Override public Submodel getSubmodelByIdMetadata(String submodelId) throws ElementDoesNotExistException { - return access.read(decoratedRepository::getSubmodelByIdMetadata, submodelId); + return access.read(() -> decoratedRepository.getSubmodelByIdMetadata(submodelId)); } @Override public File getFileByPathSubmodel(String submodelId, String idShortPath) throws ElementDoesNotExistException, ElementNotAFileException, FileDoesNotExistException { - return access.read(decoratedRepository::getFileByPathSubmodel, submodelId, idShortPath); + return access.read(() -> decoratedRepository.getFileByPathSubmodel(submodelId, idShortPath)); } @Override public void setFileValue(String submodelId, String idShortPath, String fileName, InputStream inputStream) throws ElementDoesNotExistException, ElementNotAFileException { - access.write(decoratedRepository::setFileValue, submodelId, idShortPath, fileName, inputStream); + access.write(() -> decoratedRepository.setFileValue(submodelId, idShortPath, fileName, inputStream)); } @Override public void deleteFileValue(String submodelId, String idShortPath) throws ElementDoesNotExistException, ElementNotAFileException, FileDoesNotExistException { - access.write(decoratedRepository::deleteFileValue, submodelId, idShortPath); + access.write(() -> decoratedRepository.deleteFileValue(submodelId, idShortPath)); } @Override public void patchSubmodelElements(String submodelId, List submodelElementList) { - access.write(decoratedRepository::patchSubmodelElements, submodelId, submodelElementList); + access.write(() -> decoratedRepository.patchSubmodelElements(submodelId, submodelElementList)); } @Override public InputStream getFileByFilePath(String submodelId, String filePath) { - return access.read(decoratedRepository::getFileByFilePath, submodelId, filePath); + return access.read(() -> decoratedRepository.getFileByFilePath(submodelId, filePath)); } @Override