// Path: src/main/java/org/mockenize/service/FileService.java
// @Service
// public class FileService {
// 	
// 	@Autowired
// 	private MockService mockService;
// 	
// 	@Autowired
// 	private ObjectMapper mapper = new ObjectMapper();
// 
// 	private Log log = LogFactory.getLog(getClass());
// 
// 	public void loadFile(File file) {
// 		if (file != null && file.exists()) {
// 			if (file.isFile() && file.canRead()) {
// 				try (FileInputStream fileInputStream = new FileInputStream(file)) {
// 					String json = CharStreams.toString(new InputStreamReader(fileInputStream));
// 					read(json);
// 				} catch (IOException e) {
// 					log.error(e);
// 				}
// 			} else {
// 				for (File f : file.listFiles()) {
// 					loadFile(f);
// 				}
// 			}
// 		}
// 	}
// 	
// 	public Collection<MultipleMockBean> loadFile(InputStream fileInputStream) throws IOException {
// 		String json = CharStreams.toString(new InputStreamReader(fileInputStream));
// 		return read(json);
// 	}
// 	
// 	private Collection<MultipleMockBean> read(String json) throws IOException {
// 		if(json.startsWith("[")) {
// 			Collection<MultipleMockBean> multipleMockBeans = mapper.readValue(json, new TypeReference<List<MultipleMockBean>>(){});
// 			for (MultipleMockBean mockBean : multipleMockBeans) {
// 				mockService.save(mockBean);
// 			}
// 			return multipleMockBeans;
// 		} else {
// 			MultipleMockBean mockBean = mapper.readValue(json, MultipleMockBean.class);
// 			Arrays.asList(mockService.save(mockBean));
// 		}
// 		return Arrays.asList();
// 	}
// }


import java.io.File;
import org.mockenize.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
package org.mockenize.listener;



@Component
public class LoadFileListener implements ApplicationListener<ContextRefreshedEvent> {

	@Value("${default.file}")
	private File file;

	@Autowired
// Path: src/main/java/org/mockenize/service/FileService.java
// @Service
// public class FileService {
// 	
// 	@Autowired
// 	private MockService mockService;
// 	
// 	@Autowired
// 	private ObjectMapper mapper = new ObjectMapper();
// 
// 	private Log log = LogFactory.getLog(getClass());
// 
// 	public void loadFile(File file) {
// 		if (file != null && file.exists()) {
// 			if (file.isFile() && file.canRead()) {
// 				try (FileInputStream fileInputStream = new FileInputStream(file)) {
// 					String json = CharStreams.toString(new InputStreamReader(fileInputStream));
// 					read(json);
// 				} catch (IOException e) {
// 					log.error(e);
// 				}
// 			} else {
// 				for (File f : file.listFiles()) {
// 					loadFile(f);
// 				}
// 			}
// 		}
// 	}
// 	
// 	public Collection<MultipleMockBean> loadFile(InputStream fileInputStream) throws IOException {
// 		String json = CharStreams.toString(new InputStreamReader(fileInputStream));
// 		return read(json);
// 	}
// 	
// 	private Collection<MultipleMockBean> read(String json) throws IOException {
// 		if(json.startsWith("[")) {
// 			Collection<MultipleMockBean> multipleMockBeans = mapper.readValue(json, new TypeReference<List<MultipleMockBean>>(){});
// 			for (MultipleMockBean mockBean : multipleMockBeans) {
// 				mockService.save(mockBean);
// 			}
// 			return multipleMockBeans;
// 		} else {
// 			MultipleMockBean mockBean = mapper.readValue(json, MultipleMockBean.class);
// 			Arrays.asList(mockService.save(mockBean));
// 		}
// 		return Arrays.asList();
// 	}
// }


// Path: src/main/java/org/mockenize/listener/LoadFileListener.java
import java.io.File;
import org.mockenize.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

package org.mockenize.listener;



@Component
public class LoadFileListener implements ApplicationListener<ContextRefreshedEvent> {

	@Value("${default.file}")
	private File file;

	@Autowired
	private FileService loadFileService;