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,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();
}
}