Subversion Repositories XServices

Rev

Rev 185 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
102 brianR 1
/*
2
 *   Copyright 2013 Brian Rosenberger (Brutex Network)
3
 *
4
 *   Licensed under the Apache License, Version 2.0 (the "License");
5
 *   you may not use this file except in compliance with the License.
6
 *   You may obtain a copy of the License at
7
 *
8
 *       http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *   Unless required by applicable law or agreed to in writing, software
11
 *   distributed under the License is distributed on an "AS IS" BASIS,
12
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *   See the License for the specific language governing permissions and
14
 *   limitations under the License.
15
 */
16
 
17
package net.brutex.xservices.util.cache;
18
 
19
import java.io.File;
20
import java.util.ArrayList;
21
import java.util.Enumeration;
22
import java.util.List;
23
import java.util.concurrent.ExecutorService;
24
import javax.servlet.ServletException;
25
import javax.servlet.http.HttpServlet;
26
import net.brutex.xservices.types.scm.ObjectFactory;
185 brianR 27
import org.apache.logging.log4j.LogManager;
28
import org.apache.logging.log4j.Logger;
102 brianR 29
 
30
/**
31
 * @author Brian Rosenberger, bru(at)brutex.de
32
 *
33
 */
34
 
35
 
36
public class CacheServlet extends HttpServlet
37
{
185 brianR 38
	private static final Logger logger = LogManager.getLogger();
39
  List<File> configfiles = new ArrayList<File>();
102 brianR 40
  int cacheinterval;
41
  private final ObjectFactory FACTORY = new ObjectFactory();
42
 
43
  public void init()
44
    throws ServletException
45
  {
46
    super.init();
47
    ExecutorService executor = (ExecutorService)getServletContext()
48
      .getAttribute("CACHE_EXECUTOR");
49
 
50
    Enumeration attributes = getServletContext()
51
      .getInitParameterNames();
52
    while (attributes.hasMoreElements()) {
53
      String name = (String)attributes.nextElement();
54
      if (name.startsWith("cvs-config-")) {
55
        String configfile = getServletContext()
56
          .getInitParameter(name);
57
        this.logger.info("CVS configuration file: " + configfile);
58
        this.configfiles.add(new File(configfile));
59
      }
60
    }
61
    this.cacheinterval = 15;
62
    try {
63
      this.cacheinterval = Integer.parseInt(getServletContext()
64
        .getInitParameter("cvs-cache-interval"));
65
    } catch (NumberFormatException e) {
66
      this.logger.debug("Could not read parameter 'cvs-cache-interval' from web.xml. Using default value '" + this.cacheinterval + "' minutes");
67
    }
68
    this.logger.info("CacheServlet set to " + this.cacheinterval + " minutes interval.");
69
  }
70
}