From b3f227b3be49ca5634eea4a063744a08dfe62a24 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Manuel=20Carrasco=20Mo=C3=B1ino?= Date: Tue, 26 Nov 2013 19:53:07 +0100 Subject: [PATCH] forgot delete this file --- .../client/plugins/deferred/PromiseRF.java | 99 ------------------- 1 file changed, 99 deletions(-) delete mode 100644 gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseRF.java diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseRF.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseRF.java deleted file mode 100644 index 5f573a1d..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/PromiseRF.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2013, The gwtquery team. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.query.client.plugins.deferred; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import javax.validation.ConstraintViolation; - -import com.google.gwt.query.client.plugins.deferred.Deferred.DeferredPromiseImpl; -import com.google.web.bindery.requestfactory.shared.Receiver; -import com.google.web.bindery.requestfactory.shared.Request; -import com.google.web.bindery.requestfactory.shared.RequestContext; -import com.google.web.bindery.requestfactory.shared.ServerFailure; - -/** - * Utility class used to create promises for RequestFactory services. - *
- *    Request req1 = loginFact.api().login(null, null);
- *    Request req2 = srvFact.api().getCurrentUser();
- *    
- *    // We can use `when` to append different requests
- *    Promise requestingAll = Deferred.when(new PromiseRF(req1), new PromiseRF(req2);
- *    // Or we can use just one promise for multiple RF requests
- *    Promise requestingAll = new PromiseRF(req1, req2);
- *    
- *    requestingAll.done(new Function() {
- *        public void f() {
- *          SessionProxy session = arguments(0, 0);
- *          UserProxy user = arguments(1, 0);
- *        }
- *      })
- *      .fail(new Function() {
- *        public void f() {
- *          ServerFailure failure = arguments(0);
- *        }
- *      }); 
- * 
- */ -public class PromiseRF extends DeferredPromiseImpl { - private int total = 0; - private List responses = new ArrayList(); - private List contexts = new ArrayList(); - - /** - * Fire a RF Request. - */ - public PromiseRF(Request request) { - this(new Request[] {request}); - } - - /** - * Fire multiple RF Requests. - * - * Unlike RequestContext.append which only supports compatible requests, - * we can append any kind of requestContexts here. - */ - public PromiseRF(Request[] requests) { - for (Request request : requests) { - total ++; - request.to(new Receiver() { - public void onConstraintViolation(Set> violations) { - dfd.reject(new ServerFailure("ConstraintViolation"), violations); - } - public void onFailure(ServerFailure error) { - dfd.reject(error); - } - public void onSuccess(Object response) { - responses.add(response); - // Resolve only when all requests have been received - if (responses.size() == total) { - dfd.resolve(responses.toArray(new Object[responses.size()])); - } - } - }); - if (!contexts.contains(request.getRequestContext())) { - contexts.add(request.getRequestContext()); - } - } - - // We fire each context instead of appending them so as we can deal - // with different request factories. - for (RequestContext ctx : contexts) { - ctx.fire(); - } - } -} -- 2.39.5