/** unregister all cluster valve to host or engine */
 protected void unregisterClusterValve() {
   for (Iterator<Valve> iter = valves.iterator(); iter.hasNext(); ) {
     ClusterValve valve = (ClusterValve) iter.next();
     if (log.isDebugEnabled())
       log.debug(
           "Invoking removeValve on "
               + getContainer()
               + " with class="
               + valve.getClass().getName());
     if (valve != null) {
       container.getPipeline().removeValve(valve);
       valve.setCluster(null);
     }
   }
 }
Exemple #2
0
  // -------------------- JMX and Registration  --------------------
  @Override
  public String getObjectNameKeyProperties() {
    StringBuilder name = new StringBuilder("type=Valve");

    Container container = getContainer();

    name.append(MBeanUtils.getContainerKeyProperties(container));

    int seq = 0;

    // Pipeline may not be present in unit testing
    Pipeline p = container.getPipeline();
    if (p != null) {
      for (Valve valve : p.getValves()) {
        // Skip null valves
        if (valve == null) {
          continue;
        }
        // Only compare valves in pipeline until we find this valve
        if (valve == this) {
          break;
        }
        if (valve.getClass() == this.getClass()) {
          // Duplicate valve earlier in pipeline
          // increment sequence number
          seq++;
        }
      }
    }

    if (seq > 0) {
      name.append(",seq=");
      name.append(seq);
    }

    String className = this.getClass().getName();
    int period = className.lastIndexOf('.');
    if (period >= 0) {
      className = className.substring(period + 1);
    }
    name.append(",name=");
    name.append(className);

    return name.toString();
  }