Skip to content

Commit

Permalink
optimize: @servicemark 注解,移除value属性,code属性必填。
Browse files Browse the repository at this point in the history
  • Loading branch information
wangliang181230 committed Feb 14, 2025
1 parent 2f292d4 commit fb5c2c8
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static <S> ServiceInfo<S> of(S service) {
}

ServiceMark mark = service.getClass().getAnnotation(ServiceMark.class);
String code = StringUtils.isNotBlank(mark.code()) ? mark.code() : mark.value();
String code = mark.code();
if (StringUtils.isBlank(code)) {
throw new IllegalArgumentException("service的@ServiceMark.code或@ServiceMark.value不能为空");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,12 @@
public @interface ServiceMark {

/**
* 服务代码(同 code 属性,设置一个即可,两个都设置时,优先读取 code 属性)
* 服务代码
* 注:大小写不敏感
*
* @return code 返回服务代码
*/
String value() default "";

/**
* 服务代码(同 value 属性,设置一个即可,两个都设置时,优先读取 code 属性)
* 注:大小写不敏感
*
* @return code 返回服务代码
*/
String code() default "";
String code();

/**
* 是否默认服务
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package icu.easyj.core.factory;

@ServiceMark(value = "A", isDefault = true)
@ServiceMark(code = "A", isDefault = true)
class TestServiceImplA implements ITestService {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package icu.easyj.core.factory;

@ServiceMark(value = "B", order = 1)
@ServiceMark(code = "B", order = 1)
class TestServiceImplB1 implements ITestService {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package icu.easyj.core.factory;

@ServiceMark(value = "B", order = 2)
@ServiceMark(code = "B", order = 2)
class TestServiceImplB2 implements ITestService {
}

0 comments on commit fb5c2c8

Please sign in to comment.