ENTAXY-248 release 1.8.1

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

View File

@ -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,76 @@
<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</groupId>
<artifactId>management</artifactId>
<version>1.8.1</version>
</parent>
<groupId>ru.entaxy.esb.platform.runtime.core.management</groupId>
<artifactId>blueprint-generator-service</artifactId>
<packaging>bundle</packaging>
<name>ENTAXY :: PLATFORM :: CORE :: MANAGEMENT :: BLUEPRINT GENERATOR SERVICE</name>
<description>ENTAXY :: PLATFORM :: CORE :: MANAGEMENT :: BLUEPRINT GENERATOR SERVICE</description>
<properties>
<bundle.osgi.export.pkg>ru.entaxy.platform.core.blueprint.generator</bundle.osgi.export.pkg>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.karaf</groupId>
<artifactId>org.apache.karaf.util</artifactId>
</dependency>
<!-- dependency>
<groupId>ru.entaxy.esb.platform.runtime.base</groupId>
<artifactId>base-support</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency-->
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
<version>1.4.0</version>
<scope>compile</scope>
</dependency>
<!-- dependency>
<groupId>ru.entaxy.esb.system.core</groupId>
<artifactId>template</artifactId>
<version>${project.version}</version>
</dependency-->
<dependency>
<groupId>
ru.entaxy.esb.platform.runtime.base.connecting.generator
</groupId>
<artifactId>generator-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>
ru.entaxy.esb.platform.runtime.base.connecting.generator
</groupId>
<artifactId>generator-factory</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven-bundle-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Entaxy-Template-Provider>true</Entaxy-Template-Provider>
<_dsannotations>*</_dsannotations>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,63 @@
/*-
* ~~~~~~licensing~~~~~~
* blueprint-generator
* ==========
* 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.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 + '\'' +
'}';
}
}

View File

@ -0,0 +1,32 @@
/*-
* ~~~~~~licensing~~~~~~
* blueprint-generator
* ==========
* 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.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;
}

View File

@ -0,0 +1,107 @@
/*-
* ~~~~~~licensing~~~~~~
* blueprint-generator
* ==========
* 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.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);
}
}

View File

@ -0,0 +1,60 @@
[#ftl attributes={"generated.type":"blueprint"}]
[#--
~~~~~~licensing~~~~~~
blueprint-generator-service
==========
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~~~~~~
--]
<?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}&amp;subjectId=[=systemName]"/>
<setHeader name="NTX_DestinationPointAfterBridge">
<simple>system:[=systemName]</simple>
</setHeader>
<to uri="jms:queue:entaxy.local.out.[=origin]"/>
</route>
</camelContext>
</blueprint>

View File

@ -0,0 +1,69 @@
[#ftl attributes={"generated.type":"blueprint"}]
[#--
~~~~~~licensing~~~~~~
blueprint-generator-service
==========
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~~~~~~
--]
<?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'
&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>
</route>
</camelContext>
</blueprint>

View File

@ -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"
}
]
}

View File

@ -0,0 +1,96 @@
[#ftl attributes={"generated.type":"blueprint"}]
[#--
~~~~~~licensing~~~~~~
blueprint-generator-service
==========
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~~~~~~
--]
<?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}&amp;subjectId=[=systemName]"/>
</when>
</choice>
<to uri="bean:profileOutput?method=sendTo"/>
</route>
</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,63 @@
<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</groupId>
<artifactId>management</artifactId>
<version>1.8.1</version>
</parent>
<groupId>ru.entaxy.esb.platform.runtime.core.management</groupId>
<artifactId>cluster-node-management</artifactId>
<packaging>bundle</packaging>
<name>ENTAXY :: PLATFORM :: RUNTIME :: CORE :: MANAGEMENT :: CLUSTER NODE MANAGEMENT</name>
<description>ENTAXY :: PLATFORM :: RUNTIME :: CORE :: MANAGEMENT :: CLUSTER NODE MANAGEMENT</description>
<properties>
<bundle.osgi.export.pkg>ru.entaxy.esb.platform.core.management.cluster.node</bundle.osgi.export.pkg>
<bundle.osgi.private.pkg>ru.entaxy.esb.platform.core.management.cluster.node.impl</bundle.osgi.private.pkg>
</properties>
<dependencies>
<dependency>
<groupId>ru.entaxy.esb.platform.runtime.base</groupId>
<artifactId>management-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.karaf</groupId>
<artifactId>org.apache.karaf.util</artifactId>
<version>${karaf.version}</version>
</dependency>
<!-- @TODO move declaration to root/pom.xml -->
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
<version>1.4.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>${osgi.compendium.version}</version>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-all</artifactId>
<version>${hazelcast.version}</version>
</dependency>
<dependency>
<groupId>
ru.entaxy.esb.platform.runtime.core.management
</groupId>
<artifactId>node-management</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,29 @@
/*-
* ~~~~~~licensing~~~~~~
* cluster-node-management
* ==========
* Copyright (C) 2020 - 2022 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.platform.core.management.cluster.node;
public interface Attributes {
public static final String ENTAXY_PLATFORM_VERSION = "entaxyPlatformVersion";
public static final String HTTP_PORT = "httpPort";
public static final String SSH_PORT = "sshPort";
public static final String UI_ENABLED = "uiEnabled";
}

View File

@ -0,0 +1,131 @@
/*-
* ~~~~~~licensing~~~~~~
* cluster-node-management
* ==========
* Copyright (C) 2020 - 2022 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.platform.core.management.cluster.node.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.List;
import org.apache.karaf.features.FeaturesService;
import org.apache.karaf.util.tracker.BaseActivator;
import org.apache.karaf.util.tracker.annotation.RequireService;
import org.apache.karaf.util.tracker.annotation.Services;
import org.osgi.service.cm.ConfigurationAdmin;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.Member;
import com.hazelcast.core.MemberAttributeEvent;
import com.hazelcast.core.MembershipEvent;
import com.hazelcast.core.MembershipListener;
import ru.entaxy.esb.platform.core.management.cluster.node.Attributes;
import ru.entaxy.esb.platform.core.management.node.ClusterLocalNodeDataProvider;
import ru.entaxy.esb.platform.core.management.node.LocalNodeMBean;
import ru.entaxy.esb.platform.core.management.node.NodeDataProvider;
import ru.entaxy.platform.base.support.CommonUtils;
@Services(requires = {
@RequireService(ConfigurationAdmin.class),
@RequireService(FeaturesService.class),
@RequireService(HazelcastInstance.class),
@RequireService(LocalNodeMBean.class)
}
)
public class Activator extends BaseActivator implements MembershipListener {
private HazelcastInstance hazelcastInstance;
private LocalNodeMBean localNodeMBean;
private Member localMember;
private MemberMBeanManager memberMBeanManager;
@Override
protected void doStart() throws Exception {
ConfigurationAdmin configurationAdmin = getTrackedService(ConfigurationAdmin.class);
if (configurationAdmin == null)
return;
FeaturesService featuresService = getTrackedService(FeaturesService.class);
if (featuresService == null)
return;
localNodeMBean = getTrackedService(LocalNodeMBean.class);
if (localNodeMBean == null)
return;
hazelcastInstance = getTrackedService(HazelcastInstance.class);
if (hazelcastInstance == null)
return;
localMember = hazelcastInstance.getCluster().getLocalMember();
fillMemberData();
registerDataProvider();
memberMBeanManager = new MemberMBeanManager(bundleContext);
initializeMBeans();
hazelcastInstance.getCluster().addMembershipListener(this);
}
protected void fillMemberData() {
NodeDataProvider dataProvider = localNodeMBean.getDataProvider();
localMember.setStringAttribute(Attributes.ENTAXY_PLATFORM_VERSION, dataProvider.getEntaxyPlatformVersion());
localMember.setStringAttribute(Attributes.HTTP_PORT, dataProvider.getHttpPort());
localMember.setStringAttribute(Attributes.SSH_PORT, dataProvider.getSshPort());
localMember.setBooleanAttribute(Attributes.UI_ENABLED, dataProvider.isUIEnabled());
}
protected void registerDataProvider() {
bundleContext.registerService(ClusterLocalNodeDataProvider.class
, new ClusterLocalNodeDataProviderImpl(localMember, localNodeMBean.getDataProvider())
, new Hashtable<>());
}
protected void initializeMBeans() {
List<Member> members = new ArrayList<>(hazelcastInstance.getCluster().getMembers());
members.remove(localMember);
if (members.size() > 0)
memberMBeanManager.added(members);
}
@Override
public void memberAdded(MembershipEvent membershipEvent) {
if (membershipEvent.getMember() != localMember)
memberMBeanManager.added(Arrays.asList(new Member[] {membershipEvent.getMember()}));
}
@Override
public void memberRemoved(MembershipEvent membershipEvent) {
if (membershipEvent.getMember() != localMember)
memberMBeanManager.removed(Arrays.asList(new Member[] {membershipEvent.getMember()}));
}
@Override
public void memberAttributeChanged(MemberAttributeEvent memberAttributeEvent) {
if (memberAttributeEvent.getMember() != localMember)
memberMBeanManager.modified(Arrays.asList(new Member[] {memberAttributeEvent.getMember()}));
}
}

View File

@ -0,0 +1,56 @@
/*-
* ~~~~~~licensing~~~~~~
* cluster-node-management
* ==========
* Copyright (C) 2020 - 2022 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.platform.core.management.cluster.node.impl;
import com.hazelcast.core.Member;
import ru.entaxy.esb.platform.core.management.node.ClusterLocalNodeDataProvider;
import ru.entaxy.esb.platform.core.management.node.NodeDataProvider;
public class ClusterLocalNodeDataProviderImpl extends MemberAwareDataProvider implements ClusterLocalNodeDataProvider {
protected NodeDataProvider localDataProvider;
public ClusterLocalNodeDataProviderImpl(Member member, NodeDataProvider localDataProvider) {
super(member);
this.localDataProvider = localDataProvider;
}
@Override
public String getEntaxyPlatformVersion() {
return localDataProvider.getEntaxyPlatformVersion();
}
@Override
public String getHttpPort() {
return localDataProvider.getHttpPort();
}
@Override
public String getSshPort() {
return localDataProvider.getSshPort();
}
@Override
public boolean isUIEnabled() {
return localDataProvider.isUIEnabled();
}
}

View File

@ -0,0 +1,75 @@
/*-
* ~~~~~~licensing~~~~~~
* cluster-node-management
* ==========
* Copyright (C) 2020 - 2022 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.platform.core.management.cluster.node.impl;
import javax.management.NotCompliantMBeanException;
import com.hazelcast.core.Member;
import ru.entaxy.esb.platform.base.management.core.api.AnnotatedMBean;
import ru.entaxy.esb.platform.core.management.node.ClusterNodeMBean;
public class ClusterNodeMBeanImpl extends AnnotatedMBean<ClusterNodeMBean> implements ClusterNodeMBean {
protected MemberAwareDataProvider dataProvider;
protected ClusterNodeMBeanImpl(Member member) throws NotCompliantMBeanException {
super(ClusterNodeMBean.class);
this.dataProvider = new MemberAwareDataProvider(member);
}
@Override
public String getEntaxyPlatformVersion() {
return dataProvider.getEntaxyPlatformVersion();
}
@Override
public String getHttpPort() {
return dataProvider.getHttpPort();
}
@Override
public String getSshPort() {
return dataProvider.getSshPort();
}
@Override
public boolean isUIEnabled() {
return dataProvider.isUIEnabled();
}
@Override
public boolean isClusterEnabled() {
return dataProvider.isClusterEnabled();
}
@Override
public String getClusterIP() {
return dataProvider.getClusterIP();
}
@Override
public String getClusterPort() {
return dataProvider.getClusterPort();
}
}

View File

@ -0,0 +1,72 @@
/*-
* ~~~~~~licensing~~~~~~
* cluster-node-management
* ==========
* Copyright (C) 2020 - 2022 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.platform.core.management.cluster.node.impl;
import com.hazelcast.core.Member;
import ru.entaxy.esb.platform.core.management.cluster.node.Attributes;
import ru.entaxy.esb.platform.core.management.node.NodeDataProvider;
public class MemberAwareDataProvider implements NodeDataProvider {
protected Member member;
public MemberAwareDataProvider(Member member) {
super();
this.member = member;
}
@Override
public String getEntaxyPlatformVersion() {
return member.getStringAttribute(Attributes.ENTAXY_PLATFORM_VERSION);
}
@Override
public String getHttpPort() {
return member.getStringAttribute(Attributes.HTTP_PORT);
}
@Override
public String getSshPort() {
return member.getStringAttribute(Attributes.SSH_PORT);
}
@Override
public boolean isUIEnabled() {
return member.getBooleanAttribute(Attributes.UI_ENABLED);
}
@Override
public boolean isClusterEnabled() {
return true;
}
@Override
public String getClusterIP() {
return member.getAddress().getHost();
}
@Override
public String getClusterPort() {
return member.getAddress().getPort()+"";
}
}

View File

@ -0,0 +1,71 @@
/*-
* ~~~~~~licensing~~~~~~
* cluster-node-management
* ==========
* Copyright (C) 2020 - 2022 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.platform.core.management.cluster.node.impl;
import java.util.Iterator;
import java.util.List;
import javax.management.NotCompliantMBeanException;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.hazelcast.core.Member;
import ru.entaxy.esb.platform.base.management.core.ManagementCore;
import ru.entaxy.esb.platform.base.management.core.utils.ManagedObjectsListener;
import ru.entaxy.esb.platform.core.management.node.ClusterNodeMBean;
public class MemberMBeanManager extends ManagedObjectsListener<List<Member>, Member, ClusterNodeMBean, ClusterNodeMBeanImpl> {
private static final Logger log = LoggerFactory.getLogger(MemberMBeanManager.class);
public MemberMBeanManager(BundleContext bundleContext) {
super(bundleContext, ClusterNodeMBean.class);
}
@Override
protected Iterator<Member> getIterator(List<Member> managedObject) {
return managedObject.iterator();
}
@Override
protected String getKeyValue(Member object) {
return object.getUuid();
}
@Override
protected ClusterNodeMBeanImpl createService(Member managedObject) {
try {
return new ClusterNodeMBeanImpl(managedObject);
} catch (NotCompliantMBeanException e) {
log.error("Error creating [ClusterNodeMBeanImpl]", e);
return null;
}
}
@Override
protected String getJmxObjectName(Member managedObject) {
return ManagementCore.ENTAXY_JMX_DOMAIN + ":" + ManagementCore.REMOTE_NODE_KEY + "="
+ managedObject.getAddress().getHost()+"-"+managedObject.getAddress().getPort();
}
}

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,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ru.entaxy.esb.platform.runtime.core</groupId>
<artifactId>management</artifactId>
<version>1.8.1</version>
</parent>
<groupId>ru.entaxy.esb.platform.runtime.core.management</groupId>
<artifactId>connection-management</artifactId>
<packaging>bundle</packaging>
<name>ENTAXY :: PLATFORM :: RUNTIME :: CORE :: MANAGEMENT :: CONNECTION MANAGEMENT</name>
<description>ENTAXY :: PLATFORM :: RUNTIME :: CORE :: MANAGEMENT :: CONNECTION MANAGEMENT</description>
<properties>
<bundle.osgi.export.pkg>
ru.entaxy.esb.platform.core.management.connection
</bundle.osgi.export.pkg>
<bundle.osgi.private.pkg>
ru.entaxy.esb.platform.core.management.connection.impl,
ru.entaxy.esb.platform.core.management.connection.tracker
</bundle.osgi.private.pkg>
</properties>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
<version>1.4.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr</artifactId>
<version>2.1.20</version>
</dependency>
<dependency>
<groupId>
ru.entaxy.esb.platform.runtime.base
</groupId>
<artifactId>base-support</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.platform.runtime.base</groupId>
<artifactId>management-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<_dsannotations>*</_dsannotations>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,63 @@
/*-
* ~~~~~~licensing~~~~~~
* connection-management
* ==========
* 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.platform.core.management.connection;
public interface ConnectionMBean {
public static final String CONNECTION_KEY = "connection";
/*
* connection name
*/
public String getName();
/*
* if connection is platform one or user defined
*/
public boolean isPlatform();
/*
* status of the bundle if connection is deplyed
*/
public String getStatus();
/*
* if the connection local or shared (cluster)
*/
public boolean isLocal();
/*
* if the connection is shared (single malt)
* or prototype-like (blended)
*/
public boolean isShared();
/*
* if the connection is deployed or only defined
*/
public boolean isDeployed();
/*
* bundle id for single malt connection
* null for blended
*/
public String getBundleId();
}

