-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring to split conf-core and conf-dicom, infinispan initial commit
- Loading branch information
romank-agfa
committed
May 28, 2015
1 parent
1433f50
commit b9bd91f
Showing
9 changed files
with
263 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<!-- | ||
~ ***** BEGIN LICENSE BLOCK ***** | ||
~ Version: MPL 1.1/GPL 2.0/LGPL 2.1 | ||
~ | ||
~ The contents of this file are subject to the Mozilla Public License Version | ||
~ 1.1 (the "License"); you may not use this file except in compliance with | ||
~ the License. You may obtain a copy of the License at | ||
~ http://www.mozilla.org/MPL/ | ||
~ | ||
~ Software distributed under the License is distributed on an "AS IS" basis, | ||
~ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | ||
~ for the specific language governing rights and limitations under the | ||
~ License. | ||
~ | ||
~ The Original Code is part of dcm4che, an implementation of DICOM(TM) in | ||
~ Java(TM), hosted at https://github.com/gunterze/dcm4che. | ||
~ | ||
~ The Initial Developer of the Original Code is | ||
~ Agfa Healthcare. | ||
~ Portions created by the Initial Developer are Copyright (C) 2014 | ||
~ the Initial Developer. All Rights Reserved. | ||
~ | ||
~ Contributor(s): | ||
~ See @authors listed below | ||
~ | ||
~ Alternatively, the contents of this file may be used under the terms of | ||
~ either the GNU General Public License Version 2 or later (the "GPL"), or | ||
~ the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | ||
~ in which case the provisions of the GPL or the LGPL are applicable instead | ||
~ of those above. If you wish to allow use of your version of this file only | ||
~ under the terms of either the GPL or the LGPL, and not to allow others to | ||
~ use your version of this file under the terms of the MPL, indicate your | ||
~ decision by deleting the provisions above and replace them with the notice | ||
~ and other provisions required by the GPL or the LGPL. If you do not delete | ||
~ the provisions above, a recipient may use your version of this file under | ||
~ the terms of any one of the MPL, the GPL or the LGPL. | ||
~ | ||
~ ***** END LICENSE BLOCK ***** | ||
--> | ||
<project | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.dcm4chee</groupId> | ||
<artifactId>dcm4chee-conf-infinispan</artifactId> | ||
<packaging>jar</packaging> | ||
<parent> | ||
<groupId>org.dcm4che.dcm4chee-conf</groupId> | ||
<artifactId>dcm4chee-conf-parent</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.dcm4che</groupId> | ||
<artifactId>dcm4che-conf-core</artifactId> | ||
<version>${dcm4che.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>javax</groupId> | ||
<artifactId>javaee-api</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.infinispan</groupId> | ||
<artifactId>infinispan-core</artifactId> | ||
<version>5.1.2.FINAL</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>2.5</version> | ||
<configuration> | ||
<archive> | ||
<manifestEntries> | ||
<Dependencies>org.dcm4che.conf.core, org.infinispan </Dependencies> | ||
</manifestEntries> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
|
||
</project> |
102 changes: 102 additions & 0 deletions
102
dcm4chee-conf-infinispan/src/main/java/infinispan/CachedDicomConfigurationDecorator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
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.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
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 { | ||
|
||
|
||
private static Logger log = LoggerFactory | ||
.getLogger(CachedDicomConfigurationDecorator.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; | ||
} | ||
|
||
@Override | ||
public Map<String, Object> getConfigurationRoot() throws ConfigurationException { | ||
|
||
// if cache not inited | ||
if (serializedDevicesCache.isEmpty()) { | ||
Map<String, Object> configurationRoot = super.getConfigurationRoot(); | ||
|
||
Map<String, Object> dicomConfigurationRoot = (Map<String, Object>) configurationRoot.get("dicomConfigurationRoot"); | ||
Map<String, Object> dicomDevicesRoot = (Map<String, Object>) dicomConfigurationRoot.get("dicomDevicesRoot"); | ||
|
||
for (Map.Entry<String, Object> deviceEntry : dicomDevicesRoot.entrySet()) { | ||
serializedDevicesCache.put(deviceEntry.getKey(), deviceEntry.getValue()); | ||
} | ||
|
||
metadataCache.put("deviceNames", dicomDevicesRoot.keySet()); | ||
|
||
return configurationRoot; | ||
} | ||
|
||
// recreate full tree from cache | ||
HashMap<String, Object> root = new HashMap<>(); | ||
HashMap<String, Object> configRoot = new HashMap<>(); | ||
HashMap<String, Object> devicesRoot = new HashMap<>(); | ||
|
||
root.put("dicomConfigurationRoot", configRoot); | ||
configRoot.put("dicomDevicesRoot", devicesRoot); | ||
|
||
Set<String> deviceNames = (Set<String>) metadataCache.get("deviceNames"); | ||
for (String name : deviceNames) { | ||
devicesRoot.put(name, serializedDevicesCache.get(name)); | ||
} | ||
|
||
return root; | ||
} | ||
|
||
@Override | ||
public Object getConfigurationNode(String path, Class configurableClass) throws ConfigurationException { | ||
return ConfigNodeUtil.getNode(getConfigurationRoot(), path); | ||
} | ||
|
||
|
||
@Override | ||
public boolean nodeExists(String path) throws ConfigurationException { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void persistNode(String path, Map<String, Object> configNode, Class configurableClass) throws ConfigurationException { | ||
metadataCache.clear(); | ||
serializedDevicesCache.clear(); | ||
} | ||
|
||
@Override | ||
public void refreshNode(String path) throws ConfigurationException { | ||
metadataCache.clear(); | ||
serializedDevicesCache.clear(); | ||
} | ||
|
||
@Override | ||
public void removeNode(String path) throws ConfigurationException { | ||
metadataCache.clear(); | ||
serializedDevicesCache.clear(); | ||
} | ||
|
||
@Override | ||
public synchronized Iterator search(String liteXPathExpression) throws IllegalArgumentException, ConfigurationException { | ||
return ConfigNodeUtil.search(getConfigurationRoot(), liteXPathExpression); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
dcm4chee-conf-infinispan/src/main/java/infinispan/InfinispanConfigurationCacheFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package infinispan; | ||
|
||
import org.infinispan.Cache; | ||
import org.infinispan.manager.EmbeddedCacheManager; | ||
|
||
import javax.annotation.Resource; | ||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
@ApplicationScoped | ||
public class InfinispanConfigurationCacheFactory { | ||
|
||
@Resource(lookup="java:jboss/infinispan/dcm4che-config") | ||
private EmbeddedCacheManager defaultCacheManager; | ||
|
||
public Cache getDevicesCache() { | ||
return defaultCacheManager.getCache(); | ||
} | ||
public Cache getMetadataCache() { | ||
return defaultCacheManager.getCache("metadata"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters