- Revision
- 311
- Author
- mward
- Date
- 2007-09-11 23:33:37 -0500 (Tue, 11 Sep 2007)
Log Message
created a new RubyAwareRegistrar interface as well as an associated Abstract implementation
Modified Paths
- trunk/core/src/main/java/org/codehaus/waffle/registrar/pico/PicoRegistrar.java
- trunk/examples/jruby-example/src/main/java/org/codehaus/waffle/example/jruby/JRubyRegistrar.java
Added Paths
Diff
Added: trunk/core/src/main/java/org/codehaus/waffle/registrar/AbstractRubyAwareRegistrar.java (0 => 311)
--- trunk/core/src/main/java/org/codehaus/waffle/registrar/AbstractRubyAwareRegistrar.java (rev 0) +++ trunk/core/src/main/java/org/codehaus/waffle/registrar/AbstractRubyAwareRegistrar.java 2007-09-12 04:33:37 UTC (rev 311) @@ -0,0 +1,15 @@ +package org.codehaus.waffle.registrar; + + +public abstract class AbstractRubyAwareRegistrar extends AbstractRegistrar implements RubyAwareRegistrar { + private final RubyAwareRegistrar rubyAwareRegistrar; + + public AbstractRubyAwareRegistrar(Registrar delegate) { + super(delegate); + rubyAwareRegistrar = (RubyAwareRegistrar)delegate; + } + + public void registerRubyScript(String key, String className) { + rubyAwareRegistrar.registerRubyScript(key, className); + } +}
Added: trunk/core/src/main/java/org/codehaus/waffle/registrar/RubyAwareRegistrar.java (0 => 311)
--- trunk/core/src/main/java/org/codehaus/waffle/registrar/RubyAwareRegistrar.java (rev 0) +++ trunk/core/src/main/java/org/codehaus/waffle/registrar/RubyAwareRegistrar.java 2007-09-12 04:33:37 UTC (rev 311) @@ -0,0 +1,6 @@ +package org.codehaus.waffle.registrar; + +public interface RubyAwareRegistrar { + + void registerRubyScript(String key, String className); +}
Modified: trunk/core/src/main/java/org/codehaus/waffle/registrar/pico/PicoRegistrar.java (310 => 311)
--- trunk/core/src/main/java/org/codehaus/waffle/registrar/pico/PicoRegistrar.java 2007-09-12 02:47:23 UTC (rev 310) +++ trunk/core/src/main/java/org/codehaus/waffle/registrar/pico/PicoRegistrar.java 2007-09-12 04:33:37 UTC (rev 311) @@ -10,13 +10,14 @@ *****************************************************************************/ package org.codehaus.waffle.registrar.pico; +import org.codehaus.waffle.registrar.Registrar; +import org.codehaus.waffle.registrar.RubyAwareRegistrar; import org.picocontainer.ComponentAdapter; import org.picocontainer.MutablePicoContainer; import org.picocontainer.Parameter; +import org.picocontainer.defaults.CachingComponentAdapter; import org.picocontainer.defaults.ConstantParameter; import org.picocontainer.defaults.ConstructorInjectionComponentAdapter; -import org.picocontainer.defaults.CachingComponentAdapter; -import org.codehaus.waffle.registrar.Registrar; /** * This Registrar is backed by PicoContainer for managing Dependency Injection. This registrar @@ -25,7 +26,7 @@ * @author Michael Ward * @author Mauro Talevi */ -public class PicoRegistrar implements Registrar { +public class PicoRegistrar implements Registrar, RubyAwareRegistrar { private final MutablePicoContainer picoContainer; public PicoRegistrar(MutablePicoContainer picoContainer) { @@ -68,7 +69,6 @@ picoContainer.registerComponent(componentAdapter); } - // expose to interface? public void registerRubyScript(String key, String className) { ComponentAdapter componentAdapter = new RubyScriptComponentAdapter(key, className); CachingComponentAdapter cachingComponentAcdapter = new CachingComponentAdapter(componentAdapter);
Modified: trunk/examples/jruby-example/src/main/java/org/codehaus/waffle/example/jruby/JRubyRegistrar.java (310 => 311)
--- trunk/examples/jruby-example/src/main/java/org/codehaus/waffle/example/jruby/JRubyRegistrar.java 2007-09-12 02:47:23 UTC (rev 310) +++ trunk/examples/jruby-example/src/main/java/org/codehaus/waffle/example/jruby/JRubyRegistrar.java 2007-09-12 04:33:37 UTC (rev 311) @@ -1,21 +1,16 @@ package org.codehaus.waffle.example.jruby; import org.codehaus.waffle.example.jruby.dao.SimplePersonDAO; -import org.codehaus.waffle.registrar.AbstractRegistrar; +import org.codehaus.waffle.registrar.AbstractRubyAwareRegistrar; import org.codehaus.waffle.registrar.Registrar; -import org.codehaus.waffle.registrar.pico.PicoRegistrar; -import org.jruby.Ruby; import java.util.ArrayList; import java.util.List; -public class JRubyRegistrar extends AbstractRegistrar { - private PicoRegistrar picoRegistrar; - Ruby runtime = Ruby.getDefaultInstance(); +public class JRubyRegistrar extends AbstractRubyAwareRegistrar { public JRubyRegistrar(Registrar delegate) { super(delegate); - picoRegistrar = (PicoRegistrar) delegate; } @Override @@ -27,9 +22,9 @@ myList.add(15); registerInstance(List.class, myList); - picoRegistrar.registerRubyScript("foobar", "FooBar"); // register the controller! - picoRegistrar.registerRubyScript("hello", "HelloController"); // register the controller! - picoRegistrar.registerRubyScript("person", "PersonController"); // register the controller! + registerRubyScript("foobar", "FooBar"); // register the controller! + registerRubyScript("hello", "HelloController"); // register the controller! + registerRubyScript("person", "PersonController"); // register the controller! } @Override
To unsubscribe from this list please visit:
