Java tutorial
/** * Copyright (C) 2013 Seajas, the Netherlands. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3, as * published by the Free Software Foundation. * * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */ package com.seajas.search.profiler.task; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.seajas.search.profiler.model.archive.Archive; import com.seajas.search.profiler.service.profiler.ProfilerService; /** * Archive injection task. * * @author Jasper van Veghel <jasper@seajas.com> */ @Component public class ArchiveInjectionTask implements InjectionTask { /** * The logger. */ private static final Logger logger = LoggerFactory.getLogger(ArchiveInjectionTask.class); /** * Profiler service. */ @Autowired private ProfilerService profilerService; /** * {@inheritDoc} */ @Override public void inject(final String triggerName, final Long intervalTotal, final InjectionJobInterrupted interrupted) { // XXX: There is currently no such thing as an archive-queue based on the triggerName List<Archive> enabledArchives = profilerService.getEnabledArchives(); if (logger.isInfoEnabled()) logger.info("Starting archive injection under trigger '" + triggerName + "' (" + enabledArchives.size() + " archive" + (enabledArchives.size() != 1 ? "s" : "") + ")"); // We report on the number of feeds first, and then move on to potentially canceling the operation if (Boolean.getBoolean("profiler.indexing.disabled")) { if (logger.isInfoEnabled()) logger.info( "Indexing has been explicitly disabled using 'profiler.indexing.disabled=true'. Skipping injection."); return; } for (Archive archive : enabledArchives) { if (interrupted.isInterrupted()) { logger.warn("This job was interrupted - not continuing with archive injection"); break; } logger.warn( "TODO: Injecting archives is not yet supported within the new distributed architecture - skipping '" + archive.getName() + "'"); } logger.info("Finished archive injection for trigger '" + triggerName + "'"); } }