[강운덕] [LUCYSUS-1744] interceptor load 코드 수정.

git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@533 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
Woonduk Kang
2012-08-24 09:40:46 +00:00
parent 01c0bc2e62
commit df7ee7c408
37 changed files with 396 additions and 164 deletions
@@ -1,18 +1,25 @@
package com.profiler.interceptor;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;
public class InterceptorRegistry {
private static final ConcurrentMap<Integer, Interceptor> INTERCEPTOR_MAP = new ConcurrentHashMap<Integer, Interceptor>(256);
private static final AtomicInteger ID = new AtomicInteger(0);
public static void addInterceptor(Integer key, Interceptor interceptor) {
INTERCEPTOR_MAP.put(key, interceptor);
private static int MAX = 1024;
private static final Interceptor[] INDEX = new Interceptor[MAX];
public static int addInterceptor(Interceptor interceptor) {
int id = ID.getAndIncrement();
if (id > MAX) {
throw new IllegalArgumentException("id" + id);
}
INDEX[id] = interceptor;
return id;
}
public static Interceptor getInterceptor(int key) {
return INTERCEPTOR_MAP.get(key);
return INDEX[key];
}
}