Skip to content

Commit

Permalink
Added namespace support (binding variable, new category method, cover…
Browse files Browse the repository at this point in the history
…ed in the tutorial)

Upped the release version to 0.4.4
Updated the Javadocs
Fixed some a couple typos in the tutorial
  • Loading branch information
glaforge committed Sep 10, 2010
1 parent 6062dc8 commit cd458eb
Show file tree
Hide file tree
Showing 45 changed files with 1,395 additions and 204 deletions.
14 changes: 12 additions & 2 deletions core/build.groovy
@@ -1,7 +1,7 @@
new AntBuilder().sequential {

// current Gaelyk version
version = '0.4.3'
version = '0.4.4'

// various directory places and file names
src = "src/main"
Expand All @@ -16,7 +16,9 @@ new AntBuilder().sequential {
zipname = "${target}/gaelyk-template-project-${version}.zip"
projLib = "${tmpProj}/war/WEB-INF/lib"

apidir = "../website/war/api"
website = "../website"
apidir = "${website}/war/api"
websiteLib = "${website}/war/WEB-INF/lib"

if (!args) {
echo "Usage: groovy build (jar|template|javadoc|dist)"
Expand Down Expand Up @@ -72,6 +74,14 @@ new AntBuilder().sequential {
}
}

if (action == 'dist') {
echo "Updating the Gaelyk JAR of the website"
delete {
fileset dir: websiteLib, includes: "gaelyk-*.jar"
}
copy file: jarname, todir: websiteLib
}

echo "Done."
}
}
5 changes: 5 additions & 0 deletions core/src/main/groovyx/gaelyk/GaelykBindingEnhancer.groovy
Expand Up @@ -29,6 +29,7 @@ import com.google.appengine.api.blobstore.BlobstoreServiceFactory
import com.google.appengine.api.utils.SystemProperty
import groovyx.gaelyk.logging.LoggerAccessor
import com.google.appengine.api.oauth.OAuthServiceFactory
import com.google.appengine.api.NamespaceManager

/**
* Class responsible for adding adding Google App Engine related services into the binding of Groovlets and Templates.
Expand Down Expand Up @@ -84,5 +85,9 @@ class GaelykBindingEnhancer {
binding.setVariable("logger", new LoggerAccessor())

binding.setVariable("oauth", OAuthServiceFactory.OAuthService)

// Namespace added in SDK 1.3.7
binding.setVariable("namespace", NamespaceManager)

}
}
30 changes: 30 additions & 0 deletions core/src/main/groovyx/gaelyk/GaelykCategory.groovy
Expand Up @@ -54,6 +54,7 @@ import com.google.appengine.api.blobstore.BlobstoreServiceFactory
import com.google.appengine.api.blobstore.BlobstoreFailureException
import javax.servlet.http.HttpServletResponse
import com.google.appengine.api.datastore.Key
import com.google.appengine.api.NamespaceManager

/**
* Category methods decorating the Google App Engine SDK classes
Expand Down Expand Up @@ -884,4 +885,33 @@ class GaelykCategory {
fetchData(selfKey, byteRange.start, byteRange.end)
}

// ----------------------------------------------------------------
// Category methods dedicated to the NamespaceManager
// ----------------------------------------------------------------

/**
* Use a namespace in the context of the excution of the closure.
* This method will save the original namespace and restore it afterwards.
*
* <pre><code>
* namespace.of('test') { ... }
* </code></pre>
*
* @param nm NamespaceManager class
* @param ns the name of the namespace to use
* @param c the code to execute under that namespace
*/
static void of(Class nm, String ns, Closure c) {
if (nm != NamespaceManager)
throw new MissingMethodException("with", nm, [ns, c] as Object[])

def oldNs = NamespaceManager.get()
NamespaceManager.set(ns)
try {
c()
} finally {
NamespaceManager.set(oldNs)
}
}

}
51 changes: 51 additions & 0 deletions core/src/test/groovyx/gaelyk/NamespaceCategoryMethodsTest.groovy
@@ -0,0 +1,51 @@
package groovyx.gaelyk

import com.google.appengine.api.NamespaceManager
import com.google.appengine.tools.development.testing.LocalServiceTestHelper

/**
* Test the category methods associated with the NamespaceManager class introduced in SDK 1.3.7.
*
* @author Guillaume Laforge
*/
class NamespaceCategoryMethodsTest extends GroovyTestCase {

def namespace = NamespaceManager

// setup the local environement so the NamespaceManager is initialized
private LocalServiceTestHelper helper = new LocalServiceTestHelper()

protected void setUp() {
super.setUp()
helper.setUp()
}

protected void tearDown() {
super.tearDown()
helper.tearDown()
}

void testNamespaceOf() {
use(GaelykCategory) {
def oldNs = namespace.get()
boolean executed = false

namespace.of("customerA") {
executed = true
assert namespace.get() == "customerA"
}
assert executed

def currentNs = namespace.get()
// check that the original namespace is restored
assert oldNs == currentNs
}
}

void testAnExceptionIsThrownWhenUsingCategoryMethodWithWrongClass() {
shouldFail(MissingMethodException) {
Integer.of("foo") {}
}
}

}
Binary file removed template-project/war/WEB-INF/lib/gaelyk-0.4.3.jar
Binary file not shown.
Binary file not shown.
Binary file removed website/war/WEB-INF/lib/gaelyk-0.4.3.jar
Binary file not shown.
Binary file added website/war/WEB-INF/lib/gaelyk-0.4.4.jar
Binary file not shown.
6 changes: 4 additions & 2 deletions website/war/api/allclasses-frame.html
Expand Up @@ -21,9 +21,11 @@
<TD NOWRAP><FONT CLASS="FrameItemFont">
<!--<A HREF="org/omg/CORBA/ARG_IN.html" title="interface in org.omg.CORBA" target="classFrame"><I>ARG_IN</I></A>-->
<!--<BR>-->
<A HREF="groovyx/gaelyk/routes/CachedResponse.html" title="class in groovyx.gaelyk.routes" target="classFrame">CachedResponse</A>
<A HREF="groovyx/gaelyk/cache/CacheHandler.html" title="class in groovyx.gaelyk.cache" target="classFrame">CacheHandler</A>
<BR>
<A HREF="groovyx/gaelyk/routes/CachedResponse.CustomServletOutputStream.html" title="class in groovyx.gaelyk.routes.CachedResponse" target="classFrame">CachedResponse.CustomServletOutputStream</A>
<A HREF="groovyx/gaelyk/cache/CachedResponse.html" title="class in groovyx.gaelyk.cache" target="classFrame">CachedResponse</A>
<BR>
<A HREF="groovyx/gaelyk/cache/CachedResponse.CustomServletOutputStream.html" title="class in groovyx.gaelyk.cache.CachedResponse" target="classFrame">CachedResponse.CustomServletOutputStream</A>
<BR>
<A HREF="groovyx/gaelyk/ExpirationTimeCategory.html" title="class in groovyx.gaelyk" target="classFrame">ExpirationTimeCategory</A>
<BR>
Expand Down
8 changes: 4 additions & 4 deletions website/war/api/deprecated-list.html
Expand Up @@ -2,9 +2,9 @@

<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<!-- Generated by groovydoc (1.7.4) on -->
<title>Deprecated API (Gaelyk 0.4.3)</title>
<meta name="date" content="2010-07-31">
<!-- Generated by groovydoc (1.8.0-beta-2-SNAPSHOT) on -->
<title>Deprecated API (Gaelyk 0.4.4)</title>
<meta name="date" content="2010-09-10">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<link href="groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="groovy.ico" type="image/x-icon" rel="icon">
Expand All @@ -13,7 +13,7 @@
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Deprecated API (Gaelyk 0.4.3)";
parent.document.title="Deprecated API (Gaelyk 0.4.4)";
}
}
</script>
Expand Down
8 changes: 4 additions & 4 deletions website/war/api/groovyx/gaelyk/ExpirationTimeCategory.html
Expand Up @@ -6,17 +6,17 @@

<html>
<head>
<!-- Generated by groovydoc (1.7.4) on Sat Jul 31 11:50:39 CEST 2010 -->
<title>ExpirationTimeCategory (Gaelyk 0.4.3)</title>
<meta name="date" content="2010-07-31">
<!-- Generated by groovydoc (1.8.0-beta-2-SNAPSHOT) on Fri Sep 10 17:14:19 CEST 2010 -->
<title>ExpirationTimeCategory (Gaelyk 0.4.4)</title>
<meta name="date" content="2010-09-10">
<link href="../../groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="../../groovy.ico" type="image/x-icon" rel="icon">
<link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style">
<script type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="ExpirationTimeCategory (Gaelyk 0.4.3)";
parent.document.title="ExpirationTimeCategory (Gaelyk 0.4.4)";
}
}
</script>
Expand Down
8 changes: 4 additions & 4 deletions website/war/api/groovyx/gaelyk/GaelykBindingEnhancer.html
Expand Up @@ -6,17 +6,17 @@

<html>
<head>
<!-- Generated by groovydoc (1.7.4) on Sat Jul 31 11:50:39 CEST 2010 -->
<title>GaelykBindingEnhancer (Gaelyk 0.4.3)</title>
<meta name="date" content="2010-07-31">
<!-- Generated by groovydoc (1.8.0-beta-2-SNAPSHOT) on Fri Sep 10 17:14:19 CEST 2010 -->
<title>GaelykBindingEnhancer (Gaelyk 0.4.4)</title>
<meta name="date" content="2010-09-10">
<link href="../../groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="../../groovy.ico" type="image/x-icon" rel="icon">
<link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style">
<script type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="GaelykBindingEnhancer (Gaelyk 0.4.3)";
parent.document.title="GaelykBindingEnhancer (Gaelyk 0.4.4)";
}
}
</script>
Expand Down
40 changes: 34 additions & 6 deletions website/war/api/groovyx/gaelyk/GaelykCategory.html
Expand Up @@ -6,17 +6,17 @@

<html>
<head>
<!-- Generated by groovydoc (1.7.4) on Sat Jul 31 11:50:39 CEST 2010 -->
<title>GaelykCategory (Gaelyk 0.4.3)</title>
<meta name="date" content="2010-07-31">
<!-- Generated by groovydoc (1.8.0-beta-2-SNAPSHOT) on Fri Sep 10 17:14:19 CEST 2010 -->
<title>GaelykCategory (Gaelyk 0.4.4)</title>
<meta name="date" content="2010-09-10">
<link href="../../groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="../../groovy.ico" type="image/x-icon" rel="icon">
<link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style">
<script type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="GaelykCategory (Gaelyk 0.4.3)";
parent.document.title="GaelykCategory (Gaelyk 0.4.4)";
}
}
</script>
Expand Down Expand Up @@ -172,7 +172,7 @@ <H2>
"http://www.google.com" as Link
"+3361234543" as PhoneNumber
"50 avenue de la Madeleine, Paris" as PostalAddress
"groovy" as Category
"groovy" as DatastoreCategory
"32" as Rating
"long text" as Text
"foobar" as BlobKey
Expand Down Expand Up @@ -569,6 +569,18 @@ <H2>
</TD>
</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1" CLASS="ClassItemFont">
<CODE>static&nbsp;void</CODE></FONT>
</TD>
<TD>
<CODE><b><a href="#of(java.lang.Class, java.lang.String, groovy.lang.Closure)">of</a></b>(<a href='http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html' title='Class'>Class</a> nm, <a href='http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html' title='String'>String</a> ns, <a href='http://groovy.codehaus.org/gapi/groovy/lang/Closure.html' title='Closure'>Closure</a> c)</CODE>
<BR>
<P>Use a namespace in the context of the excution of the closure.
</P>
</TD>
</TR>

<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1" CLASS="ClassItemFont">
<CODE>static&nbsp;void</CODE></FONT>
Expand Down Expand Up @@ -837,7 +849,7 @@ <H2>
"http://www.google.com" as Link
"+3361234543" as PhoneNumber
"50 avenue de la Madeleine, Paris" as PostalAddress
"groovy" as Category
"groovy" as DatastoreCategory
"32" as Rating
"long text" as Text
"foobar" as BlobKey
Expand Down Expand Up @@ -1283,6 +1295,22 @@ <H2>
</DL>
<HR>

<A NAME="of(java.lang.Class, java.lang.String, groovy.lang.Closure)"><!-- --></A><H3>
of</H3>
<PRE>static&nbsp;void <B>of</B>(<a href='http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html' title='Class'>Class</a> nm, <a href='http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html' title='String'>String</a> ns, <a href='http://groovy.codehaus.org/gapi/groovy/lang/Closure.html' title='Closure'>Closure</a> c)</PRE>
<DL>
<DD> Use a namespace in the context of the excution of the closure.
This method will save the original namespace and restore it afterwards.