View File

@ -0,0 +1,30 @@
/*-
* ~~~~~~licensing~~~~~~
* connection-management
* ==========
* 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.platform.core.management.connection;
public interface ConnectionsMBean {
public static final String CAPABILITY_NAMESPACE = "entaxy.runtime.connection";
public static final String CONNECTIONS_KEY = "category";
public static final String CONNECTIONS_KEY_VALUE = "connections";
}

View File

@ -0,0 +1,91 @@
/*-
* ~~~~~~licensing~~~~~~
* connection-management
* ==========
* 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.platform.core.management.connection.impl;
import javax.management.NotCompliantMBeanException;
import javax.management.StandardMBean;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import ru.entaxy.esb.platform.core.management.connection.ConnectionMBean;
public class ConnectionMBeanImpl extends StandardMBean implements ConnectionMBean {
protected ManagedConnection connection;
protected BundleContext bundleContext;
public ConnectionMBeanImpl(BundleContext bundleContext, ManagedConnection connection) throws NotCompliantMBeanException {
super(ConnectionMBean.class);
this.bundleContext = bundleContext;
this.connection = connection;
}
@Override
public String getName() {
return connection.getName();
}
@Override
public boolean isPlatform() {
return connection.isPlatform();
}
@Override
public String getStatus() {
int state = this.bundleContext.getBundle(connection.getBundleId()).getState();
switch (state) {
case Bundle.ACTIVE:
return "Active";
case Bundle.INSTALLED:
return "Installed";
case Bundle.RESOLVED:
return "Resolved";
case Bundle.STARTING:
return "Starting";
case Bundle.STOPPING:
return "Stopping";
default:
return "Unknown";
}
}
@Override
public boolean isLocal() {
return connection.isLocal;
}
@Override
public boolean isShared() {
return connection.isShared();
}
@Override
public boolean isDeployed() {
return connection.isDeployed;
}
@Override
public String getBundleId() {
return connection.getBundleId() + "";
}
}

View File

@ -0,0 +1,126 @@
/*-
* ~~~~~~licensing~~~~~~
* connection-management
* ==========
* 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.platform.core.management.connection.impl;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import javax.management.DynamicMBean;
import javax.management.MBeanRegistration;
import javax.management.NotCompliantMBeanException;
import javax.management.StandardMBean;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.ServiceScope;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.esb.platform.base.management.core.ManagementCore;
import ru.entaxy.esb.platform.base.management.core.Qualifier;
import ru.entaxy.esb.platform.core.management.connection.ConnectionMBean;
import ru.entaxy.esb.platform.core.management.connection.ConnectionsMBean;
import ru.entaxy.esb.platform.core.management.connection.tracker.DeployedConnectionTracker;
@Component(
service = {ConnectionsMBean.class, DynamicMBean.class, MBeanRegistration.class},
property = {ManagementCore.JMX_OBJECTNAME
+ "=" + ManagementCore.Q_RUNTIME_S
+ "," + ConnectionsMBean.CONNECTIONS_KEY
+ "=" + ConnectionsMBean.CONNECTIONS_KEY_VALUE},
scope = ServiceScope.SINGLETON,
immediate = true
)
public class ConnectionsMBeanImpl extends StandardMBean
implements ConnectionsMBean, ManagedConnectionsListener {
private static final Logger log = LoggerFactory.getLogger(ConnectionsMBeanImpl.class);
public static final Qualifier Q_CONNECTIONS = ManagementCore.Q_RUNTIME
.qualifier(ConnectionsMBean.CONNECTIONS_KEY, ConnectionsMBean.CONNECTIONS_KEY_VALUE);
protected BundleContext bundleContext;
protected DeployedConnectionTracker tracker;
protected static class ManagedConnectionDescriptor {
ManagedConnection connection;
ServiceRegistration<ConnectionMBean> registration;
}
protected Map<String, ManagedConnectionDescriptor> managed = new HashMap<>();
public ConnectionsMBeanImpl() throws NotCompliantMBeanException {
super(ConnectionsMBean.class);
}
@Activate
public void activate(ComponentContext componentContext) {
this.bundleContext = componentContext.getBundleContext();
tracker = new DeployedConnectionTracker(bundleContext, this);
tracker.open();
}
@Deactivate
public void deactivate() {
tracker.close();
}
@Override
public void addded(ManagedConnections connections) {
Hashtable props = new Hashtable<>();
// String jmxObjectName = "jmx.objectname";
// String objectName = "ru.entaxy.esb:group=platform,category=connections,connection=";
for (ManagedConnection connection: connections.managedConnections) {
if (managed.containsKey(connection.getName()))
this.managed.get(connection.getName()).registration.unregister();
try {
ConnectionMBeanImpl service = new ConnectionMBeanImpl(bundleContext, connection);
ManagedConnectionDescriptor descriptor = new ManagedConnectionDescriptor();
descriptor.connection = connection;
props.put(ManagementCore.JMX_OBJECTNAME
, Q_CONNECTIONS.qualifier(ConnectionMBean.CONNECTION_KEY
, connection.getName()).getValue());
descriptor.registration = bundleContext.registerService(ConnectionMBean.class
, service
, props);
} catch (Exception e) {
log.error("Error adding connection [" + connection.getName() + "]", e);
}
}
}
@Override
public void removed(ManagedConnections connections) {
for (ManagedConnection connection: connections.managedConnections) {
if (managed.containsKey(connection.getName())) {
this.managed.get(connection.getName()).registration.unregister();
this.managed.remove(connection.getName());
}
}
}
}

View File

@ -0,0 +1,98 @@
/*-
* ~~~~~~licensing~~~~~~
* connection-management
* ==========
* 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.platform.core.management.connection.impl;
public class ManagedConnection {
protected String name;
protected boolean isPlatform;
protected boolean isLocal;
protected boolean isShared;
protected long bundleId;
protected boolean isDeployed;
public String getName() {
return name;
}
public boolean isPlatform() {
return isPlatform;
}
public boolean isLocal() {
return isLocal;
}
public boolean isShared() {
return isShared;
}
public long getBundleId() {
return bundleId;
}
public boolean isDeployed() {
return isDeployed;
}
public void setName(String name) {
this.name = name;
}
public void setPlatform(boolean isPlatform) {
this.isPlatform = isPlatform;
}
public void setLocal(boolean isLocal) {
this.isLocal = isLocal;
}
public void setShared(boolean isShared) {
this.isShared = isShared;
}
public void setBundleId(long bundleId) {
this.bundleId = bundleId;
}
public void setDeployed(boolean isDeployed) {
this.isDeployed = isDeployed;
}
public ManagedConnection name(String name) {
setName(name);
return this;
}
public ManagedConnection platform(boolean isPlatform) {
setPlatform(isPlatform);
return this;
}
public ManagedConnection local(boolean isLocal) {
setLocal(isLocal);
return this;
}
public ManagedConnection shared(boolean isShared) {
setShared(isShared);
return this;
}
public ManagedConnection bundleId(long bundleId) {
setBundleId(bundleId);
return this;
}
public ManagedConnection deployed(boolean deployed) {
setDeployed(deployed);
return this;
}
}

View File

@ -0,0 +1,29 @@
/*-
* ~~~~~~licensing~~~~~~
* connection-management
* ==========
* 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.platform.core.management.connection.impl;
import java.util.ArrayList;
import java.util.List;
public class ManagedConnections {
public List<ManagedConnection> managedConnections = new ArrayList<>();
}

View File

@ -0,0 +1,27 @@
/*-
* ~~~~~~licensing~~~~~~
* connection-management
* ==========
* 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.platform.core.management.connection.impl;
public interface ManagedConnectionsListener {
public void addded(ManagedConnections connections);
public void removed(ManagedConnections connections);
}

View File

@ -0,0 +1,84 @@
/*-
* ~~~~~~licensing~~~~~~
* connection-management
* ==========
* 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.platform.core.management.connection.tracker;
import java.util.List;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.wiring.BundleCapability;
import org.osgi.framework.wiring.BundleRevision;
import org.osgi.util.tracker.BundleTrackerCustomizer;
import ru.entaxy.esb.platform.core.management.connection.ConnectionsMBean;
import ru.entaxy.esb.platform.core.management.connection.impl.ManagedConnection;
import ru.entaxy.esb.platform.core.management.connection.impl.ManagedConnections;
import ru.entaxy.esb.platform.core.management.connection.impl.ManagedConnectionsListener;
import ru.entaxy.platform.base.support.CommonUtils;
public class DeployedConnectionCustomizer implements BundleTrackerCustomizer<ManagedConnections> {
protected ManagedConnectionsListener listener;
public DeployedConnectionCustomizer(ManagedConnectionsListener listener) {
this.listener = listener;
}
@Override
public ManagedConnections addingBundle(Bundle bundle, BundleEvent event) {
BundleRevision revision = bundle.adapt(BundleRevision.class);
if (revision == null)
return null;
List<BundleCapability> capabilities = revision.getDeclaredCapabilities(ConnectionsMBean.CAPABILITY_NAMESPACE);
if ((capabilities==null) || (capabilities.size()==0))
return null;
ManagedConnections result = new ManagedConnections();
for (BundleCapability capability: capabilities) {
Object val = capability.getAttributes().get("name");
String name = val==null?"":val.toString();
if (!CommonUtils.isValid(name))
continue;
val = capability.getAttributes().get("platform");
boolean isPlatform = val==null?false:"true".equals(val.toString());
ManagedConnection mc = (new ManagedConnection())
.name(name)
.platform(isPlatform)
.deployed(true)
.local(isPlatform)
.shared(true)
.bundleId(bundle.getBundleId());
result.managedConnections.add(mc);
}
listener.addded(result);
return result;
}
@Override
public void modifiedBundle(Bundle bundle, BundleEvent event, ManagedConnections object) {
// TODO Auto-generated method stub
}
@Override
public void removedBundle(Bundle bundle, BundleEvent event, ManagedConnections object) {
listener.removed(object);
}
}

View File

@ -0,0 +1,37 @@
/*-
* ~~~~~~licensing~~~~~~
* connection-management
* ==========
* 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.platform.core.management.connection.tracker;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.BundleTracker;
import ru.entaxy.esb.platform.core.management.connection.impl.ManagedConnections;
import ru.entaxy.esb.platform.core.management.connection.impl.ManagedConnectionsListener;
public class DeployedConnectionTracker extends BundleTracker<ManagedConnections> {
public DeployedConnectionTracker(BundleContext bundleContext, ManagedConnectionsListener listener) {
super(bundleContext
, Bundle.ACTIVE | Bundle.INSTALLED | Bundle.RESOLVED | Bundle.STARTING | Bundle.STOPPING
, new DeployedConnectionCustomizer(listener));
}
}

View File

@ -7,7 +7,7 @@
<parent>
<groupId>ru.entaxy.esb.platform.runtime.core</groupId>
<artifactId>management</artifactId>
<version>1.8.0</version>
<version>1.8.1</version>
</parent>
<groupId>ru.entaxy.esb.platform.runtime.core.management</groupId>
@ -22,6 +22,9 @@
ru.entaxy.esb.platform.runtime.core.management.connection.api,
ru.entaxy.esb.platform.runtime.core.management.connection.util
</bundle.osgi.export.pkg>
<!-- bundle.osgi.private.pkg>
ru.entaxy.esb.platform.runtime.core.management.connection.impl
</bundle.osgi.private.pkg -->
</properties>
<dependencies>
@ -30,6 +33,23 @@
<artifactId>connection-producer</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.platform.runtime.core</groupId>
<artifactId>artifact-management</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.platform.runtime.base</groupId>
<artifactId>base-support</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>
ru.entaxy.esb.platform.runtime.base.connecting
</groupId>
<artifactId>connection</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -24,5 +24,10 @@ import ru.entaxy.esb.platform.runtime.base.connecting.connection.Connection;
import java.util.List;
public interface ConnectionManager {
/*
@Deprecated
public List<Connection> createAndInstallConnections(String json) throws Exception;
*/
public List<Connection> installUpdateConnections(String json, String newTimestamp) throws Exception;
public List<Connection> checkInstallConnections(String json, String timestamp) throws Exception;
}

