summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/src/main/java/org/openecomp/core/factory/api/AbstractComponentFactory.java
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2019-10-18 14:58:21 +0100
committerandre.schmid <andre.schmid@est.tech>2019-10-21 15:53:58 +0100
commit105ce0729d5333cc095ef5bd8104a6c5b90cc9f0 (patch)
treef85c45d12fcc2595ad02516ad182ff5f71c9bf0d /openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/src/main/java/org/openecomp/core/factory/api/AbstractComponentFactory.java
parentd289108897f3baf5bc51092c4f55309bdd90f8d9 (diff)
Fix factory instance creation instability
Refactor the factory registry and instance creation. Remove unnecessary static code in Factory creation. Centralize the responsibility to read the factory registry configuration and cache the factory instances in a Singleton called FactoryRegistryManager. Clean the base abstract factory that was sharing non factory code, it had all the factory registry code statically, never used by the concrete factory classes. Change-Id: Ie2e9c29013acd36ddaf15383dd6b06432fbdbb66 Issue-ID: SDC-1905 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/src/main/java/org/openecomp/core/factory/api/AbstractComponentFactory.java')
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/src/main/java/org/openecomp/core/factory/api/AbstractComponentFactory.java61
1 files changed, 0 insertions, 61 deletions
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/src/main/java/org/openecomp/core/factory/api/AbstractComponentFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/src/main/java/org/openecomp/core/factory/api/AbstractComponentFactory.java
index 1ea6fe8d43..3de0d88f43 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/src/main/java/org/openecomp/core/factory/api/AbstractComponentFactory.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-facade-lib/openecomp-facade-core/src/main/java/org/openecomp/core/factory/api/AbstractComponentFactory.java
@@ -16,66 +16,5 @@
package org.openecomp.core.factory.api;
-import org.apache.commons.lang3.StringUtils;
-import org.openecomp.core.factory.FactoryConfig;
-import org.openecomp.core.factory.impl.AbstractFactoryBase;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.common.errors.ErrorCategory;
-import org.openecomp.sdc.common.errors.ErrorCode;
-
-import java.util.Map;
-
public abstract class AbstractComponentFactory<I> extends AbstractFactory<I> {
-
- static {
- Registry registry = new RegistryImpl();
- InitializationHelper.registerFactoryMapping(registry);
- }
-
- @FunctionalInterface
- interface Registry {
- void register(String factory, String impl);
- }
-
- private static class RegistryImpl implements Registry {
- @Override
- public void register(String factory, String impl) {
- AbstractFactoryBase.registerFactory(factory, impl);
- }
- }
-
- static class InitializationHelper {
-
-
- private static boolean isRegistered = false;
-
- private InitializationHelper() {
- }
-
- static synchronized void registerFactoryMapping(Registry registry) {
- if (!isRegistered) {
- registerFactoryMappingImpl(registry);
- isRegistered = true;
- }
- }
-
- private static void registerFactoryMappingImpl(Registry registry) {
- Map<String, String> factoryMap = FactoryConfig.getFactoriesMap();
-
- for (Map.Entry<String, String> entry : factoryMap.entrySet()) {
- String abstractClassName = entry.getKey();
- String concreteTypeName = entry.getValue();
-
- if (StringUtils.isEmpty(concreteTypeName)) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withId("E0003")
- .withMessage("Missing configuration value:" + concreteTypeName + ".")
- .withCategory(ErrorCategory.SYSTEM).build());
-
- }
- registry.register(abstractClassName, concreteTypeName);
- }
- }
- }
-
}