Exemplo n.º 1
0
  /**
   * Add a new Valve to the end of the pipeline associated with this Container. Prior to adding the
   * Valve, the Valve's <code>setContainer()</code> method will be called, if it implements <code>
   * Contained</code>, with the owning Container as an argument. The method may throw an <code>
   * IllegalArgumentException</code> if this Valve chooses not to be associated with this Container,
   * or <code>IllegalStateException</code> if it is already associated with a different Container.
   *
   * @param valve Valve to be added
   * @exception IllegalArgumentException if this Container refused to accept the specified Valve
   * @exception IllegalArgumentException if the specified Valve refuses to be associated with this
   *     Container
   * @exception IllegalStateException if the specified Valve is already associated with a different
   *     Container
   */
  public void addValve(GlassFishValve valve) {

    if (firstTcValve != null) {
      // Wrap GlassFish-style valve inside Tomcat-style valve
      addValve(new TomcatValveAdapter(valve));
      return;
    }

    // Validate that we can add this Valve
    if (valve instanceof Contained) ((Contained) valve).setContainer(this.container);

    // Start the new component if necessary
    if (started) {
      if (valve instanceof Lifecycle) {
        try {
          ((Lifecycle) valve).start();
        } catch (LifecycleException e) {
          log.log(Level.SEVERE, ADD_VALVE_EXCEPTION, e);
        }
      }
      /**
       * CR 6411114 (MBean registration moved to ValveBase.start()) // Register the newly added
       * valve registerValve(valve);
       */
    }

    // Add this Valve to the set associated with this Pipeline
    GlassFishValve results[] = new GlassFishValve[valves.length + 1];
    System.arraycopy(valves, 0, results, 0, valves.length);
    results[valves.length] = valve;
    valves = results;
  }
Exemplo n.º 2
0
 /**
  * Return the set of Valves in the pipeline associated with this Container, including the basic
  * Valve (if any). If there are no such Valves, a zero-length array is returned.
  */
 public GlassFishValve[] getValves() {
   if (basic == null) {
     return (valves);
   }
   GlassFishValve results[] = new GlassFishValve[valves.length + 1];
   System.arraycopy(valves, 0, results, 0, valves.length);
   results[valves.length] = basic;
   return (results);
 }