View File

@ -19,39 +19,157 @@
*/
package ru.entaxy.esb.platform.runtime.core.management.connection.impl;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.esb.platform.runtime.base.connecting.connection.Connection;
import ru.entaxy.esb.platform.runtime.base.connecting.connection.util.ConnectionUtil;
import ru.entaxy.esb.platform.runtime.base.connecting.producer.connection.util.ConnectionProducerUtil;
import ru.entaxy.esb.platform.runtime.core.management.connection.api.ConnectionManager;
import ru.entaxy.esb.system.management.blueprint.generator.Blueprint;
import java.io.File;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import org.osgi.framework.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import ru.entaxy.esb.platform.runtime.base.connecting.connection.Connection;
import ru.entaxy.esb.platform.runtime.base.connecting.connection.util.ConnectionUtil;
import ru.entaxy.esb.platform.runtime.base.connecting.generator.Generated;
import ru.entaxy.esb.platform.runtime.base.connecting.producer.connection.util.ConnectionProducerUtil;
import ru.entaxy.esb.platform.runtime.core.management.connection.api.ConnectionManager;
import ru.entaxy.platform.core.artifact.Artifact;
import ru.entaxy.platform.core.artifact.Artifacts;
import ru.entaxy.platform.core.artifact.DeployedArtifact;
import ru.entaxy.platform.core.artifact.installer.builder.Installer;
import ru.entaxy.platform.core.artifact.installer.builder.typed.BlueprintInstaller;
import ru.entaxy.platform.core.artifact.service.ArtifactService;
public class ConnectionManagerImpl implements ConnectionManager {
private static final String CONNECTION = "connection";
private static final String GROUP_ID = "ru.entaxy.esb.";
/*
private static final String GROUP_ID = "ru.entaxy.esb.";
private static final String XML_EXTENSION = "xml";
private static final String LOCAL_FILE_REPOSITORY = "data" + File.separator + "local-repository";
*/
protected ArtifactService artifactService;
private static final Logger log = LoggerFactory.getLogger(ConnectionManagerImpl.class);
@Override
public List<Connection> checkInstallConnections(String json, String timestamp) throws Exception {
List<Connection> connections = parseConnections(json);
for (Connection connection: connections) {
Artifact artifact = createArtifactForConnection(connection);
artifact.getCoordinates().timestamped(timestamp);
DeployedArtifact deployed;
if (connection.isPlatform()) {
deployed = artifactService.deployLocal(artifact);
} else {
deployed = artifactService.deployShared(artifact);
}
log.info("Artifact [{}] deployed to location [{}]", artifact.getCoordinates(), deployed.getLocation());
Installer<?> installer = connection.isPlatform()
?artifactService.installers().local()
:artifactService.installers().cluster();
// TODO add support for other types
// assume artifact is blueprint
installer
.artifact(deployed)
.typed(BlueprintInstaller.class)
.installOnlyIfMissing()
.start()
.install();
}
return connections;
}
@Override
public List<Connection> installUpdateConnections(String json, String newTimestamp) throws Exception {
List<Connection> connections = parseConnections(json);
for (Connection connection: connections) {
Artifact artifact = createArtifactForConnection(connection);
artifact.getCoordinates().timestamped(newTimestamp);
DeployedArtifact deployed;
if (connection.isPlatform()) {
deployed = artifactService.deployLocal(artifact);
} else {
deployed = artifactService.deployShared(artifact);
}
log.info("Artifact [{}] deployed to location [{}]", artifact.getCoordinates(), deployed.getLocation());
Installer<?> installer = connection.isPlatform()
?artifactService.installers().local()
:artifactService.installers().cluster();
// TODO add support for other types
// assume artifact is blueprint
installer
.artifact(deployed)
.typed(BlueprintInstaller.class)
.update(deployed
.getArtifact().getProperties()
.getOrDefault(Constants.BUNDLE_SYMBOLICNAME, "")
.toString())
.start()
.install();
}
return connections;
}
protected List<Connection> parseConnections(String json){
List<Connection> connectionList = new ArrayList<>();
JsonElement jsonElement = getJsonElement(json);
List<JsonObject> jsonConnectionList = getJsonConnectionList(jsonElement);
for (JsonObject jsonConnection : jsonConnectionList) {
connectionList.add(ConnectionProducerUtil.createConnection(jsonConnection));
}
return connectionList;
}
protected List<Artifact> createArtifactsForConnections(List<Connection> connections) throws Exception{
List<Artifact> artifacts = new ArrayList<>();
for (Connection connection: connections)
artifacts.add(createArtifactForConnection(connection));
return artifacts;
}
protected Artifact createArtifactForConnection(Connection connection) throws Exception{
Generated result = ConnectionUtil.getInit(connection);
String type = CONNECTION;
String name = connection.getName();
String version = "1.0.0";
// TODO add support for other artifact types
if (Generated.GENERATED_TYPE_BLUEPRINT.equals(result.getType())) {
Artifact artifact = Artifacts.fromGenerated(result);
artifact.getCoordinates()
.timestampedVersion(version)
.groupId(Artifact.DEFAULT_RUNTIME_GROUP_ID + "." + type)
.artifactId(type + "-" + name);
artifact.provideCapability(artifact.getCoordinates().getGroupId())
.attribute("name",connection.getName())
.attribute("platform", connection.isPlatform()?"true":"false");
log.info("Artifact of category [{}] is prepared: [{}]", artifact.getCategory(), artifact.getCoordinates());
return artifact;
} else {
log.error("Generated result for connection [{}] is of type '{}' while expected '{}'"
, connection.getName()
, result.getType()
, Generated.GENERATED_TYPE_BLUEPRINT);
return null;
}
}
/*
public List<Connection> createAndInstallConnections(String json) throws Exception {
return createConnections(json, false, true);
}
@ -69,7 +187,7 @@ public class ConnectionManagerImpl implements ConnectionManager {
}
return connectionList;
}
*/
private JsonElement getJsonElement(String json) {
return new Gson().fromJson(json, JsonElement.class);
}
@ -95,7 +213,7 @@ public class ConnectionManagerImpl implements ConnectionManager {
return jsonConnectionList;
}
/*
private Connection createConnection(JsonObject jsonConnection, boolean register, boolean install) {
Connection connection = ConnectionProducerUtil.createConnection(jsonConnection);
if (register) {
@ -115,20 +233,64 @@ public class ConnectionManagerImpl implements ConnectionManager {
String name = connection.getName();
String type = CONNECTION;
String version = String.valueOf(1.0);
Blueprint blueprint = ConnectionUtil.getInit(connection);
log.debug(new String(blueprint.getBody(), Charset.defaultCharset()));
Generated result = ConnectionUtil.getInit(connection);
// TODO: pass the Generated to artifact management
if (Generated.GENERATED_TYPE_BLUEPRINT.equals(result.getType())) {
Artifact artifact = Artifacts.fromGenerated(result);
artifact.getCoordinates()
.timestampedVersion(version)
.groupId(Artifact.DEFAULT_RUNTIME_GROUP_ID + "." + type)
.artifactId(type + "-" + name);
log.info("Artifact of category [{}] is prepared: [{}]", artifact.getCategory(), artifact.getCoordinates());
// return bundleManager.installAndStartBundle(name, type, version, blueprint);
// Local bundle install needed instead of cellar install to cluster
String bundleUrl = deployBlueprint(GROUP_ID + type, type + "-" + name,
version, XML_EXTENSION, blueprint.getBody());
Bundle bundle = installAndStartBundle(bundleUrl);
return bundle;
// TODO: 09.07.2021 callback for webeditor needed
DeployedArtifact deployedArtifact = artifactService.deployLocal(artifact);
log.info("Artifact [{}] deployed to location [{}]", artifact.getCoordinates(), deployedArtifact.getLocation());
InstallationResult installationResult = this.artifactService
.installers()
.cluster()
.artifact(deployedArtifact)
.typed(BlueprintInstaller.class)
.start()
.update(deployedArtifact.getArtifact().getProperties().getOrDefault(Constants.BUNDLE_SYMBOLICNAME, "").toString())
.install();
*/
/*
log.debug(new String(result.getObject().toString().getBytes(), Charset.defaultCharset()));
log.info("Blueprint is generated for connection [{}]", connection.getName());
// Local bundle install needed instead of cellar install to cluster
String bundleUrl = deployBlueprint(GROUP_ID + type, type + "-" + name,
version, XML_EXTENSION, result.getObject().toString().getBytes());
Bundle bundle = installAndStartBundle(bundleUrl);
*/
/* if (installationResult.isSuccessful()) {
if (installationResult.getObject() != null)
if (installationResult.getObject() instanceof Bundle) {
Bundle bundle = (Bundle)installationResult.getObject();
log.info("Bundle [{}] successfully {}'d from artifact [{}]"
, bundle.getBundleId()
, installationResult.getResult().name()
, deployedArtifact.getArtifact().getCoordinates());
return bundle;
}
}
return null;
// TODO: 09.07.2021 callback for webeditor needed
} else {
log.error("Generated result for connection [{}] is of type '{}' while expected '{}'"
, connection.getName()
, result.getType()
, Generated.GENERATED_TYPE_BLUEPRINT);
return null;
}
}
// ru.entaxy.esb.system.deployer.file.FileSystemRepositoryImpl.deployBlueprint method copy
@Deprecated
public String deployBlueprint(String groupId, String name, String version,
String extension, byte[] data) throws Exception {
Path path = preparePath(groupId, name, version, extension);
@ -139,13 +301,15 @@ public class ConnectionManagerImpl implements ConnectionManager {
return "blueprint:file:" + path.normalize();
}
@Deprecated
private Path preparePath(String groupId, String name, String version, String extension) {
String gpoupIdPath = groupId.replaceAll("\\.", Matcher.quoteReplacement(File.separator));
String fileName = name + "-" + version + "." + extension;
Path path = Paths.get(LOCAL_FILE_REPOSITORY, gpoupIdPath, fileName);
return path;
}
@Deprecated
private Bundle installAndStartBundle(String bundleUrl) {
BundleContext bundleContext = FrameworkUtil.getBundle(ConnectionManagerImpl.class).getBundleContext();
Bundle bundle = null;
@ -161,6 +325,9 @@ public class ConnectionManagerImpl implements ConnectionManager {
}
return bundle;
}
*/
public void setArtifactService(ArtifactService artifactService) {
this.artifactService = artifactService;
}
}

