initial public commit

This commit is contained in:
2021-09-06 17:46:59 +03:00
commit b744b08829
824 changed files with 91593 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
/*-
* ~~~~~~licensing~~~~~~
* bridge-profile-manager
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.management.bridge.profile.manager;
import ru.entaxy.esb.system.management.bridge.profile.manager.dto.BridgeProfileDto;
import ru.entaxy.esb.system.management.bridge.profile.manager.sender.BridgeProfileType;
import ru.entaxy.esb.system.management.bundle.jpa.dto.BundleDto;
import java.util.List;
public interface BridgeProfileManager {
BundleDto installBridgeProfile(BridgeProfileDto bridgeProfileDto) throws Exception;
BundleDto startBridgeProfile(BridgeProfileDto bridgeProfileDto) throws Exception;
BundleDto stopBridgeProfile(BridgeProfileDto bridgeProfileDto) throws Exception;
BridgeProfileType getBridgeProfile(BridgeProfileDto bridgeProfileDto) throws Exception;
List<BridgeProfileType> getBridgeProfiles() throws Exception;
BundleDto uninstallBridgeProfile(BridgeProfileDto bridgeProfileDto) throws Exception;
List<String> getListEsb() throws Exception;
}

View File

@@ -0,0 +1,136 @@
/*-
* ~~~~~~licensing~~~~~~
* bridge-profile-manager
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.management.bridge.profile.manager;
import com.google.gson.Gson;
import ru.entaxy.esb.system.common.exception.EsbNotFound;
import ru.entaxy.esb.system.jpa.SystemService;
import ru.entaxy.esb.system.jpa.entity.System;
import ru.entaxy.esb.system.management.bridge.profile.manager.dto.BridgeProfileDto;
import ru.entaxy.esb.system.management.bridge.profile.manager.mapper.BridgeProfileMapper;
import ru.entaxy.esb.system.management.bridge.profile.manager.sender.BridgeProfileSender;
import ru.entaxy.esb.system.management.bridge.profile.manager.sender.BridgeProfileType;
import ru.entaxy.esb.system.management.bridge.profile.manager.service.BridgeService;
import ru.entaxy.esb.system.management.bundle.jpa.dto.BundleDto;
import java.util.List;
public class BridgeProfileManagerImpl implements BridgeProfileManager {
private static final Gson gson = new Gson();
private BridgeProfileSender bridgeProfileSender;
private SystemService systemService;
private BridgeProfileMapper bridgeProfileMapper;
private BridgeService bridgeService;
@Override
public BundleDto installBridgeProfile(BridgeProfileDto bridgeProfileDto) throws Exception {
System system = systemService.getByUuid(bridgeProfileDto.getProfileUuid());
systemService.addExportAllowed(system, bridgeProfileDto.getEsbName());
BundleDto bundleDto;
try {
checkOnConnectEsbBridge(bridgeProfileDto.getEsbName());
bundleDto = gson.fromJson(sendOnOtherEsb(system, bridgeProfileDto.getEsbName(),
"create"), BundleDto.class);
} catch (Exception ex) {
systemService.removeExportAllowed(system, bridgeProfileDto.getEsbName());
throw ex;
}
return bundleDto;
}
@Override
public BundleDto startBridgeProfile(BridgeProfileDto bridgeProfileDto) throws Exception {
System system = systemService.getByUuid(bridgeProfileDto.getProfileUuid());
checkOnConnectEsbBridge(bridgeProfileDto.getEsbName());
systemService.addExportAllowed(system, bridgeProfileDto.getEsbName());
BundleDto bundleDto = gson.fromJson(sendOnOtherEsb(system, bridgeProfileDto.getEsbName(),
"start"), BundleDto.class);
return bundleDto;
}
@Override
public BundleDto stopBridgeProfile(BridgeProfileDto bridgeProfileDto) throws Exception {
System system = systemService.getByUuid(bridgeProfileDto.getProfileUuid());
checkOnConnectEsbBridge(bridgeProfileDto.getEsbName());
systemService.addExportAllowed(system, bridgeProfileDto.getEsbName());
BundleDto bundleDto = gson.fromJson(sendOnOtherEsb(system, bridgeProfileDto.getEsbName(),
"stop"), BundleDto.class);
return bundleDto;
}
@Override
public BridgeProfileType getBridgeProfile(BridgeProfileDto request) throws Exception {
System system = systemService.getByUuid(request.getProfileUuid());
checkOnConnectEsbBridge(request.getEsbName());
systemService.addExportAllowed(system, request.getEsbName());
BridgeProfileType response = gson.fromJson(sendOnOtherEsb(system, request.getEsbName(),
"get"), BridgeProfileType.class);
return response;
}
@Override
public List<BridgeProfileType> getBridgeProfiles() throws Exception {
return bridgeProfileMapper.toBridgeProfileTypes(systemService.getFullSystemListByNotOrigin());
}
@Override
public BundleDto uninstallBridgeProfile(BridgeProfileDto bridgeProfileDto) throws Exception {
System system = systemService.getByUuid(bridgeProfileDto.getProfileUuid());
checkOnConnectEsbBridge(bridgeProfileDto.getEsbName());
systemService.removeExportAllowed(system, bridgeProfileDto.getEsbName());
BundleDto bundleDto = gson.fromJson(sendOnOtherEsb(system, bridgeProfileDto.getEsbName(),
"uninstall"), BundleDto.class);
return bundleDto;
}
@Override
public List<String> getListEsb() throws Exception {
return bridgeService.getEsbList();
}
private String sendOnOtherEsb(System system, String exportAllowed, String command) {
return bridgeProfileSender.sendOnOtherEsb(bridgeProfileMapper.toBridgeProfileType(system),
exportAllowed, command);
}
public void checkOnConnectEsbBridge(String esbName) {
if (!bridgeService.getEsbList().contains(esbName)) {
throw new EsbNotFound("ESB not found {" + esbName + "}");
}
}
public void setSystemService(SystemService systemService) {
this.systemService = systemService;
}
public void setBridgeProfileMapper(BridgeProfileMapper bridgeProfileMapper) {
this.bridgeProfileMapper = bridgeProfileMapper;
}
public void setBridgeService(BridgeService bridgeService) {
this.bridgeService = bridgeService;
}
public void setBridgeProfileSender(BridgeProfileSender bridgeProfileSender) {
this.bridgeProfileSender = bridgeProfileSender;
}
}

View File

@@ -0,0 +1,69 @@
/*-
* ~~~~~~licensing~~~~~~
* bridge-profile-manager
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.management.bridge.profile.manager.dto;
public class BridgeProfileDto {
private String profileUuid;
private String esbName;
private String status;
private String origin;
private String createdBy;
public String getProfileUuid() {
return profileUuid;
}
public void setProfileUuid(String profileUuid) {
this.profileUuid = profileUuid;
}
public String getEsbName() {
return esbName;
}
public void setEsbName(String esbName) {
this.esbName = esbName;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getOrigin() {
return origin;
}
public void setOrigin(String origin) {
this.origin = origin;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
}

View File

@@ -0,0 +1,61 @@
/*-
* ~~~~~~licensing~~~~~~
* bridge-profile-manager
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.management.bridge.profile.manager.mapper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import ru.entaxy.esb.system.jpa.entity.System;
import ru.entaxy.esb.system.management.bridge.profile.manager.sender.BridgeProfileType;
import ru.entaxy.esb.system.management.bundle.jpa.dto.BundleDto;
import ru.entaxy.esb.system.management.bundle.jpa.entity.BundleEntity;
import java.util.List;
@Mapper
public interface BridgeProfileMapper {
@Mappings({
@Mapping(source = "bundleName", target = "name"),
@Mapping(source = "bundleUrl", target = "url"),
})
BundleEntity toBundleEntity(BundleDto bundle);
@Mappings({
@Mapping(target = "bundleName", source = "name"),
@Mapping(target = "bundleUrl", source = "url"),
})
BundleDto toBundleDto(BundleEntity bundle);
@Mappings({
@Mapping(source = "name", target = "profileName"),
@Mapping(source = "bundleEntity.status", target = "status"),
})
BridgeProfileType toBridgeProfileType(System system);
@Mappings({
@Mapping(source = "profileName", target = "name"),
@Mapping(target = "createDate", expression = "java(new java.util.Date())"),
@Mapping(source = "status", target = "bundleEntity.status"),
})
System toSystemEntity(BridgeProfileType bridgeProfileType);
List<BridgeProfileType> toBridgeProfileTypes(List<System> systemList);
}

View File

@@ -0,0 +1,35 @@
/*-
* ~~~~~~licensing~~~~~~
* bridge-profile-manager
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.management.bridge.profile.manager.recipient;
public interface BridgeProfileRecipientManager {
String installBridgeProfile(String json, String origin) throws Exception;
String startBridgeProfile(String json, String origin) throws Exception;
String stopBridgeProfile(String json, String origin) throws Exception;
String getBridgeProfile(String json, String origin) throws Exception;
String uninstallBridgeProfile(String json, String origin) throws Exception;
void restore() throws Exception;
}

View File

@@ -0,0 +1,152 @@
/*-
* ~~~~~~licensing~~~~~~
* bridge-profile-manager
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.management.bridge.profile.manager.recipient;
import com.google.gson.Gson;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import ru.entaxy.esb.system.jpa.SystemService;
import ru.entaxy.esb.system.jpa.entity.System;
import ru.entaxy.esb.system.management.bridge.profile.manager.mapper.BridgeProfileMapper;
import ru.entaxy.esb.system.management.bridge.profile.manager.sender.BridgeProfileType;
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.manager.BundleManager;
import java.io.IOException;
import java.util.HashMap;
public class BridgeProfileRecipientManagerImpl implements BridgeProfileRecipientManager {
private static final Log LOG = LogFactory.getLog(BridgeProfileRecipientManagerImpl.class);
private static final String BRIDGE_PROFILE = "bridge-profile";
private static final String ORIGIN = "origin";
private static final Gson gson = new Gson();
private boolean isRestoreFromDB;
private BundleManager bundleManager;
private SystemService systemService;
private BridgeProfileMapper bridgeProfileMapper;
@Override
public String installBridgeProfile(String json, String origin) throws Exception {
System system = createSystem(gson.fromJson(json, BridgeProfileType.class), origin);
BundleDto bundle = bundleManager.installAndStartBundle(system.getName(), BRIDGE_PROFILE,
String.valueOf(system.getVersion()), getParam(origin));
systemService.setBundleEntity(system, bridgeProfileMapper.toBundleEntity(bundle));
return gson.toJson(bundle);
}
@Override
public String startBridgeProfile(String json, String origin) throws Exception {
BridgeProfileType bridgeProfileType = gson.fromJson(json, BridgeProfileType.class);
System system = systemService.getByUuid(bridgeProfileType.getUuid());
BundleDto bundle = bundleManager.startBundle(bridgeProfileMapper.toBundleDto(system.getBundleEntity()));
systemService.setBundleEntity(system, bridgeProfileMapper.toBundleEntity(bundle));
return gson.toJson(bundle);
}
@Override
public String stopBridgeProfile(String json, String origin) throws Exception {
BridgeProfileType bridgeProfileType = gson.fromJson(json, BridgeProfileType.class);
System system = systemService.getByUuid(bridgeProfileType.getUuid());
BundleDto bundle = bundleManager.stopBundle(bridgeProfileMapper.toBundleDto(system.getBundleEntity()));
systemService.setBundleEntity(system, bridgeProfileMapper.toBundleEntity(bundle));
return gson.toJson(bundle);
}
@Override
public String getBridgeProfile(String json, String origin) throws Exception {
BridgeProfileType bridgeProfileType = gson.fromJson(json, BridgeProfileType.class);
System system = systemService.getByUuid(bridgeProfileType.getUuid());
return gson.toJson(bridgeProfileMapper.toBridgeProfileType(system));
}
@Override
public String uninstallBridgeProfile(String json, String origin) throws Exception {
BridgeProfileType bridgeProfileType = gson.fromJson(json, BridgeProfileType.class);
System system = systemService.getByUuid(bridgeProfileType.getUuid());
bundleManager.uninstallBundle(system.getName(), BRIDGE_PROFILE,
String.valueOf(system.getVersion()));
systemService.remove(system);
return gson.toJson(new BundleDto(system.getName(), BundleStatus.UNINSTALL));
}
private HashMap<String, String> getParam(String origin) {
HashMap<String, String> param = new HashMap<>();
param.put(ORIGIN, origin);
return param;
}
private System createSystem(BridgeProfileType bridgeProfileType, String origin) {
System system = bridgeProfileMapper.toSystemEntity(bridgeProfileType);
system.setOrigin(origin);
system.setBundleEntity(null);
return systemService.create(system);
}
@Override
public void restore() throws Exception {
if (!isRestoreFromDB)
return;
for (System system : systemService.getSystemList()) {
if (system.getOrigin() != null && !system.getOrigin().isEmpty()) {
try {
LOG.info("Restore bridge profile of system " + system.getName());
bundleManager.restore(bridgeProfileMapper.toBundleDto(system.getBundleEntity()));
} catch (IOException e) {
LOG.warn("Recreate bridge profile of system " + system.getName());
restoreProfile(system);
}
} else {
LOG.info("No bridge brofile founded in system");
}
}
}
private void restoreProfile(System system) throws Exception {
BundleDto bundle = bundleManager.installBundle(system.getName(), BRIDGE_PROFILE,
String.valueOf(system.getVersion()), getParam(system.getOrigin()));
bundle.setStatus(bridgeProfileMapper.toBundleDto(system.getBundleEntity()).getStatus());
bundleManager.checkCurrentBundleStatus(bundle);
systemService.setBundleEntity(system, bridgeProfileMapper.toBundleEntity(bundle));
}
public void setBundleManager(BundleManager bundleManager) {
this.bundleManager = bundleManager;
}
public void setSystemService(SystemService systemService) {
this.systemService = systemService;
}
public void setBridgeProfileMapper(BridgeProfileMapper bridgeProfileMapper) {
this.bridgeProfileMapper = bridgeProfileMapper;
}
public void setIsRestoreFromDB(String isRestoreFromDB) {
this.isRestoreFromDB = Boolean.parseBoolean(isRestoreFromDB);
}
}

View File

@@ -0,0 +1,25 @@
/*-
* ~~~~~~licensing~~~~~~
* bridge-profile-manager
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.management.bridge.profile.manager.sender;
public interface BridgeProfileSender {
String sendOnOtherEsb(BridgeProfileType bridgeProfileType, String esbName, String command);
}

View File

@@ -0,0 +1,63 @@
/*-
* ~~~~~~licensing~~~~~~
* bridge-profile-manager
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.management.bridge.profile.manager.sender;
import com.google.gson.Gson;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.ExchangeBuilder;
public class BridgeProfileSenderImpl implements BridgeProfileSender {
private static final String HEADER_BRIDGE_NAME = "NTX_Bridge";
private static final String HEADER_COMMAND = "NTX_CommandBridgeProfileManager";
private static final String HEADER_DESTINATION_SYSTEM = "NTX_DestinationQueueAfterBridge";
private static final Gson gson = new Gson();
private CamelContext context;
@Override
public String sendOnOtherEsb(BridgeProfileType bridgeProfileType, String esbName, String command) {
Exchange exchange = ExchangeBuilder.anExchange(context)
.withHeader(HEADER_DESTINATION_SYSTEM, "profile-controller-route")
.withHeader(HEADER_BRIDGE_NAME, esbName)
.withHeader(HEADER_COMMAND, command)
.withBody(gson.toJson(bridgeProfileType))
.build();
ProducerTemplate template = exchange.getContext().createProducerTemplate();
template.send("direct-vm:send-message", exchange);
return exchange.getOut() != null && exchange.getOut().getBody() != null ?
exchange.getOut().getBody().toString() : null;
}
public CamelContext getContext() {
return context;
}
public void setContext(CamelContext context) {
this.context = context;
}
}

View File

@@ -0,0 +1,116 @@
/*-
* ~~~~~~licensing~~~~~~
* bridge-profile-manager
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.management.bridge.profile.manager.sender;
import java.io.Serializable;
public class BridgeProfileType implements Serializable {
private String uuid;
private String profileName;
private String status;
private String description;
private String version;
private String createdBy;
private String createdDate;
private String editedBy;
private String editedDate;
private String origin;
public String getProfileName() {
return profileName;
}
public void setProfileName(String profileName) {
this.profileName = profileName;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public String getCreatedDate() {
return createdDate;
}
public void setCreatedDate(String createdDate) {
this.createdDate = createdDate;
}
public String getEditedBy() {
return editedBy;
}
public void setEditedBy(String editedBy) {
this.editedBy = editedBy;
}
public String getEditedDate() {
return editedDate;
}
public void setEditedDate(String editedDate) {
this.editedDate = editedDate;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getOrigin() {
return origin;
}
public void setOrigin(String origin) {
this.origin = origin;
}
}

View File

@@ -0,0 +1,27 @@
/*-
* ~~~~~~licensing~~~~~~
* bridge-profile-manager
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.management.bridge.profile.manager.service;
import java.util.List;
public interface BridgeService {
List<String> getEsbList();
}

View File

@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~~~~~~licensing~~~~~~
bridge-profile-manager
==========
Copyright (C) 2020 - 2021 EmDev LLC
==========
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
~~~~~~/licensing~~~~~~
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<cm:property-placeholder persistent-id="ru.entaxy.esb" update-strategy="reload">
<cm:default-properties>
<cm:property name="is.restore.from.db" value="true"/>
</cm:default-properties>
</cm:property-placeholder>
<reference id="pooledConnectionFactory" interface="javax.jms.ConnectionFactory"/>
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="pooledConnectionFactory"/>
</bean>
<bean id="bridgeProfileManager"
class="ru.entaxy.esb.system.management.bridge.profile.manager.BridgeProfileManagerImpl">
<property name="systemService" ref="systemService"/>
<property name="bridgeService" ref="bridgeService"/>
<property name="bridgeProfileMapper" ref="bridgeProfileMapper"/>
<property name="bridgeProfileSender" ref="bridgeProfileSender"/>
</bean>
<bean id="bridgeProfileRecipientManager"
class="ru.entaxy.esb.system.management.bridge.profile.manager.recipient.BridgeProfileRecipientManagerImpl"
init-method="restore">
<property name="isRestoreFromDB" value="${is.restore.from.db}"/>
<property name="systemService" ref="systemService"/>
<property name="bundleManager" ref="bundleManager"/>
<property name="bridgeProfileMapper" ref="bridgeProfileMapper"/>
</bean>
<service ref="bridgeProfileManager"
interface="ru.entaxy.esb.system.management.bridge.profile.manager.BridgeProfileManager"/>
<bean id="bridgeProfileMapper"
class="ru.entaxy.esb.system.management.bridge.profile.manager.mapper.BridgeProfileMapperImpl"/>
<bean id="bridgeProfileSender"
class="ru.entaxy.esb.system.management.bridge.profile.manager.sender.BridgeProfileSenderImpl">
<property name="context" ref="system-management-service"/>
</bean>
<reference id="bridgeService" interface="ru.entaxy.esb.system.management.bridge.profile.manager.service.BridgeService"
timeout="30000"
availability="optional"/>
<reference id="systemService"
interface="ru.entaxy.esb.system.jpa.SystemService"
timeout="30000"
availability="mandatory"/>
<reference id="bundleManager"
interface="ru.entaxy.esb.system.management.bundle.manager.BundleManager"
timeout="30000"
availability="mandatory"/>
<camelContext id="system-management-service" xmlns="http://camel.apache.org/schema/blueprint">
<route id="direct-profile-controller-route">
<from uri="direct-vm:send-message"/>
<setHeader name="NTX_ExchangePattern">
<simple>InOut</simple>
</setHeader>
<toD uri="jms:queue:entaxy.local.out.${headers.NTX_Bridge}?exchangePattern=InOut"/>
</route>
<route id="profile-controller-route">
<from uri="jms:queue:entaxy.profile.controller.route"/>
<choice>
<when>
<simple>${headers.NTX_CommandBridgeProfileManager} == "create"</simple>
<to uri="bean:bridgeProfileRecipientManager?
method=installBridgeProfile(${body}, ${headers.NTX_Origin})"/>
</when>
<when>
<simple>${headers.NTX_CommandBridgeProfileManager} == "start"</simple>
<to uri="bean:bridgeProfileRecipientManager?
method=startBridgeProfile(${body}, ${headers.NTX_Origin})"/>
</when>
<when>
<simple>${headers.NTX_CommandBridgeProfileManager} == "stop"</simple>
<to uri="bean:bridgeProfileRecipientManager?
method=stopBridgeProfile(${body}, ${headers.NTX_Origin})"/>
</when>
<when>
<simple>${headers.NTX_CommandBridgeProfileManager} == "uninstall"</simple>
<to uri="bean:bridgeProfileRecipientManager?
method=uninstallBridgeProfile(${body})"/>
</when>
<when>
<simple>${headers.NTX_CommandBridgeProfileManager} == "get"</simple>
<to uri="bean:bridgeProfileRecipientManager?
method=getBridgeProfile(${body})"/>
</when>
</choice>
</route>
</camelContext>
</blueprint>