release version 1.11.0
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* blueprint-generator
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2025 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.blueprint.generator;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Blueprint {
|
||||
|
||||
private String name;
|
||||
private byte[] body;
|
||||
|
||||
private Map<String, Object> properties = new HashMap<>();
|
||||
|
||||
public Blueprint(String name, byte[] body) {
|
||||
this.name = name;
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public byte[] getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(byte[] body) {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public Map<String, Object> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Blueprint{" +
|
||||
"name='" + name + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* blueprint-generator
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2025 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.blueprint.generator;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
|
||||
public interface BlueprintGenerator {
|
||||
|
||||
Blueprint createBlueprint(URL templateUrl, String templateName, String systemName, Map<String, String> params)
|
||||
throws Exception;
|
||||
|
||||
Blueprint createBlueprint(String templateName, String systemName, Map<String, String> params)
|
||||
throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* blueprint-generator
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2025 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.blueprint.generator;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.osgi.service.component.annotations.Component;
|
||||
import org.osgi.service.component.annotations.Reference;
|
||||
import org.osgi.service.component.annotations.ReferenceCardinality;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ru.entaxy.base.generator.template.Template;
|
||||
import ru.entaxy.base.generator.template.TemplateAwareGenerator;
|
||||
import ru.entaxy.base.generator.template.TemplateImpl;
|
||||
import ru.entaxy.base.generator.template.TemplateService;
|
||||
import ru.entaxy.esb.platform.runtime.base.connecting.generator.Generated;
|
||||
import ru.entaxy.esb.platform.runtime.base.connecting.generator.Generator;
|
||||
import ru.entaxy.esb.platform.runtime.base.connecting.generator.factory.GeneratorFactory;
|
||||
|
||||
@Component(service = {BlueprintGenerator.class}, immediate = true)
|
||||
public class BlueprintGeneratorImpl implements BlueprintGenerator {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(BlueprintGeneratorImpl.class);
|
||||
private static final String SYSTEM_NAME = "systemName";
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY)
|
||||
protected TemplateService templateService;
|
||||
|
||||
@Override
|
||||
public Blueprint createBlueprint(URL templateUrl, String templateName, String systemName, Map<String, String> params)
|
||||
throws Exception {
|
||||
TemplateImpl template = new TemplateImpl();
|
||||
template.setTemplateName(templateName);
|
||||
template.setTemplateLocation(templateUrl.toString());
|
||||
template.setType("ftl");
|
||||
return createBlueprintWithTemplate(template, systemName, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Blueprint createBlueprint(String templateName, String systemName, Map<String, String> params) throws Exception {
|
||||
Template template = templateService.getTemplateById(templateName);
|
||||
if (template == null) {
|
||||
LOG.error("Template not found: [{}]", templateName);
|
||||
// TODO throw exception
|
||||
return null;
|
||||
}
|
||||
return createBlueprintWithTemplate(template, systemName, params);
|
||||
}
|
||||
|
||||
protected Blueprint createBlueprintWithTemplate(ru.entaxy.base.generator.template.Template template,
|
||||
String systemName, Map<String, String> params) throws Exception {
|
||||
TemplateAwareGenerator generator = GeneratorFactory.createGenerator(template);
|
||||
if (generator == null) {
|
||||
LOG.error("Generator not found for template: [{}]", template.getId());
|
||||
// TODO throw exception
|
||||
return null;
|
||||
}
|
||||
addSystemParam(params, systemName);
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
parameters.putAll(params);
|
||||
Generated result = generator.generate(template,parameters);
|
||||
if ((result == null) || (result.getObject() == null)) {
|
||||
LOG.error("Generator returned null for template: [{}]", template.getId());
|
||||
// TODO throw exception
|
||||
return null;
|
||||
}
|
||||
if (!Generated.GENERATED_TYPE_BLUEPRINT.equals(result.getType())) {
|
||||
LOG.error("Generator returned type [{}], while [{}] is expected for template: [{}]"
|
||||
, result.getType()
|
||||
, Generated.GENERATED_TYPE_BLUEPRINT
|
||||
, template.getId());
|
||||
// TODO throw exception
|
||||
return null;
|
||||
}
|
||||
Blueprint blueprint = new Blueprint(template.getTemplateName(), result.getObject().toString().getBytes());
|
||||
blueprint.getProperties().putAll(result.getProperties());
|
||||
blueprint.getProperties().put("template.name", template.getTemplateName());
|
||||
blueprint.getProperties().put("template.id", template.getId());
|
||||
blueprint.getProperties().put("template.type", template.getType());
|
||||
return blueprint;
|
||||
}
|
||||
|
||||
private void addSystemParam(Map<String, String> params, String systemName) {
|
||||
params.put(SYSTEM_NAME, systemName);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
[#ftl attributes={"generated.type":"blueprint"}]
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
|
||||
|
||||
<bean id="inConnectorCollector" class="ru.entaxy.esb.system.profile.commons.InConnectorCollector"/>
|
||||
|
||||
<bean id="system-profile" class="ru.entaxy.esb.system.registry.systems.profile.impl.defaults.DefaultSystemProfile"
|
||||
activation="eager">
|
||||
<property name="systemName" value="[=systemName]"/>
|
||||
<property name="profileOutput" ref="profileOutput"/>
|
||||
</bean>
|
||||
|
||||
<bean id="profileOutput" class="ru.entaxy.esb.system.profile.commons.profile_output.ProfileOutputImpl"
|
||||
activation="eager">
|
||||
<property name="systemName" value="[=systemName]"/>
|
||||
</bean>
|
||||
|
||||
<service activation="eager" auto-export="interfaces" ref="system-profile"/>
|
||||
|
||||
<reference id="pooledConnectionFactory" interface="javax.jms.ConnectionFactory"/>
|
||||
|
||||
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
|
||||
<property name="connectionFactory" ref="pooledConnectionFactory"/>
|
||||
</bean>
|
||||
|
||||
<camelContext id="profile-[=systemName]" xmlns="http://camel.apache.org/schema/blueprint">
|
||||
<route>
|
||||
<from uri="direct-vm:profile-[=systemName]-enter-point"/>
|
||||
<log message="Message ${headers} send to bridge" loggingLevel="TRACE"/>
|
||||
<toD uri="permission:checkSystemAccessException?objectId=${headers.X-SystemId}&subjectId=[=systemName]"/>
|
||||
<setHeader name="NTX_DestinationPointAfterBridge">
|
||||
<simple>system:[=systemName]</simple>
|
||||
</setHeader>
|
||||
<to uri="jms:queue:entaxy.local.out.[=origin]"/>
|
||||
</route>
|
||||
</camelContext>
|
||||
</blueprint>
|
||||
@@ -0,0 +1,48 @@
|
||||
[#ftl attributes={"generated.type":"blueprint"}]
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
|
||||
|
||||
<reference id="entaxy-broker" interface="org.apache.camel.Component"
|
||||
filter="(connection.name=entaxy-broker)"/>
|
||||
|
||||
<camelContext id="route-[=systemName]" xmlns="http://camel.apache.org/schema/blueprint">
|
||||
<route>
|
||||
<from uri="direct-vm:profile-[=systemName]-exit-point"/>
|
||||
<log message="Message ${headers} send to route" loggingLevel="TRACE"/>
|
||||
|
||||
<when>
|
||||
<simple>${headers.ENTAXY_Destination} == 'nsi'
|
||||
&& ${headers.ENTAXY_DestinationType} == null
|
||||
</simple>
|
||||
<setHeader name="NTX_NSI_Answer">
|
||||
<simple>true</simple>
|
||||
</setHeader>
|
||||
<to uri="entaxy-broker:queue:entaxy.nsi.entry.point?exchangePattern=InOnly"/>
|
||||
</when>
|
||||
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${headers.ENTAXY_DestinationType} == 'system.name'</simple>
|
||||
<toD uri="system:${headers.ENTAXY_Destination}"/>
|
||||
</when>
|
||||
<when>
|
||||
<simple>${headers.ENTAXY_DestinationType} == 'system-group.name'</simple>
|
||||
<toD uri="system-group:${headers.ENTAXY_Destination}"/>
|
||||
</when>
|
||||
<when>
|
||||
<simple>${headers.ENTAXY_DestinationType} == 'queue.name'</simple>
|
||||
<toD uri="entaxy-broker:queue:${headers.ENTAXY_Destination}"/>
|
||||
</when>
|
||||
<when>
|
||||
<simple>${headers.ENTAXY_DestinationType} == 'topic.name'</simple>
|
||||
<toD uri="entaxy-broker:topic:${headers.ENTAXY_Destination}"/>
|
||||
</when>
|
||||
<otherwise>
|
||||
<toD uri="system:${headers.ENTAXY_Destination}"/>
|
||||
</otherwise>
|
||||
</choice>
|
||||
</route>
|
||||
</camelContext>
|
||||
</blueprint>
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"templates":[
|
||||
{
|
||||
"id":"bridge-profile",
|
||||
/* by default:
|
||||
"name":"{id}",
|
||||
"type":"ftl",
|
||||
"path":"DEFAULT_PATH"
|
||||
"filename":"{id}"
|
||||
"fullname":"{id}.{type}",
|
||||
*/
|
||||
"description":"Ftl template for bridge profile"
|
||||
},
|
||||
{
|
||||
"id":"default-route",
|
||||
"description":"Ftl template for default route from profile"
|
||||
},
|
||||
{
|
||||
"id":"profile",
|
||||
"description":"Ftl template for system profile"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
[#ftl attributes={"generated.type":"blueprint"}]
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
|
||||
|
||||
<reference-list id="outConnector"
|
||||
interface="ru.entaxy.esb.system.profile.commons.connectors.out.OutConnector"
|
||||
filter="(systemName=[=systemName])" availability="optional">
|
||||
<reference-listener ref="profileOutput"
|
||||
bind-method="register" unbind-method="unregister"/>
|
||||
</reference-list>
|
||||
|
||||
<reference-list id="inConnector"
|
||||
interface="ru.entaxy.esb.system.profile.commons.connectors.in.InConnector"
|
||||
filter="(systemName=[=systemName])" availability="optional">
|
||||
<reference-listener ref="inConnectorCollector"
|
||||
bind-method="register" unbind-method="unregister"/>
|
||||
</reference-list>
|
||||
|
||||
<bean id="inConnectorCollector" class="ru.entaxy.esb.system.profile.commons.InConnectorCollector"/>
|
||||
|
||||
<bean id="system-profile" class="ru.entaxy.esb.system.registry.systems.profile.impl.defaults.DefaultSystemProfile"
|
||||
activation="eager">
|
||||
<property name="systemName" value="[=systemName]"/>
|
||||
<property name="profileOutput" ref="profileOutput"/>
|
||||
<property name="inConnectorCollector" ref="inConnectorCollector"/>
|
||||
</bean>
|
||||
|
||||
<bean id="profileOutput" class="ru.entaxy.esb.system.profile.commons.profile_output.ProfileOutputImpl"
|
||||
activation="eager">
|
||||
<property name="systemName" value="[=systemName]"/>
|
||||
</bean>
|
||||
|
||||
<service activation="eager" auto-export="interfaces" ref="system-profile"/>
|
||||
|
||||
<reference id="pooledConnectionFactory" interface="javax.jms.ConnectionFactory"/>
|
||||
|
||||
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
|
||||
<property name="connectionFactory" ref="pooledConnectionFactory"/>
|
||||
</bean>
|
||||
|
||||
<camelContext id="profile-[=systemName]" xmlns="http://camel.apache.org/schema/blueprint">
|
||||
|
||||
<route>
|
||||
<from uri="direct-vm:profile-[=systemName]-exit-dispatcher"/>
|
||||
<log message="Message ${headers} send to profile dispatcher" loggingLevel="TRACE"/>
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${headers.NTX_NextPoint} != null</simple>
|
||||
<setProperty name="NTX_Tmp">
|
||||
<simple>${headers.NTX_NextPoint}</simple>
|
||||
</setProperty>
|
||||
<removeHeader headerName="NTX_NextPoint"/>
|
||||
<toD uri="${exchangeProperty.NTX_Tmp}"/>
|
||||
</when>
|
||||
<otherwise>
|
||||
<to uri="direct-vm:profile-[=systemName]-exit-point"/>
|
||||
</otherwise>
|
||||
</choice>
|
||||
</route>
|
||||
|
||||
<route>
|
||||
<from uri="direct-vm:profile-[=systemName]-enter-point"/>
|
||||
<log message="Message ${headers} send to profile output" loggingLevel="TRACE"/>
|
||||
[#-- <choice>--]
|
||||
[#-- <when>--]
|
||||
[#-- <simple>${headers.NTX_Origin} == null</simple>--]
|
||||
[#-- <toD uri="permission:checkSystemAccessException?objectId=${headers.X-SystemId}&subjectId=[=systemName]"/>--]
|
||||
[#-- </when>--]
|
||||
[#-- </choice>--]
|
||||
<to uri="bean:profileOutput?method=sendTo"/>
|
||||
</route>
|
||||
</camelContext>
|
||||
</blueprint>
|
||||
Reference in New Issue
Block a user