TopologyHelper.java
2.45 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
66
67
68
69
70
71
72
73
74
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.felix.scr.annotations.Activate
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
* org.apache.sling.settings.SlingSettingsService
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemfd.watchfolder.util;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.settings.SlingSettingsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(metatype=0, immediate=1)
@Service(value={TopologyHelper.class})
public class TopologyHelper {
private static final Logger logger = LoggerFactory.getLogger(TopologyHelper.class);
@Reference
private SlingSettingsService slingSettingsService;
private String localInstanceId;
private Set<String> localInstanceRunModes;
@Activate
public void activate() {
this.localInstanceId = this.slingSettingsService.getSlingId();
this.localInstanceRunModes = this.slingSettingsService.getRunModes();
logger.info("Initialized local instance ID: " + this.localInstanceId + ", run modes: " + this.localInstanceRunModes);
}
public String getLocalInstanceId() {
return this.localInstanceId;
}
public boolean isRunModeActiveLocally(String runModes) {
if (runModes == null || runModes.trim().length() == 0) {
return true;
}
List<String> runModesToCheck = Arrays.asList(runModes.split(","));
boolean result = false;
for (String m : runModesToCheck) {
if ((m = m.trim()).equals("*")) {
result = true;
break;
}
if (!this.localInstanceRunModes.contains(m)) continue;
result = true;
break;
}
return result;
}
protected void bindSlingSettingsService(SlingSettingsService slingSettingsService) {
this.slingSettingsService = slingSettingsService;
}
protected void unbindSlingSettingsService(SlingSettingsService slingSettingsService) {
if (this.slingSettingsService == slingSettingsService) {
this.slingSettingsService = null;
}
}
}