initial public commit

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

View File

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

View File

@ -0,0 +1,87 @@
/*-
* ~~~~~~licensing~~~~~~
* cellar-deployer
* ==========
* Copyright (C) 2020 - 2021 EmDev LLC
* ==========
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.esb.system.deployer.cellar.deployer;
import org.apache.karaf.cellar.bundle.management.CellarBundleMBean;
import ru.entaxy.esb.system.common.exception.BundleNotFound;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.TabularData;
public class BundleControllerImpl implements BundleController {
private final CellarBundleMBean cellarBundleMBean;
private String cellarGroup = "default";
public BundleControllerImpl(CellarBundleMBean cellarBundleMBean) {
this.cellarBundleMBean = cellarBundleMBean;
}
public String installAndStartBundle(String bundleUrl, String bundleName) throws Exception {
cellarBundleMBean.install(cellarGroup, bundleUrl, true);
return getStatus(bundleName);
}
public void installBundle(String bundleUrl) throws Exception {
cellarBundleMBean.install(cellarGroup, bundleUrl);
}
public String stopBundle(String bundleName) throws Exception {
cellarBundleMBean.stop(cellarGroup, bundleName);
return getStatus(bundleName);
}
public String updateBundle(String bundleName) throws Exception {
cellarBundleMBean.update(cellarGroup, bundleName);
return getStatus(bundleName);
}
public String startBundle(String bundleName) throws Exception {
cellarBundleMBean.start(cellarGroup, bundleName);
return getStatus(bundleName);
}
public void uninstallBundle(String bundleName) throws Exception {
cellarBundleMBean.uninstall(cellarGroup, bundleName);
}
private String getStatus(String bundleName) throws Exception {
TabularData tabularData = cellarBundleMBean.getBundles(cellarGroup);
String status = null;
for (Object value : tabularData.values()) {
CompositeData compositeData = (CompositeData) value;
if (bundleName.equals(compositeData.get("name"))) {
status = compositeData.get("status").toString();
}
}
if (status == null) {
throw new BundleNotFound();
}
return status.toUpperCase();
}
public String getCellarGroup() {
return cellarGroup;
}
public void setCellarGroup(String cellarGroup) {
this.cellarGroup = cellarGroup;
}
}

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~~~~~~licensing~~~~~~
cellar-deployer
==========
Copyright (C) 2020 - 2021 EmDev LLC
==========
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
~~~~~~/licensing~~~~~~
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
">
<cm:property-placeholder persistent-id="ru.entaxy.esb.deployer.cellar" update-strategy="reload">
<cm:default-properties>
<cm:property name="cellar.group" value="default"/>
</cm:default-properties>
</cm:property-placeholder>
<bean id="bundleController" class="ru.entaxy.esb.system.deployer.cellar.deployer.BundleControllerImpl">
<argument ref="cellarBundleMBean"/>
<property name="cellarGroup" value="${cellar.group}"/>
</bean>
<service ref="bundleController" interface="ru.entaxy.esb.system.deployer.cellar.deployer.BundleController"/>
<reference id="cellarBundleMBean"
interface="org.apache.karaf.cellar.bundle.management.CellarBundleMBean"/>
</blueprint>

View File

@ -0,0 +1,30 @@
###
# ~~~~~~licensing~~~~~~
# cellar-deployer
# ==========
# 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~~~~~~
###
appender.file.type=File
appender.file.name=file
appender.file.fileName=target/camel-test.log
appender.file.layout.type=PatternLayout
appender.file.layout.pattern=%d %-5p %c{1} - %m %n
appender.out.type=Console
appender.out.name=out
appender.out.layout.type=PatternLayout
appender.out.layout.pattern=[%30.30t] %-30.30c{1} %-5p %m%n
rootLogger.level=INFO
rootLogger.appenderRef.out.ref=out