Permalink
Browse files

Added namespace support (binding variable, new category method, cover…

…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...
1 parent 6062dc8 commit cd458ebf745f41c43007d643aed93baf6b1bbac9 @glaforge glaforge committed Sep 10, 2010
Showing with 1,395 additions and 204 deletions.
  1. +12 −2 core/build.groovy
  2. +5 −0 core/src/main/groovyx/gaelyk/GaelykBindingEnhancer.groovy
  3. +30 −0 core/src/main/groovyx/gaelyk/GaelykCategory.groovy
  4. +51 −0 core/src/test/groovyx/gaelyk/NamespaceCategoryMethodsTest.groovy
  5. BIN template-project/war/WEB-INF/lib/gaelyk-0.4.3.jar
  6. BIN template-project/war/WEB-INF/lib/gaelyk-0.4.4.jar
  7. BIN website/war/WEB-INF/lib/gaelyk-0.4.3.jar
  8. BIN website/war/WEB-INF/lib/gaelyk-0.4.4.jar
  9. +4 −2 website/war/api/allclasses-frame.html
  10. +4 −4 website/war/api/deprecated-list.html
  11. +4 −4 website/war/api/groovyx/gaelyk/ExpirationTimeCategory.html
  12. +4 −4 website/war/api/groovyx/gaelyk/GaelykBindingEnhancer.html
  13. +34 −6 website/war/api/groovyx/gaelyk/GaelykCategory.html
  14. +4 −10 website/war/api/groovyx/gaelyk/GaelykIncomingEmailServlet.html
  15. +4 −22 website/war/api/groovyx/gaelyk/GaelykServlet.html
  16. +4 −22 website/war/api/groovyx/gaelyk/GaelykTemplateServlet.html
  17. +4 −10 website/war/api/groovyx/gaelyk/GaelykXmppServlet.html
  18. +4 −4 website/war/api/groovyx/gaelyk/QueueAccessor.html
  19. +225 −0 website/war/api/groovyx/gaelyk/cache/CacheHandler.html
  20. +355 −0 website/war/api/groovyx/gaelyk/cache/CachedResponse.CustomServletOutputStream.html
  21. +361 −0 website/war/api/groovyx/gaelyk/cache/CachedResponse.html
  22. +38 −0 website/war/api/groovyx/gaelyk/cache/package-frame.html
  23. +124 −0 website/war/api/groovyx/gaelyk/cache/package-summary.html
  24. +4 −4 website/war/api/groovyx/gaelyk/logging/GroovyLogger.html
  25. +4 −4 website/war/api/groovyx/gaelyk/logging/LoggerAccessor.html
  26. +2 −2 website/war/api/groovyx/gaelyk/logging/package-summary.html
  27. +2 −2 website/war/api/groovyx/gaelyk/package-summary.html
  28. +4 −10 website/war/api/groovyx/gaelyk/plugins/LazyBinding.html
  29. +4 −16 website/war/api/groovyx/gaelyk/plugins/PluginBaseScript.html
  30. +4 −4 website/war/api/groovyx/gaelyk/plugins/PluginsHandler.html
  31. +4 −10 website/war/api/groovyx/gaelyk/plugins/PluginsListBaseScript.html
  32. +2 −2 website/war/api/groovyx/gaelyk/plugins/package-summary.html
  33. +4 −4 website/war/api/groovyx/gaelyk/routes/HttpMethod.html
  34. +4 −4 website/war/api/groovyx/gaelyk/routes/RedirectionType.html
  35. +4 −4 website/war/api/groovyx/gaelyk/routes/Route.html
  36. +4 −10 website/war/api/groovyx/gaelyk/routes/RoutesBaseScript.html
  37. +4 −4 website/war/api/groovyx/gaelyk/routes/RoutesFilter.html
  38. +1 −1 website/war/api/groovyx/gaelyk/routes/package-frame.html
  39. +2 −12 website/war/api/groovyx/gaelyk/routes/package-summary.html
  40. +4 −4 website/war/api/help-doc.html
  41. +19 −12 website/war/api/index-all.html
  42. +5 −2 website/war/api/overview-frame.html
  43. +1 −0 website/war/api/package-list
  44. +8 −0 website/war/download.gtpl
  45. +34 −3 website/war/tutorial.gtpl
View
@@ -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"
@@ -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)"
@@ -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."
}
}
@@ -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.
@@ -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)
+
}
}
@@ -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
@@ -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)
+ }
+ }
+
}
@@ -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 not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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>
@@ -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">
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -172,7 +172,7 @@
"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
@@ -574,6 +574,18 @@
<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>
+ </TD>
+ <TD>
<CODE><b><a href="#putAt(MemcacheService, java.lang.String, java.lang.Object)">putAt</a></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)</CODE>
<BR>
<P>Put an object into the cache, identified by its key, using the subscript notation:
@@ -837,7 +849,7 @@
"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
@@ -1283,6 +1295,22 @@
</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>
@@ -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>
@@ -177,12 +177,6 @@
</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>
Oops, something went wrong.

0 comments on commit cd458eb

Please sign in to comment.