package org.apache.flume.interceptor;

import java.util.LinkedList;
import java.util.List;

import org.apache.flume.Context;
import org.apache.flume.Event;
import org.apache.flume.interceptor.service.FlumeCacheService;
import org.apache.flume.interceptor.service.ICacheService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/** *
 * Implements a cacheable interceptor
 *
 * @see <a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/html/cache.html">Spring Cache docs</a>
 *
 */

public class CacheableInterceptor implements Interceptor {
    private ApplicationContext context;
    private ICacheService<Event> service;

	public CacheableInterceptor() {
        // Get Spring context
        this.context = new ClassPathXmlApplicationContext("beans.xml");
	}

	@Override
	public void initialize() {
        // Get cache service instance
        service = context.getBean( ICacheService.class );
    }

	@Override
	public Event intercept(Event event) {
        // Edit the FlumeCacheService.intercept method to implement
        // the transformation you want to cache.
        return service.intercept(event);
	}

	@Override
    public List<Event> intercept(List<Event> events) {
        List<Event> intercepted = new LinkedList<Event>();
        for (Event e : events) {
            intercepted.add(intercept(e));
        }
        return intercepted;
	}

    ApplicationContext getContext() {
        return context;
    }

    ICacheService<Event> getService() {
        return service;
    }

    @Override
	public void close() {
	}

	public static class Builder implements Interceptor.Builder {
		public Interceptor build() {
            return new CacheableInterceptor();
		}

		@Override
		public void configure(Context context) {
		}
	}
}
@@ -405,18 +405,16 @@
 xt;%0A%0A/**
- *
 %0A * Impl
@@ -572,19 +572,16 @@
 ocs%3C/a%3E%0A
- *%0A
  */%0A%0Apub
@@ -719,17 +719,20 @@
 rvice;%0A%0A
-%09
+    
 public C
@@ -857,21 +857,27 @@
 .xml%22);%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    
 @Overrid
@@ -870,33 +870,36 @@
 %0A%0A    @Override%0A
-%09
+    
 public void init
@@ -981,17 +981,16 @@
 getBean(
- 
 ICacheSe
@@ -1000,17 +1000,16 @@
 ce.class
- 
 );%0A    %7D
@@ -1010,17 +1010,20 @@
 %0A    %7D%0A%0A
-%09
+    
 @Overrid
@@ -1020,25 +1020,28 @@
   @Override%0A
-%09
+    
 public Event
@@ -1224,21 +1224,27 @@
 event);%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    
 @Overrid
@@ -1473,17 +1473,20 @@
 cepted;%0A
-%09
+    
 %7D%0A%0A    A
@@ -1634,17 +1634,20 @@
 verride%0A
-%09
+    
 public v
@@ -1660,21 +1660,27 @@
 ose() %7B%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    
 public s
@@ -1732,18 +1732,24 @@
 ilder %7B%0A
-%09%09
+        
 public I
@@ -1820,15 +1820,27 @@
 ();%0A
-%09%09%7D%0A%0A%09%09
+        %7D%0A%0A        
 @Ove
@@ -1845,18 +1845,24 @@
 verride%0A
-%09%09
+        
 public v
@@ -1898,12 +1898,21 @@
 ) %7B%0A
-%09%09%7D%0A%09
+        %7D%0A    
 %7D%0A%7D

Reformat code