ENTAXY-248 release 1.8.1

This commit is contained in:
2022-02-28 15:20:38 +03:00
parent 4d274c4fcc
commit c826adf1db
1958 changed files with 195926 additions and 10280 deletions

View File

@ -7,7 +7,7 @@
<parent>
<groupId>ru.entaxy.esb.system</groupId>
<artifactId>management</artifactId>
<version>1.8.0</version>
<version>1.8.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -25,7 +25,7 @@
<bundle.osgi.import.pkg>
!com.sun.org.apache.xml.internal.dtm.ref,
!org.mapstruct.*,
ru.entaxy.esb.system.management.blueprint.generator,
ru.entaxy.platform.core.blueprint.generator,
ru.entaxy.esb.system.management.bundle.jpa,
ru.entaxy.esb.system.management.bundle.jpa.entity,
ru.entaxy.esb.system.management.bundle.jpa.dto,
@ -70,31 +70,27 @@
<artifactId>connector-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.system.deployer</groupId>
<artifactId>nexus-deployer</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.system.management.bundle.jpa</groupId>
<artifactId>bundle-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<!-- dependency>
<groupId>ru.entaxy.esb.system.management.blueprint.generator</groupId>
<artifactId>blueprint-generator</artifactId>
<version>${project.version}</version>
</dependency-->
<dependency>
<groupId>ru.entaxy.esb.platform.runtime.core</groupId>
<artifactId>artifact-management</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.system.deployer</groupId>
<artifactId>cellar-deployer</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.system.deployer</groupId>
<artifactId>deployer-api</artifactId>
<version>${project.version}</version>
<groupId>
ru.entaxy.esb.platform.runtime.core.management
</groupId>
<artifactId>blueprint-generator-service</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -19,8 +19,8 @@
*/
package ru.entaxy.esb.system.management.bundle.manager;
import ru.entaxy.esb.system.management.blueprint.generator.Blueprint;
import ru.entaxy.esb.system.management.bundle.jpa.dto.BundleDto;
import ru.entaxy.platform.core.blueprint.generator.Blueprint;
import java.net.URL;
import java.util.Map;

View File

