<?xml version="1.0" encoding="utf-8"?>
<!-- 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
-->
<?xml-stylesheet type="text/xsl" href="https://rollerweblogger.org/roller-ui/styles/rss.xsl" media="screen"?><rss version="2.0" 
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
  <title>Blogging Roller</title>
  <link>https://rollerweblogger.org/roller/</link>
    <atom:link rel="self" type="application/rss+xml" href="https://rollerweblogger.org/roller/feed/entries/rss?tags=jruby" />
  <description>Dave Johnson on open web technologies, social software and software development</description>
  <language>en-us</language>
  <copyright>Copyright 2026</copyright>
  <lastBuildDate>Tue, 7 Apr 2026 09:28:33 +0000</lastBuildDate>
  <generator>Apache Roller 6.1.5</generator>
  <item>
    <guid isPermaLink="true">https://rollerweblogger.org/roller/entry/jruby_on_roller</guid>
    <title>JRuby on Roller</title>
    <dc:creator>Dave Johnson</dc:creator>
    <link>https://rollerweblogger.org/roller/entry/jruby_on_roller</link>
    <pubDate>Tue, 20 Mar 2007 21:46:23 +0000</pubDate>
    <category>Roller</category>
    <category>java</category>
    <category>jruby</category>
    <category>roller</category>
<description>&lt;p&gt;This is just a quick follow-up to my previous post on &lt;a href=&quot;http://rollerweblogger.org/roller/entry/groovy_roller_redux&quot;&gt;Pluggable renderers and scripting languages in Roller&lt;/a&gt;. It took me a while, but I finally made &lt;a href=&quot;http://jruby.codehaus.org/&quot;&gt;JRuby&lt;/a&gt; code work inside a Roller page template. Here&amp;#39;s an example JRuby page template that displays most recent blog titles and text in HTML format.&lt;br&gt;&lt;/p&gt;&lt;pre&gt;&lt;p&gt;$out.println &amp;quot;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;quot;&lt;br&gt;$out.println &amp;quot;&amp;lt;title&amp;gt;#{$model.weblog.name}&amp;lt;/title&amp;gt;&amp;quot;&lt;br&gt;$out.println &amp;quot;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;&amp;quot;&lt;br&gt;$out.println &amp;quot;&amp;lt;h1&amp;gt;#{$model.weblog.name}&amp;lt;/h1&amp;gt;&amp;quot;&lt;br&gt;$model.weblogEntriesPager.entries.keySet().each {|day|&lt;br&gt;&amp;nbsp;&amp;nbsp; $model.weblogEntriesPager.entries.get(day).each {|entry|&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $out.println &amp;quot;&amp;lt;h3&amp;gt;#{entry.title}&amp;lt;/h3&amp;gt;&amp;quot;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $out.println &amp;quot;&amp;lt;p&amp;gt;#{entry.text}&amp;lt;/p&amp;gt;&amp;quot;&lt;br&gt;&amp;nbsp;&amp;nbsp; } &lt;br&gt;}&lt;br&gt;$out.println &amp;quot;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&amp;quot;&lt;/p&gt;&lt;/pre&gt;

Not the most beautiful thing in the world, I must admit. Any JRuby experts reading along? Is there a simple templating solution that will work in JRuby... something like Groovy Templates? And is there a way to map puts output to a java.io.Writer that will work via BSF?&lt;br&gt;</description>  </item>
  <item>
    <guid isPermaLink="true">https://rollerweblogger.org/roller/entry/groovy_roller_redux</guid>
    <title>Pluggable renderers and scripting languages in Roller</title>
    <dc:creator>Dave Johnson</dc:creator>
    <link>https://rollerweblogger.org/roller/entry/groovy_roller_redux</link>
    <pubDate>Sun, 11 Mar 2007 23:45:03 +0000</pubDate>
    <category>Roller</category>
    <category>groovy</category>
    <category>javascript</category>
    <category>jruby</category>
    <category>roller</category>
    <category>scripting</category>
