Skip to content

Commit

Permalink
Merge pull request #39 from tomsun28/feature-annotation
Browse files Browse the repository at this point in the history
bugfix-@RequiresRoles can not support one more role#38
  • Loading branch information
tomsun28 authored Dec 7, 2020
2 parents 3bed46f + 6c6d235 commit 3030a64
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ private synchronized void init() {
if (scanPackages == null) {
scanPackages = Collections.singletonList(" ");
}
scanClasses = ClassScanner.scanPackages(scanPackages);
isInit = true;
scanClasses = ClassScanner.scanPackages(scanPackages);
logger.info("sureness: annotationLoader success init, load {} classes total.", scanClasses.size());
}

Expand All @@ -57,21 +57,20 @@ public Set<String> providePathData() {
}
if (method.isAnnotationPresent(RequiresRoles.class)) {
RequiresRoles requiresRoles = method.getDeclaredAnnotation(RequiresRoles.class);

StringBuilder builder = new StringBuilder();
for (int i = 0; i < requiresRoles.roles().length; i++) {
if (i < requiresRoles.roles().length) {
if (i < requiresRoles.roles().length - 1) {
builder.append(requiresRoles.roles()[i]).append(",");
} else {
builder.append(requiresRoles.roles()[i]);
}
String path = requiresRoles.mapping().toLowerCase()
+ "===" + requiresRoles.method().toLowerCase()
+ "===[" + builder.toString() + "]";
resource.add(path);
if (logger.isDebugEnabled()) {
logger.debug("sureness: annotationLoader load path {}.", path);
}
}
String path = requiresRoles.mapping().toLowerCase()
+ "===" + requiresRoles.method().toLowerCase()
+ "===[" + builder.toString() + "]";
resource.add(path);
if (logger.isDebugEnabled()) {
logger.debug("sureness: annotationLoader load path {}.", path);
}
}
}
Expand Down

0 comments on commit 3030a64

Please sign in to comment.