diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/cache/ApplicationLevelCache.java b/annotation/src/main/java/lcsb/mapviewer/annotation/cache/ApplicationLevelCache.java index 988858a11d95c9151ae3af4f96a747252e7e2d6d..67aa9ff6f02dd0788fdd1dce8f9a7b3debac5a12 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/cache/ApplicationLevelCache.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/cache/ApplicationLevelCache.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.Map; import org.apache.log4j.Logger; +import org.springframework.stereotype.Service; import org.w3c.dom.Node; import lcsb.mapviewer.common.Configuration; @@ -19,6 +20,7 @@ import lcsb.mapviewer.model.cache.CacheType; * @author Piotr Gawron * */ +@Service public final class ApplicationLevelCache extends XmlParser implements QueryCacheInterface { /** diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/cache/GeneralCache.java b/annotation/src/main/java/lcsb/mapviewer/annotation/cache/GeneralCache.java index e82c7109828bdaaeab49c376771ae036c3c5e5d1..cd267870605bf4f36867f05c74fcd28964a2759b 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/cache/GeneralCache.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/cache/GeneralCache.java @@ -2,6 +2,7 @@ package lcsb.mapviewer.annotation.cache; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.w3c.dom.Node; @@ -31,7 +32,7 @@ public class GeneralCache implements GeneralCacheInterface { * Application level cache. More information can be found * {@link ApplicationLevelCache here}. */ - private QueryCacheInterface cache1 = ApplicationLevelCache.getInstance(); + private QueryCacheInterface cache1; /** * Database level cache. More information can be found @@ -43,7 +44,9 @@ public class GeneralCache implements GeneralCacheInterface { * Constructor */ @Autowired - public GeneralCache(QueryCacheInterface cache2) { + public GeneralCache(@Qualifier(value = "applicationLevelCache") QueryCacheInterface cache1, + @Qualifier(value = "permanentDatabaseLevelCache") QueryCacheInterface cache2) { + this.cache1 = cache1; this.cache2 = cache2; } diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/cache/CachableInterfaceTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/cache/CachableInterfaceTest.java index b8f7bfebfd0e92fc0d573e70256a719d686adc40..d0098feb37c20732603617e7736ad786bec7e329 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/cache/CachableInterfaceTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/cache/CachableInterfaceTest.java @@ -59,7 +59,7 @@ public class CachableInterfaceTest extends AnnotationTestFunctions { CacheTypeDao mock = Mockito.mock(CacheTypeDao.class); when(mock.getByClassName(anyString())).thenReturn(new CacheType()); ci.setCacheTypeDao(mock); - ci.setCache(new GeneralCache(null)); + ci.setCache(new GeneralCache(null, null)); String cacheKey = "https://www.google.com/"; String result = ci.getWebPageContent(cacheKey); @@ -82,7 +82,7 @@ public class CachableInterfaceTest extends AnnotationTestFunctions { ci.setCacheTypeDao(mock); String xml = "<xml><child/></xml>"; - ci.setCache(new GeneralCache(null)); + ci.setCache(new GeneralCache(null, null)); ci.setCacheNode("id", super.getNodeFromXmlString(xml)); Node node = ci.getCacheNode("id"); diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/cache/GeneralCacheTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/cache/GeneralCacheTest.java index 3a790cba661bf4e440eba4a6d4fa6008b8c6502a..b001cceb2f0887a51465f13fc4737abb8596cb4d 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/cache/GeneralCacheTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/cache/GeneralCacheTest.java @@ -19,7 +19,7 @@ import lcsb.mapviewer.model.cache.CacheType; public class GeneralCacheTest extends AnnotationTestFunctions { Logger logger = Logger.getLogger(GeneralCacheTest.class); - GeneralCache cache = new GeneralCache(null); + GeneralCache cache = new GeneralCache(null, null); @Autowired PermanentDatabaseLevelCacheInterface databaseLevelCache; diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/cache/GeneralCacheWithExclusionTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/cache/GeneralCacheWithExclusionTest.java index 4d3164868eeb8739aca5f6c4a35ab74782ffd634..f822ff5acea33a68c588f61ae783d7a03048083f 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/cache/GeneralCacheWithExclusionTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/cache/GeneralCacheWithExclusionTest.java @@ -44,7 +44,7 @@ public class GeneralCacheWithExclusionTest extends AnnotationTestFunctions { public void testExclusion() throws Exception { try { CacheType type = new CacheType(); - GeneralCache cache = new GeneralCache(null); + GeneralCache cache = new GeneralCache(null, null); cache.setCache2(ApplicationLevelCache.getInstance()); GeneralCacheWithExclusion cacheWithExclusion = new GeneralCacheWithExclusion(cache, 2); @@ -67,7 +67,7 @@ public class GeneralCacheWithExclusionTest extends AnnotationTestFunctions { public void testClear() throws Exception { try { CacheType type = new CacheType(); - GeneralCache cache = new GeneralCache(null); + GeneralCache cache = new GeneralCache(null, null); cache.setCache2(ApplicationLevelCache.getInstance()); GeneralCacheWithExclusion cacheWithExclusion = new GeneralCacheWithExclusion(cache, 0); @@ -90,7 +90,7 @@ public class GeneralCacheWithExclusionTest extends AnnotationTestFunctions { public void testRemove() throws Exception { try { CacheType type = new CacheType(); - GeneralCache cache = new GeneralCache(null); + GeneralCache cache = new GeneralCache(null, null); cache.setCache2(ApplicationLevelCache.getInstance()); GeneralCacheWithExclusion cacheWithExclusion = new GeneralCacheWithExclusion(cache, 0); @@ -114,7 +114,7 @@ public class GeneralCacheWithExclusionTest extends AnnotationTestFunctions { public void testInvalidate() throws Exception { try { CacheType type = new CacheType(); - GeneralCache cache = new GeneralCache(null); + GeneralCache cache = new GeneralCache(null, null); cache.setCache2(ApplicationLevelCache.getInstance()); GeneralCacheWithExclusion cacheWithExclusion = new GeneralCacheWithExclusion(cache, 0); diff --git a/persist/src/main/java/lcsb/mapviewer/persist/SpringApplicationContext.java b/persist/src/main/java/lcsb/mapviewer/persist/SpringApplicationContext.java index e2b982e3c74e2f54752b2f19a143148ccbcd1824..4b8aa0a9d2aa169621d6cbd4ad72a2933b12f562 100644 --- a/persist/src/main/java/lcsb/mapviewer/persist/SpringApplicationContext.java +++ b/persist/src/main/java/lcsb/mapviewer/persist/SpringApplicationContext.java @@ -53,6 +53,7 @@ public class SpringApplicationContext implements ApplicationContextAware { * @return an Object reference to the named bean. */ public static Object getBean(String beanName) { + beanName = beanName.substring(0, 1).toLowerCase() + beanName.substring(1); return context.getBean(beanName); } diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/SpringReactomeConfig.java b/reactome/src/main/java/lcsb/mapviewer/reactome/SpringReactomeConfig.java index 79d43abf5ec98ee2eecd406eaa02baee2a3186f7..d69c28be334b1d793b5c4c50cd804318af956c9f 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/SpringReactomeConfig.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/SpringReactomeConfig.java @@ -1,9 +1,12 @@ package lcsb.mapviewer.reactome; +import lcsb.mapviewer.annotation.SpringAnnotationConfig; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; @Configuration +@Import({SpringAnnotationConfig.class}) @ComponentScan(basePackages = {"lcsb.mapviewer.reactome"}) public class SpringReactomeConfig {