/**
   * Construct a new ApplicationFilterConfig for the specified filter definition.
   *
   * @param context The context with which we are associated
   * @param filterDef Filter definition for which a FilterConfig is to be constructed
   * @exception ClassCastException if the specified class does not implement the <code>
   *     javax.servlet.Filter</code> interface
   * @exception ClassNotFoundException if the filter class cannot be found
   * @exception IllegalAccessException if the filter class cannot be publicly instantiated
   * @exception InstantiationException if an exception occurs while instantiating the filter object
   * @exception ServletException if thrown by the filter's init() method
   * @throws NamingException
   * @throws InvocationTargetException
   */
  ApplicationFilterConfig(Context context, FilterDef filterDef)
      throws ClassCastException, ClassNotFoundException, IllegalAccessException,
          InstantiationException, ServletException, InvocationTargetException, NamingException {

    super();

    this.context = context;
    this.filterDef = filterDef;
    // Allocate a new filter instance if necessary
    if (filterDef.getFilter() == null) {
      getFilter();
    } else {
      this.filter = filterDef.getFilter();
      getInstanceManager().newInstance(filter);
      initFilter();
    }
  }