ServerStatisticsHandler.java
2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.scene7.is.provider.CacheSpec
* com.scene7.is.sleng.ImageAccessException
* com.scene7.is.sleng.ImageServer
* com.scene7.is.util.Statistics
* com.scene7.is.util.StatisticsSnapshot
* com.scene7.is.util.diskcache.Cache
*/
package com.scene7.is.ps.provider;
import com.scene7.is.provider.CacheSpec;
import com.scene7.is.ps.provider.ModifierSet;
import com.scene7.is.ps.provider.PropertiesHandler;
import com.scene7.is.ps.provider.Request;
import com.scene7.is.ps.provider.defs.ModifierEnum;
import com.scene7.is.sleng.ImageAccessException;
import com.scene7.is.sleng.ImageServer;
import com.scene7.is.util.Statistics;
import com.scene7.is.util.StatisticsSnapshot;
import com.scene7.is.util.diskcache.Cache;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
public class ServerStatisticsHandler
extends PropertiesHandler {
private final ImageServer server;
private final Statistics stats;
private final Cache cache;
ServerStatisticsHandler(ImageServer server, Cache cache, Statistics stats) {
this.server = server;
this.stats = stats;
this.cache = cache;
this.useClientCache(false);
}
@Override
protected Map<String, Object> getProperties(Request request) throws ImageAccessException {
request.getGlobalAttributes().set(ModifierEnum.CACHE, CacheSpec.OFF);
HashMap<String, Object> props = new HashMap<String, Object>();
StatisticsSnapshot snapshot = this.stats.getSnapshot(false);
props.putAll(snapshot.toProperties("server"));
props.putAll(this.cache.getStatisticsProps());
Properties src = this.server.getServerProps();
props.put("imageServer.version", String.valueOf(src.getProperty("version")));
props.put("imageServer.buildDate", String.valueOf(src.getProperty("buildDate")));
props.put("imageServer.startTime", String.valueOf(src.getProperty("startTime")));
return props;
}
}