package chat.server.call; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; public abstract class MethodPublisher { protected Map methodMap; protected Map allMethodMap; public MethodPublisher() { methodMap = new HashMap(); allMethodMap = new HashMap(); collectMethod(); publishMethod(); } public Method getMethod(String lower) { // TODO Auto-generated method stub return null; } protected void collectMethod() { Method[] methods = this.getClass().getDeclaredMethods(); for (Method one : methods) { allMethodMap.put(one.getName().toLowerCase(), one); } } protected abstract void publishMethod(); protected void addOneMethod(String name) { addOneMethod(name, name); } protected void addOneMethod(String methodName, String key) { if (key == null || methodName == null) { return; } methodName = methodName.toLowerCase(); Method method = allMethodMap.get(methodName); if (method != null) { key = key.toLowerCase(); method.setAccessible(true); methodMap.put(key, method); } } protected Method getOneMethod(String key) { if (key == null) { return null; } key = key.toLowerCase(); Method method = methodMap.get(key); return method; } public Map getMethodMap() { return methodMap; } }