mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-17 16:56:15 +10:00
[유치수] [NOBTS] formatting, modifying, remove unnecessary codes.
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@562 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -1,53 +1,50 @@
|
||||
package com.profiler.interceptor;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class InterceptorRegistry {
|
||||
|
||||
private final static int DEFAULT_MAX = 1024;
|
||||
private final int max;
|
||||
private final static int DEFAULT_MAX = 1024;
|
||||
private final int max;
|
||||
|
||||
private final AtomicInteger id = new AtomicInteger(0);
|
||||
private final Interceptor[] index;
|
||||
// private final ConcurrentMap<String, List<Integer>> nameToIndex = new ConcurrentHashMap<String, List<Integer>>();
|
||||
private final AtomicInteger id = new AtomicInteger(0);
|
||||
private final Interceptor[] index;
|
||||
// private final ConcurrentMap<String, List<Integer>> nameToIndex = new
|
||||
// ConcurrentHashMap<String, List<Integer>>();
|
||||
|
||||
public static final InterceptorRegistry REGISTRY = new InterceptorRegistry();
|
||||
public static final InterceptorRegistry REGISTRY = new InterceptorRegistry();
|
||||
|
||||
InterceptorRegistry() {
|
||||
this(DEFAULT_MAX);
|
||||
}
|
||||
InterceptorRegistry() {
|
||||
this(DEFAULT_MAX);
|
||||
}
|
||||
|
||||
InterceptorRegistry(int max) {
|
||||
this.max = max;
|
||||
this.index = new Interceptor[max];
|
||||
}
|
||||
InterceptorRegistry(int max) {
|
||||
this.max = max;
|
||||
this.index = new Interceptor[max];
|
||||
}
|
||||
|
||||
int addInterceptor0(Interceptor interceptor) {
|
||||
if (interceptor == null) {
|
||||
return -1;
|
||||
}
|
||||
int newId = id.getAndIncrement();
|
||||
if (newId > max) {
|
||||
throw new IllegalArgumentException("id" + id);
|
||||
}
|
||||
int addInterceptor0(Interceptor interceptor) {
|
||||
if (interceptor == null) {
|
||||
return -1;
|
||||
}
|
||||
int newId = id.getAndIncrement();
|
||||
if (newId > max) {
|
||||
throw new IllegalArgumentException("id" + id);
|
||||
}
|
||||
|
||||
this.index[newId] = interceptor;
|
||||
return newId;
|
||||
}
|
||||
this.index[newId] = interceptor;
|
||||
return newId;
|
||||
}
|
||||
|
||||
Interceptor getInterceptor0(int key) {
|
||||
return index[key];
|
||||
}
|
||||
Interceptor getInterceptor0(int key) {
|
||||
return index[key];
|
||||
}
|
||||
|
||||
public static int addInterceptor(Interceptor interceptor) {
|
||||
return REGISTRY.addInterceptor0(interceptor);
|
||||
}
|
||||
public static int addInterceptor(Interceptor interceptor) {
|
||||
return REGISTRY.addInterceptor0(interceptor);
|
||||
}
|
||||
|
||||
public static Interceptor getInterceptor(int key) {
|
||||
return REGISTRY.getInterceptor0(key);
|
||||
}
|
||||
public static Interceptor getInterceptor(int key) {
|
||||
return REGISTRY.getInterceptor0(key);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user