<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>BlackBox : Tag chama</title>
    <link>http://www.warneronstine.com/blog/articles/tag/chama</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Where technology and art disappear</description>
    <item>
      <title>MetaClass/Delegate warning</title>
      <description>&lt;p&gt;I&amp;#8217;ve been working like a fiend on &lt;a href="http://warneronstine.com/cgi-bin/trac.cgi"&gt;Chama&lt;/a&gt; and am just about ready for an alpha release (not much but will have some basic model and dao creation from a groovy dsl paired with database goodness). Like a good programmer I have been building stuff up in chunks so that I can test everything separately and now this morning I started finally integrating everything together and blammo! something strange was happening.&lt;/p&gt;

&lt;p&gt;The first part of this puzzle lies in &lt;a href="http://www.warneronstine.com/cgi-bin/trac.cgi/browser/trunk/src/main/groovy/org/chama/builder/model/QueryBuilder.groovy"&gt;&lt;code&gt;QueryBuilder.groovy&lt;/code&gt;&lt;/a&gt;, this class is a builder that eventually will get called from inside of a finder method (like &lt;code&gt;findAll()&lt;/code&gt;) and get parsed by another meta class, but more on that in a minute. Inside of &lt;code&gt;QueryBuilder&lt;/code&gt; I do some checks on whether we are passing a closure or not, if we are then I set the delegate class to the current &lt;code&gt;QueryBuilder&lt;/code&gt; instance and call the closure. Thus, when the closure continues processing the next interior method of the closure gets called it calls the &lt;code&gt;QueryBuilder&lt;/code&gt; again allowing me to create new restrictions inside the current criteria. Running my tests and everything works as expected. Now for the strange part.&lt;/p&gt;

&lt;p&gt;In the next part I created a new class &lt;a href="http://www.warneronstine.com/cgi-bin/trac.cgi/browser/trunk/src/main/groovy/org/chama/builder/model/JavaModelDAOBuilder.groovy"&gt;&lt;code&gt;JavaModelDAOBuilder.groovy&lt;/code&gt;&lt;/a&gt; which will actually parse a Groovy script and call each method in turn through a custom meta class called &lt;code&gt;MethodInterceptor&lt;/code&gt;. This meta class has now essentially taken first responder position to any method calls that happen on the Groovy script. Which actually sounds good on the surface, until I discovered that a closure is actually &amp;#8220;owned&amp;#8221; by its class. Now that the class has a meta class it will intercept all calls to the closure, completely bypassing the delegate.&lt;/p&gt;

&lt;p&gt;After some digging I can see how this makes sense and after sending a message to the list I got some great responses. The final solution that Jochen(Blackdrag) came up with is to set a flag so that meta classes can &amp;#8220;delegate&amp;#8221; to another delegate. I think that this is definitely a workable solution, but for now I have some kind of hacky solution in the &lt;code&gt;MethodInterceptor&lt;/code&gt; so that it looks for anything that the delegate should actually be handling and pass it back to that instance.&lt;/p&gt;

&lt;p&gt;The good news is that it looks like this will be fixed in the near future, for those of us really pushing Groovy&amp;#8217;s Meta Object Programming (MOP) and I think I&amp;#8217;m going to be joining the dev list so that I can watch those conversations (especially the MOP-related ones). On another note I&amp;#8217;m working on a few more Meta-related posts that will hopefully be of interest to some people ;-).&lt;/p&gt;</description>
      <pubDate>Mon, 04 Jun 2007 20:32:22 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:3499c5f8-4aff-4379-abf9-856da2c0b536</guid>
      <author>Warner Onstine</author>
      <link>http://www.warneronstine.com/blog/articles/2007/06/04/metaclass-delegate-warning</link>
      <category>programming</category>
      <category>groovy</category>
      <category>dsl</category>
      <category>chama</category>
      <category>mop</category>
      <trackback:ping>http://www.warneronstine.com/blog/articles/trackback/294</trackback:ping>
    </item>
    <item>
      <title>First Maven plugin</title>
      <description>&lt;p&gt;I&amp;#8217;ve been working on &lt;a href="http://warneronstine.com/cgi-bin/trac.cgi"&gt;Chama&lt;/a&gt; recently and have been making some good progress. One of the last big hurdles before getting all of the Model, View, Controller generation working has been:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Connecting to a database and gathering metadata - 90% complete (just have the relationship, primary key, foreign key stuff to work out)&lt;/li&gt;
