release version 1.10.0

This commit is contained in:
2024-12-14 04:07:49 +03:00
parent a5088587f7
commit c6b3d793c4
1916 changed files with 254306 additions and 0 deletions

View File

@ -0,0 +1,175 @@
ЛИЦЕНЗИЯ ОГРАНИЧЕННОГО ПРИМЕНЕНИЯ
Настоящий документ устанавливает для Пользователя условия применения Базовой (некоммерческой)
версии лицензии для пробного использования программного обеспечения ENTAXY, принадлежащего
Правообладателю Обществу с ограниченной ответственностью "ЕМДЕВ" (ОГРН 1057810026658, ИНН
7813313860, юридический адрес: 197022, Россия, г. Санкт-Петербург, ул. Профессора Попова,
д. 23, литера В, помещение 3Н), расположенной в сети Интернет по адресу
https://www.emdev.ru/about (далее - Компания).
Используя или получая доступ к Программному обеспечению, или нажав «Я согласен с Условиями»
(или аналогичную кнопку или флажок) после загрузки или установки Программного обеспечения,
Пользователь выражает свое согласие на обязательность условий и ограничений, изложенных в
настоящем документе, в противном случае, он должен не использовать или не получать доступ
к Программному обеспечению.
1. ТЕРМИНЫ И ОПРЕДЕЛЕНИЯ
a) ПО Программное обеспечение, интеграционная шина «ЭНТАКСИ» (ENTAXY) в любой ее версии
или редакции, исключительные права на которую принадлежат Правообладателю.
b) Правообладатель (Компания) ООО «ЕМДЕВ», ОГРН 1057810026658, ИНН 7813313860, исключительные
права которого подтверждаются Свидетельством о государственной регистрации в Реестре программ
для ЭВМ № 2021610848 от 19.01.2021 года.
c) Пользователь юридическое или физическое лицо, получившее через скачивание с сайта
https://entaxy.ru или иным образом, дистрибутив ПО, пользующееся ПО.
d) ИС интеллектуальная собственность закреплённое законом исключительное право, а также
личные неимущественные права авторов произведений на результат интеллектуальной деятельности.
e) Подписка это коммерческое предложение Правообладателя, состоящее из Лицензии на использование
ПО и доступа к технической поддержке программного обеспечения на срок Подписки. Подписка
включает предоставление Пользователю неисключительного права использования ПО, в том числе
получение обновлений функционала ПО и безопасности ПО, исправление ошибок ПО и получение
патчей с обновлениями и исправлениями программного обеспечения. Подписка приобретается
Пользователем на период времени, указанный в Сертификате. Количество подписок устанавливается
для каждого Пользователя индивидуально в Сертификате.
f) Сертификат документ, выдаваемый Дистрибъютором или Авторизованным партнёром (Партнёром),
подтверждающий факт приобретения физическим или юридическим лицом Подписки на программное
обеспечение в ограниченном объёме и на определённый период времени.
g) Лицензия (простая (неисключительная) совокупность ограниченных прав использования ПО,
предоставленных Пользователю согласно условиям Подписки.
h) Библиотека совокупность подпрограмм и объектов, используемых для разработки программного
обеспечения.
i) Исходный код текст компьютерной программы на каком-либо языке программирования, состоящий
из одного или нескольких файлов, который может быть прочтён человеком.
j) Объектный код файл (часть машинного кода) с промежуточным представлением отдельного модуля
программы, полученный в результате обработки исходного кода, еще не связанный в полную программу.
Это машинный код для одной конкретной библиотеки или модуля, который будет составлять готовый
продукт.
k) Некоммерческое использование индивидуальное личное использование Пользователем программного
обеспечения с целью обучения работе с Программным обеспечением, для оценки или демонстрации
возможностей Программного обеспечения, при котором, Пользователем не извлекается коммерческая
выгода и/или не идёт в доход денежное вознаграждение при использовании Программного обеспечения.
2. ДОПУСТИМЫЕ СПОСОБЫ ИСПОЛЬЗОВАНИЯ ПРОГРАММНОГО ОБЕСПЕЧЕНИЯ
2.1. Правообладатель предоставляет Пользователю ограниченное право использования Программного
обеспечения на условиях простой (неисключительной) лицензии в объёме, ограниченном правом
воспроизведения полной рабочей версии программного обеспечения, новых версий программного обеспечения
в памяти оборудования и его запуска на оборудовании в соответствии со ст. 1280 ГК РФ.
2.2. Право на использование Программного обеспечения, предоставляемое Пользователю, носит
неисключительный характер.
2.3. Пользователю предоставляется всемирная, неисключительная, не подлежащая сублицензированию,
лицензия на ограниченное использование Программного обеспечения.
2.4. Пользователь, имеющий Базовую (некоммерческую) версию лицензии для пробного использования
имеет право приобрести Подписку на программное обеспечение. В этом случае Пользователь обязан
обратиться в службу поддержки Правообладателя по адресу: https://entaxy.ru/ для изменения
вида лицензии с Базовой бесплатной версии на Подписки.
2.5. Срок использования скачанной Пользователем базовой (некоммерческой) версии лицензии для
пробного использования программного обеспечения не ограничен.
2.6. Использование Пользователем настоящего программного обеспечения в целях разработки,
модификации, обновления другого ПО, принадлежащего третьим лицам, а не Правообладателю,
без разрешения Правообладателя не допускается.
3. АВТОРСКОЕ ПРАВО.
3.1. Все авторские права, все права интеллектуальной собственности на Программное обеспечение
и любые его копии принадлежат Правообладателю.
3.2. Все авторские права, все права интеллектуальной собственности в отношении любого контента,
к которому можно получить доступ с помощью Программного обеспечения, является собственностью
соответствующего владельца контента и защищается применимым законодательством об авторском
праве или другими законами и договорами об интеллектуальной собственности.
3.3. Условия использования Программного обеспечения.
Лицензия, предоставленная Пользователю, действительна только в том случае, если Пользователь
придерживается следующих условий:
3.3.1. Принятие уведомлений об авторских правах. Пользователю запрещается удалять или изменять
какие-либо уведомления об авторских правах или лицензиях, которые появляются при использовании
Программного обеспечения или на нем.
3.3.2. Модификация. Пользователю запрещается модифицировать, изменять, декомпилировать,
расшифровывать, дизассемблировать, переводить или реверсировать, перепроектировать
Программное обеспечение.
3.3.3. Распространение. Пользователю запрещается сублицензировать, передавать право использования
ПО или иным образом распространять или предоставлять Программное обеспечение любой третьей стороне.
3.3.4. SaaS. За исключением случаев, когда это разрешено Правообладателем, Пользователю запрещено
использовать Программное обеспечение в коммерческих целях для оказания услуг третьим лицам.
4. ОТВЕТСТВЕННОСТЬ ПРАВООБЛАДАТЕЛЯ ПРИ НАРУШЕНИИ ПОЛЬЗОВАТЕЛЕМ ПРАВ «ИС»
4.1. Правообладатель не несет никаких обязательств в отношении каких-либо претензий к Пользователю
на предмет нарушения последним прав Интеллектуальной собственности, возникших в связи с
использованием Пользователем:
4.1.1. Любых компонентов программного обеспечения с открытым исходным кодом, включенных в
Программное обеспечение;
4.1.2. Любого нарушения правил использования Программного обеспечения, установленного условиями
настоящего соглашения;
4.1.3. Любого использования Программного обеспечения в сочетании с другими ПО, оборудованием,
или данными, не предоставленными Пользователю Правообладателем;
4.1.4. Любого изменения Программного обеспечения любым третьим лицом, а не Правообладателем.
5. НАСТОЯЩИМ ПРАВООБЛАДАТЕЛЬ ЗАЯВЛЯЕТ, ЧТО ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ ПРЕДОСТАВЛЯЕТСЯ ПОЛЬЗОВАТЕЛЮ
ПО ПРИНЦИПУ «AS IS» - «КАК ЕСТЬ». НИ ПРИ КАКИХ ОБСТОЯТЕЛЬСТВАХ ПРАВООБЛАДАТЕЛЬ НЕ ГАРАНТИРУЕТ
И НЕ ОБЕЩАЕТ, ЧТО ПРЕДОСТАВЛЕННОЕ ИМ ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ БУДЕТ ПОДХОДИТЬ ИЛИ НЕ ПОДХОДИТЬ
ДЛЯ КОНКРЕТНЫХ ЦЕЛЕЙ ПОЛЬЗОВАТЕЛЯ, ЧТО ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ БУДЕТ ОТВЕЧАТЬ ВСЕМ КОММЕРЧЕСКИМ
И ЛИЧНЫМ СУБЪЕКТИВНЫМ ОЖИДАНИЯМ ПОЛЬЗОВАТЕЛЯ, ЧТО ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ БУДЕТ РАБОТАТЬ
ИСПРАВНО, БЕЗ ТЕХНИЧЕСКИХ ОШИБОК, БЫСТРО И БЕСПЕРЕБОЙНО.
6. ОГРАНИЧЕНИЕ ОТВЕТСТВЕННОСТИ.
НИ ПРИ КАКИХ ОБСТОЯТЕЛЬСТВАХ ПРАВООБЛАДАТЕЛЬ ИЛИ ЕГО АФФИЛЛИРОВАННЫЕ ЛИЦА НЕ НЕСУТ ПЕРЕД ПОЛЬЗОВАТЕЛЕМ
ОТВЕТСТВЕННОСТИ ЗА ЛЮБЫЕ ПРЯМЫЕ ИЛИ КОСВЕННЫЕ УБЫТКИ ПОЛЬЗОВАТЕЛЯ, ЕГО РАСХОДЫ ИЛИ РЕАЛЬНЫЙ УЩЕРБ,
ВКЛЮЧАЯ, ПОМИМО ПРОЧЕГО, ПРОСТОИ; УТРАТУ БИЗНЕСА; УПУЩЕННУЮ ВЫГОДУ; НЕДОПОЛУЧЕННУЮ ПРИБЫЛЬ;
ПОТЕРЮ ИЛИ ПОВРЕЖДЕНИЕ ДАННЫХ, ИМУЩЕСТВА И ИНОЕ.
ОГРАНИЧЕНИЯ ПРИМЕНЯЮТСЯ НЕЗАВИСИМО ОТ ОСНОВАНИЯ НАСТУПЛЕНИЯ ОТВЕТСТВЕННОСТИ; В ТОМ ЧИСЛЕ ВСЛЕДСТВИЕ
ДЕЙСТВИЯ ИЛИ БЕЗДЕЙСТВИЯ, НЕБРЕЖНОСТИ, УМЫСЛА, ПРЯМОГО ИЛИ КОСВЕННОГО; НЕОСТОРОЖНОСТИ; ЗАБЛУЖДЕНИЯ;
КЛЕВЕТЫ; НАРУШЕНИЯ КОНФИДЕНЦИАЛЬНОСТИ ИЛИ ПРАВА ИНТЕЛЛЕКТУАЛЬНОЙ СОБСТВЕННОСТИ; ИЛИ ЛЮБОЕ ДРУГОЕ
ОСНОВАНИЕ НАСТУПЛЕНИЯ ОТВЕТСТВЕННОСТИ.
7. ОБЯЗАННОСТЬ ПОЛЬЗОВАТЕЛЯ:
Не осуществлять самостоятельно и (или) с привлечением третьих лиц нижеследующие действия
(включая, но не ограничиваясь) по:
-дизассемблированию и (или) декомпилированию (преобразованию объектного кода в исходный код)
Программного обеспечения;
-модификации Программного обеспечения, в том числе вносить изменения в объектный код, исходный
код Программного обеспечения, за исключением тех изменений, которые вносятся средствами,
включёнными в Программное обеспечение и описанными непосредственно в документации к нему;
-созданию условий для использования Программного обеспечения лицами, не имеющими прав на
использование данного Программного обеспечения, включая (но не ограничиваясь) вмешательство
третьих лиц в функционирование Программного обеспечения, предоставление третьим лицам доступа
к исследованию и (или) замене настроек Программного обеспечения, включая его первичную установку;
-распространению Программного обеспечения в целом или в части (включая приложенную к нему документацию).
8. БИБЛИОТЕКА ПО. ИСПОЛЬЗУЕМЫЕ ПРОГРАММНЫЕ СРЕДСТВА.
8.1. Настоящим, Правообладатель заверяет, что Библиотека программного обеспечения состоит из
лицензионных продуктов, используемых на законных основаниях, а
именно https://entaxy.ru/libs/licenses/root-aggregated.deps.
8.2. Любые программные средства, применяемые Пользователем при работе с ПО, должны быть
совместимы с библиотекой ПО, указанной в п.8.1. настоящего соглашения.
8.3. Перечень внешних модулей ПО, указанный в п.8.1 настоящего соглашения, может изменяться
Правообладателем в одностороннем порядке, в зависимости от выпуска релизов программного обеспечения,
содержащих все изменения и дополнения программного обеспечения.
9. ВНЕСЕНИЕ ИЗМЕНЕНИЙ В ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ.
9.1. Программное обеспечение, интеграционная шина «ЭНТАКСИ» (ENTAXY) является свободно распространяемым
программным обеспечением.
9.2. Пользователь имеет право вносить изменения в исходный код программного обеспечения исключительно
с согласия Правообладателя в порядке предложения изменений/правок/дополнений через механизм
«Pull Requests» в открытом репозитории Правообладателя по адресу: https://git.entaxy.ru/entaxy/entaxy-public.
9.3. Любые изменения программного обеспечения, осуществляемые Пользователем без соблюдения условий
пункта 9.2. настоящего документа, являются нарушением авторских и смежных прав Правообладателя,
прав интеллектуальной собственности Правообладателя и влекут применение к Пользователю мер
ответственности в соответствии с условиями настоящей Лицензии, а также применимого законодательства
Российской Федерации.
10. ЗАКЛЮЧИТЕЛЬНЫЕ ПОЛОЖЕНИЯ.
10.1. В случае нарушения Пользователем любого из условий настоящей Лицензии, Правообладатель имеет
право взыскать с Пользователя любые причинённые таким нарушением убытки, реальный ущерб,
недополученную прибыль, упущенную выгоду, а также в случае нарушения Пользователем условий
пункта 9.2 настоящего соглашения, в том числе, взыскать с Пользователя штраф в размере
2 000 000 (Два миллиона) рублей за каждый установленный случай несанкционированного изменения
исходного или объектного кода Программного обеспечения «Энтакси» (Entaxy).
10.2. В рамках исполнения Пользователем обязательств по настоящей Лицензии, применимое
законодательство Российской Федерации.
10.3. Если какое-либо положение настоящей Лицензии будет признано судом недействительным,
остальные положения будут продолжать своё действие, а Пользователь будет обязан продолжать
исполнять свои обязанности в соответствии с этими положениями.

