Skip to content

Commit

Permalink
[DCMEEREQ-305] Configuration Storage
Browse files Browse the repository at this point in the history
  • Loading branch information
romank committed May 28, 2015
1 parent b9bd91f commit ea769dc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 44 deletions.
2 changes: 1 addition & 1 deletion dcm4chee-conf-db/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<version>1.0.0-SNAPSHOT</version>
</parent>
<properties>
<ds>java:/ConfigDS</ds>
<ds>java:/PacsDS</ds>
<hbm2ddl.auto>validate</hbm2ddl.auto>
<show_sql>false</show_sql>
<project.classifier></project.classifier>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public Map<String, Object> getConfigurationRoot() throws ConfigurationException

@Override
public Object getConfigurationNode(String path, Class configurableClass) throws ConfigurationException {
return ConfigNodeUtil.getNode(db.getFullTree(), path);
return ConfigNodeUtil.getNode(getConfigurationRoot(), path);
}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,42 +1,54 @@
package infinispan;

import org.dcm4che3.conf.core.DelegatingConfiguration;
import org.dcm4che3.conf.core.api.Configuration;
import org.dcm4che3.conf.core.api.ConfigurationException;
import org.dcm4che3.conf.core.util.ConfigNodeUtil;
import org.infinispan.Cache;
import org.infinispan.manager.EmbeddedCacheManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.decorator.Decorator;
import javax.decorator.Delegate;
import javax.inject.Inject;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

//TODO: convert to CDI decorator
public class CachedDicomConfigurationDecorator extends DelegatingConfiguration {
@Decorator
public abstract class InfinispanDicomConfigurationDecorator implements Configuration {


private static Logger log = LoggerFactory
.getLogger(CachedDicomConfigurationDecorator.class);
@Inject
@Delegate
Configuration delegate;

@Resource(lookup = "java:jboss/infinispan/dcm4che-config")
private EmbeddedCacheManager defaultCacheManager;

@PostConstruct
public void init() {
serializedDevicesCache = defaultCacheManager.getCache();
metadataCache = defaultCacheManager.getCache("metadata");
}

private static Logger log = LoggerFactory
.getLogger(InfinispanDicomConfigurationDecorator.class);


private Cache<String, Object> serializedDevicesCache;
private Cache<String, Object> metadataCache;

public CachedDicomConfigurationDecorator(Configuration delegate, Cache<String, Object> serializedDevicesCache, Cache<String, Object> metadataCache) {
super(delegate);
this.serializedDevicesCache = serializedDevicesCache;
this.metadataCache = metadataCache;
}
private Cache<String, Object> metadataCache;

@Override
public Map<String, Object> getConfigurationRoot() throws ConfigurationException {

// if cache not inited
if (serializedDevicesCache.isEmpty()) {
Map<String, Object> configurationRoot = super.getConfigurationRoot();
if (!metadataCache.containsKey("deviceNames")) {
Map<String, Object> configurationRoot = delegate.getConfigurationRoot();

Map<String, Object> dicomConfigurationRoot = (Map<String, Object>) configurationRoot.get("dicomConfigurationRoot");
Map<String, Object> dicomDevicesRoot = (Map<String, Object>) dicomConfigurationRoot.get("dicomDevicesRoot");
Expand Down Expand Up @@ -74,23 +86,22 @@ public Object getConfigurationNode(String path, Class configurableClass) throws

@Override
public boolean nodeExists(String path) throws ConfigurationException {
return false;
return ConfigNodeUtil.nodeExists(getConfigurationRoot(), path);
}

@Override
public void persistNode(String path, Map<String, Object> configNode, Class configurableClass) throws ConfigurationException {
metadataCache.clear();
serializedDevicesCache.clear();
}

// TODO: opt
@Override
public void refreshNode(String path) throws ConfigurationException {
public void persistNode(String path, Map<String, Object> configNode, Class configurableClass) throws ConfigurationException {
delegate.persistNode(path, configNode, configurableClass);
metadataCache.clear();
serializedDevicesCache.clear();
}

// TODO: opt
@Override
public void removeNode(String path) throws ConfigurationException {
delegate.removeNode(path);
metadataCache.clear();
serializedDevicesCache.clear();
}
Expand Down

0 comments on commit ea769dc

Please sign in to comment.