GuideProgressiveStrategyManagerImpl.java
3.65 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
75
76
77
78
79
/*
* 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.ReferenceStrategy
* org.apache.felix.scr.annotations.References
* org.apache.felix.scr.annotations.Service
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemds.guide.service.impl;
import com.adobe.aemds.guide.service.GuideProgressiveStrategy;
import com.adobe.aemds.guide.service.GuideProgressiveStrategyManager;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
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.ReferenceStrategy;
import org.apache.felix.scr.annotations.References;
import org.apache.felix.scr.annotations.Service;
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(immediate=1, metatype=0, label="Adaptive Form Progressive Strategy Manager", description="Adaptive Form Progressive Strategy Manager Service")
@Service(value={GuideProgressiveStrategyManager.class})
@References(value={@Reference(cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE, policy=ReferencePolicy.DYNAMIC, strategy=ReferenceStrategy.EVENT, referenceInterface=GuideProgressiveStrategy.class)})
public class GuideProgressiveStrategyManagerImpl
implements GuideProgressiveStrategyManager {
private static Logger logger = LoggerFactory.getLogger(GuideProgressiveStrategyManagerImpl.class);
private Map<String, GuideProgressiveStrategy> guideProgressiveStrategies = new HashMap<String, GuideProgressiveStrategy>();
private final Object strategyRegLock = new Object();
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
protected void bindGuideProgressiveStrategy(GuideProgressiveStrategy guideProgressiveStrategy) {
Object object = this.strategyRegLock;
synchronized (object) {
if (this.guideProgressiveStrategies.get(guideProgressiveStrategy.getName()) != null) {
logger.warn("Strategy Name Conflict: Strategy with name " + guideProgressiveStrategy.getName() + " already exist. Discarding the old service and registering the new one with same name.");
}
this.guideProgressiveStrategies.put(guideProgressiveStrategy.getName(), guideProgressiveStrategy);
logger.info("Registering strategy " + guideProgressiveStrategy.getName() + ": " + guideProgressiveStrategy);
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
protected void unbindGuideProgressiveStrategy(GuideProgressiveStrategy guideProgressiveStrategy) {
Object object = this.strategyRegLock;
synchronized (object) {
this.guideProgressiveStrategies.remove(guideProgressiveStrategy.getName());
logger.info("Un-registering strategy " + guideProgressiveStrategy.getName() + ": " + guideProgressiveStrategy);
}
}
@Override
public GuideProgressiveStrategy getGuideProgressiveStrategyService(String name) {
return this.guideProgressiveStrategies.get(name);
}
@Override
public Collection<GuideProgressiveStrategy> getAllGuideProgressiveStrategyServices() {
return this.guideProgressiveStrategies.values();
}
}