View File

@ -0,0 +1,39 @@
<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.10.0</version>
</parent>
<groupId>ru.entaxy.esb.platform.runtime.core.management</groupId>
<artifactId>object-management</artifactId>
<packaging>bundle</packaging>
<name>ENTAXY :: CORE :: MANAGEMENT :: OBJECT</name>
<description>ENTAXY :: CORE :: MANAGEMENT :: OBJECT</description>
<properties>
<bundle.osgi.export.pkg>
ru.entaxy.platform.core.management.object,
ru.entaxy.platform.core.management.object.factory
</bundle.osgi.export.pkg>
<bundle.osgi.private.pkg>
ru.entaxy.platform.core.management.object.impl,
ru.entaxy.platform.core.management.object.factory.impl,
ru.entaxy.platform.core.management.object.shell
</bundle.osgi.private.pkg>
<bundle.osgi.remove.headers>none</bundle.osgi.remove.headers>
</properties>
<dependencies>
<dependency>
<groupId>ru.entaxy.esb.platform.runtime.core</groupId>
<artifactId>object-runtime-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.karaf.bundle</groupId>
<artifactId>org.apache.karaf.bundle.core</artifactId>
<version>${karaf.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,46 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Inherited
@Retention(RUNTIME)
@Target(TYPE)
public @interface ContainerMBean {
String id() default "";
String subQualifierName() default EntaxyRuntimeObjectContainerMBean.JMX_QUALIFIER_NAME;
String subQualifierValue();
}

View File

@ -0,0 +1,162 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object;
import java.util.Map;
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;
@MBeanAnnotated(policy = MBeanExportPolicy.ANNOTATED_ONLY)
public interface EntaxyRuntimeItemMBean {
String JMX_SUBPATH_QUALIFIER = "subgroup";
String JMX_SUBQUALIFIER_AUTO = "@AUTO@";
EntaxyRuntimeItemMBean DEFAULT_PARENT_MBEAN = new EntaxyRuntimeItemMBean() {
@Override
public Class<? extends EntaxyRuntimeItemMBean> getMBeanClass() {
// TODO Auto-generated method stub
return null;
}
public String getJMXSubQualifier() {
return ManagementCore.Q_RUNTIME_S;
};
@Override
public String getJMXSubQualifierValue() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getJMXSubQualifierName() {
// TODO Auto-generated method stub
return null;
}
@Override
public Qualifier getJMXQualifier() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getId() {
// TODO Auto-generated method stub
return null;
}
public EntaxyRuntimeItemMBean getParentMBean() {
return null;
}
@Override
public void setParentMBean(EntaxyRuntimeItemMBean mBean) {
// TODO Auto-generated method stub
}
@Override
public void setParentSubPath(String subPath) {
// TODO Auto-generated method stub
}
@Override
public void setJMXSubQualifierName(String name) {
// TODO Auto-generated method stub
}
@Override
public void setJMXSubQualifierValue(String value) {
// TODO Auto-generated method stub
}
@Override
public Map<String, EntaxyRuntimeItemMBean> getChildMBeans() {
// TODO Auto-generated method stub
return null;
}
@Override
public void addChildMBean(EntaxyRuntimeItemMBean mBean) {
// TODO Auto-generated method stub
}
@Override
public void removeChildMBean(EntaxyRuntimeItemMBean mBean) {
// TODO Auto-generated method stub
}
};
Qualifier getJMXQualifier();
default String getJMXSubQualifier() {
return getJMXSubQualifierName().concat("=").concat(getJMXSubQualifierValue());
};
default EntaxyRuntimeItemMBean getParentMBean() {
return DEFAULT_PARENT_MBEAN;
};
void setParentMBean(EntaxyRuntimeItemMBean mBean);
default String getParentSubPath() {
return "";
};
void setParentSubPath(String subPath);
Map<String, EntaxyRuntimeItemMBean> getChildMBeans();
void addChildMBean(EntaxyRuntimeItemMBean mBean);
void removeChildMBean(EntaxyRuntimeItemMBean mBean);
String getJMXSubQualifierName();
void setJMXSubQualifierName(String name);
String getJMXSubQualifierValue();
void setJMXSubQualifierValue(String value);
String getId();
Class<? extends EntaxyRuntimeItemMBean> getMBeanClass();
}

View File

@ -0,0 +1,38 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object;
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 EntaxyRuntimeObjectContainerMBean extends EntaxyRuntimeItemMBean {
String JMX_QUALIFIER_NAME = "category";
String JMX_DEFAULT_CATEGORY = "objects";
}

View File

@ -0,0 +1,99 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object;
import java.util.Map;
import javax.management.MBeanOperationInfo;
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.RuntimeTypedMBean;
import ru.entaxy.esb.platform.base.management.core.utils.BundleAwareMBean;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObject;
@MBeanAnnotated(policy = MBeanExportPolicy.ANNOTATED_ONLY)
public interface EntaxyRuntimeObjectMBean extends EntaxyRuntimeItemMBean, BundleAwareMBean, RuntimeTypedMBean {
public static final String DEFAULT_OBJECT_SUBQUALIFIER = "object";
EntaxyRuntimeObject getRuntimeObject();
@Override
default String getJMXSubQualifierName() {
if (this.getClass().isAnnotationPresent(ObjectMBean.class))
return this.getClass().getAnnotation(ObjectMBean.class).subQualifierName();
return DEFAULT_OBJECT_SUBQUALIFIER;
}
@Attribute(desc = "Managed bean Id")
String getId();
@Deprecated(since = "1.10.0", forRemoval = true)
@Attribute(desc = "Object Name")
String getName();
@Attribute(desc = "Object Id")
String getObjectId();
@Attribute(desc = "Object Type")
String getObjectType();
@Attribute(desc = "Object full Id")
String getObjectFullId();
@Attribute(desc = "Object label")
public String getObjectLabel();
@Attribute(desc = "Display name")
public String getDisplayName();
@Attribute(desc = "Object factory Id")
String getFactoryId();
@Attribute(desc = "Object scope")
String getScope();
@Attribute(desc = "Object owner for private objects")
String getOwner();
@Attribute(desc = "Object container Id")
String getContainerId();
@Attribute(desc = "Object is provided via capability descriptor")
boolean isProvided();
@Attribute(desc = "Object is ghost: assumed by relations but not present")
boolean isGhost();
@Operation(desc = "Gets JSON configuration of the object", impact = MBeanOperationInfo.INFO)
String readConfiguration();
@Operation(desc = "Reads extended data of the object", impact = MBeanOperationInfo.INFO)
Map<String, Map<String, Object>> readExtendedData();
}

View File

@ -0,0 +1,45 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object;
import java.util.List;
public interface EntaxyRuntimeObjectMBeanCustomizer {
public interface Customized {
EntaxyRuntimeObjectMBean getCustomizedMBean();
List<EntaxyRuntimeObjectMBean> getAdditionalMBeans();
}
String getId();
boolean isAccepted(EntaxyRuntimeObjectMBean bean);
Customized customize(EntaxyRuntimeObjectMBean bean);
}

View File

@ -0,0 +1,56 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object;
import java.util.List;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObject;
public interface EntaxyRuntimeObjectMBeanFactory {
String JMX_QUALIFIER_NAME = "category";
String JMX_DEFAULT_CATEGORY = "objects";
String getId();
default String getCategory() {
return JMX_DEFAULT_CATEGORY;
};
default String getJMXSubQualifier() {
return JMX_QUALIFIER_NAME.concat("=").concat(getCategory());
}
List<String> getSupportedTypes();
<T extends EntaxyRuntimeObjectMBean> T createMBean(EntaxyRuntimeObject entaxyRuntimeObject);
// <T extends EntaxyRuntimeObjectContainerMBean> T createMBeanContainerForType(String
// entaxyObjectType);
List<? extends EntaxyRuntimeItemMBean> createMBeans();
}

View File

@ -0,0 +1,43 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Inherited
@Retention(RUNTIME)
@Target(TYPE)
public @interface MBeanFactory {
String[] supportedTypes();
String id();
}

View File

@ -0,0 +1,40 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Retention(RUNTIME)
@Target(TYPE)
public @interface ObjectMBean {
String subQualifierName();
}

View File

@ -0,0 +1,62 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.factory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeObjectMBeanFactory;
import ru.entaxy.platform.core.management.object.MBeanFactory;
public abstract class AbstractMBeanFactory implements EntaxyRuntimeObjectMBeanFactory {
protected String id;
protected List<String> supportedTypes = new ArrayList<>();
protected AbstractMBeanFactory() {
super();
this.id = this.getClass().getSimpleName();
if (this.getClass().isAnnotationPresent(MBeanFactory.class)) {
MBeanFactory anno = this.getClass().getAnnotation(MBeanFactory.class);
this.id = anno.id();
supportedTypes.addAll(Arrays.asList(anno.supportedTypes()));
}
}
@Override
public String getId() {
return this.id;
}
@Override
public List<String> getSupportedTypes() {
return this.supportedTypes;
}
}

View File

@ -0,0 +1,54 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.factory;
import javax.management.NotCompliantMBeanException;
import ru.entaxy.esb.platform.base.management.core.Qualifier;
import ru.entaxy.platform.core.management.object.ContainerMBean;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeObjectContainerMBean;
public abstract class AbstractObjectContainerMBean<T extends EntaxyRuntimeObjectContainerMBean>
extends AbstractObjectItemMBean<T>
implements EntaxyRuntimeObjectContainerMBean {
protected AbstractObjectContainerMBean(Class<T> mbeanInterface) throws NotCompliantMBeanException {
super(mbeanInterface);
if (this.getClass().isAnnotationPresent(ContainerMBean.class)) {
ContainerMBean anno = this.getClass().getAnnotation(ContainerMBean.class);
jmxSubQualifierName = anno.subQualifierName();
jmxSubQualifierValue = anno.subQualifierValue();
id = anno.id();
}
}
@Override
public Qualifier getJMXQualifier() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,134 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.factory;
import java.util.HashMap;
import java.util.Map;
import javax.management.NotCompliantMBeanException;
import ru.entaxy.esb.platform.base.management.core.Qualifier;
import ru.entaxy.esb.platform.base.management.core.api.AnnotatedMBean;
import ru.entaxy.platform.base.support.CommonUtils;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeItemMBean;
public abstract class AbstractObjectItemMBean<T extends EntaxyRuntimeItemMBean> extends AnnotatedMBean<T>
implements EntaxyRuntimeItemMBean {
protected String jmxSubQualifierName;
protected String jmxSubQualifierValue;
protected String id;
protected EntaxyRuntimeItemMBean parentMBean;
protected String parentSubPath;
protected Map<String, EntaxyRuntimeItemMBean> children = new HashMap<>();
protected AbstractObjectItemMBean(Class<T> mbeanInterface) throws NotCompliantMBeanException {
super(mbeanInterface);
}
@Override
public Qualifier getJMXQualifier() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getJMXSubQualifierName() {
return jmxSubQualifierName;
}
@Override
public void setJMXSubQualifierName(String name) {
jmxSubQualifierName = name;
}
@Override
public String getJMXSubQualifierValue() {
return jmxSubQualifierValue;
}
@Override
public void setJMXSubQualifierValue(String value) {
jmxSubQualifierValue = value;
}
@Override
public String getId() {
return id;
}
@Override
public Class<? extends EntaxyRuntimeItemMBean> getMBeanClass() {
return this.interfaceClass;
}
@Override
public EntaxyRuntimeItemMBean getParentMBean() {
if (this.parentMBean != null)
return this.parentMBean;
return EntaxyRuntimeItemMBean.super.getParentMBean();
}
@Override
public void setParentMBean(EntaxyRuntimeItemMBean mBean) {
if (this.parentMBean != null)
this.parentMBean.removeChildMBean(this);
this.parentMBean = mBean;
if (parentMBean != null)
this.parentMBean.addChildMBean(this);
}
@Override
public String getParentSubPath() {
if (CommonUtils.isValid(this.parentSubPath))
return this.parentSubPath;
return EntaxyRuntimeItemMBean.super.getParentSubPath();
}
@Override
public void setParentSubPath(String parentSubPath) {
this.parentSubPath = parentSubPath;
}
@Override
public Map<String, EntaxyRuntimeItemMBean> getChildMBeans() {
return this.children;
}
@Override
public void addChildMBean(EntaxyRuntimeItemMBean mBean) {
children.put(mBean.getId(), mBean);
}
@Override
public void removeChildMBean(EntaxyRuntimeItemMBean mBean) {
children.remove(mBean.getId());
}
}

View File

@ -0,0 +1,214 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.factory;
import java.util.HashMap;
import java.util.Map;
import javax.management.NotCompliantMBeanException;
import org.apache.karaf.bundle.core.BundleInfo;
import org.apache.karaf.bundle.core.BundleState;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.platform.base.support.CommonUtils;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeObjectMBean;
import ru.entaxy.platform.core.management.object.factory.impl.ServiceHelper;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObject;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObjectService;
public abstract class AbstractObjectMBean<T extends EntaxyRuntimeObjectMBean>
extends AbstractObjectItemMBean<T>
implements EntaxyRuntimeObjectMBean {
private static final Logger LOG = LoggerFactory.getLogger(AbstractObjectMBean.class);
protected EntaxyRuntimeObject entaxyRuntimeObject;
protected AbstractObjectMBean(Class<T> mbeanInterface, EntaxyRuntimeObject entaxyRuntimeObject)
throws NotCompliantMBeanException {
super(mbeanInterface);
this.entaxyRuntimeObject = entaxyRuntimeObject;
}
@Override
public String getJMXSubQualifierName() {
if (CommonUtils.isValid(this.jmxSubQualifierName))
return this.jmxSubQualifierName;
return EntaxyRuntimeObjectMBean.super.getJMXSubQualifierName();
}
@Override
public String getJMXSubQualifierValue() {
return entaxyRuntimeObject.getObjectFullId().replace(':', '_');
}
@Override
public long getBundleId() {
if (entaxyRuntimeObject.getBundleInfo() != null)
return entaxyRuntimeObject.getBundleInfo().getBundleId();
return -1;
}
@Override
public String getBundleState() {
if (getBundleId() < 0)
return BundleState.Unknown.name();
BundleInfo bi = ServiceHelper.getInstance().getBundleInfo(getBundleId());
if (bi == null)
return BundleState.Unknown.name();
return bi.getState().name();
}
@Override
public String getBundleSymbolicName() {
if (entaxyRuntimeObject.isGhost())
return "";
if (entaxyRuntimeObject.getContainer() == null)
return "";
return entaxyRuntimeObject.getContainer().getName();
}
@Override
public String getId() {
if (entaxyRuntimeObject != null)
return entaxyRuntimeObject.getObjectFullId();
return super.getId();
}
@Override
public void refreshBundleInfo() {
// TODO Auto-generated method stub
}
@Override
public EntaxyRuntimeObject getRuntimeObject() {
return this.entaxyRuntimeObject;
}
@Override
public String getName() {
return entaxyRuntimeObject.getAttributeOrDefault("name", getObjectId()).toString();
};
@Override
public String getObjectId() {
return this.entaxyRuntimeObject.getId();
}
@Override
public String getObjectType() {
return this.entaxyRuntimeObject.getType();
}
@Override
public String getObjectFullId() {
return this.entaxyRuntimeObject.getObjectFullId();
}
@Override
public String getDisplayName() {
return this.entaxyRuntimeObject.getDisplayName();
}
@Override
public String getObjectLabel() {
return entaxyRuntimeObject.getAttributeOrDefault("label", "").toString();
}
@Override
public String getFactoryId() {
return this.entaxyRuntimeObject.getFactoryId();
}
@Override
public String getContainerId() {
return "" + getBundleId();
}
@Override
public String getScope() {
return this.entaxyRuntimeObject.getScope();
}
@Override
public String getOwner() {
return this.entaxyRuntimeObject.getOwner();
}
@Override
public String getRuntimeType() {
if (entaxyRuntimeObject != null)
return entaxyRuntimeObject.getType();
return EntaxyRuntimeObjectMBean.super.getRuntimeType();
}
@Override
public boolean isProvided() {
if (entaxyRuntimeObject != null)
return entaxyRuntimeObject.isProvided();
return false;
}
@Override
public boolean isGhost() {
if (entaxyRuntimeObject != null)
return entaxyRuntimeObject.isGhost();
return true;
}
@Override
public String readConfiguration() {
if (entaxyRuntimeObject != null)
return entaxyRuntimeObject.getConfiguration();
return "";
}
@Override
public Map<String, Map<String, Object>> readExtendedData() {
try {
BundleContext bundleContext = FrameworkUtil.getBundle(EntaxyRuntimeObjectService.class).getBundleContext();
ServiceReference<EntaxyRuntimeObjectService> ref =
bundleContext.getServiceReference(EntaxyRuntimeObjectService.class);
EntaxyRuntimeObjectService objectService = bundleContext.getService(ref);
Map<String, Map<String, Object>> result = objectService.getExtendedObjectInfo(entaxyRuntimeObject);
bundleContext.ungetService(ref);
if (result != null)
return result;
} catch (Exception e) {
LOG.error(String.format("Error reading extended data for [%s]", entaxyRuntimeObject.getObjectFullId()), e);
}
return new HashMap<>();
}
}

View File

@ -0,0 +1,65 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.factory;
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.platform.core.management.object.EntaxyRuntimeObjectContainerMBean;
@MBeanAnnotated(policy = MBeanExportPolicy.ANNOTATED_ONLY)
public interface ObjectsContainerMBean extends EntaxyRuntimeObjectContainerMBean {
@Operation(desc = "Refreshes full object tree")
void refresh();
@Operation(desc = "Start bundle")
String startBundle(
@Parameter(name = "idOrName", desc = "Id or name of the object") String idOrName,
@Parameter(name = "runtimeType", desc = "Runtime type of the object") String runtimeType,
@Parameter(name = "forced", desc = "Operation flag for forced processing") boolean forced,
@Parameter(name = "soft", desc = "Operation flag for soft processing") boolean soft) throws Exception;
@Operation(desc = "Stop bundle")
String stopBundle(
@Parameter(name = "idOrName", desc = "Id or name of the object") String idOrName,
@Parameter(name = "runtimeType", desc = "Runtime type of the object") String runtimeType,
@Parameter(name = "forced", desc = "Operation flag for forced processing") boolean forced,
@Parameter(name = "soft", desc = "Operation flag for soft processing") boolean soft) throws Exception;
@Operation(desc = "Uninstall bundle")
String uninstallBundle(
@Parameter(name = "idOrName", desc = "Id or name of the object") String idOrName,
@Parameter(name = "runtimeType", desc = "Runtime type of the object") String runtimeType,
@Parameter(name = "forced", desc = "Operation flag for forced processing") boolean forced,
@Parameter(name = "soft", desc = "Operation flag for soft processing") boolean soft) throws Exception;
@Operation(desc = "Find objects by osgi filter")
String findObjects(
@Parameter(name = "osgiFilter", desc = "OSGI filter") String osgiFilter) throws Exception;
}

View File

@ -0,0 +1,88 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.factory.impl;
import java.util.ArrayList;
import java.util.List;
import javax.management.NotCompliantMBeanException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeItemMBean;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeObjectMBean;
import ru.entaxy.platform.core.management.object.MBeanFactory;
import ru.entaxy.platform.core.management.object.factory.AbstractMBeanFactory;
import ru.entaxy.platform.core.management.object.impl.EntaxyRuntimeObjectMBeanManager;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObject;
@MBeanFactory(id = "root-object-factory", supportedTypes = {"*"})
// @Component(service = EntaxyRuntimeObjectMBeanFactory.class, immediate = true)
public class EntaxyObjectMBeanFactory extends AbstractMBeanFactory {
private static final Logger log = LoggerFactory.getLogger(EntaxyObjectMBeanFactory.class);
protected ObjectsContainerMBeanImpl objectsContainerMBeanImpl;
protected EntaxyRuntimeObjectMBeanManager objectMBeanManager;
public EntaxyObjectMBeanFactory(EntaxyRuntimeObjectMBeanManager objectMBeanManager) {
super();
this.objectMBeanManager = objectMBeanManager;
try {
objectsContainerMBeanImpl = new ObjectsContainerMBeanImpl();
} catch (NotCompliantMBeanException e) {
log.error("Error creating MBean for ObjectsContainerMBean", e);
}
}
public void activate() {}
@Override
public <T extends EntaxyRuntimeObjectMBean> T createMBean(EntaxyRuntimeObject entaxyRuntimeObject) {
try {
EntaxyRuntimeObjectMBeanImpl result = new EntaxyRuntimeObjectMBeanImpl(entaxyRuntimeObject);
if (objectsContainerMBeanImpl != null)
result.setParentMBean(objectsContainerMBeanImpl);
return (T) result;
} catch (NotCompliantMBeanException e) {
log.error("Error creating MBean for [" + entaxyRuntimeObject.getObjectFullId() + "]", e);
return null;
}
}
@Override
public List<? extends EntaxyRuntimeItemMBean> createMBeans() {
List<EntaxyRuntimeItemMBean> result = new ArrayList<>();
if (objectsContainerMBeanImpl != null) {
objectsContainerMBeanImpl.manager = objectMBeanManager;
result.add(objectsContainerMBeanImpl);
}
return result;
}
}

View File

@ -0,0 +1,41 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.factory.impl;
import javax.management.NotCompliantMBeanException;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeObjectMBean;
import ru.entaxy.platform.core.management.object.factory.AbstractObjectMBean;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObject;
public class EntaxyRuntimeObjectMBeanImpl extends AbstractObjectMBean<EntaxyRuntimeObjectMBean>
implements EntaxyRuntimeObjectMBean {
public EntaxyRuntimeObjectMBeanImpl(EntaxyRuntimeObject entaxyRuntimeObject) throws NotCompliantMBeanException {
super(EntaxyRuntimeObjectMBean.class, entaxyRuntimeObject);
}
}

View File

@ -0,0 +1,150 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.factory.impl;
import javax.management.NotCompliantMBeanException;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import ru.entaxy.platform.base.support.CommonUtils;
import ru.entaxy.platform.base.support.JSONUtils;
import ru.entaxy.platform.core.management.object.ContainerMBean;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeObjectMBeanFactory;
import ru.entaxy.platform.core.management.object.factory.AbstractObjectContainerMBean;
import ru.entaxy.platform.core.management.object.factory.ObjectsContainerMBean;
import ru.entaxy.platform.core.management.object.impl.EntaxyRuntimeObjectMBeanManager;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObjectManager.OperationResult;
import java.util.stream.Collectors;
@ContainerMBean(id = "objects", subQualifierValue = EntaxyRuntimeObjectMBeanFactory.JMX_DEFAULT_CATEGORY)
public class ObjectsContainerMBeanImpl extends AbstractObjectContainerMBean<ObjectsContainerMBean>
implements ObjectsContainerMBean {
protected EntaxyRuntimeObjectMBeanManager manager;
protected ObjectsContainerMBeanImpl() throws NotCompliantMBeanException {
super(ObjectsContainerMBean.class);
}
@Override
public void refresh() {
manager.refresh();
}
@Override
public String startBundle(String idOrName, String runtimeType, boolean forced, boolean soft) throws Exception {
if (ServiceHelper.getInstance() == null) {
throw new IllegalStateException("Service helper is not initialized");
}
String objectFullId = ServiceHelper.getInstance()
.entaxyObjectService.findObject(idOrName, runtimeType).getObjectFullId();
OperationResult result;
if (forced) {
result = ServiceHelper.getInstance().entaxyRuntimeObjectManager.startForced(objectFullId);
} else if (soft) {
result = ServiceHelper.getInstance().entaxyRuntimeObjectManager.startSoft(objectFullId);
} else {
result = ServiceHelper.getInstance().entaxyRuntimeObjectManager.start(objectFullId);
}
return getOutput(result);
}
@Override
public String stopBundle(String idOrName, String runtimeType, boolean forced, boolean soft) throws Exception {
if (ServiceHelper.getInstance() == null) {
throw new IllegalStateException("Service helper is not initialized");
}
String objectFullId = ServiceHelper.getInstance()
.entaxyObjectService.findObject(idOrName, runtimeType).getObjectFullId();
OperationResult result;
if (forced) {
result = ServiceHelper.getInstance().entaxyRuntimeObjectManager.stopForced(objectFullId);
} else if (soft) {
result = ServiceHelper.getInstance().entaxyRuntimeObjectManager.stopSoft(objectFullId);
} else {
result = ServiceHelper.getInstance().entaxyRuntimeObjectManager.stop(objectFullId);
}
return getOutput(result);
}
@Override
public String uninstallBundle(String idOrName, String runtimeType, boolean forced, boolean soft) throws Exception {
if (ServiceHelper.getInstance() == null) {
throw new IllegalStateException("Service helper is not initialized");
}
String objectFullId = ServiceHelper.getInstance()
.entaxyObjectService.findObject(idOrName, runtimeType).getObjectFullId();
OperationResult result;
if (forced) {
result = ServiceHelper.getInstance().entaxyRuntimeObjectManager.uninstallForced(objectFullId);
} else if (soft) {
result = ServiceHelper.getInstance().entaxyRuntimeObjectManager.uninstallSoft(objectFullId);
} else {
result = ServiceHelper.getInstance().entaxyRuntimeObjectManager.uninstall(objectFullId);
}
return getOutput(result);
}
private String getOutput(OperationResult result) {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("result", result.getResult().name());
if (!result.getAffected().isEmpty()) {
JsonArray affectedArray = new JsonArray();
for (String key : result.getAffected().keySet()) {
JsonObject affected = new JsonObject();
affected.addProperty("objectId", key);
affected.addProperty("action", result.getAffected().get(key).name());
affectedArray.add(affected);
}
jsonObject.addProperty("affected", affectedArray.toString());
}
if (CommonUtils.isValid(result.getMessage())) {
jsonObject.addProperty("message", result.getMessage());
}
return jsonObject.toString();
}
public String findObjects(String osgiFilter) throws Exception {
return JSONUtils.GSON.toJson(manager.findObjects(osgiFilter).stream().map(object -> {
return object.getObjectFullId();
}).collect(Collectors.toList()));
}
}

View File

@ -0,0 +1,81 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.factory.impl;
import org.apache.karaf.bundle.core.BundleInfo;
import org.apache.karaf.bundle.core.BundleService;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.*;
import ru.entaxy.platform.base.objects.EntaxyObjectService;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObjectManager;
@Component(service = ServiceHelper.class, immediate = true)
public class ServiceHelper {
private static ServiceHelper INSTANCE;
public static ServiceHelper getInstance() {
return INSTANCE;
}
@Reference(cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC,
policyOption = ReferencePolicyOption.GREEDY)
volatile public EntaxyObjectService entaxyObjectService;
@Reference(cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC,
policyOption = ReferencePolicyOption.GREEDY)
volatile public EntaxyRuntimeObjectManager entaxyRuntimeObjectManager;
@Reference(cardinality = ReferenceCardinality.MANDATORY)
BundleService bundleService;
BundleContext bundleContext;
@Activate
public void activate(ComponentContext componentContext) {
INSTANCE = this;
this.bundleContext = componentContext.getBundleContext();
}
@Deactivate
public void deactivate() {
INSTANCE = null;
}
public BundleService getBundleService() {
return bundleService;
}
public BundleInfo getBundleInfo(long id) {
Bundle b = FrameworkUtil.getBundle(getClass()).getBundleContext().getBundle(id);
if (b == null)
return null;
return bundleService.getInfo(b);
}
}

View File

@ -0,0 +1,133 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.impl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.osgi.framework.BundleContext;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeItemMBean;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeObjectMBeanFactory;
public class EntaxyRuntimeItemMBeanInfo<T extends EntaxyRuntimeItemMBean> {
public enum ItemStatus {
NEW,
ACTIVE,
REREGISTER,
RECREATE,
REMOVE,
UNKNOWN
}
public MBeanHolder<T> mbeanHolder = null;
boolean isVirtual = false;
protected BundleContext bundleContext;
public ItemStatus itemStatus = ItemStatus.UNKNOWN;
public ItemStatus status() {
return itemStatus;
}
public ItemStatus status(ItemStatus newStatus) {
if (newStatus == null)
return status(ItemStatus.UNKNOWN);
this.itemStatus = newStatus;
return status();
}
public boolean isInStatus(ItemStatus checkStatus) {
return this.itemStatus.equals(checkStatus);
}
EntaxyRuntimeItemMBeanInfo<?> parentMBeanInfo;
List<EntaxyRuntimeItemMBeanInfo<?>> children = new ArrayList<>();
protected EntaxyRuntimeObjectMBeanFactory factory;
public String getId() {
return mbeanHolder == null ? "" : mbeanHolder.mbean.getId();
}
public boolean createHolder(T mbean) {
mbeanHolder = MBeanHolder.create(mbean);
return isCreated();
}
public boolean isCreated() {
if (mbeanHolder == null)
return false;
return mbeanHolder.mbean != null;
}
public boolean isRegistered() {
return isCreated() && (mbeanHolder.registration != null);
}
public void setBundleContext(BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
public void register(BundleContext bundleContext) {
setBundleContext(bundleContext);
register();
}
public void register() {
try {
if (this.mbeanHolder.bundleContext == null)
this.mbeanHolder.bundleContext = this.bundleContext;
this.mbeanHolder.register();
} catch (Exception ignore) {
// NOOP
}
}
public void unregister() {
try {
this.mbeanHolder.unregister();
} catch (Exception ignore) {
// NOOP
}
}
public Map<String, EntaxyRuntimeItemMBean> getAllChildMBeans() {
if (this.mbeanHolder != null)
return this.mbeanHolder.mbean.getChildMBeans();
return Collections.emptyMap();
};
public Map<String, EntaxyRuntimeItemMBean> getPrimaryChildMBeans() {
return getAllChildMBeans();
};
}

View File

@ -0,0 +1,33 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.impl;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeObjectContainerMBean;
public class EntaxyRuntimeObjectContainerMBeanInfo
extends EntaxyRuntimeItemMBeanInfo<EntaxyRuntimeObjectContainerMBean> {
}

View File

@ -0,0 +1,43 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.impl;
import java.util.ArrayList;
import java.util.List;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeObjectMBeanCustomizer;
public class EntaxyRuntimeObjectMBeanCustomizerHolder {
public EntaxyRuntimeObjectMBeanCustomizer customizer;
public List<EntaxyRuntimeItemMBeanInfo<?>> mbeanInfo = new ArrayList<>();
public EntaxyRuntimeObjectMBeanCustomizerHolder(EntaxyRuntimeObjectMBeanCustomizer customizer) {
this.customizer = customizer;
}
}

View File

@ -0,0 +1,119 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeItemMBean;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeObjectMBean;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObject;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeRelation;
public class EntaxyRuntimeObjectMBeanInfo extends EntaxyRuntimeItemMBeanInfo<EntaxyRuntimeObjectMBean> {
public enum LOAD_STATUS {
AUTO_LOADED,
LOADED,
NONE
}
public EntaxyRuntimeObjectMBeanInfo(EntaxyRuntimeObject runtimeObject) {
this.runtimeObject = runtimeObject;
}
String foundPattern;
EntaxyRuntimeObject runtimeObject;
EntaxyRuntimeObject parentObject;
EntaxyRuntimeRelation relationFromParent;
LOAD_STATUS loadStatus = LOAD_STATUS.NONE;
Map<String, List<EntaxyRuntimeObjectMBeanInfo>> secondaryBeans = new HashMap<>();
public boolean isGhost() {
return this.runtimeObject.isGhost();
}
public void resetStatus() {
this.loadStatus = LOAD_STATUS.NONE;
}
public void makeAutoLoaded() {
this.loadStatus = LOAD_STATUS.AUTO_LOADED;
}
public boolean isAutoLoaded() {
return LOAD_STATUS.AUTO_LOADED.equals(this.loadStatus);
}
public void makeLoaded() {
this.loadStatus = LOAD_STATUS.LOADED;
}
public boolean isLoaded() {
return LOAD_STATUS.LOADED.equals(this.loadStatus);
}
public boolean isUpdatedByLoad() {
return !LOAD_STATUS.NONE.equals(this.loadStatus);
}
public void register() {
super.register();
for (String key : secondaryBeans.keySet()) {
List<EntaxyRuntimeObjectMBeanInfo> list = secondaryBeans.get(key);
for (EntaxyRuntimeObjectMBeanInfo sMBean : list)
sMBean.register(this.bundleContext);
}
}
public void unregister() {
for (String key : secondaryBeans.keySet()) {
List<EntaxyRuntimeObjectMBeanInfo> list = secondaryBeans.get(key);
for (EntaxyRuntimeObjectMBeanInfo sMBean : list)
sMBean.unregister();
}
super.unregister();
}
@Override
public Map<String, EntaxyRuntimeItemMBean> getPrimaryChildMBeans() {
final List<String> secondariesIds =
secondaryBeans.values().stream().flatMap(list -> list.stream())
.map(bi -> bi.mbeanHolder.mbean.getId())
.collect(Collectors.toList());
Map<String, EntaxyRuntimeItemMBean> result =
getAllChildMBeans().entrySet().stream().filter(e -> !secondariesIds.contains(e.getValue().getId()))
.collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
return result;
}
}

View File

@ -0,0 +1,734 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.impl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.osgi.framework.BundleContext;
import org.osgi.framework.InvalidSyntaxException;
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.ReferencePolicy;
import org.osgi.service.component.annotations.ReferencePolicyOption;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.platform.base.objects.EntaxyObject.OBJECT_RELATION;
import ru.entaxy.platform.base.support.CommonUtils;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeItemMBean;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeObjectMBean;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeObjectMBeanCustomizer;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeObjectMBeanCustomizer.Customized;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeObjectMBeanFactory;
import ru.entaxy.platform.core.management.object.factory.impl.EntaxyObjectMBeanFactory;
import ru.entaxy.platform.core.management.object.impl.EntaxyRuntimeItemMBeanInfo.ItemStatus;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObject;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObjectManager;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObjectService;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeRelation;
@Component(service = EntaxyRuntimeObjectMBeanManager.class, immediate = true)
public class EntaxyRuntimeObjectMBeanManager implements EntaxyRuntimeObjectService.Listener {
private static final Logger log = LoggerFactory.getLogger(EntaxyRuntimeObjectMBeanManager.class);
private static final String TYPE_WILDCARD = "*";
@Reference(cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC,
policyOption = ReferencePolicyOption.GREEDY)
volatile EntaxyRuntimeObjectService entaxyRuntimeObjectService;
@Reference(cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC,
policyOption = ReferencePolicyOption.GREEDY)
volatile EntaxyRuntimeObjectManager entaxyRuntimeObjectManager;
protected static class FactorySearchResult {
public static FactorySearchResult create(EntaxyRuntimeObjectMBeanFactory factory, String pattern) {
return new FactorySearchResult(factory, pattern);
}
EntaxyRuntimeObjectMBeanFactory factory;
String pattern;
protected FactorySearchResult(EntaxyRuntimeObjectMBeanFactory factory, String pattern) {
this.factory = factory;
this.pattern = pattern;
}
}
protected Map<String, EntaxyRuntimeObjectMBeanFactory> factoriesMap = new HashMap<>();
protected Map<String, EntaxyRuntimeItemMBeanInfo<?>> infoById = new HashMap<>();
protected Map<String, EntaxyRuntimeObjectMBeanCustomizerHolder> customizersMap =
new HashMap<>();
// protected Map<String, EntaxyRuntimeItemMBeanInfo<?>> infoByJMXObjectName = new HashMap<>();
protected List<EntaxyRuntimeObjectMBeanInfo> toRemove = new ArrayList<>();
protected BundleContext bundleContext;
protected boolean activated = false;
protected Object lock = new Object();
@Activate
public EntaxyRuntimeObjectMBeanManager(BundleContext bundleContext) {
super();
this.bundleContext = bundleContext;
// add root factory
addFactory(new EntaxyObjectMBeanFactory(this));
}
@Activate
public void activate(ComponentContext componentContext) {
// this.bundleContext = componentContext.getBundleContext();
activated = true;
synchronized (lock) {
entaxyRuntimeObjectService.addListener(this);
loadCurrentObjects();
}
}
@Deactivate
public void deactivate() {
entaxyRuntimeObjectService.removeListener(this);
}
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC,
policyOption = ReferencePolicyOption.GREEDY,
collectionType = CollectionType.SERVICE, unbind = "removeFactory")
public void addFactory(EntaxyRuntimeObjectMBeanFactory factory) {
synchronized (lock) {
for (String pattern : factory.getSupportedTypes()) {
factoriesMap.put(pattern, factory);
}
List<? extends EntaxyRuntimeItemMBean> mbeans = factory.createMBeans();
if (mbeans != null)
for (EntaxyRuntimeItemMBean mbean : mbeans) {
EntaxyRuntimeItemMBeanInfo<?> mbeanInfo = MBeanUtils.createMBeanInfo(mbean);
if (!mbeanInfo.isCreated()) {
log.error("Error creating MBeanInfo for mbean [{}]", mbean.getId());
continue;
}
if (infoById.containsKey(mbeanInfo.getId())) {
try {
infoById.get(mbeanInfo.getId()).unregister();
} catch (Exception ignore) {
// ignore
}
}
infoById.put(mbeanInfo.getId(), mbeanInfo);
mbeanInfo.register(bundleContext);
}
// review all created mbeans if they suit newly added factory
List<EntaxyRuntimeObjectMBeanInfo> infoToRecreate = new ArrayList<>();
List<EntaxyRuntimeItemMBeanInfo<?>> infoToReregister = new ArrayList<>();
for (EntaxyRuntimeItemMBeanInfo<?> itemInfo : infoById.values()) {
if (!(itemInfo instanceof EntaxyRuntimeObjectMBeanInfo))
continue;
EntaxyRuntimeObjectMBeanInfo mBeanInfo = (EntaxyRuntimeObjectMBeanInfo) itemInfo;
FactorySearchResult result = findFactory(mBeanInfo.runtimeObject);
if (result.factory.getId().equals(factory.getId()))
if (!infoToRecreate.contains(mBeanInfo))
infoToRecreate.add(mBeanInfo);
}
List<EntaxyRuntimeItemMBean> itemsToReregister = new ArrayList<>();
for (EntaxyRuntimeObjectMBeanInfo mBeanInfo : infoToRecreate)
collectCascadeChildren(itemsToReregister, mBeanInfo.mbeanHolder.mbean);
infoToReregister.addAll(itemsToReregister.stream()
.map(item -> infoById.get(item.getId()))
.filter(item -> item != null)
.collect(Collectors.toList()));
infoToReregister.removeAll(infoToRecreate);
List<EntaxyRuntimeObject> runtimeObjects = infoToRecreate.stream()
.map(inf -> inf.runtimeObject)
.collect(Collectors.toList());
ObjectHelper helper = new ObjectHelper(runtimeObjects);
List<EntaxyRuntimeObjectMBeanInfo> recreatedInfos = helper.load();
List<EntaxyRuntimeObjectMBeanInfo> toRegister = new ArrayList<>();
for (EntaxyRuntimeObjectMBeanInfo newInfo : recreatedInfos) {
EntaxyRuntimeObjectMBeanInfo oldInfo = (EntaxyRuntimeObjectMBeanInfo) infoById.get(newInfo.getId());
if (oldInfo == null) {
// just add
infoById.put(newInfo.getId(), newInfo);
newInfo.setBundleContext(bundleContext);
newInfo.status(ItemStatus.REREGISTER);
toRegister.add(newInfo);
} else {
// mbean info already exists
if (newInfo.isAutoLoaded()) {
// object loaded only as someone's parent
// so we just switch the children links
switchChildren(newInfo.mbeanHolder.mbean, oldInfo.mbeanHolder.mbean);
if (oldInfo.isInStatus(ItemStatus.REMOVE))
oldInfo.status(ItemStatus.REREGISTER);
} else if (newInfo.isLoaded()) {
// unregister existing mbean
oldInfo.unregister();
updateObjectMBeanInfo(newInfo, oldInfo, toRegister);
switchChildren(oldInfo.mbeanHolder.mbean, newInfo.mbeanHolder.mbean);
// detach old secondaries from parent
for (String key : oldInfo.secondaryBeans.keySet()) {
List<EntaxyRuntimeObjectMBeanInfo> list = oldInfo.secondaryBeans.get(key);
for (EntaxyRuntimeObjectMBeanInfo bi : list)
bi.mbeanHolder.mbean.setParentMBean(null);
}
// remove all secondaries
oldInfo.secondaryBeans.clear();
// add new secondaries
oldInfo.secondaryBeans.putAll(newInfo.secondaryBeans);
// set new mbean
oldInfo.mbeanHolder.mbean = newInfo.mbeanHolder.mbean;
oldInfo.status(ItemStatus.REREGISTER);
// schedule existing to re-register
toRegister.add(oldInfo);
}
}
}
/*
* for (EntaxyRuntimeObjectMBeanInfo mBeanInfo : infoToRecreate) { FactorySearchResult
* searchResult = findFactory(mBeanInfo.runtimeObject); EntaxyRuntimeObjectMBean
* newMBean = searchResult.factory.createMBean(mBeanInfo.runtimeObject);
* EntaxyRuntimeObjectMBeanInfo newInfo = (EntaxyRuntimeObjectMBeanInfo)
* MBeanUtils.createMBeanInfo(newMBean);
*
* mBeanInfo.mbeanHolder.unregister();
*
* if (newInfo.mbeanHolder.mbean.getParentMBean() == null) {
* newInfo.mbeanHolder.mbean.setParentMBean(mBeanInfo.mbeanHolder.mbean.getParentMBean()
* ); }
*
* // unlink from parent and switch children
* mBeanInfo.mbeanHolder.mbean.setParentMBean(null);
* switchChildren(mBeanInfo.mbeanHolder.mbean, newInfo.mbeanHolder.mbean);
*
* infoById.put(newInfo.getId(), newInfo); newInfo.mbeanHolder.bundleContext =
* bundleContext; newInfo.mbeanHolder.register(); }
*/
for (EntaxyRuntimeItemMBeanInfo<?> toReg : toRegister) {
toReg.unregister();
toReg.register();
}
infoToReregister.removeAll(toRegister);
for (EntaxyRuntimeItemMBeanInfo<?> toReg : infoToReregister) {
toReg.unregister();
toReg.register();
}
}
}
public void refresh() {
synchronized (lock) {
toRemove.addAll(infoById.values().stream()
.filter(v -> (v instanceof EntaxyRuntimeObjectMBeanInfo))
.map(v -> EntaxyRuntimeObjectMBeanInfo.class.cast(v))
.collect(Collectors.toList()));
tryToRemove();
loadCurrentObjects();
}
}
public void removeFactory(EntaxyRuntimeObjectMBeanFactory factory) {
for (String pattern : factory.getSupportedTypes()) {
factoriesMap.remove(pattern);
}
}
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC,
policyOption = ReferencePolicyOption.GREEDY,
collectionType = CollectionType.SERVICE, unbind = "removeCustomizer")
public void addCustomizer(EntaxyRuntimeObjectMBeanCustomizer customizer) {
synchronized (lock) {
EntaxyRuntimeObjectMBeanCustomizerHolder holder = customizersMap.get(customizer.getId());
if (holder != null) {
// just switch to new customizer
holder.customizer = customizer;
} else {
holder = new EntaxyRuntimeObjectMBeanCustomizerHolder(customizer);
customizersMap.put(customizer.getId(), holder);
for (EntaxyRuntimeItemMBeanInfo<?> itemInfo : infoById.values()) {
if ((itemInfo.mbeanHolder == null)
|| !(itemInfo.mbeanHolder.mbean instanceof EntaxyRuntimeObjectMBean))
continue;
if (!customizer.isAccepted((EntaxyRuntimeObjectMBean) itemInfo.mbeanHolder.mbean))
continue;
EntaxyRuntimeObjectMBeanInfo objectInfo = (EntaxyRuntimeObjectMBeanInfo) itemInfo;
Customized customized = customizer.customize(objectInfo.mbeanHolder.mbean);
if (customized.getAdditionalMBeans() == null || customized.getAdditionalMBeans().isEmpty())
continue;
List<EntaxyRuntimeObjectMBeanInfo> secondaries = customized.getAdditionalMBeans().stream()
.map(b -> (EntaxyRuntimeObjectMBeanInfo) MBeanUtils.createMBeanInfo(b)).map(bi -> {
bi.status(ItemStatus.NEW);
bi.runtimeObject = objectInfo.runtimeObject;
return bi;
}).collect(Collectors.toList());
for (EntaxyRuntimeObjectMBeanInfo bi : secondaries) {
bi.register(bundleContext);
}
objectInfo.secondaryBeans.put(customizer.getId(), secondaries);
}
}
}
}
public void removeCustomizer(EntaxyRuntimeObjectMBeanCustomizer customizer) {
synchronized (lock) {
for (EntaxyRuntimeItemMBeanInfo<?> itemInfo : infoById.values()) {
if ((itemInfo.mbeanHolder == null)
|| !(itemInfo.mbeanHolder.mbean instanceof EntaxyRuntimeObjectMBean))
continue;
EntaxyRuntimeObjectMBeanInfo objectInfo = (EntaxyRuntimeObjectMBeanInfo) itemInfo;
if (objectInfo.secondaryBeans.containsKey(customizer.getId())) {
for (EntaxyRuntimeObjectMBeanInfo sBean : objectInfo.secondaryBeans.get(customizer.getId()))
sBean.unregister();
objectInfo.secondaryBeans.remove(customizer.getId());
}
}
customizersMap.remove(customizer.getId());
}
}
protected void loadCurrentObjects() {
ObjectHelper helper = new ObjectHelper(entaxyRuntimeObjectService.getObjects());
List<EntaxyRuntimeObjectMBeanInfo> mBeanInfoList = helper.load();
for (EntaxyRuntimeObjectMBeanInfo mBeanInfo : mBeanInfoList) {
infoById.put(mBeanInfo.getId(), mBeanInfo);
mBeanInfo.register(bundleContext);
mBeanInfo.resetStatus();
}
}
protected FactorySearchResult findFactory(EntaxyRuntimeObject entaxyRuntimeObject) {
EntaxyRuntimeObjectMBeanFactory result = null;
String type = entaxyRuntimeObject.getType();
while (CommonUtils.isValid(type)) {
result = factoriesMap.get(type);
if (result != null)
return FactorySearchResult.create(result, type);
int index = type.lastIndexOf('.');
if (index < 0) {
if (type.equals(TYPE_WILDCARD))
type = "";
else
type = TYPE_WILDCARD;
} else {
if (type.endsWith(TYPE_WILDCARD))
type = type.substring(0, index);
else {
type = type.substring(0, index).concat(".").concat(TYPE_WILDCARD);
}
}
}
return FactorySearchResult.create(null, "");
}
protected void findFactory(EntaxyRuntimeObjectMBeanInfo mBeanInfo) {
FactorySearchResult searchResult = findFactory(mBeanInfo.runtimeObject);
if (searchResult != null) {
mBeanInfo.factory = searchResult.factory;
mBeanInfo.foundPattern = searchResult.pattern;
}
}
// EntaxyRuntimeObjectService.Listener
@Override
public void objectAdded(EntaxyRuntimeObject object) {
if (object == null)
return;
synchronized (lock) {
ObjectHelper helper = new ObjectHelper(Collections.singletonList(object));
List<EntaxyRuntimeObjectMBeanInfo> mBeanInfoList = helper.load();
List<EntaxyRuntimeObjectMBeanInfo> toRegister = new ArrayList<>();
for (EntaxyRuntimeObjectMBeanInfo mBeanInfo : mBeanInfoList) {
if (!infoById.containsKey(mBeanInfo.getId())) {
// just add
infoById.put(mBeanInfo.getId(), mBeanInfo);
mBeanInfo.setBundleContext(bundleContext);;
mBeanInfo.status(ItemStatus.REREGISTER);
toRegister.add(mBeanInfo);
} else {
// mbean info already exists
EntaxyRuntimeObjectMBeanInfo existing =
(EntaxyRuntimeObjectMBeanInfo) infoById.get(mBeanInfo.getId());
if (mBeanInfo.isAutoLoaded()) {
// object loaded only as someone's parent
// so we just switch the children links
// switchChildren(mBeanInfo.mbeanHolder.mbean, existing.mbeanHolder.mbean);
switchChildren(mBeanInfo.mbeanHolder.mbean, existing.mbeanHolder.mbean,
existing.secondaryBeans.values().stream().flatMap(list -> list.stream())
.map(bi -> bi.mbeanHolder.mbean).collect(Collectors.toList()));
if (existing.isInStatus(ItemStatus.REMOVE))
existing.status(ItemStatus.REREGISTER);
} else if (mBeanInfo.isLoaded()) {
// unregister existing mbean
existing.unregister();
updateObjectMBeanInfo(mBeanInfo, existing, toRegister);
// switchChildren(existing.mbeanHolder.mbean, mBeanInfo.mbeanHolder.mbean);
switchChildren(existing.mbeanHolder.mbean, mBeanInfo.mbeanHolder.mbean,
existing.secondaryBeans.values().stream().flatMap(list -> list.stream())
.map(bi -> bi.mbeanHolder.mbean).collect(Collectors.toList()));
// detach old secondaries from parent
for (String key : existing.secondaryBeans.keySet()) {
List<EntaxyRuntimeObjectMBeanInfo> list = existing.secondaryBeans.get(key);
for (EntaxyRuntimeObjectMBeanInfo bi : list)
bi.mbeanHolder.mbean.setParentMBean(null);
}
// remove all secondaries
existing.secondaryBeans.clear();
// add new secondaries
existing.secondaryBeans.putAll(mBeanInfo.secondaryBeans);
// set new mbean
existing.mbeanHolder.mbean = mBeanInfo.mbeanHolder.mbean;
existing.status(ItemStatus.REREGISTER);
// schedule existing to re-register
toRegister.add(existing);
}
}
}
for (EntaxyRuntimeObjectMBeanInfo mbean : toRegister) {
if (mbean.isRegistered())
mbean.unregister();
mbean.register();
}
}
}
protected void switchChildren(EntaxyRuntimeItemMBean fromMBean, EntaxyRuntimeItemMBean toMBean,
List<EntaxyRuntimeItemMBean> ignore) {
// avoid cuncurrent modifications
List<EntaxyRuntimeItemMBean> children = new ArrayList<>(fromMBean.getChildMBeans().values());
for (EntaxyRuntimeItemMBean child : children)
if (!ignore.contains(child))
child.setParentMBean(toMBean);
}
protected void switchChildren(EntaxyRuntimeItemMBean fromMBean, EntaxyRuntimeItemMBean toMBean) {
// avoid cuncurrent modifications
List<EntaxyRuntimeItemMBean> children = new ArrayList<>(fromMBean.getChildMBeans().values());
for (EntaxyRuntimeItemMBean child : children)
child.setParentMBean(toMBean);
}
protected void updateObjectMBeanInfo(EntaxyRuntimeObjectMBeanInfo fromMBeanInfo,
EntaxyRuntimeObjectMBeanInfo toMBeanInfo, List<EntaxyRuntimeObjectMBeanInfo> affectedItems) {
// switch existing children to new mbean
// and schedule them to re-register
/*
* List<EntaxyRuntimeItemMBean> children = new
* ArrayList<>(fromMBeanInfo.mbeanHolder.mbean.getChildMBeans().values()); for
* (EntaxyRuntimeItemMBean child : children) {
* child.setParentMBean(toMBeanInfo.mbeanHolder.mbean); if
* (!affectedItems.contains(infoById.get(child.getId())))
* affectedItems.add((EntaxyRuntimeObjectMBeanInfo) infoById.get(child.getId()));
*
* List<EntaxyRuntimeItemMBean> cascadeChildren = new ArrayList<>();
* collectCascadeChildren(cascadeChildren, child); affectedItems.addAll(
* cascadeChildren.stream() .map(c -> (EntaxyRuntimeObjectMBeanInfo)
* infoById.get(c.getId())) .collect(Collectors.toList())); }
*/
// set parent to new mbean
// existing.mbeanHolder.mbean.setParentMBean(mBeanInfo.mbeanHolder.mbean.getParentMBean());
// toMBeanInfo.mbeanHolder.mbean.setParentMBean(null);
// update existing
toMBeanInfo.factory = fromMBeanInfo.factory;
toMBeanInfo.foundPattern = fromMBeanInfo.foundPattern;
toMBeanInfo.relationFromParent = fromMBeanInfo.relationFromParent;
toMBeanInfo.runtimeObject = fromMBeanInfo.runtimeObject;
}
protected void collectCascadeChildren(List<EntaxyRuntimeItemMBean> result, EntaxyRuntimeItemMBean startMBean) {
for (EntaxyRuntimeItemMBean child : startMBean.getChildMBeans().values()) {
result.add(child);
collectCascadeChildren(result, child);
}
}
@Override
public void objectModified(EntaxyRuntimeObject object) {
// we'll do the same as when an object is added
objectAdded(object);
}
@Override
public void objectRemoved(EntaxyRuntimeObject object) {
synchronized (lock) {
if (!infoById.containsKey(object.getObjectFullId()))
return;
toRemove.add((EntaxyRuntimeObjectMBeanInfo) infoById.get(object.getObjectFullId()));
tryToRemove();
}
}
protected void tryToRemove() {
int currentSize = -1;
while (currentSize != toRemove.size()) {
currentSize = toRemove.size();
List<EntaxyRuntimeObjectMBeanInfo> removed = new ArrayList<>();
for (EntaxyRuntimeObjectMBeanInfo item : toRemove) {
if (item.isRegistered())
item.unregister();
// if (item.mbeanHolder.mbean.getChildMBeans().isEmpty()) {
if (item.getPrimaryChildMBeans().isEmpty()) {
// remove from parent
item.mbeanHolder.mbean.setParentMBean(null);
// remove
infoById.remove(item.getId());
removed.add(item);
}
}
toRemove.removeAll(removed);
}
}
// Util classes
protected class ObjectHelper {
List<EntaxyRuntimeObject> objects;
Map<String, EntaxyRuntimeObjectMBeanInfo> createdInfo = new HashMap<>();
public ObjectHelper(List<EntaxyRuntimeObject> objects) {
this.objects = objects;
}
public List<EntaxyRuntimeObjectMBeanInfo> load() {
// create Mbean info objects
for (EntaxyRuntimeObject object : this.objects) {
String objectId = object.getObjectFullId();
EntaxyRuntimeObjectMBeanInfo mBeanInfo = getOrCreateMBeanInfo(object);
if (mBeanInfo == null)
continue;
mBeanInfo.makeLoaded();
EntaxyRuntimeObjectMBean mBean = mBeanInfo.mbeanHolder.mbean;
List<EntaxyRuntimeRelation> relations = object.getIncomiingRelations(OBJECT_RELATION.COMPOSITION);
if (relations.isEmpty())
relations = object.getIncomiingRelations(OBJECT_RELATION.AGGREGATION);
if (relations.isEmpty())
continue;
EntaxyRuntimeRelation parentLink = relations.get(0);
EntaxyRuntimeObject parentObject = parentLink.getMain();
String parentObjectId = parentObject.getObjectFullId();
EntaxyRuntimeObjectMBeanInfo mBeanInfoParent = getOrCreateMBeanInfo(parentObject);
if (!mBeanInfoParent.isLoaded())
mBeanInfoParent.makeAutoLoaded();
mBean.setParentMBean(mBeanInfoParent.mbeanHolder.mbean);
if (CommonUtils.isValid(parentLink.getName()))
mBean.setJMXSubQualifierName(parentLink.getName());
mBean.setParentSubPath(parentLink.getGroup());
}
return new ArrayList<>(createdInfo.values());
}
protected EntaxyRuntimeObjectMBeanInfo getOrCreateMBeanInfo(EntaxyRuntimeObject object) {
String objectId = object.getObjectFullId();
if (!createdInfo.containsKey(objectId)) {
FactorySearchResult searchResult = findFactory(object);
if (searchResult.factory == null) {
log.warn("No MBean factory found for object [{}]", objectId);
return null;
}
EntaxyRuntimeObjectMBean mBean = searchResult.factory.createMBean(object);
EntaxyRuntimeObjectMBeanInfo mBeanInfo =
(EntaxyRuntimeObjectMBeanInfo) MBeanUtils.createMBeanInfo(mBean);
for (EntaxyRuntimeObjectMBeanCustomizerHolder holder : customizersMap.values()) {
EntaxyRuntimeObjectMBeanCustomizer customizer = holder.customizer;
if (customizer.isAccepted(mBean)) {
Customized customized = customizer.customize(mBean);
if (customized.getAdditionalMBeans() != null && !customized.getAdditionalMBeans().isEmpty())
mBeanInfo.secondaryBeans.put(customizer.getId(),
customized.getAdditionalMBeans().stream()
.map(b -> (EntaxyRuntimeObjectMBeanInfo) MBeanUtils.createMBeanInfo(b))
.map(bi -> {
bi.status(ItemStatus.NEW);
bi.runtimeObject = object;
return bi;
})
.collect(Collectors.toList()));
}
}
mBeanInfo.status(ItemStatus.NEW);
mBeanInfo.runtimeObject = object;
createdInfo.put(objectId, mBeanInfo);
return mBeanInfo;
} else {
return createdInfo.get(objectId);
}
}
}
public Map<String, EntaxyRuntimeObjectMBeanFactory> getFactoriesMap() {
return Collections.unmodifiableMap(factoriesMap);
}
public Map<String, EntaxyRuntimeItemMBeanInfo<?>> getInfoById() {
return Collections.unmodifiableMap(infoById);
}
public List<EntaxyRuntimeObject> findObjects(String osgiFilter) throws InvalidSyntaxException {
return entaxyRuntimeObjectService.findObjects(osgiFilter);
}
}

View File

@ -0,0 +1,150 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.impl;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import javax.management.DynamicMBean;
import javax.management.MBeanRegistration;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.esb.platform.base.management.core.ManagementCore;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeItemMBean;
public class MBeanHolder<T extends EntaxyRuntimeItemMBean> {
private static final Logger log = LoggerFactory.getLogger(MBeanHolder.class);
public static <S extends EntaxyRuntimeItemMBean> MBeanHolder<S> create(S mbean) {
MBeanHolder<S> result = new MBeanHolder<S>();
result.mbean = mbean;
result.objectId = mbean.getId();
return result;
}
public static <S extends EntaxyRuntimeItemMBean> MBeanHolder<S> register(Class<? extends S> mbeanClass,
S mbean,
Dictionary<String, Object> properties,
BundleContext bundleContext) {
MBeanHolder<S> result = create(mbean);
if (properties != null) {
result.clearProperties();
Enumeration<String> keys = properties.keys();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
result.registrationProperties.put(key, properties.get(key));
}
}
if (mbeanClass != null)
result.register(mbeanClass);
else
result.register();
return result;
}
ServiceRegistration<?> registration;
public String objectId;
public T mbean;
Dictionary<String, Object> registrationPropertiesDefaults = new Hashtable<>();
Dictionary<String, Object> registrationProperties = new Hashtable<>();
BundleContext bundleContext;
public void clearProperties() {
this.registrationProperties = new Hashtable<>();
}
protected void loadDefaultProperties() {
Iterator<String> iter = registrationPropertiesDefaults.keys().asIterator();
while (iter.hasNext()) {
String key = iter.next();
registrationProperties.put(key, registrationPropertiesDefaults.get(key));
}
}
public void register() {
if (this.mbean == null)
return;
register(this.mbean.getMBeanClass());
}
public void register(Class<? extends EntaxyRuntimeItemMBean> mbeanClass) {
if (this.mbean == null)
return;
unregister();
String[] classes = new String[] {
mbeanClass.getName(),
DynamicMBean.class.getName(),
MBeanRegistration.class.getName()
};
loadDefaultProperties();
if (registrationProperties.get(ManagementCore.JMX_OBJECTNAME) == null) {
registrationProperties.put(ManagementCore.JMX_OBJECTNAME,
MBeanUtils.addNamespace(MBeanUtils.calculateJmxObjectName(mbean)));
}
try {
registration = bundleContext.registerService(classes, mbean, registrationProperties);
} catch (Exception e) {
log.error("Error registering MBean [" + mbean.getId() + "]", e);
}
}
public void unregister() {
if (registration != null) {
try {
registration.unregister();
} catch (Exception ignore) {
// NOOP
}
registration = null;
}
clearProperties();
}
}

