Examples of Promise


Examples of com.amazonaws.services.simpleworkflow.flow.core.Promise

                }
            }

            @Override
            protected void doFinally() throws Throwable {
                Promise r = methodResult.get();
                if (r == null || r.isReady()) {
                    Object workflowResult = r == null ? null : r.get();
                    String convertedResult = dataConverter.toData(workflowResult);
                    result.set(convertedResult);
                }
            }
        };
View Full Code Here

Examples of com.google.gwt.query.client.Promise

          // We filter resolved arguments with the filter function
          Object newArgs = filter.setArguments(oldArgs).f(oldArgs);

          if (newArgs instanceof Promise) {
            // If filter function returns a promise we pipeline it.
            final Promise p = (Promise) newArgs;
            if (type == PROGRESS) {
              p.progress(new Function(){public void f() {
                settle(PROGRESS, getArguments());
              }});
            } else {
              p.always(new Function(){public void f() {
                settle((type == DONE || type == FAIL && cont) && p.isResolved() ? DONE : FAIL, getArguments());
              }});
            }
          } else {
            // Otherwise we change the arguments by the new ones
            newArgs = Boolean.TRUE.equals(newArgs) ? oldArgs :
View Full Code Here

Examples of com.google.gwt.query.client.Promise

          // We filter resolved arguments with the filter function
          Object newArgs = filter.setArguments(oldArgs).f(oldArgs);

          if (newArgs instanceof Promise) {
            // If filter function returns a promise we pipeline it.
            final Promise p = (Promise) newArgs;
            if (type == PROGRESS) {
              p.progress(new Function(){public void f() {
                settle(PROGRESS, getArguments());
              }});
            } else {
              p.always(new Function(){public void f() {
                settle((type == DONE || type == FAIL && cont) && p.isResolved() ? DONE : FAIL, getArguments());
              }});
            }
          } else {
            // Otherwise we change the arguments by the new ones
            newArgs = Boolean.TRUE.equals(newArgs) ? oldArgs :
View Full Code Here

Examples of com.google.gwt.query.client.Promise

      onError.setElement(settings.getContext());
    }

    final String dataType = settings.getDataType();

    Promise ret = null;

    if ("jsonp".equalsIgnoreCase(dataType)) {
      ret = GQ.getAjaxTransport().getJsonP(settings);
    } else if ("loadscript".equalsIgnoreCase(dataType)){
      ret = GQ.getAjaxTransport().getLoadScript(settings);
    } else {
      ret = GQ.getAjaxTransport().getXhr(settings)
        .then(new Function() {
          public Object f(Object...args) {
            Response response = arguments(0);
            Request request = arguments(1);
            Object retData = response.getText();
            if (retData != null && !"".equals(retData)) {
              try {
                if ("xml".equalsIgnoreCase(dataType)) {
                  retData = JsUtils.parseXML(response.getText());
                } else if ("json".equalsIgnoreCase(dataType)) {
                  retData = GQ.create(response.getText());
                } else {
                  retData = response.getText();
                  if ("script".equalsIgnoreCase(dataType)) {
                    ScriptInjector.fromString((String)retData).setWindow(window).inject();
                  }
                }
              } catch (Exception e) {
                if (GWT.isClient() && GWT.getUncaughtExceptionHandler() != null) {
                  GWT.getUncaughtExceptionHandler().onUncaughtException(e);
                } else {
                  e.printStackTrace();
                }
              }
            }
            return new Object[]{retData, "success", request, response};
          }
        }, new Function() {
          public Object f(Object...args) {
            Throwable exception = arguments(0);
            Request request = getArgument(1, Request.class);
            String msg = String.valueOf(exception);
            return new Object[]{null, msg, request, null, exception};
          }
        });
    }
    if (onSuccess != null) {
      ret.done(onSuccess);
    }
    if (onError != null) {
      ret.fail(onError);
    }
    return ret;
  }
View Full Code Here

