From e8178c4a9a8bae43dceba56b02026e78a20e33c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20F=C3=B6rster?= Date: Wed, 5 Jun 2024 16:29:02 +0200 Subject: [PATCH 1/4] Bump version to 9.2.1-SNAPSHOT --- metasvc-client/pom.xml | 2 +- metasvc-lobid-client/pom.xml | 2 +- metasvc-model/pom.xml | 2 +- metasvc-server/backend-api/pom.xml | 2 +- metasvc-server/backend-file/pom.xml | 2 +- metasvc-server/backend-inmemory/pom.xml | 2 +- metasvc-server/backend-jdbi/pom.xml | 2 +- metasvc-server/backend-lobid/pom.xml | 2 +- metasvc-server/business/pom.xml | 2 +- metasvc-server/pom.xml | 2 +- metasvc-server/webapp/pom.xml | 2 +- pom.xml | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/metasvc-client/pom.xml b/metasvc-client/pom.xml index 8440a9990..bbec75261 100644 --- a/metasvc-client/pom.xml +++ b/metasvc-client/pom.xml @@ -6,7 +6,7 @@ io.github.dbmdz.metadata metasvc - 9.2.0 + 9.2.1-SNAPSHOT Metadata-Service: Repository Client diff --git a/metasvc-lobid-client/pom.xml b/metasvc-lobid-client/pom.xml index 460cf6e08..6c97c6fdf 100644 --- a/metasvc-lobid-client/pom.xml +++ b/metasvc-lobid-client/pom.xml @@ -7,7 +7,7 @@ io.github.dbmdz.metadata metasvc - 9.2.0 + 9.2.1-SNAPSHOT Metadata-Service: lobid.org Client diff --git a/metasvc-model/pom.xml b/metasvc-model/pom.xml index 3151902db..c5b46773b 100644 --- a/metasvc-model/pom.xml +++ b/metasvc-model/pom.xml @@ -6,7 +6,7 @@ io.github.dbmdz.metadata metasvc - 9.2.0 + 9.2.1-SNAPSHOT Metadata-Service: Model diff --git a/metasvc-server/backend-api/pom.xml b/metasvc-server/backend-api/pom.xml index d42062bc3..57f323da9 100644 --- a/metasvc-server/backend-api/pom.xml +++ b/metasvc-server/backend-api/pom.xml @@ -6,7 +6,7 @@ io.github.dbmdz.metadata metasvc-server - 9.2.0 + 9.2.1-SNAPSHOT Metadata-Service: Repository Server (Backend API) diff --git a/metasvc-server/backend-file/pom.xml b/metasvc-server/backend-file/pom.xml index 8493090de..291d0888c 100644 --- a/metasvc-server/backend-file/pom.xml +++ b/metasvc-server/backend-file/pom.xml @@ -5,7 +5,7 @@ io.github.dbmdz.metadata metasvc-server - 9.2.0 + 9.2.1-SNAPSHOT Metadata-Service: Repository Server (Backend IMPL File) diff --git a/metasvc-server/backend-inmemory/pom.xml b/metasvc-server/backend-inmemory/pom.xml index 4bc9bda9d..c6fc47e5c 100644 --- a/metasvc-server/backend-inmemory/pom.xml +++ b/metasvc-server/backend-inmemory/pom.xml @@ -6,7 +6,7 @@ io.github.dbmdz.metadata metasvc-server - 9.2.0 + 9.2.1-SNAPSHOT Metadata-Service: Repository Server (Backend IMPL InMemory) diff --git a/metasvc-server/backend-jdbi/pom.xml b/metasvc-server/backend-jdbi/pom.xml index 5680de1e7..e7e27e330 100644 --- a/metasvc-server/backend-jdbi/pom.xml +++ b/metasvc-server/backend-jdbi/pom.xml @@ -8,7 +8,7 @@ io.github.dbmdz.metadata metasvc-server - 9.2.0 + 9.2.1-SNAPSHOT Metadata-Service: Repository Server (Backend IMPL JDBI PostgreSql) diff --git a/metasvc-server/backend-lobid/pom.xml b/metasvc-server/backend-lobid/pom.xml index e36b2c189..6b48dbe17 100644 --- a/metasvc-server/backend-lobid/pom.xml +++ b/metasvc-server/backend-lobid/pom.xml @@ -6,7 +6,7 @@ io.github.dbmdz.metadata metasvc-server - 9.2.0 + 9.2.1-SNAPSHOT Metadata-Service: Repository Server (Backend IMPL External System lobid.org) diff --git a/metasvc-server/business/pom.xml b/metasvc-server/business/pom.xml index 09f2f0658..aed66b419 100644 --- a/metasvc-server/business/pom.xml +++ b/metasvc-server/business/pom.xml @@ -6,7 +6,7 @@ io.github.dbmdz.metadata metasvc-server - 9.2.0 + 9.2.1-SNAPSHOT Metadata-Service: Repository Server (Business) diff --git a/metasvc-server/pom.xml b/metasvc-server/pom.xml index 4a02aa020..504c9cecc 100644 --- a/metasvc-server/pom.xml +++ b/metasvc-server/pom.xml @@ -6,7 +6,7 @@ io.github.dbmdz.metadata metasvc - 9.2.0 + 9.2.1-SNAPSHOT Metadata-Service: Repository Server diff --git a/metasvc-server/webapp/pom.xml b/metasvc-server/webapp/pom.xml index 09f4e7887..7565e2f0e 100644 --- a/metasvc-server/webapp/pom.xml +++ b/metasvc-server/webapp/pom.xml @@ -6,7 +6,7 @@ io.github.dbmdz.metadata metasvc-server - 9.2.0 + 9.2.1-SNAPSHOT Metadata-Service: Repository Server (Webapp) diff --git a/pom.xml b/pom.xml index 2c7d22b3a..ea8c05c60 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ io.github.dbmdz.metadata metasvc - 9.2.0 + 9.2.1-SNAPSHOT pom Metadata-Service From 6bba795c93ca5fbef320239e20f6b5b255f2b199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20F=C3=B6rster?= Date: Wed, 5 Jun 2024 16:30:55 +0200 Subject: [PATCH 2/4] [METASVC-132] Speedup reflection --- .../identifiable/DerivedIdentifiableBuildHelper.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/metasvc-model/src/main/java/de/digitalcollections/model/identifiable/DerivedIdentifiableBuildHelper.java b/metasvc-model/src/main/java/de/digitalcollections/model/identifiable/DerivedIdentifiableBuildHelper.java index dbf5ce773..a0f8fafd7 100644 --- a/metasvc-model/src/main/java/de/digitalcollections/model/identifiable/DerivedIdentifiableBuildHelper.java +++ b/metasvc-model/src/main/java/de/digitalcollections/model/identifiable/DerivedIdentifiableBuildHelper.java @@ -4,6 +4,7 @@ import java.lang.reflect.Method; import java.lang.reflect.Type; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; import org.slf4j.Logger; @@ -41,22 +42,22 @@ public static D build(Identifiable identifiable, Class< if (!identifiableGetter.getName().startsWith("get")) continue; Type returnType = identifiableGetter.getGenericReturnType(); // ...find the corresponding setter of the new object... - Method[] setters = + Optional setter = derivedInstSetters.stream() .filter( derivSetter -> derivSetter .getName() - .equals(identifiableGetter.getName().replaceFirst("^get", "set")) + .equals("set" + identifiableGetter.getName().substring(3)) && derivSetter.getParameterCount() == 1 && derivSetter .getParameters()[0] .getParameterizedType() .equals(returnType)) - .toArray(i -> new Method[i]); - if (setters.length != 1) continue; + .findFirst(); + if (setter.isEmpty()) continue; // ...and invoke this setter with the getter's returned value - setters[0].invoke(derivedInst, identifiableGetter.invoke(identifiable)); + setter.get().invoke(derivedInst, identifiableGetter.invoke(identifiable)); } return derivedInst; } catch (InstantiationException From b8f6784be6c91a50e0d2bf215ecb613aab5527eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20F=C3=B6rster?= Date: Wed, 5 Jun 2024 16:35:41 +0200 Subject: [PATCH 3/4] Add changelog entry --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4f7c8edb..a17051424 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## Unreleased +### Fixed + +- Increased performance of reflection by 32.8% + ## [9.2.0](https://github.com/dbmdz/metadata-service/releases/tag/9.2.0) - 2024-06-03 ### Added From 37c6551c561baea3434ccf58db3829e723254f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20F=C3=B6rster?= Date: Fri, 7 Jun 2024 11:44:15 +0200 Subject: [PATCH 4/4] Refactor setter name in reflection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …use string variable instead building it within the stream --- .../model/identifiable/DerivedIdentifiableBuildHelper.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/metasvc-model/src/main/java/de/digitalcollections/model/identifiable/DerivedIdentifiableBuildHelper.java b/metasvc-model/src/main/java/de/digitalcollections/model/identifiable/DerivedIdentifiableBuildHelper.java index a0f8fafd7..14a424719 100644 --- a/metasvc-model/src/main/java/de/digitalcollections/model/identifiable/DerivedIdentifiableBuildHelper.java +++ b/metasvc-model/src/main/java/de/digitalcollections/model/identifiable/DerivedIdentifiableBuildHelper.java @@ -42,13 +42,12 @@ public static D build(Identifiable identifiable, Class< if (!identifiableGetter.getName().startsWith("get")) continue; Type returnType = identifiableGetter.getGenericReturnType(); // ...find the corresponding setter of the new object... + String searchedSetter = "set" + identifiableGetter.getName().substring(3); Optional setter = derivedInstSetters.stream() .filter( derivSetter -> - derivSetter - .getName() - .equals("set" + identifiableGetter.getName().substring(3)) + derivSetter.getName().equals(searchedSetter) && derivSetter.getParameterCount() == 1 && derivSetter .getParameters()[0]