View File

@ -25,6 +25,7 @@ import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
import ru.entaxy.esb.platform.runtime.core.management.connection.api.ConnectionManager;
import ru.entaxy.platform.base.support.osgi.OSGIUtils;
public class ConnectionManagerUtil {
@ -35,9 +36,21 @@ public class ConnectionManagerUtil {
// get our own bundleContext
BundleContext bundleContext = FrameworkUtil.getBundle(ConnectionManagerUtil.class).getBundleContext();
try {
return OSGIUtils.services().bundleContext(bundleContext)
.waitService(2000)
.ofClass(ConnectionManager.class)
.<ConnectionManager>get();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
return null;
}
// found an issue: service is not returned 'cause the initializers start earlier than
// Karaf publishes service
// So we should use tracker here to be sure the service is active
/*
if (tracker == null) {
tracker = new ServiceTracker(bundleContext, ConnectionManager.class, null);
tracker.open();
@ -47,10 +60,12 @@ public class ConnectionManagerUtil {
} catch (Exception e) {
// TODO: handle exception
}
*/
/*
ServiceReference<ConnectionManager> connectionManagerServiceReference =
tracker.getServiceReference();
// bundleContext.getServiceReference(ConnectionManager.class);
return bundleContext.getService(connectionManagerServiceReference);
*/
}
}

View File

