Examples of Callable


Examples of EDU.oswego.cs.dl.util.concurrent.Callable

      closeAllSuckers();     
     
      //Note we use a timed callable since remoting has a habit of hanging on attempting to close
      //We do not want this to hang the system - especially failover
     
      Callable callable = new Callable() { public Object call()
      {
        try
        {
          connection.close();
        }
        catch (JMSException ignore)
        {         
        }
        return null;
        } };
     
      Callable timedCallable = new TimedCallable(callable, CLOSE_TIMEOUT);
     
      try
      {
        timedCallable.call();
      }
      catch (Throwable t)
      {
        //Ignore - the server might have already closed - so this is ok
      }
View Full Code Here

Examples of com.caucho.quercus.env.Callable

      return NullValue.NULL;

    ArrayValue filteredArray = new ArrayValueImpl();

    if (! callbackName.isDefault()) {
      Callable callback = callbackName.toCallable(env);
     
      if (callback == null || ! callback.isValid(env)) {
        return NullValue.NULL;
      }

      try {
        Iterator<Map.Entry<Value,Value>> iter = array.getIterator(env);

        while (iter.hasNext()) {
          Map.Entry<Value,Value> entry = iter.next();
         
          Value key = entry.getKey();
          Value value;
         
          if (entry instanceof ArrayValue.Entry)
            value = ((ArrayValue.Entry) entry).getRawValue();
          else
            value = entry.getValue();
          // php/1740         
          boolean isMatch
            = callback.callArray(env, array, key, value).toBoolean();
         
          if (isMatch)
            filteredArray.put(key, value);
        }
      }
View Full Code Here

Examples of com.google.gxp.compiler.base.Callable

    }

    public Expression visitUnboundCall(UnboundCall call) {
      TemplateName calleeName = call.getCallee();
      Map<String, Attribute> params = call.getAttributes();
      Callable callee = params.containsKey(Implementable.INSTANCE_PARAM_NAME)
          ? serviceDirectory.getInstanceCallable(calleeName)
          : serviceDirectory.getCallable(calleeName);

      if (callee == null) {
        alertSink.add(new CallableNotFoundError(call, calleeName));
        return new StringConstant(call, null, "");
      } else {
        final ImmutableMap.Builder<String, Attribute> newAttrBuilder = ImmutableMap.builder();

        // construct a Map of attribute bundles with one entry for each bundle parameter
        final Map<String, Map<AttributeValidator, Attribute>> attrBundles
            = Maps.newLinkedHashMap();
        for (FormalParameter parameter : callee.getParameters()) {
          if (parameter.getType() instanceof BundleType) {
            attrBundles.put(parameter.getPrimaryName(),
                            new LinkedHashMap<AttributeValidator, Attribute>());
          }
        }

        for (final Map.Entry<String, Attribute> param : params.entrySet()) {
          final String name = param.getKey();
          final FormalParameter parameter = callee.getParameter(name);
          Attribute attr = param.getValue();
          if (parameter == null) {
            alertSink.add(new BadParameterError(attr.getValue(), callee, name));
            continue;
          }
          // TODO(harryh): maybe better to use a  DefaultingExpressionVisitor
          //               here?
          if (attr.getValue() instanceof ObjectConstant) {
            ObjectConstant oc = (ObjectConstant) attr.getValue();
            // TODO(harryh): maybe this should be in Validator?
            if (!parameter.regexMatches(oc)) {
              alertSink.add(new InvalidParameterFailedRegexError(
                                calleeName, name, parameter.getRegex(), oc));
            }
            attr = parameter.hasConstructor()
                ? attr.withValue(new ConstructedConstant(oc, oc.getValue(), callee, parameter))
                : attr.withValue(parameter.getType().parseObjectConstant(name, oc, alertSink));
          }

          attr = attr.withValue(prepareExpressionAsParameterValue(parameter, attr.getValue()));

          final Attribute updatedAttr = visitAttribute(attr);

          parameter.getType().acceptTypeVisitor(new DefaultingTypeVisitor<Void>() {
            protected Void defaultVisitType(Type type) {
              newAttrBuilder.put(name, updatedAttr);
              return null;
            }

            public Void visitBundleType(BundleType type) {
              final AttributeValidator validator = type.getValidator(name);
              String innerContentTypeString = validator.getContentType();
              if (innerContentTypeString != null) {
                Schema innerSchema = schemaFactory.fromContentTypeName(innerContentTypeString);
                attrBundles.get(parameter.getPrimaryName()).put(validator,
                                                         updatedAttr.withInnerSchema(innerSchema));
              } else {
                attrBundles.get(parameter.getPrimaryName()).put(validator, updatedAttr);
              }
              return null;
            }
          });
        }

        // go through the attrBundleMap and turn each entry into an
        // AttrBundleParam and put this into the builder map.
        for (Map.Entry<String, Map<AttributeValidator, Attribute>> attrBundle :
                attrBundles.entrySet()) {
          FormalParameter parameter = callee.getParameterByPrimary(attrBundle.getKey());
          BundleType bt = (BundleType) parameter.getType();

          // special case for the (common case) of a single bundle on the
          // callee side. In this case there is no mixing of attributes
          // between bundles so the GxpAttrBundleBuilder does not need to
          // include only some attributes from passed in bundles.  See the
          // empty constructor in j/c/g/gxp/base/GxpAttrBundleBuilder.java
          Set<String> includeAttrs = (attrBundles.size() == 1)
              ? Collections.<String>emptySet() : bt.getAttrMap().keySet();

          AttrBundleParam newBundle =
              new AttrBundleParam(call, callee.getSchema(), includeAttrs,
                                  attrBundle.getValue(), call.getAttrBundles());

          newAttrBuilder.put(attrBundle.getKey(),
                             new Attribute(call, attrBundle.getKey(),
                                           newBundle, null));
        }

        // Handle content parameter
        FormalParameter contentParam = callee.getContentConsumingParameter();
        Expression content = prepareExpressionAsParameterValue(contentParam,
                                                               apply(call.getContent()));
        boolean contentIgnorable = content.alwaysOnlyWhitespace();
        if (contentParam == null) {
          if (!contentIgnorable) {
View Full Code Here

Examples of com.google.gxp.compiler.base.Callable

    public Call visitUnboundCall(UnboundCall call) {
      throw new UnexpectedNodeException(call);
    }

    public Call visitBoundCall(final BoundCall call) {
      Callable callee = call.getCallee();

      final ImmutableMap.Builder<String, Attribute> newAttrBuilder = ImmutableMap.builder();

      // this is a map of all Name->AttributeValidators for the bundles
      // parameters of the callee.  We will remove items from the map
      // as they are found.
      Map<String, AttributeValidator> validatorMap = Maps.newHashMap();

      for (FormalParameter parameter : callee.getParameters()) {
        if (parameter.getType() instanceof BundleType) {
          // build up validatorMap
          BundleType calleeBundle = (BundleType) parameter.getType();
          validatorMap.putAll(calleeBundle.getAttrMap());
        }
      }

      // this is a set of all allowed attributes for the call attr bundles
      // it remains unchanged for the entire execution of this function
      Set<String> allowedAttributes = ImmutableSet.copyOf(validatorMap.keySet());

      for (final Map.Entry<String, Attribute> param : call.getAttributes().entrySet()) {
        Expression actualArgument = param.getValue().getValue();
        if (actualArgument instanceof AttrBundleParam) {
          AttrBundleParam bundle = (AttrBundleParam) actualArgument;
          for (Map.Entry<AttributeValidator, Attribute> attr : bundle.getAttrs().entrySet()) {
            validatorMap.remove(attr.getKey().getName());
            if (attr.getValue().getCondition() != null
                && attr.getKey().isFlagSet(AttributeValidator.Flag.REQUIRED)) {
              alertSink.add(new RequiredAttributeHasCondError(call, attr.getValue()));
            }
          }
        }
        newAttrBuilder.put(param.getKey(), visitAttribute(param.getValue()));
      }

      validateAttributeBundles(call, call.getAttrBundles(), validatorMap, allowedAttributes);
      Map<String, Attribute> newAttrParams = newAttrBuilder.build();

      // check for missing required attributes
      for (FormalParameter parameter : callee.getParameters()) {
        if (!parameter.hasDefault()) {
          if (!newAttrParams.containsKey(parameter.getPrimaryName())) {
            alertSink.add(new MissingAttributeError(call, parameter.getPrimaryName()));
          } else {
            Attribute fpAttribute = call.getAttributes().get(parameter.getPrimaryName());
View Full Code Here

Examples of com.google.gxp.compiler.base.Callable

      public Void visitBoundCall(BoundCall call) {
        throw new UnexpectedNodeException(call);
      }

      public Void visitValidatedCall(final ValidatedCall call) {
        final Callable callee = call.getCallee();
        final Map<String, Attribute> params = call.getAttributes();
        final StringBuilder sb = new StringBuilder();

        boolean isInstance = callee.acceptCallableVisitor(new CallableVisitor<Boolean>() {
          public Boolean visitCallable(Callable callable) {
            return false;
          }

          public Boolean visitInstanceCallable(InstanceCallable callable) {
View Full Code Here

Examples of com.google.gxp.compiler.base.Callable

      public String visitUnboundCall(UnboundCall call) {
        throw new UnexpectedNodeException(call);
      }

      public String visitValidatedCall(final ValidatedCall call) {
        final Callable callee = call.getCallee();
        final StringBuilder sb = new StringBuilder();

        callee.acceptCallableVisitor(new CallableVisitor<Void>() {
          public Void visitCallable(Callable callable) {
            sb.append(callee.getName().toString());
            sb.append(".getGxpClosure(");
            COMMA_JOINER.appendTo(sb, getCallArguments(callee, call.getAttributes()));
            sb.append(")");
            return null;
          }
View Full Code Here

Examples of com.google.gxp.compiler.base.Callable

            return visitor(type.getSchema());
          }
        };

      public Expression visitBoundCall(BoundCall call) {
        Callable callee = call.getCallee();

        // tranform params
        ImmutableMap.Builder<String, Attribute> newParams = ImmutableMap.builder();

        for (Map.Entry<String, Attribute> p : call.getAttributes().entrySet()) {
          String key = p.getKey();
          Visitor visitor = callee
              .getParameterByPrimary(key).getType()
              .acceptTypeVisitor(typeVisitor);
          Attribute value = visitor.visitAttribute(p.getValue());
          newParams.put(key, value);
        }
View Full Code Here

Examples of com.google.gxp.compiler.base.Callable

        throw new UnexpectedNodeException(call);
      }

      @Override
      public String visitValidatedCall(final ValidatedCall call) {
        final Callable callee = call.getCallee();
        final StringBuilder sb = new StringBuilder();

        callee.acceptCallableVisitor(new CallableVisitor<Void>() {
          public Void visitCallable(Callable callable) {
            sb.append(callee.getName().toString());
            sb.append(".getGxpClosure(");
            COMMA_JOINER.appendTo(sb, getCallArguments(callee, call.getAttributes()));
            sb.append(")");
            return null;
          }
View Full Code Here

Examples of com.google.gxp.compiler.base.Callable

    }

    @Override
    public Expression visitBoundCall(BoundCall call) {
      boolean oldVisible = visible;
      Callable callee = call.getCallee();
      for (Map.Entry<String, Attribute> param : call.getAttributes().entrySet()) {
        Type type = callee.getParameterByPrimary(param.getKey()).getType();
        visible = isTypeVisible(type);
        visitAttribute(param.getValue());
      }
      visible = oldVisible;
      return call;
View Full Code Here

Examples of com.google.gxp.compiler.base.Callable

      public Void visitBoundCall(BoundCall call) {
        throw new UnexpectedNodeException(call);
      }

      public Void visitValidatedCall(final ValidatedCall call) {
        final Callable callee = call.getCallee();
        final Map<String, Attribute> params = call.getAttributes();
        final StringBuilder sb = new StringBuilder();

        boolean isInstance = callee.acceptCallableVisitor(new CallableVisitor<Boolean>() {
          public Boolean visitCallable(Callable callable) {
            return false;
          }

          public Boolean visitInstanceCallable(InstanceCallable callable) {
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.