AccessLog.java
2.66 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
56
57
58
59
60
61
62
63
64
65
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.scene7.is.util.callbacks.Prox2
* javax.servlet.http.HttpServletRequest
* javax.servlet.http.HttpServletResponse
* org.apache.felix.scr.annotations.Activate
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Deactivate
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
* org.apache.sling.settings.SlingSettingsService
* org.osgi.service.component.ComponentContext
*/
package com.adobe.cq.dam.s7imaging.impl.ps.access_log;
import com.adobe.cq.dam.s7imaging.impl.ps.access_log.AccessLogger;
import com.scene7.is.util.callbacks.Prox2;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.settings.SlingSettingsService;
import org.osgi.service.component.ComponentContext;
@Service(value={AccessLog.class})
@Component(immediate=1)
public class AccessLog {
@Reference
private final SlingSettingsService slingSettings = null;
private final AccessLogger logger = new AccessLogger();
@Activate
protected void activate(ComponentContext ctx) {
String logPath = this.slingSettings.getSlingHomePath() + '/' + "logs";
this.logger.setDirectory(logPath);
this.logger.setPrefix("s7access-");
this.logger.setPattern("%G %a %s %{ProcessingStatus}r %{Size}r %D %{ParseTime}r %{FetchTime}r %O %{ReqType}r '%{RootId}r' %{CacheUse}r %R [%I] '%{Referer}i' %{Host}i %{X-Forwarded-For}i %{If-None-Match}i %{If-Match}i %{If-Modified-Since}i %{Digest}r %{ContentType}r %p %{Exception}r %{CacheKey}r %{PeerServer}r %{SendTime}r %{Context}r %{TransformedUrl}r %{PathBasedAccess}r %{VirtualPathAccess}r %{RequestSize}r");
this.logger.start();
}
@Deactivate
protected void deactivate(ComponentContext ctx) {
this.logger.stop();
}
public void invoke(Prox2<HttpServletRequest, HttpServletResponse, Exception> forward, HttpServletRequest req, HttpServletResponse res) throws Exception {
this.logger.invoke(forward, req, res);
}
protected void bindSlingSettings(SlingSettingsService slingSettingsService) {
this.slingSettings = slingSettingsService;
}
protected void unbindSlingSettings(SlingSettingsService slingSettingsService) {
if (this.slingSettings == slingSettingsService) {
this.slingSettings = null;
}
}
}