ENTAXY-480 release version 1.8.3

This commit is contained in:
2023-08-03 04:45:45 +03:00
parent 5844a2e5cf
commit 3cc15f7459
236 changed files with 21106 additions and 0 deletions

View File

@ -0,0 +1,339 @@
{
"factory": {
"id": "common-system-profile",
"type": "entaxy.runtime.profile",
"description": "Factory common-system-profile of entaxy.runtime.profile",
"displayName": "System profile",
"isAbstract": false
},
"entaxy.runtime.profile": {
"profileType": "SYSTEM"
},
"fields": {
"__objectId": {
"type": "String",
"required": true,
"isHidden": true,
"defaultValue": {
"@CALCULATED": {
"expression": "${properties.systemName}",
"targetPath": "$.objectId",
"removeResolved": true,
"lazy": false
}
}
},
"systemName": {
"displayName": "System Name",
"type": "String",
"required": true,
"immutable": true,
"group": "general"
},
"description": {
"displayName": "Description",
"type": "String",
"group": "general"
},
"profileProperties": {
"type": "Map",
"required": true,
"isHidden": true,
"defaultValue": {
"profile": {
"@CALCULATED": {
"expression": "${properties.systemName}",
"lazy": true
}
}
}
},
"in-flow-pre-route": {
"displayName": "In-flow pre-route",
"type": "xml:route",
"required": true,
"group": "in-flow",
"@RESOURCE": {
"provider": "entaxy-file-internal",
"endType": "String",
"format": "base64",
"preprocess":[
{
"processor": "xslt",
"source":"entaxy-file-internal:factories/common-system-profile/profile-pre-route.xslt",
"parameters": {
"profileName": {
"@CALCULATED": {
"expression": "${#OWNER#.properties.systemName}",
"lazy": false
}
}
}
},
{
"processor": "xslt",
"source":"entaxy-file-internal:routes-common/common-components.xslt",
"parameters": {
"profileName": {
"@CALCULATED": {
"expression": "${#OWNER#.properties.systemName}",
"lazy": false
}
}
}
}
]
},
"defaultValue": {
"@RESOURCE": {
"provider": "entaxy-file-internal",
"location": "factories/common-system-profile/in-flow-pre-route.xml",
"endType": "String",
"format": "base64"
}
},
"config": {
"scope": "public"
}
},
"out-flow-pre-route": {
"displayName": "Out-flow pre-route",
"type": "xml:route",
"required": true,
"group": "out-flow",
"@RESOURCE": {
"provider": "entaxy-file-internal",
"endType": "String",
"format": "base64",
"preprocess":[
{
"processor": "xslt",
"source":"entaxy-file-internal:factories/common-system-profile/profile-pre-route.xslt",
"parameters": {
"profileName": {
"@CALCULATED": {
"expression": "${#OWNER#.properties.systemName}",
"lazy": false
}
}
}
},
{
"processor": "xslt",
"source":"entaxy-file-internal:routes-common/common-components.xslt",
"parameters": {
"profileName": {
"@CALCULATED": {
"expression": "${#OWNER#.properties.systemName}",
"lazy": false
}
}
}
}
]
},
"defaultValue": {
"@RESOURCE": {
"provider": "entaxy-file-internal",
"location": "factories/common-system-profile/out-flow-pre-route.xml",
"endType": "String",
"format": "base64"
}
},
"config": {
"scope": "public"
}
},
"connector-selector": {
"displayName": "Output connector selector",
"type": "xml:route",
"required": true,
"group": "out-flow",
"@RESOURCE": {
"provider": "entaxy-file-internal",
"endType": "String",
"format": "base64",
"preprocess":[
{
"processor": "saxon",
"source":"entaxy-file-internal:factories/common-system-profile/out-flow-connector-selector.xslt",
"parameters": {
"profileName": {
"@CALCULATED": {
"expression": "${#OWNER#.properties.systemName}",
"lazy": false
}
}
}
}
]
},
"defaultValue": {
"@RESOURCE": {
"provider": "entaxy-file-internal",
"location": "factories/common-system-profile/out-flow-connector-selector.xml",
"endType": "String",
"format": "base64"
}
},
"config": {
"scope": "public"
}
},
/* TO_REMOVE */
"useDefaultRoute": {
"displayName": "Use Default Route",
"type": "Boolean",
"required": true,
"isHidden": true,
"defaultValue": true,
"fixedValue": true,
"group": "in-flow"
},
"defaultRouteContent": {
"displayName": "Default profile route",
"type": "xml:route",
"required": true,
"group": "in-flow",
"defaultValue": {
"@RESOURCE": {
"provider": "entaxy-file-internal",
"location": "factories/default-route-2/default-route.xml",
"endType": "String",
"format": "base64"
}
},
"@FACADE": {
"useFacade": true,
"type": "String",
"value": "Go to routes to view or edit this value"
},
"config": {
"scope": "public"
}
},
"defaultRoute": {
"type": "entaxy.runtime.default-route",
"isRef": true,
/* actually there's no reference, but the object must be in a model */
/* so while producing we must check the defaultRoute is found */
"isBackRef": true,
/* but only if useDefaultRoute is set to true */
"condition": "${useDefaultRoute}",
"required": true,
"immutable": true,
"defaultValue": {
"type": "entaxy.runtime.default-route",
"factoryId": "default-route-2",
"properties": {
"systemName": {
"@CALCULATED": {
"expression": "${#OWNER#.properties.systemName}",
"lazy": false
}
},
"description": {
"@CALCULATED": {
"expression": "Default route for ${#OWNER#.properties.systemName}",
"lazy": false
}
},
"routeContent": {
"@CALCULATED": {
"expression": "${#OWNER_OF_TYPE:entaxy.runtime.profile#.properties.defaultRouteContent}",
"lazy": false,
"allowObjects": false
}
}
}
}
},
"__legacyComponents": {
"type": "entaxy.runtime.profile",
"isRef": true,
"required": true,
"isHidden": true,
"isRefByValueOnly": true,
"@INTERNAL": true,
"defaultValue": {
"factoryId": "common-system-profile",
"type": "entaxy.runtime.profile",
"outputType": "legacy",
"scope": "private",
"properties": {
"systemName": {
"@CALCULATED": {
"expression": "${#OWNER#.properties.systemName}",
"lazy": false
}
}
}
}
},
"profileType": {
"type": "String",
"required": true,
"isHidden": true,
"defaultValue": {
"@CALCULATED": {
"expression": "${#FACTORY#.#TYPEINFO#.profileType}",
"lazy": false
}
}
},
"##publish": {
"defaultValue": {
"profileType": {
"@CALCULATED": {
"expression": "${#FACTORY#.#TYPEINFO#.profileType}",
"lazy": false
}
}
}
}
},
"outputs": {
"init": {
"isDefault": true,
"fields": {
"objectId": {
"isHidden": true
},
"__objectId": {},
"systemName": {},
"description": {},
"useDefaultRoute": {},
"defaultRoute": {
"isHidden": true
},
"defaultRouteContent": {},
"profileProperties": {},
"in-flow-pre-route": {},
"out-flow-pre-route": {},
"connector-selector": {},
"profileType": {},
"__legacyComponents": {}
},
"config": {
"configurable": false
}
},
"legacy": {
"fields": {
"systemName": {}
},
"scopes": ["private"],
"config": {
"@SKIP_PUBLISH": {},
"configurable": false
}
}
}
}

