GuideIntegrationServiceImpl.java
3.11 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.Component
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.ReferenceCardinality
* org.apache.felix.scr.annotations.ReferencePolicy
* org.apache.felix.scr.annotations.Service
* org.apache.sling.commons.osgi.ServiceUtil
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemds.guide.service.impl;
import com.adobe.aemds.guide.service.GuideIntegrationService;
import com.adobe.aemds.guide.service.GuideIntegrationServiceProvider;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentSkipListMap;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.commons.osgi.ServiceUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
@Component(label="Guide Integration Service", description="Provides Integration Scripts for Guide runtime", immediate=1)
@Service(value={GuideIntegrationService.class})
public class GuideIntegrationServiceImpl
implements GuideIntegrationService {
private Logger logger = LoggerFactory.getLogger(GuideIntegrationServiceImpl.class);
@Reference(name="guideIntegrationServiceProvider", referenceInterface=GuideIntegrationServiceProvider.class, cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE, policy=ReferencePolicy.DYNAMIC)
private Map<Comparable<Object>, GuideIntegrationServiceProvider> providers = new ConcurrentSkipListMap(Collections.reverseOrder());
private Collection<GuideIntegrationServiceProvider> getProviders() {
return this.providers.values();
}
@Override
public List<String> getScriptPaths() {
HashSet<String> paths = new HashSet<String>();
for (GuideIntegrationServiceProvider provider : this.getProviders()) {
try {
List<String> currentPaths = provider.getGuideIntegrationScriptPaths();
if (currentPaths == null || currentPaths.isEmpty()) continue;
paths.addAll(currentPaths);
}
catch (Exception e) {
this.logger.error("The current provider could not give path", (Throwable)e);
}
}
return new ArrayList<String>(paths);
}
protected void bindGuideIntegrationServiceProvider(GuideIntegrationServiceProvider provider, Map<String, Object> config) {
this.providers.put(ServiceUtil.getComparableForServiceRanking(config), provider);
}
protected void unbindGuideIntegrationServiceProvider(GuideIntegrationServiceProvider provider, Map<String, Object> config) {
this.providers.remove(ServiceUtil.getComparableForServiceRanking(config));
}
}