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;
|
199 |
brianR |
26 |
|
|
|
27 |
import lombok.extern.slf4j.Slf4j;
|
102 |
brianR |
28 |
import net.brutex.xservices.types.scm.ObjectFactory;
|
|
|
29 |
|
199 |
brianR |
30 |
|
102 |
brianR |
31 |
/**
|
|
|
32 |
* @author Brian Rosenberger, bru(at)brutex.de
|
|
|
33 |
*
|
|
|
34 |
*/
|
|
|
35 |
|
199 |
brianR |
36 |
@Slf4j
|
102 |
brianR |
37 |
public class CacheServlet extends HttpServlet
|
|
|
38 |
{
|
185 |
brianR |
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);
|
199 |
brianR |
57 |
log.info("CVS configuration file: {}", configfile);
|
102 |
brianR |
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) {
|
199 |
brianR |
66 |
log.debug("Could not read parameter 'cvs-cache-interval' from web.xml. Using default value '{}' minutes", this.cacheinterval );
|
102 |
brianR |
67 |
}
|
199 |
brianR |
68 |
log.info("CacheServlet set to '{}' minutes interval.", this.cacheinterval);
|
102 |
brianR |
69 |
}
|
|
|
70 |
}
|