CoreConfigServiceImpl.java
5.87 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.aemds.settings.AemDsSettingsService
* javax.transaction.TransactionManager
* org.apache.commons.io.FileUtils
* 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.framework.BundleContext
* org.osgi.service.component.ComponentContext
*/
package com.adobe.aemds.bedrock.internal;
import com.adobe.aemds.bedrock.CoreConfigService;
import com.adobe.aemds.bedrock.internal.OSGiUtils;
import com.adobe.aemds.settings.AemDsSettingsService;
import java.io.File;
import java.io.IOException;
import javax.transaction.TransactionManager;
import org.apache.commons.io.FileUtils;
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.omg.CORBA.ORB;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
@Component
@Service(value={CoreConfigService.class})
public class CoreConfigServiceImpl
implements CoreConfigService {
private String serverNativeDirPath;
private String serverConfigDirPath;
private String serverDataDirPath;
private String serverCommonDirPath;
private String serverTempDirPath;
@Reference
private SlingSettingsService settingsService;
@Reference
private AemDsSettingsService aemDsSettingsService;
@Reference
private TransactionManager transactionManager;
@Reference(referenceInterface=ORB.class)
private ORB orb;
@Activate
private void activate(ComponentContext componentContext) throws IOException {
File slingHome = new File(this.settingsService.getSlingHomePath());
File rootDir = new File(slingHome, "bedrock");
FileUtils.forceMkdir((File)rootDir);
File tempDir = new File(this.aemDsSettingsService.getTempFolderPath());
File serverNativeDir = new File(rootDir, "svcnative");
File serverConfigDir = new File(rootDir, "svcconfig");
File serverCommonDir = new File(rootDir, "svccommon");
File serverDataDir = new File(rootDir, "svcdata");
File serverTempDir = new File(tempDir, "datamanager");
FileUtils.forceMkdir((File)serverNativeDir);
FileUtils.forceMkdir((File)serverConfigDir);
FileUtils.forceMkdir((File)serverCommonDir);
FileUtils.forceMkdir((File)serverDataDir);
FileUtils.forceMkdir((File)serverTempDir);
this.serverNativeDirPath = serverNativeDir.getCanonicalPath();
this.serverConfigDirPath = serverConfigDir.getCanonicalPath();
this.serverDataDirPath = serverDataDir.getCanonicalPath();
this.serverCommonDirPath = serverCommonDir.getCanonicalPath();
this.serverTempDirPath = serverTempDir.getCanonicalPath();
OSGiUtils.setCoreConfigService(this);
OSGiUtils.setBundleContext(componentContext.getBundleContext());
OSGiUtils.setTransactionManager(this.transactionManager);
OSGiUtils.setOrb(this.orb);
this.exportServerProperties();
}
@Deactivate
private void deactivate() {
OSGiUtils.setCoreConfigService(null);
OSGiUtils.setBundleContext(null);
OSGiUtils.setTransactionManager(null);
OSGiUtils.setOrb(null);
}
public String getServerConfigHomeDir() {
return this.serverConfigDirPath;
}
public String getServerDataDir() {
return this.serverDataDirPath;
}
public String getServerNativeDir() {
return this.serverNativeDirPath;
}
public String getServerCommonDir() {
return this.serverCommonDirPath;
}
public String getServerTempDir() {
return this.serverTempDirPath;
}
public void exportServerProperties() {
System.setProperty("com.adobe.aemds.bedrock.serverConfigDirPath", this.serverConfigDirPath);
System.setProperty("com.adobe.aemds.bedrock.serverDataDirPath", this.serverDataDirPath);
System.setProperty("com.adobe.aemds.bedrock.serverNativeDirPath", this.serverNativeDirPath);
System.setProperty("com.adobe.aemds.bedrock.serverCommonDirPath", this.serverCommonDirPath);
System.setProperty("com.adobe.aemds.bedrock.serverTempDirPath", this.serverTempDirPath);
System.setProperty("com.adobe.tempDirectory", this.serverTempDirPath);
}
protected void bindSettingsService(SlingSettingsService slingSettingsService) {
this.settingsService = slingSettingsService;
}
protected void unbindSettingsService(SlingSettingsService slingSettingsService) {
if (this.settingsService == slingSettingsService) {
this.settingsService = null;
}
}
protected void bindAemDsSettingsService(AemDsSettingsService aemDsSettingsService) {
this.aemDsSettingsService = aemDsSettingsService;
}
protected void unbindAemDsSettingsService(AemDsSettingsService aemDsSettingsService) {
if (this.aemDsSettingsService == aemDsSettingsService) {
this.aemDsSettingsService = null;
}
}
protected void bindTransactionManager(TransactionManager transactionManager) {
this.transactionManager = transactionManager;
}
protected void unbindTransactionManager(TransactionManager transactionManager) {
if (this.transactionManager == transactionManager) {
this.transactionManager = null;
}
}
protected void bindOrb(ORB oRB) {
this.orb = oRB;
}
protected void unbindOrb(ORB oRB) {
if (this.orb == oRB) {
this.orb = null;
}
}
}