<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog &#187; eclipse</title>
	<atom:link href="http://blog.cliffano.com/tag/eclipse/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.cliffano.com</link>
	<description>Geeking, Living, Travelling</description>
	<lastBuildDate>Thu, 26 Jan 2012 10:18:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Sitebricks And SiteMesh On Google App Engine</title>
		<link>http://blog.cliffano.com/2009/12/06/sitebricks-and-sitemesh-on-google-app-engine/</link>
		<comments>http://blog.cliffano.com/2009/12/06/sitebricks-and-sitemesh-on-google-app-engine/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 05:01:23 +0000</pubDate>
		<dc:creator>Cliffano Subagio</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[app engine]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[sitebricks]]></category>
		<category><![CDATA[sitemesh]]></category>

		<guid isPermaLink="false">http://blog.cliffano.com/?p=812</guid>
		<description><![CDATA[For the past couple of weeks, I&#8217;ve been trying various web framework stacks to be used with Google App Engine. The ones that I gave a go, and gave a pass for various reasons, were Stapler (the enchilada that powers Hudson), Spring, and RestEasy + htmleasy. The search continued and I came across Sitebricks, still [...]]]></description>
			<content:encoded><![CDATA[<p>For the past couple of weeks, I&#8217;ve been trying various web framework stacks to be used with <a href="http://code.google.com/appengine/">Google App Engine</a>. The ones that I gave a go, and gave a pass for various reasons, were <a href="https://stapler.dev.java.net/">Stapler</a> (the enchilada that powers <a href="http://hudson-ci.org/">Hudson</a>), <a href="http://www.springsource.org/">Spring</a>, and <a href="http://www.jboss.org/resteasy/">RestEasy</a> + <a href="http://code.google.com/p/htmleasy/">htmleasy</a>.</p>
<p>The search continued and I came across <a href="http://code.google.com/p/google-sitebricks/">Sitebricks</a>, still in its alpha phase but it looks really promising. Simple and straightforward, nothing too magicky, and I got it working with GAE/J in no time.</p>
<p>To guide others who might want to give Sitebricks on Google App Engine a try, here&#8217;s what I did: (and please note that this is a miminalist guide, enough to get a simple page up and running)</p>
<ol>
<li>Using <a href="http://code.google.com/eclipse/">Google Plugin for Eclipse</a>, create a new Google Web Application Project with Google App Engine enabled and Google Web Toolkit disabled.</li>
<li>Since Sitebricks didn&#8217;t have any official release yet, I had to build the jar from the sitebricks-0.7 tag using<br />
<code>mvn install -Dmaven.test.skip=true</code><br />
. Unfortunately some of the unit tests on the trunk failed so I just skipped them, hey it&#8217;s still in alpha.</li>
<li>The above command downloaded all the dependency jars and generated a Sitebricks SNAPSHOT jar at &lt;M2_REPO&gt;/com/google/sitebricks . Copy the following jars to the Eclipse project&#8217;s /war/WEB-INF/lib directory and add them to the build path.
<ul>
<li>sitebricks-0.7.jar</li>
<li>guice-2.0.jar</li>
<li>guice-servlet-2.0.jar</li>
<li>google-collections-1.0-rc3.jar</li>
<li>aopalliance-1.0.jar</li>
<li>mvel2-2.0.14.jar</li>
<li>dom4j-1.6.1.jar</li>
<li>commons-io-1.4.jar</li>
</ul>
</li>
<li>Create the following files in src/your/package/name.<br />
GuiceInit.java</p>
<pre class="brush: java; title: ; notranslate">
public class GuiceInit extends GuiceServletContextListener {

    @Override
    public Injector getInjector() {
        return Guice.createInjector(new SitebricksModule() {
            @Override
            protected void configureSitebricks() {
                scan(FooBar.class.getPackage());
            }
        });
    }
}
</pre>
<p>FooBar.java</p>
<pre class="brush: java; title: ; notranslate">
@At(&quot;/barkleyzone&quot;)
public class FooBar {

    public String getQuote() {
        return &quot;I have nothing against old people; I want to be one myself one day&quot;;
    }

    public String getName() {
        return &quot;Charles Barkley&quot;;
    }
}
</pre>
</li>
<li>
Create FooBar.html in /war.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div&gt;
    ${name} said &quot;${quote}&quot;.
&lt;/div&gt;
</pre>
</li>
<li>
Add GuiceInit servlet context listener and GuiceFilter to /war/WEB-INF/web.xml.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;filter&gt;
    &lt;filter-name&gt;webFilter&lt;/filter-name&gt;
    &lt;filter-class&gt;com.google.inject.servlet.GuiceFilter&lt;/filter-class&gt;
&lt;/filter&gt;
&lt;filter-mapping&gt;
    &lt;filter-name&gt;webFilter&lt;/filter-name&gt;
    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;
&lt;listener&gt;
    &lt;listener-class&gt;your.package.name.GuiceInit&lt;/listener-class&gt;
&lt;/listener&gt;
</pre>
</li>
<li>Enable sessions by adding this line in /war/WEB-INF/appengine-web.xml .
<pre class="brush: xml; title: ; notranslate">
&lt;sessions-enabled&gt;true&lt;/sessions-enabled&gt;
</pre>
</li>
<li>Use Eclipse Run -&gt; Run As -&gt; Web Application to start the application and visit http://localhost:8080/barkleyzone and you should see this message:
<pre class="brush: plain; title: ; notranslate">
Charles Barkley said &quot;I have nothing against old people; I want to be one myself one day.&quot;
</pre>
</li>
</ol>
<p>As for a page layout / templating solution, <a href="http://www.opensymphony.com/sitemesh/">SiteMesh</a> has always been a personal favourite.</p>
<ol>
<li>Download <a href="https://sitemesh.dev.java.net/servlets/ProjectDocumentList?folderID=11231">sitemesh-2.4.2.jar</a>, place it in /war/WEB-INF/lib directory and add it to the build path.
</li>
<li>
Create /war/templates/main.jsp .</p>
<pre class="brush: xml; title: ; notranslate">
&lt;%@ taglib uri=&quot;http://www.opensymphony.com/sitemesh/decorator&quot; prefix=&quot;decorator&quot; %&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Test&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;decorator:body/&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
</li>
<li>
Create /war/WEB-INF/decorators.xml .</p>
<pre class="brush: xml; title: ; notranslate">
&lt;decorators defaultdir=&quot;/templates/&quot;&gt;
    &lt;decorator name=&quot;main&quot; page=&quot;main.jsp&quot;&gt;
        &lt;pattern&gt;/*&lt;/pattern&gt;
    &lt;/decorator&gt;
&lt;/decorators&gt;
</pre>
</li>
<li>
Add SiteMeshFilter to /war/WEB-INF/web.xml .</p>
<pre class="brush: xml; title: ; notranslate">
&lt;filter&gt;
    &lt;filter-name&gt;sitemesh&lt;/filter-name&gt;
    &lt;filter-class&gt;com.opensymphony.sitemesh.webapp.SiteMeshFilter&lt;/filter-class&gt;
&lt;/filter&gt;
&lt;filter-mapping&gt;
    &lt;filter-name&gt;sitemesh&lt;/filter-name&gt;
    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;
</pre>
</li>
<li>Use Eclipse to stop and start the application, view the HTML source of http://localhost:8080/barkleyzone and you should see the HTML layout wrapping the original div element.</li>
</ol>

<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fblog.cliffano.com%2F2009%2F12%2F06%2Fsitebricks-and-sitemesh-on-google-app-engine%2F" layout="standard" show_faces="false" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cliffano.com/2009/12/06/sitebricks-and-sitemesh-on-google-app-engine/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