Examples of com.google.gwt.query.client.Promise

    loadAngular();
  }

  private void loadAngular() {
    if(!isInjected()) {
      Promise loadAngular = new ScriptLoader();

      loadAngular.done(new Function() {
        public void f() {
          Browser.getWindow().getConsole().info("loading angularjs succeeded.");
          injectModules();         
        }
      });

      loadAngular.fail(new Function() {
        public void f() {
          Browser.getWindow().getConsole().warn("loading angularjs failed.");
        }
      });
View Full Code Here

Examples of com.sleepycat.je.rep.elections.Protocol.Promise

                        throw new HigherNumberedProposal(me.target);
                    } else if (me.getResponseMessage().getOp() ==
                            elections.getProtocol().PROMISE) {
                        result.promisories.add(me.target);
                        result.promisoryMessages.add(me);
                        Promise accept = (Promise) me.getResponseMessage();
                        Proposal acceptProposal = accept.getHighestProposal();
                        if ((result.acceptProposal == null) ||
                            ((acceptProposal != null) &&
                             (acceptProposal.compareTo(result.acceptProposal) >
                              0))) {
                            result.acceptProposal = acceptProposal;
                            result.acceptedValue = accept.getAcceptedValue();
                        }
                    } else if (me.getResponseMessage().getOp() ==
                               elections.getProtocol().PROTOCOL_ERROR){
                        ProtocolError protocolError =
                            (ProtocolError) me.getResponseMessage();
View Full Code Here

Examples of com.sleepycat.je.rep.elections.Protocol.Promise

        for (MessageExchange me : exchanges) {
            if (me.getResponseMessage().getOp() !=
                elections.getProtocol().PROMISE) {
                continue;
            }
            final Promise p = (Promise) me.getResponseMessage();

            if (p.getPriority() == 0) {
                zeroPrioNodes++;
                continue;
            }

            if (calculator.skipPromiseDueToVersion(p.getLogVersion())) {
                continue;
            }

            if (p.getSuggestionRanking() < maxRanking) {
               continue;
            }

            /* Use priority as a tie breaker. */
            if (p.getSuggestionRanking() == maxRanking) {
              if (p.getPriority() < maxPriority) {
                  continue;
              }
              /*
               * Use socket address to choose in case of a tie, so we
               * always have a consistent ordering.
               */
              if ((p.getPriority() ==  maxPriority) &&
                  ((maxTarget != null) &&
                   (me.target.toString().compareTo(maxTarget) <= 0))) {
                  continue;
              }
            }

            acceptorValue = p.getSuggestion();
            maxRanking = p.getSuggestionRanking();
            maxPriority = p.getPriority();
            maxTarget = me.target.toString();
        }

        if ((acceptorValue == null) && (zeroPrioNodes > 0)) {
            LoggerUtils.logMsg(logger, elections.getRepImpl(),
View Full Code Here

Examples of com.sleepycat.je.rep.elections.Protocol.Promise

                if (me.getResponseMessage().getOp() !=
                    elections.getProtocol().PROMISE) {
                    continue;
                }

                Promise p = (Promise) me.getResponseMessage();

                if (p.getLogVersion() < lowestVersion) {
                    lowestVersion = p.getLogVersion();
                }

                if (!logFormats.containsKey(p.getLogVersion())) {
                    logFormats.put(p.getLogVersion(), 1);
                } else {
                    logFormats.put(p.getLogVersion(),
                                   logFormats.get(p.getLogVersion()) + 1);
                }
            }

            /*
             * If there is only log version in the whole group, return and do
View Full Code Here

Examples of com.sleepycat.je.rep.elections.Protocol.Promise

        for (MessageExchange me : exchanges) {
            if (me.getResponseMessage().getOp() !=
                elections.getProtocol().PROMISE) {
                continue;
            }
            final Promise p = (Promise) me.getResponseMessage();
            if (p.getSuggestionRanking() < maxRanking) {
               continue;
            }
            /* Use priority as a tie breaker. */
            if (p.getSuggestionRanking() == maxRanking) {
              if (p.getPriority() < maxPriority) {
                  continue;
              }
              /*
               * Use socket address to choose in case of a tie, so we
               * always have a consistent ordering.
               */
              if ((p.getPriority() ==  maxPriority) &&
                  ((maxTarget != null) &&
                   (me.target.toString().compareTo(maxTarget) <= 0))) {
                  continue;
              }
            }

            acceptorValue = p.getSuggestion();
            maxRanking = p.getSuggestionRanking();
            maxPriority = p.getPriority();
            maxTarget = me.target.toString();
        }

        if (acceptorValue == null) {
            throw EnvironmentFailureException.unexpectedState
View Full Code Here

Examples of com.sleepycat.je.rep.elections.Protocol.Promise

                        throw new HigherNumberedProposal(me.target);
                    } else if (me.getResponseMessage().getOp() ==
                            elections.getProtocol().PROMISE) {
                        result.promisories.add(me.target);
                        result.promisoryMessages.add(me);
                        Promise accept = (Promise) me.getResponseMessage();
                        Proposal acceptProposal = accept.getHighestProposal();
                        if ((result.acceptProposal == null) ||
                            ((acceptProposal != null) &&
                             (acceptProposal.compareTo(result.acceptProposal) >
                              0))) {
                            result.acceptProposal = acceptProposal;
                            result.acceptedValue = accept.getAcceptedValue();
                        }
                    } else if (me.getResponseMessage().getOp() ==
                               elections.getProtocol().PROTOCOL_ERROR){
                        ProtocolError protocolError =
                            (ProtocolError) me.getResponseMessage();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.