@ -19,18 +19,25 @@
*/
package ru.entaxy.esb.system.management.bundle.manager;
import ru.entaxy.esb.system.deployer.api.BundleRepository;
import ru.entaxy.esb.system.deployer.cellar.deployer.BundleController;
import ru.entaxy.esb.system.management.blueprint.generator.Blueprint;
import ru.entaxy.esb.system.management.blueprint.generator.BlueprintGenerator;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import org.osgi.framework.Constants;
import ru.entaxy.esb.system.management.bundle.jpa.BundleService;
import ru.entaxy.esb.system.management.bundle.jpa.dto.BundleDto;
import ru.entaxy.esb.system.management.bundle.jpa.dto.BundleStatus;
import ru.entaxy.esb.system.management.bundle.jpa.entity.BundleType;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import ru.entaxy.platform.base.support.CommonUtils;
import ru.entaxy.platform.core.artifact.Artifact;
import ru.entaxy.platform.core.artifact.Artifacts;
import ru.entaxy.platform.core.artifact.CapabilityDescriptor;
import ru.entaxy.platform.core.artifact.DeployedArtifact;
import ru.entaxy.platform.core.artifact.legacy.BundleController;
import ru.entaxy.platform.core.artifact.service.ArtifactService;
import ru.entaxy.platform.core.blueprint.generator.Blueprint;
import ru.entaxy.platform.core.blueprint.generator.BlueprintGenerator;
public class BundleManagerImpl implements BundleManager {
@ -40,7 +47,9 @@ public class BundleManagerImpl implements BundleManager {
private BlueprintGenerator blueprintGenerator;
private BundleController bundleController;
private BundleRepository bundleRepository;
// private BundleRepository bundleRepository;
private ArtifactService artifactService;
private BundleService bundleService;
@ -78,7 +87,8 @@ public class BundleManagerImpl implements BundleManager {
private BundleDto doInstallBundle(String bundleName, String bundleType, String bundleVersion,
Map<String, String> param, boolean start) throws Exception {
BundleDto bundle = new BundleDto(bundleType + "-" + bundleName, BundleType.getValueOf(bundleType.toUpperCase()));
BundleDto bundle = new BundleDto(getFullBundleNameByNameAndType(bundleName, bundleType)
, BundleType.getValueOf(bundleType.toUpperCase()));
Blueprint blueprint = blueprintGenerator.createBlueprint(bundleType, bundleName, param);
installAndStartBundle(bundleType, bundleVersion, bundle, blueprint, start);
return bundle;
@ -96,7 +106,8 @@ public class BundleManagerImpl implements BundleManager {
private BundleDto doInstallBundle(String bundleName, String bundleType, String bundleVersion, Blueprint blueprint, boolean start)
throws Exception {
BundleDto bundle = new BundleDto(bundleType + "-" + bundleName, BundleType.getValueOf(bundleType.toUpperCase()));
BundleDto bundle = new BundleDto(getFullBundleNameByNameAndType(bundleName, bundleType)
, BundleType.getValueOf(bundleType.toUpperCase()));
installAndStartBundle(bundleType, bundleVersion, bundle, blueprint, start);
return bundle;
}
@ -113,7 +124,8 @@ public class BundleManagerImpl implements BundleManager {
private BundleDto doInstallBundle(String bundleName, String bundleType, String bundleVersion, boolean start)
throws Exception {
BundleDto bundle = new BundleDto(bundleType + "-" + bundleName, BundleType.getValueOf(bundleType.toUpperCase()));
BundleDto bundle = new BundleDto(bundleType + "-" + bundleName
, BundleType.getValueOf(bundleType.toUpperCase()));
Blueprint blueprint = blueprintGenerator.createBlueprint(bundleType, bundleName, new HashMap<>());
installAndStartBundle(bundleType, bundleVersion, bundle, blueprint, start);
return bundle;
@ -121,26 +133,32 @@ public class BundleManagerImpl implements BundleManager {
@Override
public BundleDto startBundle(BundleDto bundle) throws Exception {
bundle.setStatus(BundleStatus.valueOf(bundleController.startBundle(bundle.getBundleName())));
bundle.setStatus(BundleStatus.valueOf(
CommonUtils.getValid(bundleController.startBundle(bundle.getBundleName()), "Resolved").toUpperCase()
));
return bundle;
}
@Override
public BundleDto stopBundle(BundleDto bundle) throws Exception {
bundle.setStatus(BundleStatus.valueOf(bundleController.stopBundle(bundle.getBundleName())));
return bundle;
bundle.setStatus(BundleStatus.valueOf(
CommonUtils.getValid(bundleController.stopBundle(bundle.getBundleName()),"Resolved").toUpperCase()
));
return bundle;
}
@Override
public void uninstallBundle(String bundleName, String type, String bundleVersion) throws Exception {
bundleRepository.delete(GROUP_ID + type, bundleVersion, type + "-" + bundleName, XML_EXTENSION);
bundleController.uninstallBundle(type + "-" + bundleName);
// TODO decide if really need to delete artifacts
// bundleRepository.delete(GROUP_ID + type, bundleVersion, type + "-" + bundleName, XML_EXTENSION);
bundleController.uninstallBundle(getFullBundleNameByNameAndType(bundleName, type));
}
@Override
public void uninstallBundleByName(String bundleName, String type, String bundleVersion) throws Exception {
bundleRepository.delete(GROUP_ID + type, bundleVersion, bundleName, XML_EXTENSION);
// TODO decide if really need to delete artifacts
// bundleRepository.delete(GROUP_ID + type, bundleVersion, bundleName, XML_EXTENSION);
bundleController.uninstallBundle(bundleName);
}
@ -162,8 +180,45 @@ public class BundleManagerImpl implements BundleManager {
private void installAndStartBundle(String bundleType, String bundleVersion, BundleDto bundle, Blueprint blueprint, boolean start)
throws Exception {
bundle.setBundleUrl(bundleRepository.deployBlueprint(GROUP_ID + bundleType, bundleVersion, bundle.getBundleName(),
XML_EXTENSION, blueprint.getBody()));
Artifact artifact = Artifacts.create(Artifact.ARTIFACT_CATEGORY_BLUEPRINT);
artifact.getCoordinates()
.groupId(Artifact.DEFAULT_RUNTIME_GROUP_ID + "." + bundleType)
.artifactId(bundle.getBundleName())
.version(bundleVersion);
artifact.setContent(blueprint.getBody());
// TODO remove hardcode after blueprint-generator is removed
// and all the operations are switched to artifact-management
CapabilityDescriptor descriptor = artifact.provideCapability(artifact.getCoordinates().getGroupId())
.attribute("name", bundle.getBundleName().replace(bundleType + "-", ""))
.attribute("bundleName", bundle.getBundleName());
if (blueprint.getProperties().containsKey("systemName")) {
Object val = blueprint.getProperties().get("systemName");
if (val != null)
descriptor.attribute("system", val.toString());
}
if (blueprint.getProperties().containsKey("template.id")) {
Object val = blueprint.getProperties().get("template.id");
Object val2 = blueprint.getProperties().get("template.name");
if (val != null)
descriptor.attribute("templateId", val.toString());
else
descriptor.attribute("templateId", val2.toString());
descriptor.attribute("templateName", val2.toString());
}
DeployedArtifact deployedArtifact = artifactService.deployShared(artifact);
bundle.setBundleUrl("blueprint:" + deployedArtifact.getLocation());
String finalBundleName = deployedArtifact.getArtifact()
.getProperties().getOrDefault(Constants.BUNDLE_NAME
, deployedArtifact.getArtifact()
.getProperties().getOrDefault(Constants.BUNDLE_SYMBOLICNAME, bundle.getBundleName())).toString();
bundle.setBundleName(finalBundleName);
// bundle.setBundleUrl(bundleRepository.deployBlueprint(GROUP_ID + bundleType, bundleVersion, bundle.getBundleName(),
// XML_EXTENSION, blueprint.getBody()));
try {
if (start) {
bundle.setStatus(BundleStatus.valueOf(
@ -172,12 +227,17 @@ public class BundleManagerImpl implements BundleManager {
bundleController.installBundle(bundle.getBundleUrl());
}
} catch (Exception ex) {
bundleRepository.delete(GROUP_ID + bundleType, bundleVersion, bundle.getBundleName(),
XML_EXTENSION);
// TODO decide if we really need to delete artifact from repository
// bundleRepository.delete(GROUP_ID + bundleType, bundleVersion, bundle.getBundleName(),
// XML_EXTENSION);
throw ex;
}
}
protected String getFullBundleNameByNameAndType(String bundleName, String bundleType) {
return Artifact.DEFAULT_RUNTIME_GROUP_ID + "." + bundleType + "." + bundleType + "-" + bundleName;
}
public void setBundleService(BundleService bundleService) {
this.bundleService = bundleService;
}
@ -190,8 +250,15 @@ public class BundleManagerImpl implements BundleManager {
this.bundleController = bundleController;
}
/*
public void setBundleRepository(BundleRepository bundleRepository) {
this.bundleRepository = bundleRepository;
}
*/
public void setArtifactService(ArtifactService artifactService) {
this.artifactService = artifactService;
this.bundleController = this.artifactService.installers().cluster().bundleController();
}
}

View File

@ -27,30 +27,37 @@
<bean id="bundleManager" class="ru.entaxy.esb.system.management.bundle.manager.BundleManagerImpl">
<property name="blueprintGenerator" ref="blueprintGenerator"/>
<property name="bundleController" ref="bundleController"/>
<property name="bundleRepository" ref="bundleRepository"/>
<!-- property name="bundleController" ref="bundleController"/ -->
<!-- property name="bundleRepository" ref="bundleRepository"/ -->
<property name="bundleService" ref="bundleService"/>
<property name="artifactService" ref="artifactService"/>
</bean>
<service ref="bundleManager" interface="ru.entaxy.esb.system.management.bundle.manager.BundleManager"/>
<reference id="blueprintGenerator"
interface="ru.entaxy.esb.system.management.blueprint.generator.BlueprintGenerator"
interface="ru.entaxy.platform.core.blueprint.generator.BlueprintGenerator"
timeout="30000"
availability="mandatory"/>
<reference id="bundleController"
interface="ru.entaxy.esb.system.deployer.cellar.deployer.BundleController"
<!-- reference id="bundleController"
interface="ru.entaxy.platform.core.artifact.legacy.BundleController"
timeout="30000"
availability="mandatory"/>
availability="mandatory"/ -->
<reference id="bundleRepository"
<!-- reference id="bundleRepository"
interface="ru.entaxy.esb.system.deployer.api.BundleRepository"
timeout="30000"
availability="mandatory"/>
availability="mandatory"/ -->
<reference id="bundleService"
interface="ru.entaxy.esb.system.management.bundle.jpa.BundleService"
timeout="30000"
availability="mandatory"/>
<reference id="artifactService"
interface="ru.entaxy.platform.core.artifact.service.ArtifactService"
timeout="30000"
availability="mandatory"/>
</blueprint>