org.apache.tomcat.util.hooks
Class Hooks

java.lang.Object
  extended byorg.apache.tomcat.util.hooks.Hooks

public class Hooks
extends java.lang.Object

Hooks support. Hooks implement a chain-of-command pattern, and are commonly used in most web servers as a mechanism of extensibility. This class doesn't deal with hook invocation - the program is expected to use interfaces or base classes with the hooks beeing methods that are invoked. Reflection-based invocation is very expensive and shouldn't be used. The Hooks class will provide support for registering and maintaining a list of modules implementing each hook. The module can be added automatically to the right lists by using introspection ( if the module implements a certain method, it'll be added to the chain for the hook with the same name ). It is also possible for a module to explicitely register hooks. This class is modeled after Apache2.0 hooks - most web servers are using this pattern, but so far A2.0 has the most flexible and powerfull implementation


Nested Class Summary
static interface Hooks.HookFinder
          Interface that decouples the Hooks from the introspection code.
 
Field Summary
static int INITIAL_HOOKS
           
 
Constructor Summary
Hooks()
           
 
Method Summary
 void addModule(java.lang.Object bi)
          Add the module to all the hook chains it's implements The hook name should match a method defined in the module ( not inherited - explicitely defined there )
 void addModule(java.lang.String type, java.lang.Object bi)
           
 int getHookId(java.lang.String hookName)
           
 java.lang.String getHookName(int id)
           
 java.util.Vector getHooksVector()
           
 java.util.Vector getHooksVector(int type)
          Allow direct access to hooks.
 java.lang.Object[] getModules()
          Get all interceptors
 java.lang.Object[] getModules(int type)
           
 int registerHook(java.lang.String name)
           
 void registerHook(java.lang.String name, int id)
           
 void removeModule(java.lang.Object bi)
           
 void resetCache()
           
static void setHookFinder(Hooks.HookFinder hf)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_HOOKS

public static final int INITIAL_HOOKS
See Also:
Constant Field Values
Constructor Detail

Hooks

public Hooks()
Method Detail

getHooksVector

public java.util.Vector getHooksVector(int type)
Allow direct access to hooks. You must call resetCache() if you change the hooks


getHooksVector

public java.util.Vector getHooksVector()

resetCache

public void resetCache()

registerHook

public int registerHook(java.lang.String name)

registerHook

public void registerHook(java.lang.String name,
                         int id)

getHookName

public java.lang.String getHookName(int id)

getHookId

public int getHookId(java.lang.String hookName)

addModule

public void addModule(java.lang.Object bi)
Add the module to all the hook chains it's implements The hook name should match a method defined in the module ( not inherited - explicitely defined there )


addModule

public void addModule(java.lang.String type,
                      java.lang.Object bi)

removeModule

public void removeModule(java.lang.Object bi)

getModules

public java.lang.Object[] getModules(int type)

getModules

public java.lang.Object[] getModules()
Get all interceptors


setHookFinder

public static void setHookFinder(Hooks.HookFinder hf)


Copyright ? 2001 Apache Software Foundation. All Rights Reserved.