Skip to content

Commit

Permalink
🐛 Fixing a bug. #22
Browse files Browse the repository at this point in the history
  • Loading branch information
crossoverJie committed Nov 12, 2018
1 parent 936bccb commit 783d331
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ public void loadInterceptors(AppConfig appConfig) throws Exception {
return;
}else {
interceptors = new ArrayList<>(10) ;
Map<Integer, Class<?>> cicadaInterceptor = ClassScanner.getCicadaInterceptor(appConfig.getRootPackageName());
for (Map.Entry<Integer, Class<?>> classEntry : cicadaInterceptor.entrySet()) {
Class<?> interceptorClass = classEntry.getValue();
Map<Class<?>, Integer> cicadaInterceptor = ClassScanner.getCicadaInterceptor(appConfig.getRootPackageName());
for (Map.Entry<Class<?>, Integer> classEntry : cicadaInterceptor.entrySet()) {
Class<?> interceptorClass = classEntry.getKey();
CicadaInterceptor interceptor = (CicadaInterceptor) interceptorClass.newInstance();
interceptor.setOrder(classEntry.getKey());
interceptor.setOrder(classEntry.getValue());
interceptors.add(interceptor);
}
Collections.sort(interceptors,new OrderComparator());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class ClassScanner {


private static Map<String, Class<?>> actionMap = null;
private static Map<Integer, Class<?>> interceptorMap = null;
private static Map<Class<?>, Integer> interceptorMap = null;

private static Set<Class<?>> classes = null;

Expand Down Expand Up @@ -111,7 +111,7 @@ public static Map<String, Class<?>> getCicadaAction(String packageName) throws E
* @return
* @throws Exception
*/
public static Map<Integer, Class<?>> getCicadaInterceptor(String packageName) throws Exception {
public static Map<Class<?>, Integer> getCicadaInterceptor(String packageName) throws Exception {

if (interceptorMap == null) {
Set<Class<?>> clsList = getClasses(packageName);
Expand All @@ -133,7 +133,7 @@ public static Map<Integer, Class<?>> getCicadaInterceptor(String packageName) th
continue;
}
Interceptor interceptor = (Interceptor) annotation;
interceptorMap.put(interceptor.order(), cls);
interceptorMap.put(cls, interceptor.order());
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public boolean before(CicadaContext context,Param param) {
start = System.currentTimeMillis();
LOGGER.info("拦截请求");
context.text("拦截请求");
return false;
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Date: 2018/9/2 14:39
* @since JDK 1.8
*/
@Interceptor
@Interceptor(order = 1)
public class LoggerInterceptorAbstract extends CicadaInterceptor {

private static final Logger LOGGER = LoggerBuilder.getLogger(LoggerInterceptorAbstract.class) ;
Expand Down

0 comments on commit 783d331

Please sign in to comment.