&lt;li&gt;Getting Chama packaged up as a real distributable app that you can download and get up and going quickly&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Rather than go through a whole bunch of Ant copy scripts and integrating that with my Maven build I decided to write a plugin that would copy everything over into a specific directory structure and zip up for me (and I can also add in the tar.gz stuff real easy now too). I gotta say it wasn&amp;#8217;t &lt;em&gt;too&lt;/em&gt; difficult, although the docs leave a lot to be desired in this department. With all the plugins out there you would think this would be more fleshed out, especially since they want everyone to move away from the old Jelly scripts that people wrote in Maven 1. Anyways, it&amp;#8217;s fairly simple to do with some caveats.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There appear to be no docs on what all the custom expressions are such as:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;expression="${project}"&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;expression="${project.build.directory}"&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;expression="${component.org.codehaus.plexus.archiver.manager.ArchiverManager}"&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Or if you can actually use expressions like these when setting default values of properties (you can, at least that&amp;#8217;s what I&amp;#8217;ve gathered by looking at other plugins)&lt;/li&gt;
&lt;li&gt;And if you do or do not need to have getters and setters for your variables that you&amp;#8217;ve &amp;#8220;annotated&amp;#8221; (I say that in quotes because it doesn&amp;#8217;t act like true annotations, or at least there isn&amp;#8217;t a package in Maven called annotations where you can find docs on all of these)
&lt;ul&gt;
&lt;li&gt;My assumption is that at least the setters are necessary so that it can use those to populate the variables you want Maven to populate your plugin with)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All that said it was mostly easy to write my little packaging plugin as I was willing to dig through the source code of some of the existing plugins that were doing similar things (&lt;a href="http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/"&gt;maven-assembly-plugin&lt;/a&gt; and &lt;a href="http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/"&gt;maven-war-plugin&lt;/a&gt;). That isn&amp;#8217;t to say that I&amp;#8217;m 100% sure I understand exactly how everything works (good idea but not 100% ;-).&lt;/p&gt;

&lt;p&gt;If I get a chance I&amp;#8217;ll see if I can contribute something a little more to the plugin docs than what is there currently because others shouldn&amp;#8217;t have to do what I did to get through this and it isn&amp;#8217;t that difficult once you know the secret handshake.&lt;/p&gt;</description>
      <pubDate>Thu, 21 Dec 2006 22:04:27 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:7c902436-527a-4d5b-ae69-e3372e899787</guid>
      <author>Warner Onstine</author>
      <link>http://www.warneronstine.com/blog/articles/2006/12/21/first-maven-plugin</link>
      <category>programming</category>
      <category>maven</category>
      <category>java</category>
      <category>chama</category>
      <trackback:ping>http://www.warneronstine.com/blog/articles/trackback/231</trackback:ping>
    </item>
    <item>
      <title>New project &amp;quot;Chama&amp;quot;</title>
      <description>&lt;p&gt;So, where has all this DSL stuff been leading? One of my projects that has been sitting on the back-burner for a while has been &lt;a href="http://warneronstine.com/cgi-bin/trac.cgi/"&gt;Chama&lt;/a&gt;. Chama was born out of the frustration of writing the same boiler-plate code over and over for database-backed sites that are run on Tapestry. While you can certainly use something like Trails I was not happy with the additional amount of configuration I needed to do in order to get the forms to look and behave the way I wanted them to.&lt;/p&gt;

&lt;p&gt;Why not use Ruby on Rails then, or even &lt;a href="http://grails.codehaus.org"&gt;Grails&lt;/a&gt; if I want to stick with the Java theme?&lt;/p&gt;

&lt;p&gt;A variety of reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I'm familiar with Tapestry, Hibernate, etc.&lt;/li&gt;
&lt;li&gt;I'm very familiar with Java&lt;/li&gt;
&lt;li&gt;I want to learn &lt;a href="http://groovy.codehaus.org"&gt;Groovy&lt;/a&gt; as a language&lt;/li&gt;
&lt;li&gt;I don't want to switch out my deployment options to have to deal with deploying my apps to a new server and having to configure it all over again so that it'll run RoR&lt;/li&gt;
&lt;li&gt;I like generators ;-), no really this is an exercise that I want to undertake and if others find value in it that's great&lt;/li&gt;
&lt;li&gt;Mostly to make it easier for me to get some app ideas I've had off of the ground&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What will Chama use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Groovy as the primary language, with some Java thrown in where needed&lt;/li&gt;
&lt;li&gt;Most likely &lt;a href="http://yaml.org/"&gt;Yaml&lt;/a&gt; for configuration with &lt;a href="http://jyaml.sourceforge.net/"&gt;JYaml&lt;/a&gt; for dealing with it&lt;/li&gt;
&lt;li&gt;Quite possibly several DSLs for each area (Model, View, Controller)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I don't know yet exactly how far I'm going to take Chama, mostly I just want to get a tool together that will help me build stuff. If others find value in it and it gets extended from there and heads in a direction I never thought about, great! All the code will be available under an Apache License once I start working on stuff. I have some tentative dates setup in my &lt;a href="http://warneronstine.com/cgi-bin/trac.cgi/"&gt;Trac&lt;/a&gt; instance (what?! using Python for a Java app?). Comments are welcome, and I will use this blog to announce releases as they happen, the first milestone is set for 12/22/06 (oops was tomorrow, moving to two weeks, wow it's been two weeks since I first set this up already).&lt;/p&gt;</description>
      <pubDate>Thu, 07 Dec 2006 22:50:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:9acd0cf1-1b27-4e2e-a9f1-913a59d5ab06</guid>
      <author>Warner Onstine</author>
      <link>http://www.warneronstine.com/blog/articles/2006/12/07/new-project-chama</link>
      <category>programming</category>
      <category>dsl</category>
      <category>java</category>
      <category>tapestry</category>
      <category>groovy</category>
      <category>chama</category>
      <trackback:ping>http://www.warneronstine.com/blog/articles/trackback/4</trackback:ping>
    </item>
  </channel>
</rss>
