ConfigurationHandlerFactory.java
2.38 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.Property
* 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
*/
package com.adobe.aemfd.watchfolder.factory;
import com.adobe.aemfd.watchfolder.config.WatchFolderConfiguration;
import com.adobe.aemfd.watchfolder.spi.ConfigurationHandler;
import com.adobe.aemfd.watchfolder.workflow.WorkflowConfigurationHandler;
import java.util.HashMap;
import java.util.Map;
import javax.jcr.Property;
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;
@Component(immediate=1)
@Service(value={ConfigurationHandlerFactory.class})
public class ConfigurationHandlerFactory {
@Reference
private WorkflowConfigurationHandler workflowConfigurationHandler;
private Map<String, ConfigurationHandler> handlerMap = new HashMap<String, ConfigurationHandler>();
@Activate
public void activate() {
this.handlerMap.put("workflow", this.workflowConfigurationHandler);
}
@Deactivate
public void deactivate() {
this.handlerMap.clear();
}
private ConfigurationHandler getHandler(Property p) throws Exception {
String pName = p.getName();
int idx = pName.indexOf(46);
if (idx != -1) {
String pType = pName.substring(0, idx);
return this.handlerMap.get(pType);
}
return null;
}
public boolean enhanceConfiguration(WatchFolderConfiguration config, Property p) throws Exception {
ConfigurationHandler ch = this.getHandler(p);
return ch != null && ch.enhanceConfiguration(config, p);
}
protected void bindWorkflowConfigurationHandler(WorkflowConfigurationHandler workflowConfigurationHandler) {
this.workflowConfigurationHandler = workflowConfigurationHandler;
}
protected void unbindWorkflowConfigurationHandler(WorkflowConfigurationHandler workflowConfigurationHandler) {
if (this.workflowConfigurationHandler == workflowConfigurationHandler) {
this.workflowConfigurationHandler = null;
}
}
}