alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*   
 *  Copyright 1999-2004 The Apache Sofware Foundation.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.apache.tomcat.util.hooks;

import java.util.Vector;

/** 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
 */
public class Hooks {
    static org.apache.commons.logging.Log logger =
	org.apache.commons.logging.LogFactory.getLog(Hooks.class);

    public static final int INITIAL_HOOKS=24;
    int hookCount;
    String hookNames[];
    Vector hooksV[];

    Object hooks[][];

    Vector allModulesV;
    Object allModules[];

    private static final int dL=0;

    public Hooks() {
	this.hookCount=INITIAL_HOOKS; // XXX TODO: resizing
	hooksV=new Vector[hookCount];
	for( int i=0; i
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.