@ -23,7 +23,11 @@
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="connectionManager" class="ru.entaxy.esb.platform.runtime.core.management.connection.impl.ConnectionManagerImpl"/>
<reference id="artifactService" interface="ru.entaxy.platform.core.artifact.service.ArtifactService" availability="mandatory"></reference>
<bean id="connectionManager" class="ru.entaxy.esb.platform.runtime.core.management.connection.impl.ConnectionManagerImpl">
<property name="artifactService" ref="artifactService"></property>
</bean>
<service ref="connectionManager" interface="ru.entaxy.esb.platform.runtime.core.management.connection.api.ConnectionManager"/>

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,47 @@
<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</groupId>
<artifactId>management</artifactId>
<version>1.8.1</version>
</parent>
<groupId>ru.entaxy.esb.platform.runtime.core.management</groupId>
<artifactId>node-management</artifactId>
<version>1.8.1</version>
<packaging>bundle</packaging>
<name>ENTAXY :: PLATFORM :: RUNTIME :: CORE :: MANAGEMENT :: NODE MANAGEMENT </name>
<description>ENTAXY :: PLATFORM :: RUNTIME :: CORE :: MANAGEMENT :: NODE MANAGEMENT </description>
<properties>
<bundle.osgi.export.pkg>ru.entaxy.esb.platform.core.management.node</bundle.osgi.export.pkg>
<bundle.osgi.private.pkg>ru.entaxy.esb.platform.core.management.node.impl</bundle.osgi.private.pkg>
</properties>
<dependencies>
<dependency>
<groupId>ru.entaxy.esb.platform.runtime.base</groupId>
<artifactId>management-core</artifactId>
<version>${project.version}</version>
</dependency>
<!-- @TODO move declaration to root/pom.xml -->
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
<version>1.4.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.karaf.features</groupId>
<artifactId>org.apache.karaf.features.core</artifactId>
<version>${karaf.version}</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>${osgi.compendium.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,24 @@
/*-
* ~~~~~~licensing~~~~~~
* node-management
* ==========
* Copyright (C) 2020 - 2022 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.platform.core.management.node;
public interface ClusterLocalNodeDataProvider extends NodeDataProvider {
}

View File

@ -0,0 +1,24 @@
/*-
* ~~~~~~licensing~~~~~~
* node-management
* ==========
* Copyright (C) 2020 - 2022 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.platform.core.management.node;
public interface ClusterNodeMBean extends NodeMBean {
}

View File

@ -0,0 +1,28 @@
/*-
* ~~~~~~licensing~~~~~~
* node-management
* ==========
* Copyright (C) 2020 - 2022 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.platform.core.management.node;
import ru.entaxy.esb.platform.base.management.core.api.MBeanAnnotated;
import ru.entaxy.esb.platform.base.management.core.api.MBeanExportPolicy;
@MBeanAnnotated(policy = MBeanExportPolicy.ANNOTATED_ONLY)
public interface LocalNodeMBean extends NodeMBean, NodeDataProviderAware {
}

View File

@ -0,0 +1,24 @@
/*-
* ~~~~~~licensing~~~~~~
* node-management
* ==========
* Copyright (C) 2020 - 2022 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.platform.core.management.node;
public interface NodeDataProvider extends NodeMBean {
}

View File

@ -0,0 +1,26 @@
/*-
* ~~~~~~licensing~~~~~~
* node-management
* ==========
* Copyright (C) 2020 - 2022 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.platform.core.management.node;
public interface NodeDataProviderAware {
public NodeDataProvider getDataProvider();
}

View File

@ -0,0 +1,50 @@
/*-
* ~~~~~~licensing~~~~~~
* node-management
* ==========
* Copyright (C) 2020 - 2022 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.platform.core.management.node;
import ru.entaxy.esb.platform.base.management.core.api.Attribute;
import ru.entaxy.esb.platform.base.management.core.api.MBeanAnnotated;
import ru.entaxy.esb.platform.base.management.core.api.MBeanExportPolicy;
@MBeanAnnotated(policy = MBeanExportPolicy.ANNOTATED_ONLY)
public interface NodeMBean {
@Attribute(desc = "Entaxy Platform version")
public String getEntaxyPlatformVersion();
@Attribute(desc = "HTTP port")
public String getHttpPort();
@Attribute(desc = "SSH port")
public String getSshPort();
@Attribute(desc = "UI enabled")
public boolean isUIEnabled();
@Attribute(desc = "Cluster enabled")
public boolean isClusterEnabled();
@Attribute(desc = "Cluster IP")
public String getClusterIP();
@Attribute(desc = "Cluster port")
public String getClusterPort();
}

View File

@ -0,0 +1,206 @@
/*-
* ~~~~~~licensing~~~~~~
* node-management
* ==========
* Copyright (C) 2020 - 2022 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.platform.core.management.node.impl;
import java.io.IOException;
import javax.management.DynamicMBean;
import javax.management.MBeanRegistration;
import javax.management.NotCompliantMBeanException;
import org.apache.karaf.features.Feature;
import org.apache.karaf.features.FeaturesService;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
import org.osgi.service.component.annotations.ReferencePolicyOption;
import org.osgi.service.component.annotations.ServiceScope;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.esb.platform.base.management.core.ManagementCore;
import ru.entaxy.esb.platform.base.management.core.api.AnnotatedMBean;
import ru.entaxy.esb.platform.core.management.node.ClusterLocalNodeDataProvider;
import ru.entaxy.esb.platform.core.management.node.NodeDataProviderAware;
import ru.entaxy.esb.platform.core.management.node.LocalNodeMBean;
import ru.entaxy.esb.platform.core.management.node.NodeDataProvider;
import ru.entaxy.esb.platform.core.management.node.NodeMBean;
import ru.entaxy.platform.base.support.CommonUtils;
@Component(
service = {DynamicMBean.class, MBeanRegistration.class, LocalNodeMBean.class, NodeDataProviderAware.class},
property = {ManagementCore.JMX_OBJECTNAME + "=" + ManagementCore.Q_LOCAL_NODE_S},
scope = ServiceScope.SINGLETON,
immediate = true
)
public class LocalNodeMBeanImpl extends AnnotatedMBean<LocalNodeMBean> implements LocalNodeMBean, NodeDataProviderAware {
private static final Logger log = LoggerFactory.getLogger(LocalNodeMBeanImpl.class);
public static final String ENTAXY_PLATFORM_FEATURE_NAME = "entaxy-platform";
public static final String ENTAXY_UI_FEATURE_NAME = "entaxy-ui";
@Reference(cardinality = ReferenceCardinality.MANDATORY)
FeaturesService featuresService;
@Reference(cardinality = ReferenceCardinality.MANDATORY)
ConfigurationAdmin configurationAdmin;
protected ClusterLocalNodeDataProvider clusterLocalNodeDataProvider = null;
@Reference(cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.DYNAMIC,
policyOption = ReferencePolicyOption.GREEDY, unbind = "unsetClusterLocalNodeDataProvider")
public void setClusterLocalNodeDataProvider(ClusterLocalNodeDataProvider clusterCurrentNodeMBean) {
this.clusterLocalNodeDataProvider = clusterCurrentNodeMBean;
}
public void unsetClusterLocalNodeDataProvider(ClusterLocalNodeDataProvider clusterCurrentNodeMBean) {
this.clusterLocalNodeDataProvider = null;
}
protected LocalMBeanDataProvider dataProvider = new LocalMBeanDataProvider();
public LocalNodeMBeanImpl() throws NotCompliantMBeanException {
super(LocalNodeMBean.class);
}
protected String getInstalledFeatureVersion(String featureName) {
String result = "";
try {
Feature[] features = this.featuresService.getFeatures(featureName);
for (int i=0; i<features.length; i++) {
if (this.featuresService.isInstalled(features[i])) {
result = features[i].getVersion();
break;
}
}
} catch (Exception e) {
log.error("Error getting feature: " + featureName, e);
}
return result;
}
protected String getConfigurationValue(String pid, String name) {
String result = "";
Configuration config;
try {
config = LocalNodeMBeanImpl.this.configurationAdmin.getConfiguration(pid);
} catch (IOException e) {
log.error("Error getting configuration: " + pid, e);
return result;
}
if (config == null)
return "";
return (String) config.getProperties().get(name);
}
protected class LocalMBeanDataProvider implements NodeDataProvider {
@Override
public String getEntaxyPlatformVersion() {
return LocalNodeMBeanImpl.this.getInstalledFeatureVersion(ENTAXY_PLATFORM_FEATURE_NAME);
}
@Override
public String getHttpPort() {
return LocalNodeMBeanImpl.this.getConfigurationValue("org.ops4j.pax.web", "org.osgi.service.http.port");
}
@Override
public String getSshPort() {
return LocalNodeMBeanImpl.this.getConfigurationValue("org.apache.karaf.shell", "sshPort");
}
@Override
public boolean isUIEnabled() {
return CommonUtils.isValid(LocalNodeMBeanImpl.this.getInstalledFeatureVersion(ENTAXY_UI_FEATURE_NAME));
}
@Override
public boolean isClusterEnabled() {
return false;
}
@Override
public String getClusterIP() {
return null;
}
@Override
public String getClusterPort() {
return null;
}
}
@Override
public NodeDataProvider getDataProvider() {
return this.dataProvider;
}
protected NodeDataProvider getActiveDataProvider() {
if (this.clusterLocalNodeDataProvider == null)
return this.dataProvider;
return this.clusterLocalNodeDataProvider;
}
@Override
public String getEntaxyPlatformVersion() {
return getActiveDataProvider().getEntaxyPlatformVersion();
}
@Override
public String getHttpPort() {
return getActiveDataProvider().getHttpPort();
}
@Override
public String getSshPort() {
return getActiveDataProvider().getSshPort();
}
@Override
public boolean isUIEnabled() {
return getActiveDataProvider().isUIEnabled();
}
@Override
public boolean isClusterEnabled() {
return getActiveDataProvider().isClusterEnabled();
}
@Override
public String getClusterIP() {
return getActiveDataProvider().getClusterIP();
}
@Override
public String getClusterPort() {
return getActiveDataProvider().getClusterPort();
}
}

View File

@ -7,7 +7,7 @@
<parent>
<groupId>ru.entaxy.esb.platform.runtime</groupId>
<artifactId>core</artifactId>
<version>1.8.0</version>
<version>1.8.1</version>
</parent>
<groupId>ru.entaxy.esb.platform.runtime.core</groupId>
@ -18,6 +18,12 @@
<modules>
<module>connection-manager</module>
<module>connection-management</module>
<module>blueprint-generator-service</module>
<module>profile-management</module>
<module>node-management</module>
<module>cluster-node-management</module>
<module>profile-management-service-adapters</module>
</modules>
</project>

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,128 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ru.entaxy.esb.platform.runtime.core</groupId>
<artifactId>management</artifactId>
<version>1.8.1</version>
</parent>
<groupId>ru.entaxy.esb.platform.runtime.core.management</groupId>
<artifactId>profile-management-service-adapters</artifactId>
<packaging>bundle</packaging>
<name>ENTAXY :: PLATFORM :: RUNTIME :: CORE :: MANAGEMENT :: PROFILE MANAGEMENT SERVICE ADAPTERS</name>
<description>ENTAXY :: PLATFORM :: RUNTIME :: CORE :: MANAGEMENT :: PROFILE MANAGEMENT SERVICE ADAPTERS</description>
<properties>
<bundle.osgi.export.pkg>
<!-- ru.entaxy.esb.platform.core.management.profile,
ru.entaxy.esb.platform.core.management.profile.api -->
</bundle.osgi.export.pkg>
<bundle.osgi.private.pkg>
ru.entaxy.esb.platform.core.management.profile.adapters
<!-- ru.entaxy.esb.platform.base.management.core.utils,
ru.entaxy.platform.base.support.osgi.tracker,
ru.entaxy.platform.base.support.osgi.tracker.filter,
ru.entaxy.esb.platform.core.management.profile.impl* -->
</bundle.osgi.private.pkg>
</properties>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
<version>1.4.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr</artifactId>
<version>2.1.20</version>
</dependency>
<dependency>
<groupId>
ru.entaxy.esb.platform.runtime.base
</groupId>
<artifactId>base-support</artifactId>
<version>${project.version}</version>
</dependency>
<!-- dependency>
<groupId>ru.entaxy.esb.platform.runtime.base</groupId>
<artifactId>management-core</artifactId>
<version>${project.version}</version>
</dependency-->
<dependency>
<groupId>ru.entaxy.esb.platform.runtime.core.management</groupId>
<artifactId>profile-management</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.system.management.profile.manager</groupId>
<artifactId>profile-manager</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.system.registry.systems</groupId>
<artifactId>system-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.system.management</groupId>
<artifactId>system-management-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>
ru.entaxy.esb.system.management.connector.manager
</groupId>
<artifactId>connector-manager</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.system.management.bundle.jpa</groupId>
<artifactId>bundle-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.system.registry.connector</groupId>
<artifactId>connector-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.system.registry.connector</groupId>
<artifactId>connector-impl</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.system.core.permission</groupId>
<artifactId>permission-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>
ru.entaxy.esb.system.management.permission.manager
</groupId>
<artifactId>permission-manager</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<_dsannotations>*</_dsannotations>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,133 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management-service-adapters
* ==========
* 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.platform.core.management.profile.adapters;
import java.util.Map;
import org.osgi.service.component.annotations.CollectionType;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import ru.entaxy.esb.system.connector.entity.Connector;
import ru.entaxy.esb.system.connector.impl.ConnectorService;
import ru.entaxy.esb.system.jpa.SystemService;
import ru.entaxy.esb.system.jpa.entity.System;
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.connector.manager.ConnectorManager;
import ru.entaxy.esb.system.management.connector.manager.dto.ConnectorDto;
@Component (service = ru.entaxy.esb.platform.core.management.profile.api.ConnectorManager.class
, immediate = true)
public class ConnectorManagerAdapter implements ru.entaxy.esb.platform.core.management.profile.api.ConnectorManager {
@Reference(service = ConnectorManager.class, cardinality = ReferenceCardinality.MANDATORY
, collectionType = CollectionType.SERVICE)
ConnectorManager connectorManager;
@Reference (service = SystemService.class, cardinality = ReferenceCardinality.MANDATORY
, collectionType = CollectionType.SERVICE)
SystemService systemService;
@Reference (service = ConnectorService.class, cardinality = ReferenceCardinality.MANDATORY
, collectionType = CollectionType.SERVICE)
ConnectorService connectorService;
@Override
public void addConnector(String idOrName, String connectorFactoryId, Map<String, String> paramaters)
throws Exception {
System system = getSystemByIdOrName(idOrName);
if (system == null)
throw new IllegalArgumentException("System not found by Id or Name [" + idOrName + "]");
ConnectorDto connectorDto = new ConnectorDto();
connectorDto.setConnectorParams(paramaters);
connectorDto.setSystemUuid(system.getUuid());
connectorDto.setTemplateName(connectorFactoryId);
// FIXME remove hardcoded
connectorDto.setCreatedBy("admin");
checkBundleResult(connectorManager.installConnector(connectorDto)
, BundleStatus.ACTIVE);
}
@Override
public void removeConnector(String idOrName, String connectorName) throws Exception {
System system = getSystemByIdOrName(idOrName);
if (system == null)
throw new IllegalArgumentException("System not found by Id or Name [" + idOrName + "]");
Connector connector = connectorService.getConnectorByName(connectorName);
if (connector == null)
throw new IllegalArgumentException("Connector not found by Name [" + connectorName + "]");
checkBundleResult(connectorManager.uninstallConnector(connector)
, BundleStatus.UNINSTALL);
}
@Override
public void startConnector(String idOrName, String connectorName) throws Exception {
System system = getSystemByIdOrName(idOrName);
if (system == null)
throw new IllegalArgumentException("System not found by Id or Name [" + idOrName + "]");
Connector connector = connectorService.getConnectorByName(connectorName);
if (connector == null)
throw new IllegalArgumentException("Connector not found by Name [" + connectorName + "]");
checkBundleResult(connectorManager.startConnector(connector)
, BundleStatus.ACTIVE);
}
@Override
public void stopConnector(String idOrName, String connectorName) throws Exception {
System system = getSystemByIdOrName(idOrName);
if (system == null)
throw new IllegalArgumentException("System not found by Id or Name [" + idOrName + "]");
Connector connector = connectorService.getConnectorByName(connectorName);
if (connector == null)
throw new IllegalArgumentException("Connector not found by Name [" + connectorName + "]");
checkBundleResult(connectorManager.stopConnector(connector)
, BundleStatus.RESOLVED);
}
protected System getSystemByIdOrName(String idOrName) {
System result = systemService.getByName(idOrName);
if (result == null)
result = systemService.getByUuid(idOrName);
return result;
}
protected void checkBundleResult(BundleDto bundleDto, BundleStatus expectedStatus) throws Exception {
if ((bundleDto == null) || !expectedStatus.equals(bundleDto.getStatus()))
throw new Exception("Result bundle is null or in a wrong state");
}
}

View File

@ -0,0 +1,109 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management-service-adapters
* ==========
* 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.platform.core.management.profile.adapters;
import java.util.ArrayList;
import java.util.List;
import org.osgi.service.component.annotations.CollectionType;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import ru.entaxy.esb.system.core.permission.jpa.PermissionService;
import ru.entaxy.esb.system.core.permission.jpa.entity.Permission;
import ru.entaxy.esb.system.jpa.SystemService;
import ru.entaxy.esb.system.jpa.entity.System;
import ru.entaxy.esb.system.management.permission.manager.PermissionManager;
import ru.entaxy.esb.system.management.permission.manager.dto.PermissionDto;
@Component (service = ru.entaxy.esb.platform.core.management.profile.api.PermissionManager.class
, immediate = true)
public class PermissionManagerAdapter implements ru.entaxy.esb.platform.core.management.profile.api.PermissionManager {
@Reference(service = PermissionManager.class, cardinality = ReferenceCardinality.MANDATORY
, collectionType = CollectionType.SERVICE)
PermissionManager permissionManager;
@Reference(service = PermissionService.class, cardinality = ReferenceCardinality.MANDATORY
, collectionType = CollectionType.SERVICE)
PermissionService permissionService;
@Reference (service = SystemService.class, cardinality = ReferenceCardinality.MANDATORY
, collectionType = CollectionType.SERVICE)
SystemService systemService;
@Override
public List<String> getObjectPermissions(String objectId) throws Exception {
System system = getRequiredSystemByIdOrName(objectId);
List<Permission> permissions = permissionService.getAllById(system.getId(), "system");
long systemId = system.getId();
List<String> result = new ArrayList<>();
for (Permission perm: permissions) {
if (perm.getObjectId() == systemId) {
if ("system".equals(perm.getSubjectType())) {
System s = systemService.get(Long.parseLong(perm.getSubjectId()));
if (s != null)
result.add(s.getName());
}
}
}
return result;
}
@Override
public List<String> getSubjectPermissions(String subjectId) throws Exception {
System system = getRequiredSystemByIdOrName(subjectId);
List<Permission> permissions = permissionService.getAllById(system.getId(), "system");
String systemId = system.getId() + "";
List<String> result = new ArrayList<>();
for (Permission perm: permissions) {
if (perm.getSubjectId().equals(systemId)) {
System s = systemService.get(perm.getObjectId());
if (s != null)
result.add(s.getName());
}
}
return result;
}
@Override
public void createPremission(String objectId, String subjectId) throws Exception {
PermissionDto dto = new PermissionDto(objectId, subjectId);
permissionManager.createPermission(dto);
}
protected System getSystemByIdOrName(String idOrName) {
System result = systemService.getByName(idOrName);
if (result == null)
result = systemService.getByUuid(idOrName);
return result;
}
protected System getRequiredSystemByIdOrName(String idOrName) throws Exception {
System result = systemService.getByName(idOrName);
if (result == null)
result = systemService.getByUuid(idOrName);
if (result == null)
throw new IllegalArgumentException("System not found by Id or Name: [" + idOrName + "]");
return result;
}
}

View File

@ -0,0 +1,101 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management-service-adapters
* ==========
* 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.platform.core.management.profile.adapters;
import org.osgi.service.component.annotations.CollectionType;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import ru.entaxy.esb.system.jpa.SystemService;
import ru.entaxy.esb.system.jpa.entity.System;
import ru.entaxy.esb.system.management.profile.manager.ProfileManager;
import ru.entaxy.esb.system.management.profile.manager.dto.ProfileDto;
import ru.entaxy.esb.system.management.profile.manager.mapper.ProfileMapper;
@Component (
service = {ru.entaxy.esb.platform.core.management.profile.api.ProfileManager.class}
, immediate = true
)
public class ProfileManagerAdapter implements ru.entaxy.esb.platform.core.management.profile.api.ProfileManager{
@Reference (service = ProfileManager.class, cardinality = ReferenceCardinality.MANDATORY
, collectionType = CollectionType.SERVICE)
ProfileManager profileManager;
@Reference (service = ProfileMapper.class, cardinality = ReferenceCardinality.MANDATORY
, collectionType = CollectionType.SERVICE)
ProfileMapper profileMapper;
@Reference (service = SystemService.class, cardinality = ReferenceCardinality.MANDATORY
, collectionType = CollectionType.SERVICE)
SystemService systemService;
@Override
public void createProfile(String id, String name, String description) throws Exception {
ProfileDto dto = new ProfileDto();
dto.setUuid(id);
dto.setName(name);
dto.setDescription(description);
// TODO get the user name from JMX,
// need to investigate, how
dto.setCreatedBy("admin");
profileManager.installProfile(dto);
}
@Override
public void startProfile(String idOrName) throws Exception {
ProfileDto dto = getProfileForSystem(getSystemByIdOrName(idOrName));
if (dto == null)
throw new IllegalArgumentException("System/profile not found for [" + idOrName + "]");
profileManager.startProfile(dto);
}
@Override
public void stopProfile(String idOrName) throws Exception {
ProfileDto dto = getProfileForSystem(getSystemByIdOrName(idOrName));
if (dto == null)
throw new IllegalArgumentException("System/profile not found for [" + idOrName + "]");
profileManager.stopProfile(dto);
}
@Override
public void uninstallProfile(String idOrName) throws Exception {
ProfileDto dto = getProfileForSystem(getSystemByIdOrName(idOrName));
if (dto == null)
throw new IllegalArgumentException("System/profile not found for [" + idOrName + "]");
profileManager.uninstallProfile(dto);
}
protected System getSystemByIdOrName(String idOrName) {
System result = systemService.getByName(idOrName);
if (result == null)
result = systemService.getByUuid(idOrName);
return result;
}
protected ProfileDto getProfileForSystem(System system) {
if (system == null)
return null;
return profileMapper.toProfileDto(system);
}
}

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,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ru.entaxy.esb.platform.runtime.core</groupId>
<artifactId>management</artifactId>
<version>1.8.1</version>
</parent>
<groupId>ru.entaxy.esb.platform.runtime.core.management</groupId>
<artifactId>profile-management</artifactId>
<packaging>bundle</packaging>
<name>ENTAXY :: PLATFORM :: RUNTIME :: CORE :: MANAGEMENT :: PROFILE MANAGEMENT</name>
<description>ENTAXY :: PLATFORM :: RUNTIME :: CORE :: MANAGEMENT :: PROFILE MANAGEMENT</description>
<properties>
<bundle.osgi.export.pkg>
ru.entaxy.esb.platform.core.management.profile,
ru.entaxy.esb.platform.core.management.profile.api
</bundle.osgi.export.pkg>
<bundle.osgi.private.pkg>
ru.entaxy.esb.platform.base.management.core.utils,
ru.entaxy.platform.base.support.osgi.tracker,
ru.entaxy.platform.base.support.osgi.tracker.filter,
ru.entaxy.esb.platform.core.management.profile.impl*
</bundle.osgi.private.pkg>
</properties>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
<version>1.4.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr</artifactId>
<version>2.1.20</version>
</dependency>
<dependency>
<groupId>
ru.entaxy.esb.platform.runtime.base
</groupId>
<artifactId>base-support</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.platform.runtime.base</groupId>
<artifactId>management-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.system.auth.basic.api</groupId>
<artifactId>basic-auth-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ru.entaxy.esb.system.registry.systems</groupId>
<artifactId>system-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<_dsannotations>*</_dsannotations>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,64 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile;
import ru.entaxy.esb.platform.base.management.core.Qualifier;
import ru.entaxy.esb.platform.base.management.core.api.Attribute;
import ru.entaxy.esb.platform.base.management.core.api.MBeanAnnotated;
import ru.entaxy.esb.platform.base.management.core.api.MBeanExportPolicy;
import ru.entaxy.esb.platform.base.management.core.api.Operation;
import ru.entaxy.esb.platform.base.management.core.utils.BundleAwareMBean;
@MBeanAnnotated(policy = MBeanExportPolicy.ANNOTATION_ENRICH)
public interface ConnectorMBean extends BundleAwareMBean {
public static interface Helper {
public static Qualifier getQualifier(String profileName, String connectorName) {
return ConnectorsMBean.Helper.getQualifier(profileName).qualifier(CONNECTOR_KEY, connectorName);
}
}
public static final String CAPABILITY_NAMESPACE = "entaxy.runtime.connector";
public static final String CONNECTOR_KEY = "connector";
public static final String CONNECTOR_KEY_VALUE_DEFAULT = "default";
// TODO implement if needed
// public boolean isDefault();
@Attribute(desc = "Factory ID used to create the connector")
public String getFactoryId();
@Attribute(desc = "Connector name")
public String getName();
@Attribute(desc = "Connector registered name used in registry")
public String getRegisteredName();
@Operation(desc = "Starts the connector")
public void start() throws Exception;
@Operation(desc = "Stops the connector")
public void stop() throws Exception;
}

View File

@ -0,0 +1,37 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile;
import ru.entaxy.esb.platform.base.management.core.Qualifier;
public interface ConnectorsMBean {
public static interface Helper {
public static Qualifier getQualifier(String profileName) {
return ProfileMBean.Helper
.getQualifier(profileName)
.qualifier(CONNECTORS_KEY, CONNECTORS_KEY_VALUE);
}
}
public static final String CONNECTORS_KEY = "section";
public static final String CONNECTORS_KEY_VALUE = "connectors";
}

View File

@ -0,0 +1,44 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile;
import ru.entaxy.esb.platform.base.management.core.Qualifier;
import ru.entaxy.esb.platform.base.management.core.utils.BundleAwareMBean;
public interface DefaultRouteMBean extends BundleAwareMBean {
public static interface Helper {
public static Qualifier getQualifier(String profileName) {
return RoutesMBean.Helper.getQualifier(profileName).qualifier(ROUTE_KEY, ROUTE_KEY_VALUE_DEFAULT);
}
}
public static final String CAPABILITY_NAMESPACE = "entaxy.runtime.default-route";
public static final String ROUTE_KEY = "route";
public static final String ROUTE_KEY_VALUE_DEFAULT = "default";
public boolean isDefault();
}

View File

@ -0,0 +1,95 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile;
import java.util.List;
import java.util.Map;
import javax.management.MBeanOperationInfo;
import ru.entaxy.esb.platform.base.management.core.Qualifier;
import ru.entaxy.esb.platform.base.management.core.api.Attribute;
import ru.entaxy.esb.platform.base.management.core.api.MBeanAnnotated;
import ru.entaxy.esb.platform.base.management.core.api.MBeanExportPolicy;
import ru.entaxy.esb.platform.base.management.core.api.Operation;
import ru.entaxy.esb.platform.base.management.core.api.Parameter;
import ru.entaxy.esb.platform.base.management.core.utils.BundleAwareMBean;
@MBeanAnnotated(policy = MBeanExportPolicy.ANNOTATION_ENRICH)
public interface ProfileMBean extends BundleAwareMBean {
public static interface Helper {
public static Qualifier getQualifier(String name) {
return ProfilesMBean.Q_PROFILES.qualifier(PROFILE_KEY, name);
}
}
public static final String CAPABILITY_NAMESPACE = "entaxy.runtime.profile";
public static final String PROFILE_KEY = "profile";
@Attribute
public String getName();
@Attribute
public String getBasicAuthAccount();
@Attribute
public String getUuid();
@Attribute(desc = "Systems the current can send messages to")
public List<String> getAllowedTargets();
@Attribute(desc = "Systems the current can receive messages from")
public List<String> getAllowedSources();
@Operation(desc = "Adds connector to profile")
public void addConnector(
@Parameter(name = "factoryId", desc = "Connector factory ID") String connectorFactoryId
, @Parameter(name = "parameters", desc = "Connector parameters") Map<String, String> paramaters) throws Exception;
@Operation(desc = "Removes connector from profile")
public void removeConnector(
@Parameter(name = "connectorName", desc = "Connector name") String connectorName) throws Exception;
@Operation(desc = "Starts connector in profile")
public void startConnector(
@Parameter(name = "connectorName", desc = "Connector name") String connectorName) throws Exception;
@Operation(desc = "Stops connector in profile")
public void stopConnector(
@Parameter(name = "connectorName", desc = "Connector name") String connectorName) throws Exception;
@Operation(desc = "Creates account for this system", impact = MBeanOperationInfo.ACTION)
public void createAccount(
@Parameter(name = "login", desc = "Login") String login
, @Parameter(name = "password", desc = "Password") String password) throws Exception;
@Operation(desc = "Allow this system to send messages to other system")
public void allowTarget(
@Parameter(name="targetIdOrName", desc = "Target system Id or Name")String idOrName) throws Exception;
@Operation(desc = "Allow this system to receive messages from other system")
public void allowSource(
@Parameter(name="sourceIdOrName", desc = "Source system Id or Name")String idOrName) throws Exception;
}

View File

@ -0,0 +1,41 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile;
import ru.entaxy.esb.platform.base.management.core.ManagementCore;
import ru.entaxy.esb.platform.base.management.core.Qualifier;
import ru.entaxy.esb.platform.base.management.core.api.MBeanAnnotated;
import ru.entaxy.esb.platform.base.management.core.api.MBeanExportPolicy;
import ru.entaxy.esb.platform.core.management.profile.api.ProfileManager;
@MBeanAnnotated(policy = MBeanExportPolicy.ANNOTATION_ENRICH)
public interface ProfilesMBean extends ProfileManager {
public static final String CAPABILITY_NAMESPACE_DEFAULT_ROUTE = "entaxy.runtime.default-route";
public static final String PROFILES_KEY = "category";
public static final String PROFILES_KEY_VALUE = "profiles";
public static final Qualifier Q_PROFILES = ManagementCore.Q_RUNTIME
.qualifier(ProfilesMBean.PROFILES_KEY, ProfilesMBean.PROFILES_KEY_VALUE);
}

View File

@ -0,0 +1,38 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile;
import ru.entaxy.esb.platform.base.management.core.Qualifier;
public interface RoutesMBean {
public static interface Helper {
public static Qualifier getQualifier(String profileName) {
return ProfileMBean.Helper
.getQualifier(profileName)
.qualifier(ROUTES_KEY, ROUTES_KEY_VALUE);
}
}
public static final String ROUTES_KEY = "section";
public static final String ROUTES_KEY_VALUE = "routes";
}

View File

@ -0,0 +1,34 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.api;
import java.util.Map;
public interface ConnectorManager {
public void addConnector(String idOrName, String connectorFactoryId, Map<String, String> paramaters) throws Exception;
public void removeConnector(String idOrName, String connectorName) throws Exception;
public void startConnector(String idOrName, String connectorName) throws Exception;
public void stopConnector(String idOrName, String connectorName) throws Exception;
}

View File

@ -0,0 +1,32 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.api;
import java.util.List;
public interface PermissionManager {
public List<String> getObjectPermissions(String objectId) throws Exception;
public List<String> getSubjectPermissions(String subjectId) throws Exception;
public void createPremission(String objectId, String subjectId) throws Exception;
}

View File

@ -0,0 +1,42 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.api;
import ru.entaxy.esb.platform.base.management.core.api.Operation;
import ru.entaxy.esb.platform.base.management.core.api.Parameter;
public interface ProfileManager {
@Operation(desc = "Create and deploy new profile")
public void createProfile(
@Parameter(desc = "Profile ID", name = "id") String id,
@Parameter(desc = "System name", name = "name") String name,
@Parameter(desc = "Description", name = "description") String description) throws Exception;
@Operation(desc = "Start profile")
public void startProfile(@Parameter(desc = "Profile ID or system name", name = "idOrName") String idOrName) throws Exception;
@Operation(desc = "Stop profile")
public void stopProfile(@Parameter(desc = "Profile ID or system name", name = "idOrName") String idOrName) throws Exception;
@Operation(desc = "Uninstall profile")
public void uninstallProfile(@Parameter(desc = "Profile ID or system name", name = "idOrName") String idOrName) throws Exception;
}

View File

@ -0,0 +1,58 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.wiring.BundleCapability;
import ru.entaxy.esb.platform.base.management.core.utils.ExtendedBundleTrackerCustomizer;
import ru.entaxy.platform.base.support.CommonUtils;
import ru.entaxy.platform.base.support.osgi.tracker.filter.BundleCapabilityFilter;
public class DeployedProfileCustomizer extends ExtendedBundleTrackerCustomizer<List<ManagedProfile>> {
@Override
protected List<ManagedProfile> createManagedObject(Bundle bundle, BundleEvent event,
Map<String, List<?>> filterResults) {
@SuppressWarnings("unchecked")
List<BundleCapability> capabilities = (List<BundleCapability>)filterResults.get(BundleCapabilityFilter.DEFAULT_FILTER_ID);
if (capabilities==null)
capabilities = new ArrayList<>();
List<ManagedProfile> result = new ArrayList<>();
for (BundleCapability capability: capabilities) {
Object val = capability.getAttributes().get("name");
String name = val==null?"":val.toString();
if (!CommonUtils.isValid(name))
continue;
ManagedProfile mp = (new ManagedProfile())
.name(name);
enrich(bundle, event, filterResults, mp);
result.add(mp);
}
return result;
}
}

View File

@ -0,0 +1,41 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl;
import ru.entaxy.esb.platform.base.management.core.utils.BundleAwareManagedObjectImpl;
public class ManagedProfile extends BundleAwareManagedObjectImpl {
protected String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public ManagedProfile name(String name) {
setName(name);
return this;
}
}

View File

@ -0,0 +1,71 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl;
import java.util.Iterator;
import java.util.List;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.esb.platform.base.management.core.utils.ManagedObjectsListener;
import ru.entaxy.esb.platform.core.management.profile.ProfileMBean;
import ru.entaxy.esb.platform.core.management.profile.impl.helper.Helpers;
public class ManagedProfilesListener extends ManagedObjectsListener<List<ManagedProfile>
, ManagedProfile, ProfileMBean, ProfileMBeanImpl> {
private static final Logger log = LoggerFactory.getLogger(ManagedProfilesListener.class);
protected Helpers helpers;
public ManagedProfilesListener(BundleContext bundleContext, Helpers helpers) {
super(bundleContext, ProfileMBean.class);
this.helpers = helpers;
}
@Override
protected Iterator<ManagedProfile> getIterator(List<ManagedProfile> managedObject) {
return managedObject.iterator();
}
@Override
protected String getKeyValue(ManagedProfile object) {
return object.getName();
}
@Override
protected ProfileMBeanImpl createService(ManagedProfile managedObject) {
try {
return new ProfileMBeanImpl(bundleContext, managedObject, helpers);
} catch (Exception e) {
log.error("Error creating service", e);
return null;
} }
@Override
protected String getJmxObjectName(ManagedProfile managedObject) {
return ProfileMBean.Helper.getQualifier(managedObject.getName()).getValue();
}
}

View File

@ -0,0 +1,26 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl;
import ru.entaxy.esb.platform.core.management.profile.api.ProfileManager;
public interface ProfileHelper extends ProfileManager {
}

View File

@ -0,0 +1,119 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl;
import javax.naming.OperationNotSupportedException;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.CollectionType;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicyOption;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.esb.platform.core.management.profile.api.ProfileManager;
@Component(service = {ProfileHelper.class},
immediate = true)
public class ProfileHelperImpl implements ProfileHelper {
private static final Logger log = LoggerFactory.getLogger(ProfileHelperImpl.class);
protected static final String EXPLANATION = "ProfileManager not bound";
protected ProfileManager profileManager = null;
protected ProfileManager nullProfileManager = null;
@Activate
public void activate(ComponentContext componentContext) {
this.nullProfileManager = new ProfileManager() {
@Override
public void uninstallProfile(String idOrName) throws Exception {
throw new OperationNotSupportedException(EXPLANATION);
}
@Override
public void stopProfile(String idOrName) throws Exception {
throw new OperationNotSupportedException(EXPLANATION);
}
@Override
public void startProfile(String idOrName) throws Exception {
throw new OperationNotSupportedException(EXPLANATION);
}
@Override
public void createProfile(String id, String name, String description) throws Exception {
throw new OperationNotSupportedException(EXPLANATION);
}
};
}
public ProfileManager getEffectiveProfileManager() {
return profileManager!=null?profileManager:nullProfileManager;
}
@Reference (collectionType = CollectionType.SERVICE
, cardinality = ReferenceCardinality.OPTIONAL
, policyOption = ReferencePolicyOption.GREEDY
, service = ProfileManager.class
, unbind = "unsetProfileManager")
public void setProfileManager(ProfileManager profileManager) {
this.profileManager = profileManager;
log.debug(">> ProfileManager is bound");
}
public void unsetProfileManager(ProfileManager profileManager) {
this.profileManager = null;
log.debug(">> ProfileManager is unbound");
}
@Override
public void createProfile(String id, String name, String description) throws Exception {
getEffectiveProfileManager().createProfile(id, name, description);
}
@Override
public void startProfile(String idOrName) throws Exception {
getEffectiveProfileManager().startProfile(idOrName);
}
@Override
public void stopProfile(String idOrName) throws Exception {
getEffectiveProfileManager().stopProfile(idOrName);
}
@Override
public void uninstallProfile(String idOrName) throws Exception {
getEffectiveProfileManager().uninstallProfile(idOrName);
}
}

View File

@ -0,0 +1,141 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.management.NotCompliantMBeanException;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.esb.platform.base.management.core.utils.BundleAwareMBeanImpl;
import ru.entaxy.esb.platform.core.management.profile.ProfileMBean;
import ru.entaxy.esb.platform.core.management.profile.impl.helper.Helpers;
import ru.entaxy.esb.system.auth.basic.jpa.api.entity.BasicAuthAccount;
import ru.entaxy.esb.system.jpa.entity.System;
import ru.entaxy.platform.base.support.CommonUtils;
public class ProfileMBeanImpl extends BundleAwareMBeanImpl<ManagedProfile, ProfileMBean> implements ProfileMBean {
private static final Logger log = LoggerFactory.getLogger(ProfileMBeanImpl.class);
Helpers helpers;
public ProfileMBeanImpl(BundleContext bundleContext, ManagedProfile managedProfile
, Helpers helpers)
throws NotCompliantMBeanException {
super(ProfileMBean.class, managedProfile);
this.bundleContext = bundleContext;
this.helpers = helpers;
}
@Override
public String getName() {
return managedObject.getName();
}
@Override
public String getUuid() {
System system = helpers.systemService.getByName(getName());
if (system == null)
return "N/A";
return system.getUuid();
}
@Override
public String getBasicAuthAccount() {
Optional<BasicAuthAccount> bas = this.helpers.basicAuthService.getBySystem(getUuid());
if (bas.isPresent())
return bas.get().getLogin();
return "";
}
@Override
public void createAccount(String login, String password) throws Exception {
if (CommonUtils.isValid(getBasicAuthAccount()))
throw new IllegalArgumentException("Account already exists");
// FIXME remove hardcoded
this.helpers.basicAuthService.saveCommon(login
, password
, getUuid()
, "admin"
, "admin");
}
@Override
public void addConnector(String connectorFactoryId, Map<String, String> paramaters) throws Exception {
this.helpers.connectorHelper.addConnector(getName(), connectorFactoryId, paramaters);
}
@Override
public void removeConnector(String connectorName) throws Exception {
this.helpers.connectorHelper.removeConnector(getName(), connectorName);
}
@Override
public void startConnector(String connectorName) throws Exception {
this.helpers.connectorHelper.startConnector(getName(), connectorName);
}
@Override
public void stopConnector(String connectorName) throws Exception {
this.helpers.connectorHelper.stopConnector(getName(), connectorName);
}
@Override
public List<String> getAllowedTargets() {
try {
return helpers.permissionHelper.getObjectPermissions(getUuid());
} catch (Exception e) {
log.warn("getAllowedTargets not succeded", e);
}
return new ArrayList<>();
}
@Override
public List<String> getAllowedSources() {
try {
return helpers.permissionHelper.getSubjectPermissions(getUuid());
} catch (Exception e) {
log.warn("getAllowedSources not succeded", e);
}
return new ArrayList<>();
}
@Override
public void allowSource(String idOrName) throws Exception {
helpers.permissionHelper.createPremission(idOrName, getUuid());
}
@Override
public void allowTarget(String idOrName) throws Exception {
helpers.permissionHelper.createPremission(getUuid(), idOrName);
}
}

View File

@ -0,0 +1,171 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.management.DynamicMBean;
import javax.management.MBeanRegistration;
import javax.management.NotCompliantMBeanException;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.CollectionType;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ServiceScope;
import org.osgi.util.tracker.BundleTracker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.esb.platform.base.management.core.ManagementCore;
import ru.entaxy.esb.platform.base.management.core.api.AnnotatedMBean;
import ru.entaxy.esb.platform.core.management.profile.ConnectorMBean;
import ru.entaxy.esb.platform.core.management.profile.DefaultRouteMBean;
import ru.entaxy.esb.platform.core.management.profile.ProfileMBean;
import ru.entaxy.esb.platform.core.management.profile.ProfilesMBean;
import ru.entaxy.esb.platform.core.management.profile.impl.connector.DeployedConnectorCustomizer;
import ru.entaxy.esb.platform.core.management.profile.impl.connector.ManagedConnector;
import ru.entaxy.esb.platform.core.management.profile.impl.connector.ManagedConnectorsListener;
import ru.entaxy.esb.platform.core.management.profile.impl.helper.Helpers;
import ru.entaxy.esb.platform.core.management.profile.impl.route.DeployedDefaultRouteCustomizer;
import ru.entaxy.esb.platform.core.management.profile.impl.route.ManagedRoute;
import ru.entaxy.esb.platform.core.management.profile.impl.route.ManagedRoutesListener;
import ru.entaxy.platform.base.support.osgi.tracker.BundleTrackerUtils;
import ru.entaxy.platform.base.support.osgi.tracker.filter.BundleCapabilityFilter;
@Component(service = { ProfilesMBean.class, DynamicMBean.class, MBeanRegistration.class }, property = {
ManagementCore.JMX_OBJECTNAME + "=" + ManagementCore.Q_RUNTIME_S + "," + ProfilesMBean.PROFILES_KEY + "="
+ ProfilesMBean.PROFILES_KEY_VALUE }, scope = ServiceScope.SINGLETON, immediate = true)
public class ProfilesMBeanImpl extends AnnotatedMBean<ProfilesMBean>
implements ProfilesMBean {
private static final Logger log = LoggerFactory.getLogger(ProfilesMBeanImpl.class);
protected BundleContext bundleContext;
protected BundleTracker<List<ManagedProfile>> tracker;
protected BundleTracker<List<ManagedRoute>> routeTracker;
protected BundleTracker<List<ManagedConnector>> connectorTracker;
@Reference (cardinality = ReferenceCardinality.MANDATORY
, service = Helpers.class
, collectionType = CollectionType.SERVICE)
Helpers helpers;
public ProfilesMBeanImpl() throws NotCompliantMBeanException {
super(ProfilesMBean.class);
}
protected static class ManagedProfileDescriptor {
ManagedProfile profile;
ServiceRegistration<ProfileMBean> registration;
}
protected Map<String, ManagedProfileDescriptor> managed = new HashMap<>();
@Activate
public void activate(ComponentContext componentContext) {
this.bundleContext = componentContext.getBundleContext();
//tracker = new DeployedProfileTrackerOld(bundleContext, this);
tracker = BundleTrackerUtils.<List<ManagedProfile>>createBuilder()
.customizer(
(new DeployedProfileCustomizer())
.listener(new ManagedProfilesListener(bundleContext, this.helpers))
)
.addFilter(
(new BundleCapabilityFilter()).namespace(ProfileMBean.CAPABILITY_NAMESPACE)
)
.bundleContext(bundleContext)
.bundleState(Bundle.ACTIVE | Bundle.INSTALLED | Bundle.RESOLVED | Bundle.STARTING | Bundle.STOPPING)
.get();
tracker.open();
routeTracker = BundleTrackerUtils.<List<ManagedRoute>>createBuilder()
.customizer(
(new DeployedDefaultRouteCustomizer())
.listener(new ManagedRoutesListener(bundleContext))
)
.addFilter(
(new BundleCapabilityFilter()).namespace(DefaultRouteMBean.CAPABILITY_NAMESPACE)
)
.bundleContext(bundleContext)
.bundleState(Bundle.ACTIVE | Bundle.INSTALLED | Bundle.RESOLVED | Bundle.STARTING | Bundle.STOPPING)
.get();
routeTracker.open();
connectorTracker = BundleTrackerUtils.<List<ManagedConnector>>createBuilder()
.customizer(
(new DeployedConnectorCustomizer())
.listener(new ManagedConnectorsListener(bundleContext, this.helpers))
)
.addFilter(
(new BundleCapabilityFilter()).namespace(ConnectorMBean.CAPABILITY_NAMESPACE)
)
.bundleContext(bundleContext)
.bundleState(Bundle.ACTIVE | Bundle.INSTALLED | Bundle.RESOLVED | Bundle.STARTING | Bundle.STOPPING)
.get();
connectorTracker.open();
}
@Deactivate
public void deactivate() {
tracker.close();
routeTracker.close();
connectorTracker.close();
}
/*
* ProfileManager implementation
*/
@Override
public void createProfile(String id, String name, String description) throws Exception {
this.helpers.profileHelper.createProfile(id, name, description);
}
@Override
public void startProfile(String idOrName) throws Exception {
this.helpers.profileHelper.startProfile(idOrName);
}
@Override
public void stopProfile(String idOrName) throws Exception {
this.helpers.profileHelper.stopProfile(idOrName);
}
@Override
public void uninstallProfile(String idOrName) throws Exception {
this.helpers.profileHelper.uninstallProfile(idOrName);
}
}

