Add autoconfiguration
This commit is contained in:
parent
279baa3bfc
commit
6f182114ee
@ -18,8 +18,7 @@ public class LifecycleAspect {
|
|||||||
|
|
||||||
private final LifecycleManager lifecycleManager;
|
private final LifecycleManager lifecycleManager;
|
||||||
|
|
||||||
@Value("${aspect.base-package}")
|
private final LifecycleProperties lifecycleProperties;
|
||||||
private String basePackage;
|
|
||||||
|
|
||||||
|
|
||||||
@Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitListener) || "
|
@Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitListener) || "
|
||||||
@ -31,7 +30,7 @@ public class LifecycleAspect {
|
|||||||
public Object checkLifecycle(ProceedingJoinPoint joinPoint) throws Throwable {
|
public Object checkLifecycle(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||||
|
|
||||||
String targetClassName = joinPoint.getTarget().getClass().getPackageName();
|
String targetClassName = joinPoint.getTarget().getClass().getPackageName();
|
||||||
if (!targetClassName.startsWith(basePackage)) {
|
if (!targetClassName.startsWith(lifecycleProperties.getBasePackage())) {
|
||||||
return joinPoint.proceed();
|
return joinPoint.proceed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.knecon.fforesight.lifecyclecommons;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableConfigurationProperties(LifecycleProperties.class)
|
||||||
|
@ComponentScan(basePackageClasses = {LifecycleManager.class, LifecycleAspect.class})
|
||||||
|
public class LifecycleAutoconfiguration {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.knecon.fforesight.lifecyclecommons;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ConfigurationProperties("lifecycle")
|
||||||
|
public class LifecycleProperties {
|
||||||
|
|
||||||
|
private String basePackage;
|
||||||
|
}
|
||||||
@ -1,2 +1,2 @@
|
|||||||
aspect:
|
lifecycle:
|
||||||
base-package: com.knecon
|
base-package: com.knecon
|
||||||
@ -1,2 +1,2 @@
|
|||||||
aspect:
|
lifecycle:
|
||||||
base-package: com.knecon
|
base-package: com.knecon
|
||||||
Loading…
x
Reference in New Issue
Block a user