View Javadoc
1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd;
5   
6   import net.sourceforge.pmd.stat.Metric;
7   
8   /**
9    * Wraps a report listener in order to synchronize calls to it.
10   */
11  public final class SynchronizedReportListener implements ReportListener {
12  
13      private final ReportListener wrapped;
14  
15      /**
16       * Creates a new {@link SynchronizedReportListener} by wrapping the given
17       * report listener.
18       * 
19       * @param listener the listener to be synchronized
20       */
21      public SynchronizedReportListener(ReportListener listener) {
22          this.wrapped = listener;
23      }
24  
25      /**
26       * {@inheritDoc}
27       */
28      public synchronized void ruleViolationAdded(RuleViolation ruleViolation) {
29          wrapped.ruleViolationAdded(ruleViolation);
30      }
31  
32      /**
33       * {@inheritDoc}
34       */
35      public synchronized void metricAdded(Metric metric) {
36          wrapped.metricAdded(metric);
37      }
38  
39  }