release version 1.10.0
This commit is contained in:
@ -0,0 +1,74 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* artifact-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.core.artifact.installer.builder.typed;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractTypedInstallerFactory implements TypedInstallerFactory {
|
||||
|
||||
protected List<Class<? extends TypedInstaller>> supportedClasses;
|
||||
|
||||
protected List<String> supportedTypes;
|
||||
|
||||
protected AbstractTypedInstallerFactory() {
|
||||
super();
|
||||
if (this.getClass().isAnnotationPresent(TypedInstallerFactoryDescriptor.class)) {
|
||||
TypedInstallerFactoryDescriptor descriptor =
|
||||
this.getClass().getAnnotation(TypedInstallerFactoryDescriptor.class);
|
||||
this.supportedClasses = Arrays.asList(descriptor.supportedClasses());
|
||||
this.supportedTypes = Arrays.asList(descriptor.supportedTypes());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Class<? extends TypedInstaller>> getSupportedClasses() {
|
||||
return supportedClasses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupportedTypes() {
|
||||
return supportedTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedInstaller create(String type) {
|
||||
if (!supportedTypes.contains(type))
|
||||
return null;
|
||||
return doCreate(type);
|
||||
}
|
||||
|
||||
protected abstract TypedInstaller doCreate(String type);
|
||||
|
||||
@Override
|
||||
public TypedInstaller create(Class<? extends TypedInstaller> targetClass) {
|
||||
if (!supportedClasses.contains(targetClass))
|
||||
return null;
|
||||
return doCreate(targetClass);
|
||||
}
|
||||
|
||||
protected abstract TypedInstaller doCreate(Class<? extends TypedInstaller> targetClass);
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* artifact-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.core.artifact.installer.builder.typed;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import ru.entaxy.platform.core.artifact.Artifact;
|
||||
import ru.entaxy.platform.core.artifact.installer.builder.typed.impl.BlueprintInstallerImpl;
|
||||
import ru.entaxy.platform.core.artifact.installer.builder.typed.impl.BundleInstallerImpl;
|
||||
import ru.entaxy.platform.core.artifact.installer.builder.typed.impl.JarInstallerImpl;
|
||||
import ru.entaxy.platform.core.artifact.installer.builder.typed.impl.TypedInstallerImpl;
|
||||
|
||||
@TypedInstallerFactoryDescriptor(supportedTypes = {Artifact.ARTIFACT_CATEGORY_BLUEPRINT,
|
||||
Artifact.ARTIFACT_CATEGORY_BUNDLE, Artifact.ARTIFACT_CATEGORY_JAR},
|
||||
supportedClasses = {BlueprintInstaller.class, BundleInstaller.class, JarInstaller.class})
|
||||
public class DefaultTypedInstallerFactory extends AbstractTypedInstallerFactory {
|
||||
|
||||
protected static DefaultTypedInstallerFactory INSTANCE;
|
||||
|
||||
public static DefaultTypedInstallerFactory getInstance() {
|
||||
if (INSTANCE == null)
|
||||
INSTANCE = new DefaultTypedInstallerFactory();
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
protected static Map<String, Class<? extends TypedInstallerImpl>> typeToClassMap;
|
||||
protected static Map<Class<? extends TypedInstaller>, Class<? extends TypedInstallerImpl>> classToClassMap;
|
||||
|
||||
static {
|
||||
|
||||
typeToClassMap = new HashMap<>();
|
||||
typeToClassMap.put(Artifact.ARTIFACT_CATEGORY_BLUEPRINT, BlueprintInstallerImpl.class);
|
||||
typeToClassMap.put(Artifact.ARTIFACT_CATEGORY_BUNDLE, BundleInstallerImpl.class);
|
||||
typeToClassMap.put(Artifact.ARTIFACT_CATEGORY_JAR, JarInstallerImpl.class);
|
||||
|
||||
classToClassMap = new HashMap<>();
|
||||
classToClassMap.put(BlueprintInstaller.class, BlueprintInstallerImpl.class);
|
||||
classToClassMap.put(BundleInstaller.class, BundleInstallerImpl.class);
|
||||
classToClassMap.put(JarInstaller.class, JarInstallerImpl.class);
|
||||
|
||||
}
|
||||
|
||||
protected DefaultTypedInstallerFactory() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TypedInstaller doCreate(String type) {
|
||||
Class<? extends TypedInstallerImpl> clazz = typeToClassMap.get(type);
|
||||
if (clazz == null)
|
||||
return null;
|
||||
return createOfClass(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TypedInstaller doCreate(Class<? extends TypedInstaller> targetClass) {
|
||||
Class<? extends TypedInstallerImpl> clazz = classToClassMap.get(targetClass);
|
||||
if (clazz == null)
|
||||
return null;
|
||||
return createOfClass(clazz);
|
||||
}
|
||||
|
||||
protected TypedInstaller createOfClass(Class<? extends TypedInstallerImpl> clazz) {
|
||||
try {
|
||||
Constructor<?> constructor = clazz.getConstructor();
|
||||
return (TypedInstaller) constructor.newInstance();
|
||||
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
|
||||
| IllegalArgumentException | InvocationTargetException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* artifact-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.core.artifact.installer.builder.typed;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TypedInstallerFactory {
|
||||
|
||||
List<Class<? extends TypedInstaller>> getSupportedClasses();
|
||||
|
||||
List<String> getSupportedTypes();
|
||||
|
||||
TypedInstaller create(String type);
|
||||
|
||||
TypedInstaller create(Class<? extends TypedInstaller> targetClass);
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* artifact-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.core.artifact.installer.builder.typed;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RUNTIME)
|
||||
@Target(TYPE)
|
||||
public @interface TypedInstallerFactoryDescriptor {
|
||||
|
||||
Class<? extends TypedInstaller>[] supportedClasses();
|
||||
|
||||
String[] supportedTypes();
|
||||
|
||||
}
|
@ -0,0 +1,192 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* artifact-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.core.artifact.installer.builder.typed;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import ru.entaxy.platform.core.artifact.installer.builder.ClusterInstaller;
|
||||
import ru.entaxy.platform.core.artifact.installer.builder.Installer;
|
||||
import ru.entaxy.platform.core.artifact.installer.builder.LocalInstaller;
|
||||
|
||||
public class TypedInstallerManager {
|
||||
|
||||
|
||||
protected static Map<Class<? extends Installer<?>>, TypedInstallerStorage> storages = new HashMap<>();
|
||||
|
||||
protected static TypedInstallerStorage commonStorage = new TypedInstallerStorage();
|
||||
|
||||
static {
|
||||
storages.put(LocalInstaller.class, new TypedInstallerStorage());
|
||||
storages.put(ClusterInstaller.class, new TypedInstallerStorage());
|
||||
}
|
||||
|
||||
protected static Object storagesLock = new Object();
|
||||
|
||||
public static void register(String artifactType,
|
||||
TypedInstallerFactory factory) {
|
||||
|
||||
register(commonStorage, artifactType, factory);
|
||||
}
|
||||
|
||||
public static void register(TypedInstallerFactory factory) {
|
||||
|
||||
register(commonStorage, factory);
|
||||
}
|
||||
|
||||
protected static TypedInstallerStorage getOrCreateStorage(Class<? extends Installer<?>> installerClass) {
|
||||
if (!storages.containsKey(installerClass)) {
|
||||
synchronized (storagesLock) {
|
||||
storages.put(installerClass, new TypedInstallerStorage());
|
||||
}
|
||||
}
|
||||
return storages.get(installerClass);
|
||||
}
|
||||
|
||||
public static void register(Class<? extends Installer<?>> installerClass, String artifactType,
|
||||
TypedInstallerFactory factory) {
|
||||
register(getOrCreateStorage(installerClass), artifactType, factory);
|
||||
}
|
||||
|
||||
public static void register(Class<? extends Installer<?>> installerClass,
|
||||
TypedInstallerFactory factory) {
|
||||
register(getOrCreateStorage(installerClass), factory);
|
||||
}
|
||||
|
||||
protected static void register(TypedInstallerStorage storage, TypedInstallerFactory factory) {
|
||||
for (String type : factory.getSupportedTypes())
|
||||
register(storage, type, factory);
|
||||
}
|
||||
|
||||
protected static void register(TypedInstallerStorage storage, String artifactType,
|
||||
TypedInstallerFactory factory) {
|
||||
storage.register(artifactType, factory);
|
||||
}
|
||||
|
||||
public static TypedInstaller create(Object owner, String type) {
|
||||
return create(owner, type, false);
|
||||
}
|
||||
|
||||
public static TypedInstaller create(Object owner, String type, boolean strict) {
|
||||
for (Class<? extends Installer<?>> installerClass : storages.keySet())
|
||||
if (installerClass.isInstance(owner))
|
||||
return create(installerClass, type, strict);
|
||||
if (strict)
|
||||
return null;
|
||||
return create(null, type, strict);
|
||||
}
|
||||
|
||||
public static TypedInstaller create(Class<? extends Installer<?>> installerClass, String type) {
|
||||
return create(installerClass, type, false);
|
||||
}
|
||||
|
||||
public static TypedInstaller create(Class<? extends Installer<?>> installerClass, String type, boolean strict) {
|
||||
TypedInstallerStorage storage = installerClass == null ? null : storages.get(installerClass);
|
||||
TypedInstaller result = null;
|
||||
if (storage != null) {
|
||||
result = storage.create(type);
|
||||
}
|
||||
if (result != null)
|
||||
return result;
|
||||
if (strict)
|
||||
return null;
|
||||
else
|
||||
return commonStorage.create(type);
|
||||
|
||||
}
|
||||
|
||||
public static TypedInstaller create(Object owner, Class<? extends TypedInstaller> typedClass) {
|
||||
return create(owner, typedClass, false);
|
||||
}
|
||||
|
||||
public static TypedInstaller create(Object owner, Class<? extends TypedInstaller> typedClass, boolean strict) {
|
||||
for (Class<? extends Installer<?>> installerClass : storages.keySet())
|
||||
if (installerClass.isInstance(owner))
|
||||
return create(installerClass, typedClass, strict);
|
||||
if (strict)
|
||||
return null;
|
||||
return create(null, typedClass, strict);
|
||||
}
|
||||
|
||||
public static TypedInstaller create(Class<? extends Installer<?>> installerClass,
|
||||
Class<? extends TypedInstaller> typedClass) {
|
||||
return create(installerClass, typedClass, false);
|
||||
}
|
||||
|
||||
public static TypedInstaller create(Class<? extends Installer<?>> installerClass,
|
||||
Class<? extends TypedInstaller> typedClass, boolean strict) {
|
||||
TypedInstallerStorage storage = installerClass == null ? null : storages.get(installerClass);
|
||||
TypedInstaller result = null;
|
||||
if (storage != null) {
|
||||
result = storage.create(typedClass);
|
||||
}
|
||||
if (result != null)
|
||||
return result;
|
||||
if (strict)
|
||||
return null;
|
||||
else
|
||||
return commonStorage.create(typedClass);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected static class TypedInstallerStorage {
|
||||
|
||||
protected Map<String, TypedInstallerFactory> factories = new HashMap<>();
|
||||
|
||||
protected Object factoriesLock = new Object();
|
||||
|
||||
public void register(String type, TypedInstallerFactory factory) {
|
||||
synchronized (factoriesLock) {
|
||||
factories.put(type, factory);
|
||||
}
|
||||
}
|
||||
|
||||
public TypedInstaller create(String type) {
|
||||
if (!factories.containsKey(type))
|
||||
return null;
|
||||
return factories.get(type).create(type);
|
||||
}
|
||||
|
||||
public TypedInstaller create(Class<? extends TypedInstaller> typedClass) {
|
||||
|
||||
TypedInstallerFactory factory = null;
|
||||
|
||||
for (TypedInstallerFactory f : factories.values())
|
||||
if (f.getSupportedClasses().contains(typedClass)) {
|
||||
factory = f;
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == null)
|
||||
return null;
|
||||
|
||||
return factory.create(typedClass);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* artifact-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.core.artifact.installer.builder.typed.impl;
|
||||
|
||||
public interface HelperCreator {
|
||||
|
||||
<H extends TypedInstallerHelperImpl> H createHelper(Class<H> targetClass);
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* artifact-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.core.artifact.installer.builder.typed.impl;
|
||||
|
||||
public interface TypedInstallerHelperAware {
|
||||
|
||||
TypedInstallerHelperImpl getHelper();
|
||||
|
||||
void setHelper(TypedInstallerHelperImpl helper);
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* artifact-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.core.artifact.installer.builder.typed.impl;
|
||||
|
||||
public class TypedInstallerHelperImpl {
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* artifact-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.core.artifact.repository;
|
||||
|
||||
|
||||
|
||||
public interface RepositoryDescriptor {
|
||||
|
||||
String getName();
|
||||
|
||||
String getLocation();
|
||||
|
||||
String getUrl();
|
||||
|
||||
boolean isProxy();
|
||||
|
||||
boolean isMirror();
|
||||
|
||||
boolean isSnapshots();
|
||||
|
||||
String getRemotes();
|
||||
|
||||
boolean isReadOnly();
|
||||
|
||||
boolean isCopyOnChange();
|
||||
|
||||
boolean isEnabled();
|
||||
|
||||
String getUsername();
|
||||
|
||||
String getPassword();
|
||||
|
||||
String getRemoteHostSuffix();
|
||||
|
||||
boolean isSystem();
|
||||
|
||||
boolean isLookupEnabled();
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* artifact-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.core.artifact.repository;
|
||||
|
||||
/*
|
||||
* Internal interface to collect helpers managed by config files
|
||||
*/
|
||||
public interface RepositoryDescriptorCollector {
|
||||
public void addRepositoryDescriptor(RepositoryDescriptor helper);
|
||||
|
||||
public void removeRepositoryDescriptor(RepositoryDescriptor helper);
|
||||
}
|
@ -0,0 +1,188 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* artifact-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.core.artifact.repository.impl;
|
||||
|
||||
import ru.entaxy.platform.core.artifact.repository.RepositoryDescriptor;
|
||||
|
||||
public class RepositoryDescriptorImpl implements RepositoryDescriptor {
|
||||
|
||||
protected String name;
|
||||
String location;
|
||||
String url;
|
||||
boolean isProxy;
|
||||
boolean isMirror;
|
||||
String remotes;
|
||||
boolean isReadOnly = false;
|
||||
boolean copyOnChange;
|
||||
String username = "";
|
||||
String password = "";
|
||||
|
||||
boolean isSnapshots = false;
|
||||
|
||||
boolean isEnabled = true;
|
||||
|
||||
String remoteHostSuffix = "";
|
||||
|
||||
boolean isSystem = true;
|
||||
|
||||
boolean isLookupEnabled = true;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProxy() {
|
||||
return isProxy;
|
||||
}
|
||||
|
||||
public void setProxy(boolean isProxy) {
|
||||
this.isProxy = isProxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMirror() {
|
||||
return isMirror;
|
||||
}
|
||||
|
||||
public void setMirror(boolean isMirror) {
|
||||
this.isMirror = isMirror;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSnapshots() {
|
||||
return isSnapshots;
|
||||
}
|
||||
|
||||
public void setSnapshots(boolean isSnapshots) {
|
||||
this.isSnapshots = isSnapshots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemotes() {
|
||||
return remotes;
|
||||
}
|
||||
|
||||
public void setRemotes(String remotes) {
|
||||
this.remotes = remotes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
return isReadOnly;
|
||||
}
|
||||
|
||||
public void setReadOnly(boolean isReadOnly) {
|
||||
this.isReadOnly = isReadOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCopyOnChange() {
|
||||
return copyOnChange;
|
||||
}
|
||||
|
||||
public void setCopyOnChange(boolean copyOnChange) {
|
||||
this.copyOnChange = copyOnChange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return isEnabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean isEnabled) {
|
||||
this.isEnabled = isEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteHostSuffix() {
|
||||
return remoteHostSuffix;
|
||||
}
|
||||
|
||||
public void setRemoteHostSuffix(String remoteHostSuffix) {
|
||||
this.remoteHostSuffix = remoteHostSuffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSystem() {
|
||||
return isSystem;
|
||||
}
|
||||
|
||||
public void setSystem(boolean isSystem) {
|
||||
this.isSystem = isSystem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLookupEnabled() {
|
||||
return isLookupEnabled;
|
||||
}
|
||||
|
||||
public void setLookupEnabled(boolean isLookupEnabled) {
|
||||
this.isLookupEnabled = isLookupEnabled;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,158 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* artifact-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.core.artifact.repository.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.felix.utils.properties.TypedProperties;
|
||||
import org.apache.karaf.config.core.ConfigRepository;
|
||||
import org.osgi.framework.InvalidSyntaxException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ru.entaxy.platform.base.support.osgi.OSGIUtils;
|
||||
import ru.entaxy.platform.core.artifact.repository.ArtifactRepository;
|
||||
|
||||
public class RepositoryRegistrator {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RepositoryRegistrator.class);
|
||||
|
||||
public static RepositoryRegistrator INSTANCE = new RepositoryRegistrator();
|
||||
|
||||
private static final String REPO_CONFIG_PID = "org.ops4j.pax.url.mvn";
|
||||
|
||||
private static final String PROP_ENTAXY_SYSTEM_REPO_LIST = "org.ops4j.pax.url.mvn.repositories.entaxy";
|
||||
private static final String PROP_ENTAXY_CUSTOM_REPO_LIST = "org.ops4j.pax.url.mvn.repositories.entaxy.custom";
|
||||
|
||||
private static final String ENTAXY_PROPERTY_HTTP_PORT = "entaxy.org.osgi.service.http.port";
|
||||
|
||||
private static final String URL_PREFIX = "http://localhost:${" + ENTAXY_PROPERTY_HTTP_PORT + "}";
|
||||
|
||||
protected Map<String, ArtifactRepository> systemRepos = new HashMap<>();
|
||||
protected Map<String, ArtifactRepository> customRepos = new HashMap<>();
|
||||
|
||||
private RepositoryRegistrator() {
|
||||
|
||||
}
|
||||
|
||||
public void addRepository(ArtifactRepository repository) {
|
||||
addRepository(repository, true);
|
||||
}
|
||||
public void addRepository(ArtifactRepository repository, boolean httpEnabled) {
|
||||
Map<String, ArtifactRepository> targetMap;
|
||||
String propertyName;
|
||||
if (repository.isSystem()) {
|
||||
targetMap = systemRepos;
|
||||
propertyName = PROP_ENTAXY_SYSTEM_REPO_LIST;
|
||||
// TODO implement for initializer
|
||||
return;
|
||||
} else {
|
||||
targetMap = customRepos;
|
||||
propertyName = PROP_ENTAXY_CUSTOM_REPO_LIST;
|
||||
}
|
||||
|
||||
targetMap.put(repository.getName(), repository);
|
||||
|
||||
String repositoryUrlsResult = calculatePropertyValue(targetMap, httpEnabled);
|
||||
try {
|
||||
setPropertyValue(propertyName, repositoryUrlsResult);
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
log.error("Error updating config", e);
|
||||
} catch (InvalidSyntaxException e) {
|
||||
log.error("Error updating config", e);
|
||||
} catch (Exception e) {
|
||||
log.error("Error updating config", e);
|
||||
}
|
||||
|
||||
targetMap.remove(repository.getName());
|
||||
}
|
||||
|
||||
public void removeRepository(ArtifactRepository repository) {
|
||||
if (repository.isSystem()) {
|
||||
systemRepos.remove(repository.getName());
|
||||
} else {
|
||||
customRepos.remove(repository.getName());
|
||||
}
|
||||
}
|
||||
|
||||
protected String calculatePropertyValue(Map<String, ArtifactRepository> repoMap, boolean httpEnabled) {
|
||||
List<ArtifactRepository> list = new ArrayList<>(repoMap.values());
|
||||
Collections.sort(list, new Comparator<ArtifactRepository>() {
|
||||
|
||||
@Override
|
||||
public int compare(ArtifactRepository o1, ArtifactRepository o2) {
|
||||
return o1.getName().compareToIgnoreCase(o2.getName());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
String resultValue = "";
|
||||
List<String> urlList = new ArrayList<>();
|
||||
for (ArtifactRepository repo : list) {
|
||||
String url = URL_PREFIX.concat(repo.getUrl())
|
||||
.concat("@id=").concat(repo.getName())
|
||||
.concat("@checksum=ignore")
|
||||
.concat(repo.isSnapshotsAllowed() ? "@snapshots" : "");
|
||||
if (!httpEnabled) {
|
||||
url = url.replace("http:", "https:");
|
||||
}
|
||||
urlList.add(url);
|
||||
}
|
||||
resultValue = urlList.stream().collect(Collectors.joining(", "));
|
||||
return resultValue;
|
||||
}
|
||||
|
||||
protected void setPropertyValue(String propertyName, String propertyValue) throws Exception {
|
||||
ConfigRepository configRepository =
|
||||
OSGIUtils.services().ofClass(ConfigRepository.class).waitService(20000).get();
|
||||
|
||||
TypedProperties properties = configRepository.getConfig(REPO_CONFIG_PID);
|
||||
|
||||
String hashKey = propertyName + ".md5";
|
||||
|
||||
String newHash = DigestUtils.md5Hex(propertyValue);
|
||||
String currentHash = properties.getOrDefault(hashKey, "").toString();
|
||||
|
||||
// To avoid extra config rewriting
|
||||
// which may cause config loss while updating
|
||||
if (!newHash.equals(currentHash)) {
|
||||
properties.put(propertyName, propertyValue);
|
||||
properties.put(hashKey, newHash);
|
||||
configRepository.update(REPO_CONFIG_PID, properties);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user