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      public SynchronizedReportListener(ReportListener listener) {
16  	this.wrapped = listener;
17      }
18      
19      public synchronized void ruleViolationAdded(RuleViolation ruleViolation) {
20  	wrapped.ruleViolationAdded(ruleViolation);
21      }
22  
23      public synchronized void metricAdded(Metric metric) {
24  	wrapped.metricAdded(metric);
25      }
26  
27  }