Java tutorial
/* Copyright (c) 2010 Ministry of the Interior and Kingdom Relations, * the Netherlands. All rights reserved. * * This file is part of the MinBZK Search Enricher indexing generator. * * Search Enricher is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Search Enricher is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Search Enricher. If not, see <http://www.gnu.org/licenses/>. */ package nl.minbzk.dwr.zoeken.enricher; import java.io.FileInputStream; import java.io.InputStreamReader; import nl.minbzk.dwr.zoeken.enricher.service.EnricherService; import nl.minbzk.dwr.zoeken.enricher.settings.EnricherSettings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; /** * Heuristic search enricher. * * @author Jasper van Veghel <j.veghel@rijksoverheid.nl> */ public class Enricher { /** * The logger. */ private static Logger logger = LoggerFactory.getLogger(Enricher.class); /** * Constants. */ private static final String APPLICATION_CONTEXT = "servicesContext.xml"; /** * Application entry-point. * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { try { ApplicationContext context = new ClassPathXmlApplicationContext(APPLICATION_CONTEXT); // Create a new enricher service EnricherService service = (EnricherService) context.getBean("enricherService"); // Retrieve the fetcher settings EnricherSettings settings = (EnricherSettings) context.getBean("settings"); if (!settings.processArguments(args)) System.exit(-1); // We assume the input encoding is the same as the output encoding InputStreamReader reader = new InputStreamReader(new FileInputStream(settings.getInputFile()), settings.getEncoding()); // Now process the given file service.processImport(reader, settings.getJobOverride(), settings.getEncoding()); } catch (Exception e) { logger.error("The given import envelopes could not be processed", e); System.exit(1); } } }