<pre><code>
namespace.of('test') { ... }
</code></pre>
<DL><DT><B>Parameters:</B></DT><DD><code>nm</code> - NamespaceManager class</DD><DD><code>ns</code> - the name of the namespace to use</DD><DD><code>c</code> - the code to execute under that namespace</DD></DL>
</DD>
<P>
</DL>
<HR>

<A NAME="putAt(MemcacheService, java.lang.String, java.lang.Object)"><!-- --></A><H3>
putAt</H3>
<PRE>static&nbsp;void <B>putAt</B>(<a href='../../MemcacheService.html'>MemcacheService</a> memcache, <a href='http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html' title='String'>String</a> key, <a href='http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html' title='Object'>Object</a> value)</PRE>
Expand Down
14 changes: 4 additions & 10 deletions website/war/api/groovyx/gaelyk/GaelykIncomingEmailServlet.html
Expand Up @@ -6,17 +6,17 @@

<html>
<head>
<!-- Generated by groovydoc (1.7.4) on Sat Jul 31 11:50:39 CEST 2010 -->
<title>GaelykIncomingEmailServlet (Gaelyk 0.4.3)</title>
<meta name="date" content="2010-07-31">
<!-- Generated by groovydoc (1.8.0-beta-2-SNAPSHOT) on Fri Sep 10 17:14:19 CEST 2010 -->
<title>GaelykIncomingEmailServlet (Gaelyk 0.4.4)</title>
<meta name="date" content="2010-09-10">
<link href="../../groovy.ico" type="image/x-icon" rel="shortcut icon">
<link href="../../groovy.ico" type="image/x-icon" rel="icon">
<link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style">
<script type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="GaelykIncomingEmailServlet (Gaelyk 0.4.3)";
parent.document.title="GaelykIncomingEmailServlet (Gaelyk 0.4.4)";
}
}
</script>
Expand Down Expand Up @@ -177,12 +177,6 @@ <H2>
</th></tr>
<tr class="TableRowColor"><td colspan='2'><a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#getInitParameter(java.lang.String)' title='getInitParameter'>getInitParameter</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#getInitParameterNames()' title='getInitParameterNames'>getInitParameterNames</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#getServletConfig()' title='getServletConfig'>getServletConfig</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#getServletContext()' title='getServletContext'>getServletContext</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#getServletInfo()' title='getServletInfo'>getServletInfo</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#getServletName()' title='getServletName'>getServletName</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#init(javax.servlet.ServletConfig)' title='init'>init</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#init()' title='init'>init</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#destroy()' title='destroy'>destroy</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#log(java.lang.String)' title='log'>log</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#log(java.lang.String, java.lang.Throwable)' title='log'>log</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)' title='service'>service</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#hashCode()' title='hashCode'>hashCode</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#getClass()' title='getClass'>getClass</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#equals(java.lang.Object)' title='equals'>equals</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#toString()' title='toString'>toString</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#wait(long, int)' title='wait'>wait</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#wait(long)' title='wait'>wait</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#wait()' title='wait'>wait</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#notify()' title='notify'>notify</a>, <a href='http://java.sun.com/javaee/5/docs/api/javax/servlet/GenericServlet.html#notifyAll()' title='notifyAll'>notifyAll</a></td></tr>
</table>
&nbsp;<table BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<tr CLASS="TableSubHeadingColor"><th ALIGN="left" COLSPAN="2">
<b>Methods inherited from class <a href='http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html' title='Object'>Object</a></b>
</th></tr>
<tr class="TableRowColor"><td colspan='2'><a href='http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#hashCode()' title='hashCode'>hashCode</a>, <a href='http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#getClass()' title='getClass'>getClass</a>, <a href='http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#equals(java.lang.Object)' title='equals'>equals</a>, <a href='http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#toString()' title='toString'>toString</a>, <a href='http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#wait(long, int)' title='wait'>wait</a>, <a href='http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#wait(long)' title='wait'>wait</a>, <a href='http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#wait()' title='wait'>wait</a>, <a href='http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#notify()' title='notify'>notify</a>, <a href='http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#notifyAll()' title='notifyAll'>notifyAll</a></td></tr>
</table>
&nbsp;

<P>
Expand Down

0 comments on commit cd458eb

Please sign in to comment.