View File

@ -0,0 +1,26 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl.connector;
import ru.entaxy.esb.platform.core.management.profile.api.ConnectorManager;
public interface ConnectorHelper extends ConnectorManager {
}

View File

@ -0,0 +1,118 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl.connector;
import java.util.Map;
import javax.naming.OperationNotSupportedException;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.CollectionType;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicyOption;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.esb.platform.core.management.profile.api.ConnectorManager;
import ru.entaxy.esb.platform.core.management.profile.impl.ProfileHelperImpl;
@Component(service = ConnectorHelper.class, immediate = true)
public class ConnectorHelperImpl implements ConnectorHelper {
private static final Logger log = LoggerFactory.getLogger(ProfileHelperImpl.class);
protected static final String EXPLANATION = "ConnectorManager not bound";
protected ConnectorManager connectorManager = null;
protected ConnectorManager nullConnectorManager = null;
@Activate
public void activate(ComponentContext componentContext) {
this.nullConnectorManager = new ConnectorManager() {
@Override
public void stopConnector(String idOrName, String connectorName) throws Exception {
throw new OperationNotSupportedException(EXPLANATION);
}
@Override
public void startConnector(String idOrName, String connectorName) throws Exception {
throw new OperationNotSupportedException(EXPLANATION);
}
@Override
public void removeConnector(String idOrName, String connectorName) throws Exception {
throw new OperationNotSupportedException(EXPLANATION);
}
@Override
public void addConnector(String idOrName, String connectorFactoryId, Map<String, String> paramaters)
throws Exception {
throw new OperationNotSupportedException(EXPLANATION);
}
};
}
public ConnectorManager getEffectiveConnectorManager() {
return connectorManager!=null?connectorManager:nullConnectorManager;
}
@Reference (collectionType = CollectionType.SERVICE
, cardinality = ReferenceCardinality.OPTIONAL
, policyOption = ReferencePolicyOption.GREEDY
, service = ConnectorManager.class
, unbind = "unsetConnectorManager")
public void setConnectorManager(ConnectorManager connectorManager) {
this.connectorManager = connectorManager;
log.debug(">> ConnectorManager is bound");
}
public void unsetConnectorManager(ConnectorManager connectorManager) {
this.connectorManager = null;
log.debug(">> ConnectorManager is unbound");
}
@Override
public void addConnector(String idOrName, String connectorFactoryId, Map<String, String> paramaters)
throws Exception {
getEffectiveConnectorManager().addConnector(idOrName, connectorFactoryId, paramaters);
}
@Override
public void removeConnector(String idOrName, String connectorName) throws Exception {
getEffectiveConnectorManager().removeConnector(idOrName, connectorName);
}
@Override
public void startConnector(String idOrName, String connectorName) throws Exception {
getEffectiveConnectorManager().startConnector(idOrName, connectorName);
}
@Override
public void stopConnector(String idOrName, String connectorName) throws Exception {
getEffectiveConnectorManager().stopConnector(idOrName, connectorName);
}
}

