/* * Copyright 2013 Brian Rosenberger (Brutex Network) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package net.brutex.xservices.util.cache; import java.io.File; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.concurrent.ExecutorService; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import lombok.extern.slf4j.Slf4j; import net.brutex.xservices.types.scm.ObjectFactory; /** * @author Brian Rosenberger, bru(at)brutex.de * */ @Slf4j public class CacheServlet extends HttpServlet { List configfiles = new ArrayList(); int cacheinterval; private final ObjectFactory FACTORY = new ObjectFactory(); public void init() throws ServletException { super.init(); ExecutorService executor = (ExecutorService)getServletContext() .getAttribute("CACHE_EXECUTOR"); Enumeration attributes = getServletContext() .getInitParameterNames(); while (attributes.hasMoreElements()) { String name = (String)attributes.nextElement(); if (name.startsWith("cvs-config-")) { String configfile = getServletContext() .getInitParameter(name); log.info("CVS configuration file: {}", configfile); this.configfiles.add(new File(configfile)); } } this.cacheinterval = 15; try { this.cacheinterval = Integer.parseInt(getServletContext() .getInitParameter("cvs-cache-interval")); } catch (NumberFormatException e) { log.debug("Could not read parameter 'cvs-cache-interval' from web.xml. Using default value '{}' minutes", this.cacheinterval ); } log.info("CacheServlet set to '{}' minutes interval.", this.cacheinterval); } }