View File

@ -0,0 +1,101 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.impl;
import java.util.Arrays;
import java.util.stream.Collectors;
import ru.entaxy.esb.platform.base.management.core.ManagementCore;
import ru.entaxy.platform.base.support.CommonUtils;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeItemMBean;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeObjectContainerMBean;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeObjectMBean;
public class MBeanUtils {
public static EntaxyRuntimeItemMBeanInfo<?> createMBeanInfo(EntaxyRuntimeItemMBean mBean) {
if (EntaxyRuntimeObjectMBean.class.isAssignableFrom(mBean.getMBeanClass())) {
EntaxyRuntimeObjectMBeanInfo mBeanInfo = new EntaxyRuntimeObjectMBeanInfo(
((EntaxyRuntimeObjectMBean) mBean).getRuntimeObject());
mBeanInfo.createHolder((EntaxyRuntimeObjectMBean) mBean);
return mBeanInfo;
} else {
EntaxyRuntimeObjectContainerMBeanInfo mBeanInfo = new EntaxyRuntimeObjectContainerMBeanInfo();
mBeanInfo.createHolder((EntaxyRuntimeObjectContainerMBean) mBean);
return mBeanInfo;
}
}
public static String calculateJmxObjectName(EntaxyRuntimeItemMBean mbean) {
return calculateJmxObjectName(mbean, EntaxyRuntimeItemMBean.JMX_SUBPATH_QUALIFIER);
}
public static String calculateJmxObjectName(EntaxyRuntimeItemMBean mbean, String subPathQualifier) {
String finalName = mbean.getJMXSubQualifier();
EntaxyRuntimeItemMBean currentMbean = mbean.getParentMBean();
String parentSubPath = mbean.getParentSubPath();
String levelPlaceholderConstant = "@LEVEL@";
finalName = finalName.replace(EntaxyRuntimeItemMBean.JMX_SUBQUALIFIER_AUTO,
subPathQualifier.concat("_").concat(levelPlaceholderConstant));
while (currentMbean != null) {
String newName = currentMbean.getJMXSubQualifier();
if (CommonUtils.isValid(parentSubPath)) {
// we must create unique, but idempotent set of keys
// as a key we'll use subPathQualifier with level index
String subpath = Arrays.asList(parentSubPath.split("/"))
.stream()
.map(s -> subPathQualifier.concat("_").concat(levelPlaceholderConstant).concat("=").concat(s))
.collect(Collectors.joining(","));
if (CommonUtils.isValid(subpath))
newName = newName.concat(",").concat(subpath);
}
finalName = newName.concat(",").concat(finalName);
parentSubPath = currentMbean.getParentSubPath();
currentMbean = currentMbean.getParentMBean();
}
// replace placeholder with overall level value
String[] splitted = finalName.split(",");
for (int i = 0; i < splitted.length; i++) {
splitted[i] = splitted[i].replace(levelPlaceholderConstant, "" + i);
}
finalName = Arrays.asList(splitted).stream().collect(Collectors.joining(","));
return finalName;
}
public static String addNamespace(String qualifier) {
if (qualifier.contains(":"))
return qualifier;
return ManagementCore.ENTAXY_JMX_DOMAIN.concat(":").concat(qualifier);
}
}

