-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from spacious-team/develop
Релиз 2024.1
- Loading branch information
Showing
14 changed files
with
1,176 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
name: Отчет об ошибке | ||
about: Создайте отчет об ошибке, чтобы улучшить приложение | ||
title: '' | ||
labels: bug | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Опишите ошибку** | ||
Ясное и краткое описание ошибки. | ||
|
||
**Последовательность действий для воспроизведения** | ||
Шаги по воспроизведению ошибки. | ||
|
||
**Ожидаемый результат** | ||
Ясное и краткое описание того, что вы ожидали. | ||
|
||
**Скриншоты** | ||
Если возможно, добавьте скриншоты, чтобы объяснить проблему. | ||
|
||
**Окружение:** | ||
- ОС: [например windows 10] | ||
- Версия Java [например 19] | ||
- Версия приложения[например 2020.1] | ||
|
||
**Дополнительный контекст** | ||
Любой другой контекст проблемы. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Запрос новой функциональности | ||
about: Предложите идею для этого проекта | ||
title: '' | ||
labels: feature | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Связан ли ваш запрос новой функциональности с проблемой? Пожалуйста, опишите.** | ||
Четкое и краткое описание проблемы. Например, я всегда расстраиваюсь, когда [...] | ||
|
||
**Опишите желаемое решение** | ||
Четкое и краткое описание того, что вы хотите сделать. | ||
|
||
**Опишите альтернативы, которые вы рассмотрели** | ||
Четкое и краткое описание любых рассмотренных вами альтернативных решений или функций. | ||
|
||
**Дополнительный контекст** | ||
Любой другой контекст. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Unit Tests | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- 'master' | ||
- 'develop' | ||
push: | ||
branches: | ||
- 'master' | ||
- 'develop' | ||
|
||
jobs: | ||
tests: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'liberica' | ||
cache: maven | ||
|
||
- name: Maven Tests | ||
run: mvn --batch-mode clean test | ||
|
||
- name: Test Coverage | ||
uses: codecov/[email protected] | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
- name: SonarCloud Analyze | ||
run: > | ||
mvn --batch-mode sonar:sonar | ||
-Dsonar.projectKey=spacious-team_table-wrapper-spring-boot-starter | ||
-Dsonar.organization=spacious-team | ||
-Dsonar.host.url=https://sonarcloud.io | ||
-Dsonar.login=$SONAR_TOKEN | ||
-Dsonar.coverage.jacoco.xmlReportPaths=./target/site/jacoco/jacoco.xml | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...ain/java/org/spacious_team/table_wrapper/autoconfigure/ContextAwareReportPageFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Table Wrapper Spring Boot Starter | ||
* Copyright (C) 2024 Spacious Team <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.spacious_team.table_wrapper.autoconfigure; | ||
|
||
import org.spacious_team.table_wrapper.api.ReportPage; | ||
|
||
import java.io.InputStream; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
public interface ContextAwareReportPageFactory extends ReportPageFactory { | ||
|
||
/** | ||
* Returns the ReportPage implementation classes that can be instantiated by this factory. | ||
*/ | ||
List<Class<? extends ReportPage>> getRegisteredReportPageTypes(); | ||
|
||
/** | ||
* Register prototype spring bean definition for ReportPage implementation. | ||
* This class instance can subsequently be created using the method {@link #create(Object...)} | ||
*/ | ||
void registerBeanDefinition(Class<? extends ReportPage> clazz); | ||
|
||
/** | ||
* Chooses ReportPage implementation by its constructor argument types and creates it. | ||
* Use this method if ReportPage should be created with nonstandard configuration. | ||
* | ||
* @throws ReportPageInstantiationException if ReportPage implementations' constructor not found | ||
* or ReportPage instance creation fails | ||
* @see ReportPageFactory#create(Path) | ||
* @see ReportPageFactory#create(InputStream) | ||
*/ | ||
ReportPage create(Object... args); | ||
} |
74 changes: 74 additions & 0 deletions
74
...a/org/spacious_team/table_wrapper/autoconfigure/DefaultContextAwareReportPageFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Table Wrapper Spring Boot Starter | ||
* Copyright (C) 2024 Spacious Team <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.spacious_team.table_wrapper.autoconfigure; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.spacious_team.table_wrapper.api.ReportPage; | ||
import org.springframework.beans.factory.config.AutowireCapableBeanFactory; | ||
import org.springframework.beans.factory.config.BeanDefinition; | ||
import org.springframework.beans.factory.support.BeanDefinitionBuilder; | ||
import org.springframework.beans.factory.support.BeanDefinitionRegistry; | ||
import org.springframework.context.ApplicationContext; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CopyOnWriteArrayList; | ||
|
||
import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public class DefaultContextAwareReportPageFactory extends DefaultReportPageFactory implements ContextAwareReportPageFactory { | ||
|
||
private final List<Class<? extends ReportPage>> registeredReportPageTypes = new CopyOnWriteArrayList<>(); | ||
private final ApplicationContext context; | ||
|
||
@Override | ||
public void registerBeanDefinition(Class<? extends ReportPage> clazz) { | ||
registeredReportPageTypes.add(clazz); | ||
String beanName = getBeanName(clazz); | ||
BeanDefinition beanDefinition = BeanDefinitionBuilder.rootBeanDefinition(clazz) | ||
.setScope(SCOPE_PROTOTYPE) | ||
.getBeanDefinition(); | ||
getBeanDefinitionRegistry() | ||
.registerBeanDefinition(beanName, beanDefinition); | ||
} | ||
|
||
private static String getBeanName(Class<?> clazz) { | ||
char[] chars = clazz.getSimpleName().toCharArray(); | ||
chars[0] = Character.toLowerCase(chars[0]); | ||
return new String(chars); | ||
} | ||
|
||
private BeanDefinitionRegistry getBeanDefinitionRegistry() { | ||
AutowireCapableBeanFactory factory = context.getAutowireCapableBeanFactory(); | ||
return (BeanDefinitionRegistry) factory; | ||
} | ||
|
||
@Override | ||
public ReportPage create(Object... args) { | ||
for (Class<? extends ReportPage> clazz : registeredReportPageTypes) { | ||
try { | ||
return context.getBean(clazz, args); | ||
} catch (Exception ignore) { | ||
} | ||
} | ||
throw new ReportPageInstantiationException("Can't create ReportPage with arguments: " + List.of(args)); | ||
} | ||
} |
Oops, something went wrong.