Title: [waffle-scm] [871] sandbox/v2experiment/waffle-ruby/src/main/java/org/codehaus/waffle: sensible rename and repackage
Revision
871
Author
paul
Date
2009-01-15 05:43:31 -0600 (Thu, 15 Jan 2009)

Log Message

sensible rename and repackage

Modified Paths


Added Paths

Removed Paths

Diff

Modified: sandbox/v2experiment/examples/jruby-example/src/main/webapp/WEB-INF/web.xml (870 => 871)

--- sandbox/v2experiment/examples/jruby-example/src/main/webapp/WEB-INF/web.xml	2009-01-15 11:40:40 UTC (rev 870)
+++ sandbox/v2experiment/examples/jruby-example/src/main/webapp/WEB-INF/web.xml	2009-01-15 11:43:31 UTC (rev 871)
@@ -33,7 +33,7 @@
   <!-- Ruby Specific components -->
   <context-param>
     <param-name>org.codehaus.waffle.context.ContextContainerFactory</param-name>
-    <param-value>org.codehaus.waffle.context.pico.RubyContextContainerFactory</param-value>
+    <param-value>org.codehaus.waffle.ruby.context.RubyContextContainerFactory</param-value>
   </context-param>
   <context-param>
     <param-name>org.codehaus.waffle.bind.ControllerDataBinder</param-name>

Deleted: sandbox/v2experiment/waffle-ruby/src/main/java/org/codehaus/waffle/context/pico/RubyPicoContextContainerFactory.java (870 => 871)

--- sandbox/v2experiment/waffle-ruby/src/main/java/org/codehaus/waffle/context/pico/RubyPicoContextContainerFactory.java	2009-01-15 11:40:40 UTC (rev 870)
+++ sandbox/v2experiment/waffle-ruby/src/main/java/org/codehaus/waffle/context/pico/RubyPicoContextContainerFactory.java	2009-01-15 11:43:31 UTC (rev 871)
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) terms as published in http://waffle.codehaus.org/license.html
- */
-package org.codehaus.waffle.context.pico;
-
-import static org.picocontainer.Characteristics.CACHE;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-
-import org.codehaus.waffle.WaffleException;
-import org.codehaus.waffle.context.ContextContainerFactory;
-import org.codehaus.waffle.i18n.MessageResources;
-import org.codehaus.waffle.monitor.ContextMonitor;
-import org.codehaus.waffle.monitor.RegistrarMonitor;
-import org.codehaus.waffle.registrar.Registrar;
-import org.codehaus.waffle.registrar.pico.ParameterResolver;
-import org.codehaus.waffle.registrar.pico.RubyScriptedRegistrar;
-import org.jruby.Ruby;
-import org.picocontainer.MutablePicoContainer;
-
-/**
- * @author Michael Ward
- * @author Mauro Talevi
- */
-public class RubyPicoContextContainerFactory extends ContextContainerFactory {
-
-    public RubyPicoContextContainerFactory(MessageResources messageResources, ContextMonitor contextMonitor,
-            RegistrarMonitor registrarMonitor, ParameterResolver parameterResolver) {
-        super(messageResources, contextMonitor, registrarMonitor, parameterResolver);
-    }
-
-    @Override
-    public MutablePicoContainer buildApplicationContextContainer() {
-        MutablePicoContainer contextContainer = super.buildApplicationContextContainer();
-        registerScriptComponents(contextContainer);
-        return contextContainer;
-    }
-
-    protected void registerScriptComponents(MutablePicoContainer contextContainer) {
-        // Register Ruby Runtime at Application level
-        Ruby runtime = Ruby.newInstance();
-        runtime.getLoadService().init(new ArrayList<Object>()); // this must be called, else we won't be able to load
-                                                                // scripts!!
-        loadRubyScriptFromClassLoader("org/codehaus/waffle/waffle_erb.rb", runtime);
-        loadRubyScriptFromClassLoader("org/codehaus/waffle/waffle.rb", runtime);
-
-        // I'd prefer to do the following:
-        // runtime.evalScript("require 'string'\nrequire 'waffle'"); // load Waffle custom scripts
-        //
-        // but JRuby fails when web app is reloaded...
-        // <script>:1:in `require': JAR entry string.rb not found in ~/jruby-example/exploded/WEB-INF/lib/core.jar
-        // (IOError)
-
-        contextContainer.addComponent(Ruby.class, runtime);
-        contextContainer.as(CACHE).addComponent(RubyScriptLoader.class);
-    }
-
-    @Override
-    public Registrar createRegistrar(MutablePicoContainer contextContainer) { // todo we need tests for this ... can this
-                                                                             // be refactored cleaner?
-        RegistrarMonitor registrarMonitor = getRegistrarMonitor();
-        Registrar registrar = new RubyScriptedRegistrar(contextContainer, getParameterResolver(),
-                getPicoLifecycleStrategy(), registrarMonitor, getPicoComponentMonitor(), getMessageResources());
-        getContextMonitor().registrarCreated(registrar, registrarMonitor);
-        return registrar;
-    }
-
-    private void loadRubyScriptFromClassLoader(String fileName, Ruby runtime) {
-        BufferedReader bufferedReader = null;
-        InputStream inputStream = null;
-
-        try {
-            inputStream = this.getClass().getClassLoader().getResourceAsStream(fileName);
-            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
-            StringBuilder script = new StringBuilder();
-            String line = bufferedReader.readLine();
-
-            while (line != null) {
-                script.append(line).append("\n");
-                line = bufferedReader.readLine();
-            }
-
-            runtime.executeScript(script.toString(), fileName);
-        } catch (IOException e) {
-            throw new WaffleException(e);
-        } finally {
-            try {
-                if (inputStream != null)
-                    inputStream.close();
-                if (bufferedReader != null)
-                    bufferedReader.close();
-            } catch (IOException ignore) {
-                // ignore
-            }
-        }
-    }
-
-}