View File

@ -0,0 +1,65 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl.connector;
import javax.management.NotCompliantMBeanException;
import org.osgi.framework.BundleContext;
import ru.entaxy.esb.platform.base.management.core.utils.BundleAwareMBeanImpl;
import ru.entaxy.esb.platform.core.management.profile.ConnectorMBean;
import ru.entaxy.esb.platform.core.management.profile.impl.helper.Helpers;
public class ConnectorMBeanImpl extends BundleAwareMBeanImpl<ManagedConnector, ConnectorMBean> implements ConnectorMBean {
protected Helpers helpers;
public ConnectorMBeanImpl(BundleContext bundleContext, ManagedConnector managedObject, Helpers helpers)
throws NotCompliantMBeanException {
super(ConnectorMBean.class, managedObject);
this.bundleContext = bundleContext;
this.helpers = helpers;
}
@Override
public String getFactoryId() {
return this.managedObject.getFactoryId();
}
@Override
public String getName() {
return this.managedObject.getName();
}
@Override
public String getRegisteredName() {
return this.managedObject.getRegisteredName();
}
@Override
public void start() throws Exception {
this.helpers.connectorHelper.startConnector(this.managedObject.getSystem(), this.getRegisteredName());
}
@Override
public void stop() throws Exception {
this.helpers.connectorHelper.stopConnector(this.managedObject.getSystem(), this.getRegisteredName());
}
}

