1 package org.kohsuke.stapler; 2 3 import javax.servlet.ServletException ; 4 import java.io.IOException ; 5 import java.lang.reflect.InvocationTargetException ; 6 7 10 abstract class NameBasedDispatcher implements Dispatcher { 11 private final String name; 12 private final int argCount; 13 14 protected NameBasedDispatcher(String name, int argCount) { 15 this.name = name; 16 this.argCount = argCount; 17 } 18 19 protected NameBasedDispatcher(String name) { 20 this(name,0); 21 } 22 23 public final boolean dispatch(RequestImpl req, ResponseImpl rsp, Object node) 24 throws IOException , ServletException , IllegalAccessException , InvocationTargetException { 25 if(!req.tokens.hasMore() || !req.tokens.peek().equals(name)) 26 return false; 27 if(req.tokens.countRemainingTokens()<=argCount) 28 return false; 29 req.tokens.next(); 30 doDispatch(req,rsp,node); 31 return true; 32 } 33 34 protected abstract void doDispatch(RequestImpl req, ResponseImpl rsp, Object node) 35 throws IOException , ServletException , IllegalAccessException , InvocationTargetException ; 36 } 37 | Popular Tags |