Skip to content

Commit

Permalink
💥keep silencer simple #265
Browse files Browse the repository at this point in the history
  • Loading branch information
trydofor committed Jun 29, 2024
1 parent 81ba2e0 commit 1147482
Show file tree
Hide file tree
Showing 53 changed files with 170 additions and 274 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.io.ResourceLoader;
import pro.fessional.mirana.data.CodeEnum;
import pro.fessional.wings.silencer.spring.help.SubclassSpringLoader;
import pro.fessional.wings.silencer.support.SubclassGather;

import java.util.Map;

Expand All @@ -27,7 +27,7 @@ public class Devops7EnumsDumperTest {

@Test
public void dumpCodeEnum() {
SubclassSpringLoader loader = new SubclassSpringLoader(resourceLoader);
SubclassGather loader = new SubclassGather(resourceLoader);
Class<CodeEnum> superEnum = CodeEnum.class;

Map<Class<?>, Enum<?>[]> enums = loader.loadSubEnums("pro.fessional", superEnum);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import java.util.Arrays;
import java.util.Objects;

import static pro.fessional.wings.silencer.spring.help.CommonPropHelper.mergeIfNon;
import static pro.fessional.wings.silencer.spring.help.CommonPropHelper.nonValue;
import static pro.fessional.wings.silencer.support.PropHelper.mergeIfNon;
import static pro.fessional.wings.silencer.support.PropHelper.nonValue;

/**
* hashCode and equals with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import pro.fessional.wings.silencer.modulate.RunMode;
import pro.fessional.wings.silencer.modulate.RuntimeMode;
import pro.fessional.wings.silencer.spring.boot.ConditionalWingsEnabled;
import pro.fessional.wings.silencer.spring.help.CommonPropHelper;
import pro.fessional.wings.silencer.support.PropHelper;
import pro.fessional.wings.slardar.fastjson.FastJsonHelper;
import pro.fessional.wings.tiny.mail.database.autogen.tables.WinMailSenderTable;
import pro.fessional.wings.tiny.mail.database.autogen.tables.daos.WinMailSenderDao;
Expand Down Expand Up @@ -58,8 +58,8 @@
import java.util.concurrent.atomic.AtomicInteger;

import static org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.DEFAULT_TASK_SCHEDULER_BEAN_NAME;
import static pro.fessional.wings.silencer.spring.help.CommonPropHelper.arrayOrNull;
import static pro.fessional.wings.silencer.spring.help.CommonPropHelper.nonValue;
import static pro.fessional.wings.silencer.support.PropHelper.commaArray;
import static pro.fessional.wings.silencer.support.PropHelper.nonValue;

/**
* @author trydofor
Expand Down Expand Up @@ -280,9 +280,9 @@ private TinyMailMessage makeMailMessage(@NotNull TinyMailConfig config, @NotNull

if (msg == null) {
message.setFrom(po.getMailFrom());
message.setTo(arrayOrNull(po.getMailTo(), true));
message.setCc(arrayOrNull(po.getMailCc(), true));
message.setBcc(arrayOrNull(po.getMailBcc(), true));
message.setTo(commaArray(po.getMailTo()));
message.setCc(commaArray(po.getMailCc()));
message.setBcc(commaArray(po.getMailBcc()));
message.setReply(EmptySugar.emptyToNull(po.getMailReply()));
message.setHtml(po.getMailHtml());
message.setSubject(po.getMailSubj());
Expand Down Expand Up @@ -716,7 +716,7 @@ private String stringResource(Map<String, Resource> file) {

Map<String, String> nameUrl = new LinkedHashMap<>();
for (Map.Entry<String, Resource> en : file.entrySet()) {
nameUrl.put(en.getKey(), CommonPropHelper.stringResource(en.getValue()));
nameUrl.put(en.getKey(), PropHelper.stringResource(en.getValue()));
}
return toString(nameUrl);
}
Expand All @@ -728,7 +728,7 @@ private Map<String, Resource> resourceString(String jsonMap) {
final Map<String, Resource> rst = new LinkedHashMap<>();
Map<String, String> map = FastJsonHelper.object(jsonMap, Map.class, String.class, String.class);
for (Map.Entry<String, String> en : map.entrySet()) {
rst.put(en.getKey(), CommonPropHelper.resourceString(en.getValue(), resourceLoader));
rst.put(en.getKey(), PropHelper.resourceString(en.getValue(), resourceLoader));
}
return rst;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import pro.fessional.wings.silencer.spring.help.CommonPropHelper;
import pro.fessional.wings.silencer.support.PropHelper;

import java.io.IOException;
import java.util.Iterator;
Expand All @@ -36,7 +36,7 @@ public void jsonResourceSerializer() throws IOException {

Map<String, String> urls = new LinkedHashMap<>();
for (Map.Entry<String, Resource> en : res1.entrySet()) {
urls.put(en.getKey(), CommonPropHelper.stringResource(en.getValue()));
urls.put(en.getKey(), PropHelper.stringResource(en.getValue()));
}
final String json = objectMapper.writeValueAsString(urls);
Map<String, Resource> res2 = new LinkedHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;

import static pro.fessional.wings.silencer.spring.help.CommonPropHelper.arrayOrNull;
import static pro.fessional.wings.silencer.support.PropHelper.commaArray;
import static pro.fessional.wings.tiny.task.schedule.exec.NoticeExec.WhenDone;
import static pro.fessional.wings.tiny.task.schedule.exec.NoticeExec.WhenExec;
import static pro.fessional.wings.tiny.task.schedule.exec.NoticeExec.WhenFail;
Expand Down Expand Up @@ -316,7 +316,7 @@ private boolean notEnable(Boolean b, long id, String key) {
private boolean notApps(String apps, long id, String key) {
if (StringUtils.isEmpty(apps)) return false;

for (String s : arrayOrNull(apps, true)) {
for (String s : commaArray(apps)) {
if (s.trim().equals(appName)) return false;
}
log.info("skip tiny-task for not apps={}, cur={}, id={}, prop={}", apps, appName, id, key);
Expand All @@ -343,7 +343,7 @@ private boolean notRuns(String runs, long id, String key) {
private Set<String> noticeWhen(String nw) {
if (nw == null || nw.isEmpty()) return Collections.emptySet();
Set<String> rs = new HashSet<>();
for (String s : arrayOrNull(nw, true)) {
for (String s : commaArray(nw)) {
rs.add(s.trim().toLowerCase());
}
return rs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.Map;
import java.util.Set;

import static pro.fessional.wings.silencer.spring.help.CommonPropHelper.DisabledValue;
import static pro.fessional.wings.silencer.support.PropHelper.DisabledValue;

/**
* CUD listener settings for jooq.
Expand Down Expand Up @@ -56,7 +56,7 @@ public class FacelessJooqCudProp {
* Listening tables and their fields. `empty` means no fields are recorded, `-` means this table is ignored.
* CUD listens to tables and fields, both tables and fields are case-sensitive.
*
* @see pro.fessional.wings.silencer.spring.help.CommonPropHelper#DisabledValue
* @see pro.fessional.wings.silencer.support.PropHelper#DisabledValue
* @see #Key$table
*/
private Map<String, Set<String>> table = Collections.emptyMap();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.info.GitProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import pro.fessional.wings.silencer.enhance.ThisLazyPostProcessor;
import pro.fessional.wings.silencer.modulate.RuntimeMode;
import pro.fessional.wings.silencer.runner.ApplicationInspectRunner;
import pro.fessional.wings.silencer.runner.ApplicationReadyEventRunner;
import pro.fessional.wings.silencer.spring.WingsOrdered;
import pro.fessional.wings.silencer.spring.boot.ConditionalWingsEnabled;
import pro.fessional.wings.silencer.spring.help.ApplicationContextHelper;
import pro.fessional.wings.silencer.spring.help.VersionInfoHelper;
import pro.fessional.wings.silencer.support.InspectHelper;
import pro.fessional.wings.silencer.spring.prop.SilencerAutoLogProp;
import pro.fessional.wings.silencer.spring.prop.SilencerEnabledProp;
import pro.fessional.wings.silencer.spring.prop.SilencerRuntimeProp;
Expand Down Expand Up @@ -84,17 +86,17 @@ public ApplicationInspectRunner infoGitJvmRunner(ApplicationContext context) {
return new ApplicationInspectRunner(WingsOrdered.Lv1Config, args -> {


log.info("jvm-name=" + VersionInfoHelper.jvmName());
log.info("jvm-version=" + VersionInfoHelper.jvmVersion());
log.info("jvm-vendor=" + VersionInfoHelper.jvmVendor());
log.info("jvm-name=" + InspectHelper.jvmName());
log.info("jvm-version=" + InspectHelper.jvmVersion());
log.info("jvm-vendor=" + InspectHelper.jvmVendor());

var git = context.getBean(GitProperties.class);
log.info("git-branch=" + VersionInfoHelper.branch(git));
log.info("git-id=" + VersionInfoHelper.commitId(git));
log.info("git-time=" + VersionInfoHelper.commitDateTime(git));
log.info("git-build=" + VersionInfoHelper.buildDateTime(git));
log.info("git-version=" + VersionInfoHelper.buildVersion(git));
log.info("git-message=" + VersionInfoHelper.commitMessage(git));
log.info("git-branch=" + InspectHelper.branch(git));
log.info("git-id=" + InspectHelper.commitId(git));
log.info("git-time=" + InspectHelper.commitDateTime(git));
log.info("git-build=" + InspectHelper.buildDateTime(git));
log.info("git-version=" + InspectHelper.buildVersion(git));
log.info("git-message=" + InspectHelper.commitMessage(git));
});
}

Expand Down Expand Up @@ -152,6 +154,13 @@ else if (exists.contains(name)) {
});
}

@Bean
@ConditionalWingsEnabled
public static BeanPostProcessor thisLazyAwarePostProcessor() {
log.info("Silencer spring-auto thisLazyAwarePostProcessor");
return new ThisLazyPostProcessor();
}

@Bean
@ConditionalWingsEnabled
public RuntimeMode runtimeMode(SilencerRuntimeProp prop) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import pro.fessional.wings.silencer.app.conf.TestMergingProp;

/**
* @author trydofor
* @since 2019-07-20
*/
@SpringBootApplication
@EnableConfigurationProperties(TestMergingProp.class)
public class TestSilencerCurseApplication {

public interface InnerFace {
Expand Down

This file was deleted.

Loading

0 comments on commit 1147482

Please sign in to comment.