Blame | Last modification | View Log | Download | RSS feed
/*
* 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.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import net.brutex.xservices.types.scm.ObjectFactory;
import org.apache.log4j.Logger;
/**
* @author Brian Rosenberger, bru(at)brutex.de
*
*/
public class CacheServlet extends HttpServlet
{
private final Logger logger = Logger.getLogger(CacheServlet.class);
List<File> 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);
this.logger.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) {
this.logger.debug("Could not read parameter 'cvs-cache-interval' from web.xml. Using default value '" + this.cacheinterval + "' minutes");
}
this.logger.info("CacheServlet set to " + this.cacheinterval + " minutes interval.");
}
}