Copied: sandbox/v2experiment/waffle-ruby/src/main/java/org/codehaus/waffle/ruby/context/RubyContextContainerFactory.java (from rev 870, sandbox/v2experiment/waffle-ruby/src/main/java/org/codehaus/waffle/context/pico/RubyPicoContextContainerFactory.java) (0 => 871)

--- sandbox/v2experiment/waffle-ruby/src/main/java/org/codehaus/waffle/ruby/context/RubyContextContainerFactory.java	                        (rev 0)
+++ sandbox/v2experiment/waffle-ruby/src/main/java/org/codehaus/waffle/ruby/context/RubyContextContainerFactory.java	2009-01-15 11:43:31 UTC (rev 871)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) terms as published in http://waffle.codehaus.org/license.html
+ */
+package org.codehaus.waffle.ruby.context;
+
+import static org.picocontainer.Characteristics.CACHE;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+
+import org.codehaus.waffle.WaffleException;
+import org.codehaus.waffle.context.ContextContainerFactory;
+import org.codehaus.waffle.context.pico.RubyScriptLoader;
+import org.codehaus.waffle.i18n.MessageResources;
+import org.codehaus.waffle.monitor.ContextMonitor;
+import org.codehaus.waffle.monitor.RegistrarMonitor;
+import org.codehaus.waffle.registrar.Registrar;
+import org.codehaus.waffle.registrar.pico.ParameterResolver;
+import org.codehaus.waffle.registrar.pico.RubyScriptedRegistrar;
+import org.jruby.Ruby;
+import org.picocontainer.MutablePicoContainer;
+
+/**
+ * @author Michael Ward
+ * @author Mauro Talevi
+ */
+public class RubyContextContainerFactory extends ContextContainerFactory {
+
+    public RubyContextContainerFactory(MessageResources messageResources, ContextMonitor contextMonitor,
+            RegistrarMonitor registrarMonitor, ParameterResolver parameterResolver) {
+        super(messageResources, contextMonitor, registrarMonitor, parameterResolver);
+    }
+
+    @Override
+    public MutablePicoContainer buildApplicationContextContainer() {
+        MutablePicoContainer contextContainer = super.buildApplicationContextContainer();
+        registerScriptComponents(contextContainer);
+        return contextContainer;
+    }
+
+    protected void registerScriptComponents(MutablePicoContainer contextContainer) {
+        // Register Ruby Runtime at Application level
+        Ruby runtime = Ruby.newInstance();
+        runtime.getLoadService().init(new ArrayList<Object>()); // this must be called, else we won't be able to load
+                                                                // scripts!!
+        loadRubyScriptFromClassLoader("org/codehaus/waffle/waffle_erb.rb", runtime);
+        loadRubyScriptFromClassLoader("org/codehaus/waffle/waffle.rb", runtime);
+
+        // I'd prefer to do the following:
+        // runtime.evalScript("require 'string'\nrequire 'waffle'"); // load Waffle custom scripts
+        //
+        // but JRuby fails when web app is reloaded...
+        // <script>:1:in `require': JAR entry string.rb not found in ~/jruby-example/exploded/WEB-INF/lib/core.jar
+        // (IOError)
+
+        contextContainer.addComponent(Ruby.class, runtime);
+        contextContainer.as(CACHE).addComponent(RubyScriptLoader.class);
+    }
+
+    @Override
+    public Registrar createRegistrar(MutablePicoContainer contextContainer) { // todo we need tests for this ... can this
+                                                                             // be refactored cleaner?
+        RegistrarMonitor registrarMonitor = getRegistrarMonitor();
+        Registrar registrar = new RubyScriptedRegistrar(contextContainer, getParameterResolver(),
+                getPicoLifecycleStrategy(), registrarMonitor, getPicoComponentMonitor(), getMessageResources());
+        getContextMonitor().registrarCreated(registrar, registrarMonitor);
+        return registrar;
+    }
+
+    private void loadRubyScriptFromClassLoader(String fileName, Ruby runtime) {
+        BufferedReader bufferedReader = null;
+        InputStream inputStream = null;
+
+        try {
+            inputStream = this.getClass().getClassLoader().getResourceAsStream(fileName);
+            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
+            StringBuilder script = new StringBuilder();
+            String line = bufferedReader.readLine();
+
+            while (line != null) {
+                script.append(line).append("\n");
+                line = bufferedReader.readLine();
+            }
+
+            runtime.executeScript(script.toString(), fileName);
+        } catch (IOException e) {
+            throw new WaffleException(e);
+        } finally {
+            try {
+                if (inputStream != null)
+                    inputStream.close();
+                if (bufferedReader != null)
+                    bufferedReader.close();
+            } catch (IOException ignore) {
+                // ignore
+            }
+        }
+    }
+
+}

