1 16 package scriptella.core; 17 18 import scriptella.configuration.Location; 19 import scriptella.execution.ExecutionStatisticsBuilder; 20 21 22 28 public class StatisticInterceptor extends ElementInterceptor { 29 private Location location; 30 31 public StatisticInterceptor(ExecutableElement next, Location location) { 32 super(next); 33 this.location = location; 34 } 35 36 public void execute(final DynamicContext ctx) { 37 boolean ok = false; 38 final ExecutionStatisticsBuilder statisticsBuilder = ctx.getGlobalContext().getStatisticsBuilder(); 39 try { 40 statisticsBuilder.elementStarted(location, ctx.getConnection()); 41 executeNext(ctx); 42 ok = true; 43 } finally { 44 if (ok) { 45 statisticsBuilder.elementExecuted(); 46 } else { 47 statisticsBuilder.elementFailed(); 48 } 49 } 50 51 } 52 53 public static ExecutableElement prepare( 54 final ExecutableElement next, final Location location) { 55 return new StatisticInterceptor(next, location); 56 } 57 58 59 } 60 | Popular Tags |