View File

@ -0,0 +1,72 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl.connector;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.wiring.BundleCapability;
import ru.entaxy.esb.platform.base.management.core.utils.ExtendedBundleTrackerCustomizer;
import ru.entaxy.platform.base.support.CommonUtils;
import ru.entaxy.platform.base.support.osgi.tracker.filter.BundleCapabilityFilter;
public class DeployedConnectorCustomizer extends ExtendedBundleTrackerCustomizer<List<ManagedConnector>> {
@Override
protected List<ManagedConnector> createManagedObject(Bundle bundle, BundleEvent event,
Map<String, List<?>> filterResults) {
@SuppressWarnings("unchecked")
List<BundleCapability> capabilities = (List<BundleCapability>)filterResults.get(BundleCapabilityFilter.DEFAULT_FILTER_ID);
if (capabilities==null)
capabilities = new ArrayList<>();
List<ManagedConnector> result = new ArrayList<>();
for (BundleCapability capability: capabilities) {
Object val = capability.getAttributes().get("name");
String name = val==null?"":val.toString();
if (!CommonUtils.isValid(name))
continue;
val = capability.getAttributes().get("system");
String system = val==null?"":val.toString();
if (!CommonUtils.isValid(system))
continue;
val = capability.getAttributes().get("templateId");
String templateId = val==null?"":val.toString();
val = capability.getAttributes().get("bundleName");
String registeredName = val==null?"":val.toString();
ManagedConnector mc = (new ManagedConnector())
.name(name)
.system(system)
.factoryId(templateId)
.registeredName(registeredName);
enrich(bundle, event, filterResults, mc);
result.add(mc);
}
return result;
}
}

View File

@ -0,0 +1,85 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl.connector;
import ru.entaxy.esb.platform.base.management.core.utils.BundleAwareManagedObjectImpl;
public class ManagedConnector extends BundleAwareManagedObjectImpl {
protected String system;
protected String name;
protected String registeredName;
protected String factoryId;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public ManagedConnector name(String name) {
setName(name);
return this;
}
public String getSystem() {
return system;
}
public void setSystem(String system) {
this.system = system;
}
public ManagedConnector system(String system) {
setSystem(system);
return this;
}
public String getFactoryId() {
return factoryId;
}
public void setFactoryId(String factoryId) {
this.factoryId = factoryId;
}
public ManagedConnector factoryId(String factoryIdValue) {
this.setFactoryId(factoryIdValue);
return this;
}
public String getRegisteredName() {
return registeredName;
}
public void setRegisteredName(String registeredName) {
this.registeredName = registeredName;
};
public ManagedConnector registeredName(String registeredNameValue) {
this.setRegisteredName(registeredNameValue);
return this;
};
}

View File

@ -0,0 +1,72 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl.connector;
import java.util.Iterator;
import java.util.List;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.esb.platform.base.management.core.utils.ManagedObjectsListener;
import ru.entaxy.esb.platform.core.management.profile.ConnectorMBean;
import ru.entaxy.esb.platform.core.management.profile.impl.helper.Helpers;
public class ManagedConnectorsListener extends ManagedObjectsListener<List<ManagedConnector>, ManagedConnector, ConnectorMBean, ConnectorMBeanImpl> {
private static final Logger log = LoggerFactory.getLogger(ManagedConnectorsListener.class);
protected Helpers helpers;
public ManagedConnectorsListener(BundleContext bundleContext, Helpers helpers) {
super(bundleContext, ConnectorMBean.class);
this.helpers = helpers;
}
@Override
protected Iterator<ManagedConnector> getIterator(List<ManagedConnector> managedObject) {
return managedObject.iterator();
}
@Override
protected String getKeyValue(ManagedConnector object) {
return object.getName();
}
@Override
protected ConnectorMBeanImpl createService(ManagedConnector managedObject) {
try {
return new ConnectorMBeanImpl(bundleContext, managedObject, helpers);
} catch (Exception e) {
log.error("Error creating service", e);
return null;
}
}
@Override
protected String getJmxObjectName(ManagedConnector managedObject) {
return ConnectorMBean.Helper.getQualifier(
managedObject.getSystem(),
managedObject.getName()
).getValue();
}
}

View File

@ -0,0 +1,49 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl.helper;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import ru.entaxy.esb.platform.core.management.profile.impl.ProfileHelper;
import ru.entaxy.esb.platform.core.management.profile.impl.connector.ConnectorHelper;
import ru.entaxy.esb.platform.core.management.profile.impl.permission.PermissionHelper;
import ru.entaxy.esb.system.auth.basic.jpa.api.BasicAuthService;
import ru.entaxy.esb.system.jpa.SystemService;
@Component (service = Helpers.class, immediate = true)
public class Helpers {
@Reference (cardinality = ReferenceCardinality.MANDATORY)
public ProfileHelper profileHelper;
@Reference (cardinality = ReferenceCardinality.MANDATORY)
public ConnectorHelper connectorHelper;
@Reference (cardinality = ReferenceCardinality.MANDATORY)
public BasicAuthService basicAuthService;
@Reference (cardinality = ReferenceCardinality.MANDATORY)
public SystemService systemService;
@Reference (cardinality = ReferenceCardinality.MANDATORY)
public PermissionHelper permissionHelper;
}

View File

@ -0,0 +1,26 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl.permission;
import ru.entaxy.esb.platform.core.management.profile.api.PermissionManager;
public interface PermissionHelper extends PermissionManager {
}

View File

@ -0,0 +1,103 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl.permission;
import java.util.List;
import javax.naming.OperationNotSupportedException;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.CollectionType;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicyOption;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.esb.platform.core.management.profile.api.PermissionManager;
@Component(service = PermissionHelper.class, immediate = true)
public class PermissionHelperImpl implements PermissionHelper {
private static final Logger log = LoggerFactory.getLogger(PermissionHelperImpl.class);
protected static final String EXPLANATION = "PermissionManager not bound";
protected PermissionManager permissionManager = null;
protected PermissionManager nullPermissionManager = null;
@Activate
public void activate(ComponentContext componentContext) {
this.nullPermissionManager = new PermissionManager() {
@Override
public List<String> getSubjectPermissions(String subjectId) throws Exception {
throw new OperationNotSupportedException(EXPLANATION); }
@Override
public List<String> getObjectPermissions(String objectId) throws Exception {
throw new OperationNotSupportedException(EXPLANATION); }
@Override
public void createPremission(String objectId, String subjectId) throws Exception {
throw new OperationNotSupportedException(EXPLANATION); }
};
}
public PermissionManager getEffectivePermissionManager() {
return this.permissionManager!=null?this.permissionManager:this.nullPermissionManager;
}
@Reference (collectionType = CollectionType.SERVICE
, cardinality = ReferenceCardinality.OPTIONAL
, policyOption = ReferencePolicyOption.GREEDY
, service = PermissionManager.class
, unbind = "unsetPermissionManager")
public void setPermissionManager(PermissionManager permissionManager) {
this.permissionManager = permissionManager;
log.debug(">> PermissionManager is bound");
}
public void unsetPermissionManager(PermissionManager permissionManager) {
this.permissionManager = null;
log.debug(">> PermissionManager is unbound");
}
@Override
public List<String> getObjectPermissions(String objectId) throws Exception {
return getEffectivePermissionManager().getObjectPermissions(objectId);
}
@Override
public List<String> getSubjectPermissions(String subjectId) throws Exception {
return getEffectivePermissionManager().getSubjectPermissions(subjectId);
}
@Override
public void createPremission(String objectId, String subjectId) throws Exception {
getEffectivePermissionManager().createPremission(objectId, subjectId);
}
}

View File

@ -0,0 +1,43 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl.route;
import javax.management.NotCompliantMBeanException;
import org.osgi.framework.BundleContext;
import ru.entaxy.esb.platform.base.management.core.utils.BundleAwareMBeanImpl;
import ru.entaxy.esb.platform.core.management.profile.DefaultRouteMBean;
public class DefaultRouteMBeanImpl extends BundleAwareMBeanImpl<ManagedRoute, DefaultRouteMBean> implements DefaultRouteMBean {
public DefaultRouteMBeanImpl(BundleContext bundleContext, ManagedRoute managedRoute) throws NotCompliantMBeanException {
super(DefaultRouteMBean.class, managedRoute);
this.bundleContext = bundleContext;
this.managedObject = managedRoute;
}
@Override
public boolean isDefault() {
return this.managedObject.isDefault();
}
}

View File

@ -0,0 +1,57 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl.route;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.wiring.BundleCapability;
import ru.entaxy.esb.platform.base.management.core.utils.ExtendedBundleTrackerCustomizer;
import ru.entaxy.platform.base.support.CommonUtils;
import ru.entaxy.platform.base.support.osgi.tracker.filter.BundleCapabilityFilter;
public class DeployedDefaultRouteCustomizer extends ExtendedBundleTrackerCustomizer<List<ManagedRoute>> {
@Override
protected List<ManagedRoute> createManagedObject(Bundle bundle, BundleEvent event, Map<String, List<?>> filterResults) {
@SuppressWarnings("unchecked")
List<BundleCapability> capabilities = (List<BundleCapability>)filterResults.get(BundleCapabilityFilter.DEFAULT_FILTER_ID);
if (capabilities==null)
capabilities = new ArrayList<>();
List<ManagedRoute> result = new ArrayList<>();
for (BundleCapability capability: capabilities) {
Object val = capability.getAttributes().get("name");
String name = val==null?"":val.toString();
if (!CommonUtils.isValid(name))
continue;
ManagedRoute mr = (new ManagedRoute())
.name(name)
.defaultRoute(true);
enrich(bundle, event, filterResults, mr);
result.add(mr);
}
return result;
}
}

View File

@ -0,0 +1,56 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl.route;
import ru.entaxy.esb.platform.base.management.core.utils.BundleAwareManagedObjectImpl;
public class ManagedRoute extends BundleAwareManagedObjectImpl {
protected boolean isDefault;
protected String name;
public boolean isDefault() {
return isDefault;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setDefault(boolean isDefault) {
this.isDefault = isDefault;
}
public ManagedRoute defaultRoute(boolean isDefault) {
setDefault(isDefault);
return this;
}
public ManagedRoute name(String name) {
setName(name);
return this;
}
}

View File

@ -0,0 +1,66 @@
/*-
* ~~~~~~licensing~~~~~~
* profile-management
* ==========
* 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.platform.core.management.profile.impl.route;
import java.util.Iterator;
import java.util.List;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.esb.platform.base.management.core.utils.ManagedObjectsListener;
import ru.entaxy.esb.platform.core.management.profile.DefaultRouteMBean;
public class ManagedRoutesListener extends ManagedObjectsListener<List<ManagedRoute>, ManagedRoute, DefaultRouteMBean, DefaultRouteMBeanImpl> {
private static final Logger log = LoggerFactory.getLogger(ManagedRoutesListener.class);
public ManagedRoutesListener(BundleContext bundleContext) {
super(bundleContext, DefaultRouteMBean.class);
}
@Override
protected Iterator<ManagedRoute> getIterator(List<ManagedRoute> managedObject) {
log.debug(">> getIterator");
return managedObject.iterator();
}
@Override
protected String getKeyValue(ManagedRoute object) {
return object.getName();
}
@Override
protected DefaultRouteMBeanImpl createService(ManagedRoute managedObject) {
try {
return new DefaultRouteMBeanImpl(bundleContext, managedObject);
} catch (Exception e) {
log.error("Error creating service", e);
return null;
}
}
@Override
protected String getJmxObjectName(ManagedRoute managedObject) {
return DefaultRouteMBean.Helper.getQualifier(managedObject.getName()).getValue();
}
}