Merge pull request #3 from TouchInstinct/common-spring

Common spring
This commit is contained in:
Alexander Buntakov 2021-06-07 16:03:16 +03:00 committed by GitHub
commit 112a9fa97b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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

@ -69,4 +69,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

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