- Revision
- 787
- Author
- paul
- Date
- 2008-08-26 09:45:49 -0500 (Tue, 26 Aug 2008)
Log Message
fix up cache/non-cache stuff
Modified Paths
- trunk/waffle-core/src/main/java/org/codehaus/waffle/context/pico/PicoContextContainerFactory.java
- trunk/waffle-core/src/main/java/org/codehaus/waffle/registrar/pico/PicoRegistrar.java
- trunk/waffle-core/src/test/java/org/codehaus/waffle/registrar/pico/PicoRegistrarTest.java
- trunk/waffle-ruby/src/main/java/org/codehaus/waffle/registrar/pico/RubyScriptedRegistrar.java
Diff
Modified: trunk/waffle-core/src/main/java/org/codehaus/waffle/context/pico/PicoContextContainerFactory.java (786 => 787)
--- trunk/waffle-core/src/main/java/org/codehaus/waffle/context/pico/PicoContextContainerFactory.java 2008-08-26 12:40:02 UTC (rev 786) +++ trunk/waffle-core/src/main/java/org/codehaus/waffle/context/pico/PicoContextContainerFactory.java 2008-08-26 14:45:49 UTC (rev 787) @@ -14,6 +14,7 @@ import org.codehaus.waffle.registrar.pico.PicoRegistrar; import org.codehaus.waffle.registrar.pico.ParameterResolver; import org.picocontainer.*; +import org.picocontainer.behaviors.Caching; import org.picocontainer.monitors.NullComponentMonitor; import javax.servlet.http.HttpServletRequest;
Modified: trunk/waffle-core/src/main/java/org/codehaus/waffle/registrar/pico/PicoRegistrar.java (786 => 787)
--- trunk/waffle-core/src/main/java/org/codehaus/waffle/registrar/pico/PicoRegistrar.java 2008-08-26 12:40:02 UTC (rev 786) +++ trunk/waffle-core/src/main/java/org/codehaus/waffle/registrar/pico/PicoRegistrar.java 2008-08-26 14:45:49 UTC (rev 787) @@ -4,6 +4,7 @@ package org.codehaus.waffle.registrar.pico; import static org.picocontainer.Characteristics.NO_CACHE; +import static org.picocontainer.Characteristics.CACHE; import java.util.List; import java.util.Properties; @@ -86,8 +87,7 @@ public Registrar register(Object key, Class<?> type, Object... parameters) { ComponentAdapter componentAdapter = buildComponentAdapter(key, type, parameters); - Cached cachingComponentAdapter = new Cached(componentAdapter); - this.registerComponentAdapter(cachingComponentAdapter); + registerCachedComponentAdapter(componentAdapter); registrarMonitor.componentRegistered(key, type, parameters); return this; } @@ -111,15 +111,19 @@ public Registrar registerNonCaching(Object key, Class<?> type, Object... parameters) { ComponentAdapter componentAdapter = buildComponentAdapter(key, type, parameters); - picoContainer.as(NO_CACHE).addAdapter(componentAdapter); + registerUnCachedComponentAdapter(componentAdapter); registrarMonitor.nonCachingComponentRegistered(key, type, parameters); return this; } - public void registerComponentAdapter(ComponentAdapter componentAdapter) { + public void registerUnCachedComponentAdapter(ComponentAdapter componentAdapter) { picoContainer.as(NO_CACHE).addAdapter(componentAdapter); } + public void registerCachedComponentAdapter(ComponentAdapter componentAdapter) { + picoContainer.as(CACHE).addAdapter(componentAdapter); + } + private Parameter[] picoParameters(Object[] parameters) { if (parameters.length == 0) { return null; // pico expects a null when no parameters
Modified: trunk/waffle-core/src/test/java/org/codehaus/waffle/registrar/pico/PicoRegistrarTest.java (786 => 787)
--- trunk/waffle-core/src/test/java/org/codehaus/waffle/registrar/pico/PicoRegistrarTest.java 2008-08-26 12:40:02 UTC (rev 786) +++ trunk/waffle-core/src/test/java/org/codehaus/waffle/registrar/pico/PicoRegistrarTest.java 2008-08-26 14:45:49 UTC (rev 787) @@ -241,7 +241,7 @@ = new ConstructorInjector<FakeController>("a", FakeController.class); PicoRegistrar registrar = new PicoRegistrar(pico, null, lifecycleStrategy, new SilentMonitor(), cm); - registrar.registerComponentAdapter(componentAdapter); + registrar.registerUnCachedComponentAdapter(componentAdapter); FakeController controllerOne = (FakeController) registrar.getRegistered("a"); FakeController controllerTwo = (FakeController) pico.getComponent(FakeController.class);
Modified: trunk/waffle-ruby/src/main/java/org/codehaus/waffle/registrar/pico/RubyScriptedRegistrar.java (786 => 787)
--- trunk/waffle-ruby/src/main/java/org/codehaus/waffle/registrar/pico/RubyScriptedRegistrar.java 2008-08-26 12:40:02 UTC (rev 786) +++ trunk/waffle-ruby/src/main/java/org/codehaus/waffle/registrar/pico/RubyScriptedRegistrar.java 2008-08-26 14:45:49 UTC (rev 787) @@ -26,7 +26,7 @@ } public void registerScript(String key, String className) { - this.registerComponentAdapter(new Cached(new RubyScriptComponentAdapter(key, className))); + this.registerCachedComponentAdapter(new RubyScriptComponentAdapter(key, className)); }
To unsubscribe from this list please visit:
