All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.lsdconsulting.interceptors.aop.autoconfigure.LsdSpringAopRepositoryAutoConfiguration.kt Maven / Gradle / Ivy

Go to download

Provides various interceptors to capture events for the lsd-core library to generate sequence diagrams

There is a newer version: 8.0.73
Show newest version
package io.lsdconsulting.interceptors.aop.autoconfigure

import com.lsd.core.LsdContext
import io.lsdconsulting.interceptors.aop.AopInterceptorDelegate
import io.lsdconsulting.interceptors.aop.SpringDataRepositoryInterceptor
import io.lsdconsulting.interceptors.common.AppName.Factory.create
import jakarta.annotation.PostConstruct
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.EnableAspectJAutoProxy
import org.springframework.data.repository.Repository

/**
 *
 *
 * If a [Repository] class, [LsdContext] class and AOP dependencies are available it will automatically
 * intercept calls to the repository as well as exceptions thrown
 *
 */
@Configuration
@ConditionalOnProperty(name = ["lsd.interceptors.autoconfig.enabled"], havingValue = "true", matchIfMissing = true)
@ConditionalOnClass(value = [LsdContext::class, Repository::class])
@EnableAspectJAutoProxy
open class LsdSpringAopRepositoryAutoConfiguration {
    private val lsdContext: LsdContext = LsdContext.instance

    @Value("\${info.app.name:App}")
    private lateinit var appName: String

    @Bean
    open fun springDataRepositoryInterceptor(aopInterceptorDelegate: AopInterceptorDelegate): SpringDataRepositoryInterceptor {
        return SpringDataRepositoryInterceptor(aopInterceptorDelegate)
    }

    @Bean
    open fun aopInterceptorDelegate(): AopInterceptorDelegate {
        return AopInterceptorDelegate(lsdContext, create(appName))
    }

    @PostConstruct
    private fun postConstruct() {
        lsdContext.includeFiles(
            setOf(
                "tupadr3/font-awesome-5/database",
                "tupadr3/font-awesome-5/clock"
            )
        )
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy