Permalink
Browse files

Migrating BaseConfig from Scala to Java

  • Loading branch information...
nurkiewicz committed Jan 12, 2013
1 parent 10b895c commit 19963867db6ae1c077ca8206871a4f14a0de216a
@@ -0,0 +1,80 @@
+package com.blogspot.nurkiewicz.cacheable;
+
+import com.blogspot.nurkiewicz.cacheable.calculator.Calculator;
+import com.blogspot.nurkiewicz.cacheable.calculator.ManuallyInstrumentedCalculator;
+import com.blogspot.nurkiewicz.cacheable.calculator.PlainCalculator;
+import com.blogspot.nurkiewicz.cacheable.calculator.SpringInstrumentedCalculator;
+import org.springframework.cache.CacheManager;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
+import org.springframework.context.annotation.AdviceMode;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author Tomasz Nurkiewicz
+ * @since 1/12/13, 5:28 PM
+ */
+public abstract class BaseConfig {
+
+ @Bean
+ public Calculator calculator() {
+ return new PlainCalculator();
+ }
+
+}
+
+@Configuration
+class NoCachingConfig extends BaseConfig {}
+
+@Configuration
+class ManualCachingConfig extends BaseConfig {
+ @Bean
+ @Override
+ public Calculator calculator() {
+ return new CachingCalculatorDecorator(super.calculator());
+ }
+}
+
+@Configuration
+abstract class CacheManagerConfig extends BaseConfig {
+
+ @Bean
+ public CacheManager cacheManager() {
+ return new ConcurrentMapCacheManager();
+ }
+
+}
+
+@Configuration
+@EnableCaching(proxyTargetClass = true)
+class CacheableCglibConfig extends CacheManagerConfig {}
+
+@Configuration
+@EnableCaching(proxyTargetClass = false)
+class CacheableJdkProxyConfig extends CacheManagerConfig {}
+
+@Configuration
+@EnableCaching(mode = AdviceMode.ASPECTJ)
+class CacheableAspectJWeaving extends CacheManagerConfig {
+
+ @Bean
+ @Override
+ public Calculator calculator() {
+ return new SpringInstrumentedCalculator();
+ }
+
+}
+
+@Configuration
+@EnableCaching(mode = AdviceMode.ASPECTJ)
+class AspectJCustomAspect extends CacheManagerConfig {
+
+ @Bean
+ @Override
+ public Calculator calculator() {
+ return new ManuallyInstrumentedCalculator();
+ }
+
+}
+
@@ -1,59 +0,0 @@
-package com.blogspot.nurkiewicz.cacheable
-
-import calculator.{ManuallyInstrumentedCalculator, SpringInstrumentedCalculator, Calculator, PlainCalculator}
-import org.springframework.context.annotation.{Primary, AdviceMode, Bean, Configuration}
-import org.springframework.cache.annotation.EnableCaching
-import org.springframework.cache.CacheManager
-import org.springframework.cache.concurrent.ConcurrentMapCacheManager
-import org.springframework.cache.support.NoOpCacheManager
-
-abstract class BaseConfig {
-
- @Bean
- def calculator(): Calculator = new PlainCalculator()
-
-}
-
-@Configuration
-class NoCachingConfig extends BaseConfig
-
-@Configuration
-class ManualCachingConfig extends BaseConfig {
- @Bean
- override def calculator() = new CachingCalculatorDecorator(super.calculator())
-
-}
-
-@Configuration
-abstract class CacheManagerConfig extends BaseConfig {
-
- @Bean
- def cacheManager(): CacheManager = new ConcurrentMapCacheManager()
-
-}
-
-@Configuration
-@EnableCaching(proxyTargetClass = true)
-class CacheableCglibConfig extends CacheManagerConfig
-
-@Configuration
-@EnableCaching(proxyTargetClass = false)
-class CacheableJdkProxyConfig extends CacheManagerConfig
-
-@Configuration
-@EnableCaching(mode = AdviceMode.ASPECTJ)
-class CacheableAspectJWeaving extends CacheManagerConfig {
-
- @Bean
- override def calculator() = new SpringInstrumentedCalculator
-
-}
-
-@Configuration
-@EnableCaching(mode = AdviceMode.ASPECTJ)
-class AspectJCustomAspect extends CacheManagerConfig {
-
- @Bean
- override def calculator() = new ManuallyInstrumentedCalculator
-
-}

0 comments on commit 1996386

Please sign in to comment.