View File

@ -0,0 +1,39 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.shell;
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import ru.entaxy.platform.core.management.object.impl.EntaxyRuntimeObjectMBeanManager;
public class EntaxyRuntimeObjectMBeanManagerSupport {
public static final String COMMAND_SCOPE = "entaxy";
@Reference
public EntaxyRuntimeObjectMBeanManager mBeanManager;
}

View File

@ -0,0 +1,59 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.shell;
import java.util.HashSet;
import java.util.stream.Collectors;
import org.apache.karaf.shell.api.action.Action;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import ru.entaxy.platform.base.support.karaf.shell.ShellTableFixed;
import ru.entaxy.platform.core.management.object.EntaxyRuntimeObjectMBeanFactory;
@Service
@Command(scope = EntaxyRuntimeObjectMBeanManagerSupport.COMMAND_SCOPE, name = "object-mbean-factory-list")
public class ListMBeanFactories extends EntaxyRuntimeObjectMBeanManagerSupport implements Action {
@Override
public Object execute() throws Exception {
ShellTableFixed shellTable = new ShellTableFixed();
shellTable.column("Id");
shellTable.column("Supported types");
for (EntaxyRuntimeObjectMBeanFactory factory : new HashSet<>(mBeanManager.getFactoriesMap().values())) {
shellTable.addRow().addContent(
factory.getId(),
factory.getSupportedTypes().stream().collect(Collectors.joining("\n")));
}
shellTable.print(System.out);
return null;
}
}