<atom:summary type="html">My next ApacheCon talk is about &lt;a href=&quot;http://www.eu.apachecon.com/program/talk/87&quot;&gt;Roller and blogs as a web development platform&lt;/a&gt;.
One of the things I plan to discuss is using scripting languages within
Roller, something that&amp;#39;s possible now because Roller versions 3.0 and
later supports pluggable renderers. It&amp;#39;s undocumented and a little hacky right now, but by plugging in your own custom
renderers you can add support for new template and scripting languages
as alternatives to Roller&amp;#39;s built-in &lt;a href=&quot;http://velocity.apache.org/&quot;&gt;Velocity&lt;/a&gt;. Want to know more?&amp;nbsp;</atom:summary><description>&lt;p&gt;My next ApacheCon talk is about &lt;a href=&quot;http://www.eu.apachecon.com/program/talk/87&quot;&gt;Roller and blogs as a web development platform&lt;/a&gt;. One of the things I plan to discuss is using scripting languages within Roller, something that&amp;#39;s possible now because Roller versions 3.0 and later allows pluggable renderers. It&amp;#39;s undocumented and a little hacky right now, but by plugging in your own custom renderers you can add support for new template and scripting languages as alternatives to Roller&amp;#39;s built-in &lt;a href=&quot;http://velocity.apache.org/&quot;&gt;Velocity&lt;/a&gt;. Here are some notes on the whys and hows.&lt;br&gt; &lt;/p&gt;&lt;p&gt;&lt;b&gt;Why would you want to plugin a new scripting or template language?&lt;br&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;I can think of two reasons you might want to plug-in a new renderer to Roller. If you&amp;#39;re not happy with Velocity and want to plugin an alternative template language like Freemarker you can do it with a custom renderer. Or, if you&amp;#39;re developing sophisticated Roller templates and you need a more sophisticated programming language like Groovy, JRuby or Javascript then custom renderers are your best bet.&lt;b&gt;&lt;br&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;What can you do in an alternative scripting or template language?&lt;/b&gt;&lt;/p&gt;&lt;p&gt;In an alternative template or scripting language you can access the normal Roller model objects (see the &lt;a href=&quot;http://people.apache.org/~snoopdave/roller30-template-guide.pdf&quot;&gt;Roller Template Guide&lt;/a&gt; for a reference) and you can generate just about any type of content you want. However, you cannot access the Roller macros because they&amp;#39;re written in and require Velocity.&lt;br&gt; &lt;/p&gt;&lt;p&gt;It&amp;#39;s also worth noting that you can get in quite a bit of trouble with an alternative language. Roller&amp;#39;s built-in Velocity renderer allows users to access only a very limited set of objects, but other scripting and template languages might not be so safe. That&amp;#39;s why you might not want to make all plugin renderers available to all of your users.&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;How do you implement scripting in a plugin renderer?&lt;br&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;I plan on documenting the process at some point, but basically you implement two simple interfaces: &lt;a href=&quot;http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/RendererFactory.java?revision=443329&amp;amp;view=markup&quot;&gt;RendererFactory&lt;/a&gt; and &lt;a href=&quot;http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/Renderer.java?revision=443329&amp;amp;view=markup&quot;&gt;Renderer&lt;/a&gt;. So far, I&amp;#39;ve developed three plugin renderers: BSFRenderer, GroovletRenderer and GSPRenderer. Let&amp;#39;s discuss each so you can see how they work.&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;A BSFRenderer example&lt;/b&gt;&lt;/p&gt;&lt;p&gt;The &lt;a href=&quot;http://jakarta.apache.org/bsf/&quot;&gt;Bean Scripting Framework&lt;/a&gt; (BSF)&amp;nbsp;  makes it easy to call a wide variety of scripting languages from Java and because it works with Java SE 5, it&amp;#39;s a better choice for Roller than the Java SE 6 scripting extensions. I developed a BSF renderer (&lt;a href=&quot;http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/scripting/bsf/src/org/apache/roller/scripting/BSFRendererFactory.java?revision=517070&amp;amp;view=markup&quot;&gt;BSFRendererFactory&lt;/a&gt; and &lt;a href=&quot;http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/scripting/bsf/src/org/apache/roller/scripting/BSFRenderer.java?revision=517070&amp;amp;view=markup&quot;&gt;BSFRenderer&lt;/a&gt;) and with it, it&amp;#39;s theoretically possible to
support the use of just about any BSF scripting language in a Roller
template. I&amp;#39;ve tried Groovy and JavaScript and they both work fine, but JRuby has some conflicts with the version of Hibernate that we&amp;#39;re using in Roller so I&amp;#39;ll have to revisit JRuby later. &lt;/p&gt;&lt;p&gt;Unfortunately, with the BSFRenderer you&amp;#39;re stuck writing Servlet-like code like this Groovy example:&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; out.println(&amp;quot;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;quot;)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; out.println(&amp;quot;Hello World, my blog is ${model.weblog.name}&amp;quot;);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; out.println(&amp;quot;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&amp;quot;); &lt;/p&gt;&lt;p&gt;Ugh. Nothing to write home about, that&amp;#39;s for sure. Fortunately, there&amp;#39;s something better.&lt;/p&gt;&lt;p&gt;&lt;b&gt;A GroovletRenderer example&lt;/b&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;I also developed a GroovletRenderer and a Groovy Server Pages (GSP) GSPRenderer, which look more promising. These renderers call Groovy directly and behave like the &lt;a href=&quot;http://groovy.codehaus.org/Groovlets&quot;&gt;Groovlet&lt;/a&gt; and &lt;a href=&quot;http://groovy.codehaus.org/Groovy+Templates&quot;&gt;Groovy Template&lt;/a&gt; Servlets that come with Groovy.&lt;/p&gt;&lt;p&gt;With my new GroovletRenderer (&lt;a href=&quot;http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/scripting/groovy/src/org/apache/roller/scripting/GroovletRendererFactory.java?view=markup&quot;&gt;GroovletRendererFactory&lt;/a&gt; and &lt;a href=&quot;http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/scripting/groovy/src/org/apache/roller/scripting/GroovletRenderer.java?view=markup&quot;&gt;GroovletRenderer&lt;/a&gt;), you can use the GroovyMarkup builder to build HTML. Here&amp;#39;s an example that displays a blog title, description and most recent entries:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; html.html { // html is implicitly bound to new MarkupBuilder(out)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; head {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; title(model.weblog.name)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; body {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h1(model.weblog.name)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i(model.weblog.description)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map = model.getWeblogEntriesPager().getEntries();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.keySet().each() {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.get(it).each() {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h2(it.title)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p(it.text)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; br()&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&lt;/p&gt;&lt;p&gt;Starting to look more interesting, no? &lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;A GSPRenderer example&lt;/b&gt;&lt;/p&gt;&lt;p&gt;I also developed a GSPRenderer &lt;a href=&quot;http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/scripting/groovy/src/org/apache/roller/scripting/GSPRendererFactory.java?view=markup&quot;&gt;(GSPRendererFactory&lt;/a&gt; and &lt;a href=&quot;http://svn.apache.org/viewvc/incubator/roller/trunk/sandbox/scripting/groovy/src/org/apache/roller/scripting/GSPRendererFactory.java?view=markup&quot;&gt;GSPRenderer&lt;/a&gt;), which allows you to use a JSP like syntax with &amp;lt;% %&amp;gt; and &amp;lt;%= %&amp;gt;. Here&amp;#39;s the above example, but rewritten as a Roller GSP page:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;html&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;head&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title&amp;gt;${model.weblog.name}&amp;lt;/title&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/head&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;body&amp;gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;lt;h1&amp;gt;${model.weblog.name}&amp;lt;/h1&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;i&amp;gt;${model.weblog.description}&amp;lt;/i&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;% map = model.getWeblogEntriesPager().getEntries();&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.keySet().each() { %&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;% map.get(it).each() { %&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;h2&amp;gt;${it.title}&amp;lt;/h2&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;p&amp;gt;${it.text}&amp;lt;/p&amp;gt;&amp;lt;br /&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;% } &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }%&amp;gt; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/body&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/html&amp;gt; &lt;br&gt;&lt;/p&gt;&lt;p&gt;That&amp;#39;s all I have time for tonight. Next I hope tackle JRuby and hopefully I&amp;#39;ll find some way to support some form of JRuby templating too. Where is all this going? I don&amp;#39;t know. I&amp;#39;m not sure these plugins will make it into the Roller 4.0 release, but I do hope to make it easier to drop them and renderer plugins like them into Roller 4.0. &lt;/p&gt;</description>  </item>
  <item>
    <guid isPermaLink="true">https://rollerweblogger.org/roller/entry/jruby_on_the_javaposse</guid>
    <title>JRuby on the JavaPosse</title>
    <dc:creator>Dave Johnson</dc:creator>
    <link>https://rollerweblogger.org/roller/entry/jruby_on_the_javaposse</link>
    <pubDate>Thu, 18 Jan 2007 09:36:00 +0000</pubDate>
    <category>Java</category>
    <category>jruby</category>
<description>&lt;p&gt;Interested in the &lt;a href=&quot;http://jruby.org&quot;&gt;JRuby&lt;/a&gt; project? Then you should check out the JavaPosse podcast &lt;a href=&quot;http://javaposse.com/index.php?post_id=171709&quot;&gt;interview with JRuby developers Charles Nutter and Thomas Enebo&lt;/a&gt;. They cover project status, JRuby vs. CRuby, Ruby on Rails on the JVM and their new jobs at Sun.&lt;/p&gt;</description>  </item>
</channel>
</rss>