Permalink
Browse files

extension methods javafication

  • Loading branch information...
1 parent fb89fc4 commit 4c7664845468c34a2927c779b1f1793f2103525f @musketyr musketyr committed Nov 29, 2013
Showing with 1,977 additions and 1,591 deletions.
  1. +13 −0 core/src/main/groovyx/gaelyk/RetryingFuture.groovy
  2. +17 −14 core/src/main/groovyx/gaelyk/extensions/{BackendExtensions.groovy → BackendExtensions.java}
  3. +106 −93 core/src/main/groovyx/gaelyk/extensions/{BlobstoreExtensions.groovy → BlobstoreExtensions.java}
  4. +9 −11 .../src/main/groovyx/gaelyk/extensions/{CapabilitiesExtensions.groovy → CapabilitiesExtensions.java}
  5. +6 −8 core/src/main/groovyx/gaelyk/extensions/{ChannelExtensions.groovy → ChannelExtensions.java}
  6. +0 −248 core/src/main/groovyx/gaelyk/extensions/FilesExtensions.groovy
  7. +368 −0 core/src/main/groovyx/gaelyk/extensions/FilesExtensions.java
  8. +42 −51 core/src/main/groovyx/gaelyk/extensions/{ImageExtensions.groovy → ImageExtensions.java}
  9. +18 −0 core/src/main/groovyx/gaelyk/extensions/ImageTransformationsBuilder.java
  10. +0 −106 core/src/main/groovyx/gaelyk/extensions/MailExtensions.groovy
  11. +157 −0 core/src/main/groovyx/gaelyk/extensions/MailExtensions.java
  12. +83 −100 core/src/main/groovyx/gaelyk/extensions/{MemcacheExtensions.groovy → MemcacheExtensions.java}
  13. +10 −10 ...ain/groovyx/gaelyk/extensions/{NamespaceStaticExtensions.groovy → NamespaceStaticExtensions.java}
  14. +0 −293 core/src/main/groovyx/gaelyk/extensions/SearchExtensions.groovy
  15. +303 −0 core/src/main/groovyx/gaelyk/extensions/SearchExtensions.java
  16. +0 −177 core/src/main/groovyx/gaelyk/extensions/TaskQueueExtensions.groovy
  17. +218 −0 core/src/main/groovyx/gaelyk/extensions/TaskQueueExtensions.java
  18. +0 −198 core/src/main/groovyx/gaelyk/extensions/UrlFetchExtensions.groovy
  19. +286 −0 core/src/main/groovyx/gaelyk/extensions/UrlFetchExtensions.java
  20. +0 −280 core/src/main/groovyx/gaelyk/extensions/XmppExtensions.groovy
  21. +331 −0 core/src/main/groovyx/gaelyk/extensions/XmppExtensions.java
  22. +8 −0 core/src/main/groovyx/gaelyk/search/QueryBuilder.groovy
  23. +2 −2 core/src/test/groovyx/gaelyk/cache/MemcacheExtensionMethodsTest.groovy
@@ -45,6 +45,19 @@ class RetryingFuture<R> implements Future<R> {
}
new RetryingFuture(retries, factory)
}
+
+ /**
+ * Creates new retry future which retries particular times before failing
+ * @param retries number of retries
+ * @param factory closure to construct the future
+ * @return future which retries particular times before failing
+ */
+ static <R> Future<R> retry(int retries, Callable<Future<R>> factory){
+ if(retries <= 0){
+ return factory()
+ }
+ new RetryingFuture(retries, factory)
+ }
@Override public boolean cancel(boolean mayInterruptIfRunning) {
@@ -13,19 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package groovyx.gaelyk.extensions
+package groovyx.gaelyk.extensions;
-import groovy.transform.CompileStatic
-import com.google.appengine.api.LifecycleManager
-import com.google.appengine.api.backends.BackendService
-import com.google.appengine.api.ThreadManager
+import org.codehaus.groovy.runtime.DefaultGroovyMethods;
+
+import groovy.lang.Closure;
+import groovy.lang.DelegatesTo;
+
+import com.google.appengine.api.LifecycleManager;
+import com.google.appengine.api.ThreadManager;
+import com.google.appengine.api.backends.BackendService;
/**
- * Backend service extension methods
+ * Backend service extension methods.
*
- * @author Guillaume Laforge
+ * @author Guillaume Laforge, Vladmir Orany
*/
-class BackendExtensions {
+public class BackendExtensions {
/**
* Shortcut to use closures as shutdown hooks.
@@ -36,19 +40,18 @@
* @param manager the lifecycle manager
* @param c the closure as shutdown hook
*/
- static void shutdownHook(LifecycleManager manager, @DelegatesTo(LifecycleManager.ShutdownHook) Closure c) {
- manager.setShutdownHook(c as LifecycleManager.ShutdownHook)
+ public static void shutdownHook(LifecycleManager manager, @DelegatesTo(LifecycleManager.ShutdownHook.class) Closure<?> c) {
+ manager.setShutdownHook(DefaultGroovyMethods.asType(c, LifecycleManager.ShutdownHook.class));
}
/**
* Runs code in the background thread.
*
* @param the code supposed to run in background thread
*/
- @CompileStatic
- static Thread run(BackendService backends, Runnable code){
+ public static Thread run(BackendService backends, Runnable code){
Thread thread = ThreadManager.createBackgroundThread(code);
- thread.start()
- thread
+ thread.start();
+ return thread;
}
}
Oops, something went wrong.

0 comments on commit 4c76648

Please sign in to comment.