add common-spring

This commit is contained in:
Alexander Buntakov 2021-06-06 22:35:20 +03:00
parent 556f2e0470
commit 6ca9ebef8b
7 changed files with 50 additions and 1 deletions

View File

@ -28,3 +28,7 @@
* `SecureRandomStringGenerator` - генератор случайной строки по словарю
* `errors.*` - базовые исключения
* `<type>.*Utils` - утилиты для различных типов данных
## common-spring
Набор утилит, структур данных для `spring`, без привязки к доп. модулям, таким как `jpa` и `web`

View File

@ -70,4 +70,3 @@ subprojects {
useJUnitPlatform()
}
}

View File

@ -0,0 +1,11 @@
plugins {
id("kotlin")
id("kotlin-spring")
id("maven-publish")
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.springframework.boot:spring-boot")
}

View File

@ -0,0 +1,12 @@
@file:Suppress("unused", "MemberVisibilityCanBePrivate")
package ru.touchin.common.spring
object Ordered {
const val NORMAL = 16384
const val HIGH = NORMAL / 2
const val HIGHER = HIGH / 2
const val LOW = NORMAL * 2
const val LOWER = LOW * 2
}

View File

@ -0,0 +1,8 @@
package ru.touchin.common.spring.annotations
import org.springframework.boot.context.event.ApplicationStartedEvent
import org.springframework.context.event.EventListener
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
@EventListener(value = [ApplicationStartedEvent::class])
annotation class RunOnceOnStartup

View File

@ -0,0 +1,14 @@
@file:Suppress("unused", "MemberVisibilityCanBePrivate")
package ru.touchin.common.spring.io
import org.springframework.core.io.ClassPathResource
import java.io.InputStream
object IOUtils {
fun getInputStreamOfResourceFile(fileName: String): InputStream = ClassPathResource(fileName).inputStream
fun getResourceAsString(filename: String): String = getInputStreamOfResourceFile(filename)
.use { String(it.readBytes()) }
}

View File

@ -21,3 +21,4 @@ pluginManagement {
}
include("common")
include("common-spring")