Modified: sandbox/v2experiment/waffle-ruby/src/test/java/org/codehaus/waffle/context/pico/RubyPicoContextContainerFactoryTest.java (870 => 871)

--- sandbox/v2experiment/waffle-ruby/src/test/java/org/codehaus/waffle/context/pico/RubyPicoContextContainerFactoryTest.java	2009-01-15 11:40:40 UTC (rev 870)
+++ sandbox/v2experiment/waffle-ruby/src/test/java/org/codehaus/waffle/context/pico/RubyPicoContextContainerFactoryTest.java	2009-01-15 11:43:31 UTC (rev 871)
@@ -1,7 +1,7 @@
 package org.codehaus.waffle.context.pico;
 
-import org.codehaus.waffle.context.ContextContainer;
 import org.codehaus.waffle.monitor.SilentMonitor;
+import org.codehaus.waffle.ruby.context.RubyContextContainerFactory;
 import org.jruby.Ruby;
 import org.jruby.RubyBoolean;
 import org.jruby.RubyInteger;
@@ -10,14 +10,13 @@
 import static org.junit.Assert.assertTrue;
 import org.junit.Test;
 import org.picocontainer.MutablePicoContainer;
-import org.picocontainer.PicoContainer;
 
 public class RubyPicoContextContainerFactoryTest  {
 
     @Test
     public void canBuildApplicationContextContainer() {
-        RubyPicoContextContainerFactory factory
-                = new RubyPicoContextContainerFactory(null, new SilentMonitor(), new SilentMonitor(), null);
+        RubyContextContainerFactory factory
+                = new RubyContextContainerFactory(null, new SilentMonitor(), new SilentMonitor(), null);
         MutablePicoContainer contextContainer = factory.buildApplicationContextContainer();
         Ruby runtime = contextContainer.getComponent(Ruby.class);
         assertNotNull(runtime);


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to