View File

@ -0,0 +1,77 @@
/*-
* ~~~~~~licensing~~~~~~
* object-management
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.core.management.object.shell;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.karaf.shell.api.action.Action;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import ru.entaxy.platform.base.support.karaf.shell.ShellTableFixed;
import ru.entaxy.platform.core.management.object.impl.EntaxyRuntimeItemMBeanInfo;
import ru.entaxy.platform.core.management.object.impl.EntaxyRuntimeObjectMBeanInfo;
@Service
@Command(scope = EntaxyRuntimeObjectMBeanManagerSupport.COMMAND_SCOPE, name = "object-mbean-list")
public class ListMBeans extends EntaxyRuntimeObjectMBeanManagerSupport implements Action {
@Override
public Object execute() throws Exception {
ShellTableFixed shellTable = new ShellTableFixed();
shellTable.column("Object Id");
shellTable.column("Type");
shellTable.column("Class name");
shellTable.column("Registered");
shellTable.column("Parent Id");
shellTable.column("Ghost");
Map<String, EntaxyRuntimeItemMBeanInfo<?>> map = mBeanManager.getInfoById();
for (Entry<String, EntaxyRuntimeItemMBeanInfo<?>> entry : map.entrySet()) {
EntaxyRuntimeItemMBeanInfo<?> info = entry.getValue();
shellTable.addRow().addContent(
entry.getKey(),
info instanceof EntaxyRuntimeObjectMBeanInfo ? "OBJECT" : "CONTAINER",
info.mbeanHolder.mbean == null ? "" : info.mbeanHolder.mbean.getClass().getName(),
info.isRegistered() ? "*" : "",
info.mbeanHolder.mbean == null ? ""
: info.mbeanHolder.mbean.getParentMBean() == null ? ""
: info.mbeanHolder.mbean.getParentMBean().getId(),
info instanceof EntaxyRuntimeObjectMBeanInfo
? ((EntaxyRuntimeObjectMBeanInfo) info).isGhost() ? "*" : ""
: "");
}
shellTable.print(System.out);
return null;
}
}