import org.argeo.cms.CmsException;
import org.argeo.jcr.ArgeoJcrConstants;
import org.argeo.node.NodeConstants;
-import org.argeo.node.NodeState;
import org.argeo.util.naming.AttributesDictionary;
import org.argeo.util.naming.LdifParser;
import org.argeo.util.naming.LdifWriter;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.cm.ConfigurationEvent;
-import org.osgi.service.cm.SynchronousConfigurationListener;
+import org.osgi.service.cm.ConfigurationListener;
-class DeployConfig implements SynchronousConfigurationListener {
+class DeployConfig implements ConfigurationListener {
private final Log log = LogFactory.getLog(getClass());
private final BundleContext bc = FrameworkUtil.getBundle(getClass()).getBundleContext();
} catch (IOException e) {
throw new CmsException("Could not init deploy configs", e);
}
- bc.registerService(SynchronousConfigurationListener.class, this, null);
+ // FIXME check race conditions during initialization
+ // bc.registerService(ConfigurationListener.class, this, null);
}
private void firstInit() throws IOException {
if (!webServerConfig.isEmpty())
putFactoryDeployConfig(KernelConstants.JETTY_FACTORY_PID, webServerConfig);
- saveDeployedConfigs();
+ save();
}
private void init(ConfigurationAdmin configurationAdmin, boolean isClean) throws IOException {
assert attrs != null;
AttributesDictionary.copy(conf.getProperties(), attrs);
}
- saveDeployedConfigs();
+ save();
if (log.isDebugEnabled())
log.debug("Updated deploy config " + serviceDn(factoryPid, cn.toString()));
} else {
Attributes attrs = deployConfigs.get(serviceDn);
assert attrs != null;
AttributesDictionary.copy(conf.getProperties(), attrs);
- saveDeployedConfigs();
+ save();
if (log.isDebugEnabled())
log.debug("Updated deploy config " + serviceDn);
} else {
deployConfigs.put(serviceDn, attrs);
}
- void saveDeployedConfigs() throws IOException {
+ void save() {
try (Writer writer = Files.newBufferedWriter(deployConfigPath)) {
new LdifWriter(writer).write(deployConfigs);
+ } catch (IOException e) {
+ throw new CmsException("Cannot save deploy configs", e);
}
}
}
}
- private Dictionary<String, Object> getProps(String factoryPid, String cn) {
+ Dictionary<String, Object> getProps(String factoryPid, String cn) {
Attributes attrs = deployConfigs.get(serviceDn(factoryPid, cn));
if (attrs != null)
return new AttributesDictionary(attrs);