View File

@ -0,0 +1,104 @@
{
"factory": {
"id": "default-route-2",
"type": "entaxy.runtime.default-route",
"label": "route,default",
"isAbstract": false
},
"entaxy.runtime.default-route": {
"displayName": "Default route for system profile"
},
"fields": {
"__objectId": {
"type": "String",
"required": true,
"isHidden": true,
"defaultValue": {
"@CALCULATED": {
"expression": "${properties.systemName}-default-route",
"targetPath": "$.objectId",
"removeResolved": true,
"lazy": false
}
}
},
"systemName": {
"type": "entaxy.runtime.profile",
"isRef": true,
"required": true,
"immutable": true,
"refField": "systemName",
"isRefByValueOnly": true
},
"description": {
"type": "String"
},
"routeContent": {
"displayName": "Route",
"type": "xml:route",
"required": true,
"@RESOURCE": {
"provider": "entaxy-file-internal",
"endType": "String",
"format": "base64",
"preprocess":[
{
"processor": "xslt",
"source":"entaxy-file-internal:factories/default-route-2/default-route.xslt",
"parameters": {
"profileName": {
"@CALCULATED": {
"expression": "${#OWNER#.properties.systemName}",
"lazy": false
}
}
}
},
{
"processor": "merge",
"source":"entaxy-file-internal:factories/default-route-2/standard-router.xml",
"sourceElement": "standard-router",
"targetElement": "standard-router",
"parameters": {
"profileName": {
"@CALCULATED": {
"expression": "${#OWNER#.properties.systemName}",
"lazy": false
}
}
}
}
]
}
},
"##publish": {
"defaultValue":{
"profile": {
"@CALCULATED": {
"expression": "${properties.systemName}",
"lazy": true
}
},
"relation": {
"@CALCULATED": {
"expression": "${properties.systemName}:${#OWNER#.#FACTORY#.type}:default-route:routes",
"lazy": false
}
}
}
}
},
"outputs": {
"init": {
"isDefault": true,
"fields": {
"systemName": {},
"description": {},
"routeContent": {},
"__objectId": {}
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<route>
<in-flow-pre-route-start />
<setProperty name="NTX_profile_in_preRouted">
<constant>true</constant>
</setProperty>
</route>

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<route>
<choice>
<when>
<simple>${headers.in} == null</simple>
<connector-selector>
<properties-to-use>
<property>connector.type</property>
<property>connector.protocol</property>
<property>connector.classifier</property>
</properties-to-use>
<patterns>
<pattern>=:=:=</pattern>
<pattern>=:=:*</pattern>
<pattern>=:*:*</pattern>
<pattern>*:=:=</pattern>
<pattern>*:=:*</pattern>
</patterns>
<options>
<fail-back-to-legacy-router />
<use-the-only-connector />
<use-default-connector />
<allow-all-stars-pattern>false</allow-all-stars-pattern>
<treat-no-property-as-any>false</treat-no-property-as-any>
</options>
</connector-selector>
</when>
<otherwise>
<connector-selector>
<properties-to-use>
<property>connector.type</property>
<property>connector.protocol</property>
<property>connector.classifier</property>
</properties-to-use>
<patterns>
<pattern>=:=:=</pattern>
<pattern>=:=:*</pattern>
<pattern>=:*:*</pattern>
<pattern>*:=:=</pattern>
<pattern>*:=:*</pattern>
<pattern>*:*:*</pattern>
</patterns>
<options>
<fail-back-to-legacy-router />
<use-the-only-connector />
<use-default-connector>false</use-default-connector>
<allow-all-stars-pattern>false</allow-all-stars-pattern>
<treat-no-property-as-any>false</treat-no-property-as-any>
</options>
</connector-selector>
</otherwise>
</choice>
</route>

View File

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~~~~~~licensing~~~~~~
profile-producing
==========
Copyright (C) 2020 - 2023 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~~~~~~
-->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:local="http://ru.entaxy">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:param name="profileName" select="'common'" />
<xsl:template match="/">
<xsl:variable name="processed">
<xsl:sequence select="local:add-ids(./element()[1])" />
</xsl:variable>
<fragment>
<xsl:for-each select="$processed//route//connector-selector">
<xsl:call-template name="create-selector-bean" />
</xsl:for-each>
<xsl:apply-templates select="$processed/element()[1]" />
</fragment>
</xsl:template>
<xsl:function name="local:add-ids" as="element()*">
<xsl:param name="root" />
<xsl:apply-templates select="$root" />
</xsl:function>
<xsl:template match="//connector-selector[not(@*)]" exclude-result-prefixes="xsl fn xs local">
<connector-selector>
<xsl:attribute name="id" select="replace(generate-id(), ':', '') " />
<xsl:apply-templates select="child::node()" />
</connector-selector>
</xsl:template>
<xsl:template match="//connector-selector[@id]" exclude-result-prefixes="xsl fn xs local">
<xsl:comment>generated from 'connector-selector'</xsl:comment>
<to>
<xsl:attribute name="uri">
<xsl:text>bean:selector-</xsl:text><xsl:value-of select="./@id" />
</xsl:attribute> <!-- select="concat('bean',':','selector-', ./@id)" /-->
</to>
</xsl:template>
<xsl:template name="create-selector-bean">
<bean class="ru.entaxy.platform.profiles.runtime.support.ConnectorSelector" activation="eager">
<xsl:attribute name="id">
<xsl:text>selector-</xsl:text><xsl:value-of select="./@id" />
</xsl:attribute>
<!-- select="concat('selector-', ./@id)" / -->
<property name="config">
<xsl:attribute name="value" select="local:generate-config(.)" />
</property>
<property name="profile">
<xsl:attribute name="ref" select="concat('profile-', $profileName)" />
</property>
</bean>
</xsl:template>
<xsl:function name="local:generate-config">
<xsl:param name="selector-node" />
<xsl:text>{</xsl:text><xsl:apply-templates select="$selector-node/node()" /><xsl:text>"_end":true}</xsl:text>
</xsl:function>
<xsl:template match="//route[not(@id)]" exclude-result-prefixes="xsl fn xs">
<route>
<xsl:attribute name="id" select="concat('profile-', $profileName, '-connector-selector')" />
<from>
<xsl:attribute name="uri" select="concat('direct:profile-', $profileName, '-connector-selector')" />
</from>
<xsl:apply-templates select="./node()" />
</route>
</xsl:template>
<xsl:template match="//connector-selector[@id]/properties-to-use">
<xsl:text>"properties":[</xsl:text>
<xsl:for-each select="./property">
<xsl:text>"</xsl:text><xsl:value-of select="./text()" /><xsl:text>"</xsl:text>
<xsl:if test="./following-sibling::property"><xsl:text>,</xsl:text></xsl:if>
</xsl:for-each>
<xsl:text>],</xsl:text>
</xsl:template>
<xsl:template match="//connector-selector[@id]/patterns">
<xsl:text>"patterns":[</xsl:text>
<xsl:for-each select="./pattern">
<xsl:text>"</xsl:text><xsl:value-of select="./text()" /><xsl:text>"</xsl:text>
<xsl:if test="./following-sibling::pattern"><xsl:text>,</xsl:text></xsl:if>
</xsl:for-each>
<xsl:text>],</xsl:text>
</xsl:template>
<xsl:template match="//connector-selector[@id]/options">
<xsl:text>"options":{</xsl:text>
<xsl:for-each select="./element()">
<xsl:text>"</xsl:text><xsl:value-of select="node-name(.)" /><xsl:text>":</xsl:text>
<xsl:choose>
<xsl:when test="string-length(./text()) > 0">
<xsl:variable name="value" select="./text()" />
<xsl:choose>
<xsl:when test="($value = 'true') or ($value = 'false')">
<xsl:value-of select="./text()" /><xsl:text>,</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>"</xsl:text><xsl:value-of select="./text()" /><xsl:text>",</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:text>true,</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:text>"_end":true},</xsl:text>
</xsl:template>
<xsl:template name="default-copy" match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<route>
<out-flow-pre-route-start />
<setProperty name="NTX_profile_out_preRouted">
<constant>true</constant>
</setProperty>
</route>

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~~~~~~licensing~~~~~~
profile-producing
==========
Copyright (C) 2020 - 2023 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~~~~~~
-->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:param name="profileName" select="'common'" />
<xsl:template match="/">
<xsl:apply-templates select="child::node()" />
</xsl:template>
<xsl:template match="//in-flow-pre-route-start" exclude-result-prefixes="xsl fn xs">
<xsl:variable name="uri">
<xsl:text>direct:profile-</xsl:text><xsl:value-of select="$profileName" /><xsl:text>-in-flow-pre-route</xsl:text>
</xsl:variable>
<xsl:comment>generated from 'in-flow-pre-route-start'</xsl:comment>
<from>
<xsl:attribute name="uri" select="$uri" />
</from>
</xsl:template>
<xsl:template match="//out-flow-pre-route-start" exclude-result-prefixes="xsl fn xs">
<xsl:variable name="uri">
<xsl:text>direct:profile-</xsl:text><xsl:value-of select="$profileName" /><xsl:text>-out-flow-pre-route</xsl:text>
</xsl:variable>
<xsl:comment>generated from 'out-flow-pre-route-start'</xsl:comment>
<from>
<xsl:attribute name="uri" select="$uri" />
</from>
</xsl:template>
<xsl:template name="default-copy" match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<route>
<default-route-start />
<standard-router />
</route>

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~~~~~~licensing~~~~~~
profile-producing
==========
Copyright (C) 2020 - 2023 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~~~~~~
-->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:param name="profileName" select="'common'" />
<xsl:template match="/">
<xsl:apply-templates select="child::node()" />
</xsl:template>
<xsl:template match="//default-route-start" exclude-result-prefixes="xsl fn xs">
<xsl:variable name="uri">
<xsl:text>direct-vm:profile-</xsl:text><xsl:value-of select="$profileName" /><xsl:text>-default-route</xsl:text>
</xsl:variable>
<xsl:comment>generated from 'default-route-start'</xsl:comment>
<from>
<xsl:attribute name="uri" select="$uri" />
</from>
</xsl:template>
<xsl:template name="default-copy" match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<standard-router>
<!-- BEGIN standard-router -->
<when>
<simple>${headers.ENTAXY_Destination} == 'nsi'
&amp;&amp; ${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>
<!-- END standard-router -->
</standard-router>

View File

@ -0,0 +1,133 @@
[#ftl attributes={"generated.type":"blueprint"}]
[#--
~~~~~~licensing~~~~~~
profile-producing
==========
Copyright (C) 2020 - 2023 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~~~~~~
--]
<?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">
<!--
factoryId: common-profile-2
factoryType: entaxy.runtime.profile
outputType: init
-->
[#import "templates:object-commons/metadata-storage.ftl" as ms]
[#if properties.profileProperties??]
[@ms.metadata_storage id=properties.systemName+".metadataStorage" data=properties.profileProperties prefix="NTX_profile_" consumer=null /]
[/#if]
<service interface="ru.entaxy.platform.core.producer.support.MetadataStorage"
ref="[=properties.systemName].metadataStorage">
<service-properties>
<entry key="profile.name" value="[=properties.systemName]"/>
</service-properties>
</service>
<bean id="profile-[=properties.systemName]" class="ru.entaxy.platform.profiles.runtime.impl.SystemProfileImpl"
activation="eager" init-method="activate">
<property name="id" value="[=properties.systemName]" />
<property name="type" value="[=properties.profileType]" />
<property name="bundleContext" ref="blueprintBundleContext" />
</bean>
<service interface="ru.entaxy.platform.profiles.runtime.SystemProfile"
ref="profile-[=properties.systemName]">
<service-properties>
<entry key="profile.name" value="[=properties.systemName]"/>
</service-properties>
</service>
<camelContext id="profile-[=properties.systemName]-context" xmlns="http://camel.apache.org/schema/blueprint">
<route id="profile-[=properties.systemName]-backward-compatible">
<from uri="direct-vm:profile-[=properties.systemName]-exit-dispatcher" />
<to uri="direct-vm:profile-[=properties.systemName]-in-flow" />
</route>
<route id="profile-[=properties.systemName]-in-flow">
<from uri="direct-vm:profile-[=properties.systemName]-in-flow" />
<log message="Message ${headers} send to profile '[=properties.systemName]'" loggingLevel="TRACE"/>
<to uri="direct:profile-[=properties.systemName]-in-flow-pre-route" />
<to uri="direct:profile-[=properties.systemName]-in-flow-exit-route" />
</route>
<route id="profile-[=properties.systemName]-in-flow-exit-route">
<from uri="direct:profile-[=properties.systemName]-in-flow-exit-route" />
<setHeader name="NTX_Origin">
<constant>[=systemName]</constant>
</setHeader>
<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-[=properties.systemName]-default-route"/>
</otherwise>
</choice>
</route>
<route id="out-flow-entry">
<from uri="direct-vm:profile-[=properties.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}&amp;subjectId=[=systemName]"/>
</when>
</choice>
<to uri="direct-vm:profile-[=properties.systemName]-out-flow" />
</route>
<route id="profile-[=properties.systemName]-out-flow">
<from uri="direct-vm:profile-[=properties.systemName]-out-flow" />
<to uri="direct:profile-[=properties.systemName]-out-flow-pre-route" />
<to uri="direct:profile-[=properties.systemName]-connector-selector" />
<to uri="direct:profile-[=properties.systemName]-out-flow-exit-route" />
</route>
<route id="profile-[=properties.systemName]-out-flow-exit-route">
<from uri="direct:profile-[=properties.systemName]-out-flow-exit-route" />
<choice>
<when>
<simple>${headers.NTX_target_connector} != null</simple>
<toD uri="direct-vm:${headers.NTX_target_connector}-entry-point" />
</when>
<otherwise>
<!-- try to route via legacy scheme -->
<log message="Message ${headers} is routing via legacy scheme" loggingLevel="WARN"/>
<to uri="bean:profileOutput?method=sendTo"/>
</otherwise>
</choice>
</route>
</camelContext>
</blueprint>

View File

@ -0,0 +1,61 @@
[#ftl attributes={"generated.type":"blueprint.fragment"}]
[#--
~~~~~~licensing~~~~~~
profile-producing
==========
Copyright (C) 2020 - 2023 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~~~~~~
--]
<!--
BEGIN legacy components
@Deprecated
left for backward compatibility
to be removed in next releases
-->
<reference-list id="outConnector"
interface="ru.entaxy.esb.system.profile.commons.connectors.out.OutConnector"
filter="(systemName=[=properties.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=[=properties.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="[=properties.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="[=properties.systemName]"/>
</bean>
<service activation="eager" auto-export="interfaces" ref="system-profile"/>
<!-- END legacy components -->

View File

@ -0,0 +1,33 @@
[#ftl attributes={"generated.type":"blueprint"}]
[#--
~~~~~~licensing~~~~~~
profile-producing
==========
Copyright (C) 2020 - 2023 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~~~~~~
--]
<?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="[=properties.systemName]-default-route-context" xmlns="http://camel.apache.org/schema/blueprint">
</camelContext>
</blueprint>

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.

View File

@ -0,0 +1,25 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ru.entaxy.esb.platform.runtime.core.objects-implementations</groupId>
<artifactId>profile-implementation</artifactId>
<version>1.8.3</version>
</parent>
<groupId>ru.entaxy.esb.platform.runtime.core.objects-implementations.profile-implementation</groupId>
<artifactId>profile-runtime</artifactId>
<packaging>bundle</packaging>
<name>ENTAXY :: PLATFORM :: CORE :: OBJECTS IMPLEMENTATIONS :: PROFILE :: RUNTIME</name>
<description>ENTAXY :: PLATFORM :: CORE :: OBJECTS IMPLEMENTATIONS :: PROFILE :: RUNTIME</description>
<properties>
<bundle.osgi.export.pkg>ru.entaxy.platform.profiles.runtime*</bundle.osgi.export.pkg>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${camel.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,31 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-runtime
* ==========
* Copyright (C) 2020 - 2023 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.platform.profiles.runtime;
public interface Connector {
String getId();
String getType();
String getProtocol();
String getClassifier();
String getProperty(String propertyName);
}

View File

@ -0,0 +1,24 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-runtime
* ==========
* Copyright (C) 2020 - 2023 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.platform.profiles.runtime;
public interface InConnector extends Connector {
}

View File

@ -0,0 +1,24 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-runtime
* ==========
* Copyright (C) 2020 - 2023 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.platform.profiles.runtime;
public interface OutConnector extends Connector {
}

View File

@ -0,0 +1,27 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-runtime
* ==========
* Copyright (C) 2020 - 2023 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.platform.profiles.runtime;
public interface Profile {
String getId();
String getType();
}

View File

@ -0,0 +1,31 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-runtime
* ==========
* Copyright (C) 2020 - 2023 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.platform.profiles.runtime;
import java.util.List;
public interface SystemProfile extends Profile {
List<InConnector> getInConnectors();
List<OutConnector> getOutConnectors();
OutConnector getDefaultOutConnector();
}

View File

@ -0,0 +1,93 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-runtime
* ==========
* Copyright (C) 2020 - 2023 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.platform.profiles.runtime.impl;
import ru.entaxy.platform.profiles.runtime.Connector;
public abstract class AbstractConnector implements Connector {
public static final String PROP_ID = "id";
public static final String PROP_TYPE = "type";
public static final String PROP_PROTOCOL = "protocol";
public static final String PROP_CLASSIFIER = "classifier";
public static final String CONNECTOR_PREFIX = "connector.";
protected String id;
protected String type;
protected String protocol;
protected String classifier;
@Override
public String getId() {
return this.id;
}
@Override
public String getType() {
return this.type;
}
@Override
public String getProtocol() {
return this.protocol;
}
@Override
public String getClassifier() {
return this.classifier;
}
@Override
public String getProperty(String propertyName) {
String name = propertyName;
if (name.startsWith(CONNECTOR_PREFIX))
name = name.substring(CONNECTOR_PREFIX.length());
if (PROP_ID.equals(name))
return getId();
if (PROP_TYPE.equals(name))
return getType();
if (PROP_PROTOCOL.equals(name))
return getProtocol();
if (PROP_CLASSIFIER.equals(name))
return getClassifier();
return null;
}
public void setId(String id) {
this.id = id;
}
public void setType(String type) {
this.type = type;
}
public void setProtocol(String protocol) {
this.protocol = protocol;
}
public void setClassifier(String classifier) {
this.classifier = classifier;
}
}

View File

@ -0,0 +1,47 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-runtime
* ==========
* Copyright (C) 2020 - 2023 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.platform.profiles.runtime.impl;
import ru.entaxy.platform.profiles.runtime.Profile;
public abstract class AbstractProfile implements Profile {
protected String id;
protected String type;
@Override
public String getId() {
return this.id;
}
@Override
public String getType() {
return this.type;
}
public void setId(String id) {
this.id = id;
}
public void setType(String type) {
this.type = type;
}
}

View File

@ -0,0 +1,26 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-runtime
* ==========
* Copyright (C) 2020 - 2023 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.platform.profiles.runtime.impl;
import ru.entaxy.platform.profiles.runtime.InConnector;
public class InConnectorImpl extends AbstractConnector implements InConnector {
}

View File

@ -0,0 +1,26 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-runtime
* ==========
* Copyright (C) 2020 - 2023 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.platform.profiles.runtime.impl;
import ru.entaxy.platform.profiles.runtime.OutConnector;
public class OutConnectorImpl extends AbstractConnector implements OutConnector {
}

View File

@ -0,0 +1,146 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-runtime
* ==========
* Copyright (C) 2020 - 2023 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.platform.profiles.runtime.impl;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.jline.utils.Log;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;
import ru.entaxy.platform.profiles.runtime.Connector;
import ru.entaxy.platform.profiles.runtime.InConnector;
import ru.entaxy.platform.profiles.runtime.OutConnector;
import ru.entaxy.platform.profiles.runtime.SystemProfile;
public class SystemProfileImpl extends AbstractProfile implements SystemProfile {
protected BundleContext bundleContext;
protected ConnectorServiceTracker<InConnector> inConnectorsTracker;
protected ConnectorServiceTracker<OutConnector> outConnectorsTracker;
public void activate() {
inConnectorsTracker = new ConnectorServiceTracker<>(InConnector.class);
outConnectorsTracker = new ConnectorServiceTracker<>(OutConnector.class);
}
@Override
public List<InConnector> getInConnectors() {
return inConnectorsTracker.getServices();
}
@Override
public List<OutConnector> getOutConnectors() {
return outConnectorsTracker.getServices();
}
@Override
public OutConnector getDefaultOutConnector() {
// TODO implement
return null;
}
public void setBundleContext(BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
protected class ConnectorServiceTracker<T extends Connector>{
ServiceTracker<T, T> serviceTracker;
Class<T> serviceClass;
public ConnectorServiceTracker(Class<T> clazz) {
this.serviceClass = clazz;
try {
Filter filter = createFilter(clazz);
serviceTracker = new ServiceTracker<>(
bundleContext
, filter
, new ConnectorServiceTrackerCustomizer<T>());
serviceTracker.open(true);
} catch (Exception e) {
Log.error("Error creating service tracker for [" + SystemProfileImpl.this.getId() + "]", e);
}
}
protected Filter createFilter(Class<T> clazz) throws InvalidSyntaxException {
return SystemProfileImpl.this.bundleContext.createFilter(
String.format("(&(%s=%s)(system=%s))"
, Constants.OBJECTCLASS
, clazz.getName()
, SystemProfileImpl.this.getId())
);
}
public List<T> getServices(){
if (serviceTracker.getServices() == null)
return Collections.emptyList();
return Arrays.asList((Object[])serviceTracker.getServices())
.stream().map(service->(T)service)
.collect(Collectors.toList());
}
}
protected class ConnectorServiceTrackerCustomizer<T extends Connector> implements ServiceTrackerCustomizer<T, T>{
protected Map<String, T> storage = new LinkedHashMap<>();
@Override
synchronized public T addingService(ServiceReference<T> reference) {
T service = SystemProfileImpl.this.bundleContext.getService(reference);
synchronized (storage) {
storage.put(service.getId(), service);
}
return service;
}
@Override
synchronized public void modifiedService(ServiceReference<T> reference, T service) {
// TODO Auto-generated method stub
}
@Override
synchronized public void removedService(ServiceReference<T> reference, T service) {
synchronized (storage) {
storage.remove(service.getId());
}
}
}
}

View File

@ -0,0 +1,316 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-runtime
* ==========
* Copyright (C) 2020 - 2023 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.platform.profiles.runtime.support;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import ru.entaxy.platform.base.support.CommonUtils;
import ru.entaxy.platform.base.support.JSONUtils;
import ru.entaxy.platform.profiles.runtime.OutConnector;
import ru.entaxy.platform.profiles.runtime.Profile;
import ru.entaxy.platform.profiles.runtime.SystemProfile;
public class ConnectorSelector implements Processor {
private static final Logger log = LoggerFactory.getLogger(ConnectorSelector.class);
public static final String PROP_TARGET_CONNECTOR = "NTX_target_connector";
public static final String PROP_PREFERED_CONNECTOR = "NTX_prefered_connector";
public static final String PROP_SOURCE_PREFIX = "NTX_SOURCE_";
public static final String PATTERN_ANY = "*";
public static final String PATTERN_EQUAL = "=";
protected SystemProfile profile;
protected String config;
protected SelectorConfig selectorConfig;
@Override
public void process(Exchange exchange) throws Exception {
log.info("--> SELECTING CONNECTOR !!!");
exchange.getIn().removeHeader(PROP_TARGET_CONNECTOR);
SelectionExecutor executor = new SelectionExecutor(selectorConfig, profile);
OutConnector result = executor.findConnector(exchange);
if (result != null)
exchange.getIn().setHeader(PROP_TARGET_CONNECTOR, result.getId());
}
public SystemProfile getProfile() {
return profile;
}
public void setProfile(SystemProfile profile) {
this.profile = profile;
}
public String getConfig() {
return config;
}
public void setConfig(String config) {
this.config = config;
processConfig();
}
protected void processConfig() {
if (!CommonUtils.isValid(config)) {
selectorConfig = new SelectorConfig();
} else {
selectorConfig = new SelectorConfig(this.config);
}
}
protected static class SelectionExecutor {
protected SelectorConfig selectorConfig;
protected SystemProfile profile;
public SelectionExecutor(SelectorConfig selectorConfig, SystemProfile profile) {
this.selectorConfig = selectorConfig;
this.profile = profile;
}
public OutConnector findConnector(Exchange exchange) {
OutConnector result = null;
if (selectorConfig.useTheOnlyConnector && (profile.getOutConnectors().size()==1))
return profile.getOutConnectors().get(0);
Object value = exchange.getIn().getHeader(PROP_PREFERED_CONNECTOR);
if (value != null) {
try {
SelectorConfig preferedConfig = createConfigForPreferedConnector(value);
List<String> resolvedPatters = new ArrayList<>(preferedConfig.patterns);
result = findConnectorByPatterns(preferedConfig, resolvedPatters);
if (result != null)
return result;
} catch (Exception e) {
log.warn("Invalid prefered connector format", e);
}
}
List<String> resolvedPatterns = resolvePatternsForExchange(selectorConfig, exchange);
result = findConnectorByPatterns(selectorConfig, resolvedPatterns);
if ((result == null) && selectorConfig.useDefaultConnector)
result = profile.getDefaultOutConnector();
return result;
}
protected List<String> resolvePatternsForExchange(SelectorConfig config, Exchange exchange) {
List<String> result = new ArrayList<>();
List<String> values = new ArrayList<>();
for (String property: config.properties) {
String headerName = PROP_SOURCE_PREFIX + property.replace('.', '_');
Object value = exchange.getIn().getHeader(headerName);
if (value == null) {
if (config.treatNoPropertyAsAny)
values.add(PATTERN_ANY);
else
values.add("");
continue;
}
values.add(value.toString());
}
for (String pattern: config.patterns)
result.add(resolvePattern(pattern, values));
return result;
}
protected String resolvePattern(String pattern, List<String> values) {
String[] splitted = pattern.split(":");
for (int i=0; i<splitted.length; i++)
if (PATTERN_EQUAL.equals(splitted[i]))
splitted[i] = values.get(i);
return String.join(":", splitted);
}
protected OutConnector findConnectorByPatterns(SelectorConfig config, List<String> resolvedPatterns) {
for (String resolvedPattern: resolvedPatterns) {
if (!config.allowAllStarsPattern && isAllStarsPattern(resolvedPattern))
continue;
String[] pattern = resolvedPattern.split(":");
for (OutConnector connector: profile.getOutConnectors()) {
String[] connectorInfo = getConnectorInfo(config, connector);
boolean found = false;
for (int i=0; i<pattern.length; i++) {
if ((pattern[i] == null)
|| (PATTERN_ANY.equals(pattern[i]))
|| (pattern[i].equals(connectorInfo[i]))
)
{
found = true;
continue;
} else {
found = false;
break;
}
}
if (found)
return connector;
}
}
return null;
}
protected boolean isAllStarsPattern(String pattern) {
return Pattern.matches("[*:]+", pattern);
}
protected String[] getConnectorInfo(SelectorConfig config, OutConnector connector) {
List<String> info = new ArrayList<>();
for (String property: config.properties) {
info.add(connector.getProperty(property));
}
return info.toArray(new String[] {});
}
protected SelectorConfig createConfigForPreferedConnector(Object descriptor) throws Exception {
JsonObject preferedConnectorDescriptor = JSONUtils.getJsonRootObject(descriptor.toString());
SelectorConfig result = new SelectorConfig();
List<String> patternItems = new ArrayList<>();
for (Entry<String, JsonElement> entry: preferedConnectorDescriptor.entrySet()) {
if (!entry.getValue().isJsonPrimitive())
continue;
result.properties.add(entry.getKey());
patternItems.add(entry.getValue().getAsJsonPrimitive().getAsString());
}
String pattern = patternItems.stream().collect(Collectors.joining(":"));
if (!CommonUtils.isValid(pattern))
return null;
result.patterns.add(pattern);
result.failBackToLLegacyRouter = false;
result.useDefaultConnector = false;
result.useTheOnlyConnector = false;
result.allowAllStarsPattern = false;
result.treatNoPropertyAsAny = false;
return result;
}
}
protected static class SelectorConfig {
public interface FIELDS {
String PROPERTIES = "properties";
String PATTERNS = "patterns";
String OPTIONS = "options";
String OPTION_FAIL_BACK_TO_LEGACY = "fail-back-to-legacy-router";
String OPTION_USE_THE_ONLY_CONNECTOR = "use-the-only-connector";
String OPTION_USE_DEFAULT_CONNECTOR = "use-default-connector";
String OPTION_ALLOW_ALL_STARS_PATTERN = "allow-all-stars-pattern";
String OPTION_TREAT_NO_PROPERTY_AS_ANY = "treat-no-property-as-any";
}
List<String> properties;
List<String> patterns;
boolean failBackToLLegacyRouter = true;
boolean useTheOnlyConnector = true;
boolean useDefaultConnector = true;
boolean allowAllStarsPattern = true;
boolean treatNoPropertyAsAny = true;
public SelectorConfig() {
super();
properties = new ArrayList<>();
patterns = new ArrayList<>();
}
public SelectorConfig(String jsonData) {
JsonObject config = JSONUtils.getJsonRootObject(jsonData);
Gson gson = new Gson();
Type listType = new TypeToken<ArrayList<String>>(){}.getType();
if (config.has(FIELDS.PROPERTIES))
try {
properties = gson.fromJson(config.get(FIELDS.PROPERTIES), listType);
} catch (Exception e) {
// NOOP
}
if (config.has(FIELDS.PATTERNS))
try {
patterns = gson.fromJson(config.get(FIELDS.PATTERNS), listType);
} catch (Exception e) {
// NOOP
}
if (config.has(FIELDS.OPTIONS)) {
JsonElement je = config.get(FIELDS.OPTIONS);
if (je.isJsonObject()) {
JsonObject options = je.getAsJsonObject();
if (options.has(FIELDS.OPTION_FAIL_BACK_TO_LEGACY))
try {
failBackToLLegacyRouter = options.get(FIELDS.OPTION_FAIL_BACK_TO_LEGACY).getAsBoolean();
} catch (Exception e) {
// NOOP
}
if (options.has(FIELDS.OPTION_USE_DEFAULT_CONNECTOR))
try {
useDefaultConnector = options.get(FIELDS.OPTION_USE_DEFAULT_CONNECTOR).getAsBoolean();
} catch (Exception e) {
// NOOP
}
if (options.has(FIELDS.OPTION_USE_THE_ONLY_CONNECTOR))
try {
useTheOnlyConnector = options.get(FIELDS.OPTION_USE_THE_ONLY_CONNECTOR).getAsBoolean();
} catch (Exception e) {
// NOOP
}
if (options.has(FIELDS.OPTION_ALLOW_ALL_STARS_PATTERN))
try {
allowAllStarsPattern = options.get(FIELDS.OPTION_ALLOW_ALL_STARS_PATTERN).getAsBoolean();
} catch (Exception e) {
// NOOP
}
if (options.has(FIELDS.OPTION_TREAT_NO_PROPERTY_AS_ANY))
try {
treatNoPropertyAsAny = options.get(FIELDS.OPTION_TREAT_NO_PROPERTY_AS_ANY).getAsBoolean();
} catch (Exception e) {
// NOOP
}
}
}
}
}
}