diff --git a/mycore-base/src/main/java/org/mycore/backend/jpa/MCRJPAConfigurationCheck.java b/mycore-base/src/main/java/org/mycore/backend/jpa/MCRJPAConfigurationCheck.java index 312d8f61cd..003c04b427 100644 --- a/mycore-base/src/main/java/org/mycore/backend/jpa/MCRJPAConfigurationCheck.java +++ b/mycore-base/src/main/java/org/mycore/backend/jpa/MCRJPAConfigurationCheck.java @@ -34,7 +34,7 @@ import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor; import org.hibernate.jpa.boot.spi.PersistenceXmlParser; import org.mycore.common.config.MCRConfiguration2; -import org.mycore.common.config.MCRInstanceName; +import org.mycore.common.config.instantiator.MCRInstanceName; import org.mycore.common.events.MCRStartupHandler.AutoExecutable; import org.mycore.resource.MCRResourceResolver; import org.mycore.resource.provider.MCRResourceProvider; diff --git a/mycore-base/src/main/java/org/mycore/common/MCRBasicObjectExpander.java b/mycore-base/src/main/java/org/mycore/common/MCRBasicObjectExpander.java index 4b2935c1f5..23f2dc6a4b 100644 --- a/mycore-base/src/main/java/org/mycore/common/MCRBasicObjectExpander.java +++ b/mycore-base/src/main/java/org/mycore/common/MCRBasicObjectExpander.java @@ -124,8 +124,8 @@ private void expandClassifications(MCRObject mcrObject) { public static final class Factory implements Supplier { - @MCRInstance(name = CLASSIFICATION_MAPPER_KEY, valueClass = MCRClassificationMapper.class, required = false, - sentinel = @MCRSentinel) + @MCRSentinel + @MCRInstance(name = CLASSIFICATION_MAPPER_KEY, valueClass = MCRClassificationMapper.class, required = false) public MCRClassificationMapper classificationMapper; @Override diff --git a/mycore-base/src/main/java/org/mycore/common/MCRClassTools.java b/mycore-base/src/main/java/org/mycore/common/MCRClassTools.java index 616005f304..29cd62f9ec 100644 --- a/mycore-base/src/main/java/org/mycore/common/MCRClassTools.java +++ b/mycore-base/src/main/java/org/mycore/common/MCRClassTools.java @@ -51,20 +51,18 @@ public static Object loadClassFromURL(File file, String className) /** * Loads a class via default ClassLoader or Thread.currentThread().getContextClassLoader(). - * @param classname Name of class + * @param className Name of class * @param Type of Class * @return the initialized class * @throws ClassNotFoundException if both ClassLoader cannot load the Class */ - public static Class forName(String classname) throws ClassNotFoundException { - @SuppressWarnings("unchecked") - Class forName; + @SuppressWarnings("unchecked") + public static Class forName(String className) throws ClassNotFoundException { try { - forName = (Class) Class.forName(classname); + return (Class) Class.forName(className); } catch (ClassNotFoundException cnfe) { - forName = (Class) Class.forName(classname, true, extendedClassLoader); + return (Class) Class.forName(className, true, extendedClassLoader); } - return forName; } /** diff --git a/mycore-base/src/main/java/org/mycore/common/MCRJSONManager.java b/mycore-base/src/main/java/org/mycore/common/MCRJSONManager.java index 8511084fe7..d2a28ba4af 100644 --- a/mycore-base/src/main/java/org/mycore/common/MCRJSONManager.java +++ b/mycore-base/src/main/java/org/mycore/common/MCRJSONManager.java @@ -107,8 +107,8 @@ public GsonBuilder createGsonBuilder() { public static class Factory implements Supplier { - @MCRInstanceMap(name = TYPE_ADAPTERS_KEY, valueClass = MCRJSONTypeAdapter.class, required = false, - sentinel = @MCRSentinel) + @MCRSentinel + @MCRInstanceMap(name = TYPE_ADAPTERS_KEY, valueClass = MCRJSONTypeAdapter.class, required = false) public Map> typeAdapters; @Override diff --git a/mycore-base/src/main/java/org/mycore/common/MCRUserInformationResolver.java b/mycore-base/src/main/java/org/mycore/common/MCRUserInformationResolver.java index fb29d9e2ee..28eaf0ab50 100644 --- a/mycore-base/src/main/java/org/mycore/common/MCRUserInformationResolver.java +++ b/mycore-base/src/main/java/org/mycore/common/MCRUserInformationResolver.java @@ -142,7 +142,8 @@ public static String getSpecification(String schema, String userId) { public static class Factory implements Supplier { - @MCRInstanceMap(name = PROVIDERS_KEY, valueClass = MCRUserInformationProvider.class, sentinel = @MCRSentinel) + @MCRSentinel + @MCRInstanceMap(name = PROVIDERS_KEY, valueClass = MCRUserInformationProvider.class) public Map providers; @Override diff --git a/mycore-base/src/main/java/org/mycore/common/config/MCRConfigurableInstanceHelper.java b/mycore-base/src/main/java/org/mycore/common/config/MCRConfigurableInstanceHelper.java deleted file mode 100644 index bba78b98f0..0000000000 --- a/mycore-base/src/main/java/org/mycore/common/config/MCRConfigurableInstanceHelper.java +++ /dev/null @@ -1,1845 +0,0 @@ -/* - * This file is part of *** M y C o R e *** - * See https://www.mycore.de/ for details. - * - * MyCoRe is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * MyCoRe is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with MyCoRe. If not, see . - */ - -package org.mycore.common.config; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.SortedMap; -import java.util.TreeMap; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Supplier; -import java.util.function.ToIntFunction; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.mycore.common.MCRClassTools; -import org.mycore.common.config.annotation.MCRConfigurationProxy; -import org.mycore.common.config.annotation.MCRFactory; -import org.mycore.common.config.annotation.MCRInstance; -import org.mycore.common.config.annotation.MCRInstanceList; -import org.mycore.common.config.annotation.MCRInstanceMap; -import org.mycore.common.config.annotation.MCRPostConstruction; -import org.mycore.common.config.annotation.MCRProperty; -import org.mycore.common.config.annotation.MCRPropertyList; -import org.mycore.common.config.annotation.MCRPropertyMap; -import org.mycore.common.config.annotation.MCRRawProperties; -import org.mycore.common.config.annotation.MCRSentinel; - -import jakarta.inject.Singleton; - -/** - * Creates Objects which are configured with properties. - * - * @author Sebastian Hofmann - */ -@SuppressWarnings({ "PMD.AvoidDuplicateLiterals", "PMD.SingleMethodSingleton", - "PMD.MCR.Singleton.MethodModifiers", "PMD.MCR.Singleton.MethodReturnType", - "PMD.MCR.Singleton.ClassModifiers", "PMD.MCR.Singleton.PrivateConstructor", - "PMD.MCR.Singleton.NonPrivateConstructors", -}) -class MCRConfigurableInstanceHelper { - - private static final Logger LOGGER = LogManager.getLogger(); - - public static final Set