static List<Extension> getApplicableExtensionMethods(
     EclipseNode typeNode, Annotation ann, TypeBinding receiverType) {
   List<Extension> extensions = new ArrayList<Extension>();
   if ((typeNode != null) && (ann != null) && (receiverType != null)) {
     BlockScope blockScope = ((TypeDeclaration) typeNode.get()).initializerScope;
     EclipseNode annotationNode = typeNode.getNodeFor(ann);
     AnnotationValues<ExtensionMethod> annotation =
         createAnnotation(ExtensionMethod.class, annotationNode);
     boolean suppressBaseMethods = false;
     try {
       suppressBaseMethods = annotation.getInstance().suppressBaseMethods();
     } catch (AnnotationValueDecodeFail fail) {
       fail.owner.setError(fail.getMessage(), fail.idx);
     }
     for (Object extensionMethodProvider : annotation.getActualExpressions("value")) {
       if (extensionMethodProvider instanceof ClassLiteralAccess) {
         TypeBinding binding =
             ((ClassLiteralAccess) extensionMethodProvider).type.resolveType(blockScope);
         if (binding == null) continue;
         if (!binding.isClass() && !binding.isEnum()) continue;
         Extension e = new Extension();
         e.extensionMethods =
             getApplicableExtensionMethodsDefinedInProvider(
                 typeNode, (ReferenceBinding) binding, receiverType);
         e.suppressBaseMethods = suppressBaseMethods;
         extensions.add(e);
       }
     }
   }
   return extensions;
 }
Example #2
0
  void handleUnparkedCallEvent(UnparkedCallEvent event) {
    // Only bristuffed versions: AsteriskChannelImpl channel =
    // getChannelImplById(event.getUniqueId());
    final AsteriskChannelImpl channel = getChannelImplByNameAndActive(event.getChannel());

    if (channel == null) {
      logger.info("Ignored UnparkedCallEvent for unknown channel " + event.getChannel());
      return;
    }

    Extension wasParkedAt = channel.getParkedAt();

    if (wasParkedAt == null) {
      logger.info("Ignored UnparkedCallEvent as the channel was not parked");
      return;
    }

    synchronized (channel) {
      channel.setParkedAt(null);
    }
    logger.info(
        "Channel "
            + channel.getName()
            + " is unparked (moved away) from "
            + wasParkedAt.getExtension());
  }
 public int getBasicConstraints() {
   Extension e = getExtension(BasicConstraints.ID);
   if (e != null) {
     return ((BasicConstraints) e.getValue()).getPathLengthConstraint();
   }
   return -1;
 }
 public boolean hasUnsupportedCriticalExtension() {
   for (Iterator it = extensions.values().iterator(); it.hasNext(); ) {
     Extension e = (Extension) it.next();
     if (e.isCritical() && !e.isSupported()) return true;
   }
   return false;
 }
 public Collection getIssuerAlternativeNames() throws CertificateParsingException {
   Extension e = getExtension(IssuerAlternativeNames.ID);
   if (e != null) {
     return ((IssuerAlternativeNames) e.getValue()).getNames();
   }
   return null;
 }
 public byte[] getExtensionValue(String oid) {
   Extension e = getExtension(new OID(oid));
   if (e != null) {
     return e.getValue().getEncoded();
   }
   return null;
 }
Example #7
0
 public static Extension newExtension(String uri, Type value, boolean evenIfNull) {
   if (!evenIfNull && (value == null || value.isEmpty())) return null;
   Extension e = new Extension();
   e.setUrl(uri);
   e.setValue(value);
   return e;
 }
Example #8
0
  /**
   * Expand the temporary extensionNames map of pointid-classname to full pointid-classobject. <br>
   * This has to be done after the fact because when the pointid-classnames are parsed, the module's
   * objects aren't fully realized yet and so not all classes can be loaded. <br>
   * <br>
   *
   * @return a list of full Extension objects
   */
  private List<Extension> expandExtensionNames() {
    ModuleClassLoader moduleClsLoader = ModuleFactory.getModuleClassLoader(this);
    if (moduleClsLoader == null) {
      log.debug(
          String.format(
              "Module class loader is not available, maybe the module %s is stopped/stopping",
              getName()));
    } else if (extensions.size() != extensionNames.size()) {
      for (Map.Entry<String, String> entry : extensionNames.entrySet()) {
        String point = entry.getKey();
        String className = entry.getValue();
        log.debug("expanding extension names: " + point + " : " + className);
        try {
          Class<?> cls = moduleClsLoader.loadClass(className);
          Extension ext = (Extension) cls.newInstance();
          ext.setPointId(point);
          ext.setModuleId(this.getModuleId());
          extensions.add(ext);
          log.debug("Added extension: " + ext.getExtensionId() + " : " + ext.getClass());
        } catch (NoClassDefFoundError e) {
          log.warn("Unable to find class definition for extension: " + point, e);
        } catch (ClassNotFoundException e) {
          log.warn("Unable to load class for extension: " + point, e);
        } catch (IllegalAccessException e) {
          log.warn("Unable to load class for extension: " + point, e);
        } catch (InstantiationException e) {
          log.warn("Unable to load class for extension: " + point, e);
        }
      }
    }

    return extensions;
  }
 public void copyValues(BackboneElement dst) {
   if (modifierExtension != null) {
     dst.modifierExtension = new ArrayList<Extension>();
     for (Extension i : modifierExtension) dst.modifierExtension.add(i.copy());
   }
   ;
 }
Example #10
0
  public void setTopExtension(Extension arg0) {
    this.topExtension = arg0;

    topExtension.setPosition(centerX, getY() + length);
    if (topExtension.getWidth() == 0) {
      topExtension.setWidth(width);
    }
  }
 public void copyValues(Element dst) {
   dst.id = id == null ? null : id.copy();
   if (extension != null) {
     dst.extension = new ArrayList<Extension>();
     for (Extension i : extension) dst.extension.add(i.copy());
   }
   ;
 }
 public Set getNonCriticalExtensionOIDs() {
   HashSet s = new HashSet();
   for (Iterator it = extensions.values().iterator(); it.hasNext(); ) {
     Extension e = (Extension) it.next();
     if (!e.isCritical()) s.add(e.getOid().toString());
   }
   return Collections.unmodifiableSet(s);
 }
Example #13
0
  public void setBottomExtension(Extension arg0) {
    this.bottomExtension = arg0;

    bottomExtension.setPosition(centerX, getY());
    if (bottomExtension.getWidth() == 0) {
      bottomExtension.setWidth(width);
    }
  }
 /**
  * Returns an unmodifiable list containing all extensions on this element which match the given
  * URL.
  *
  * @param theUrl The URL. Must not be blank or null.
  * @return an unmodifiable list containing all extensions on this element which match the given
  *     URL
  */
 public List<Extension> getExtensionsByUrl(String theUrl) {
   org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must not be blank or null");
   ArrayList<Extension> retVal = new ArrayList<Extension>();
   for (Extension next : getExtension()) {
     if (theUrl.equals(next.getUrl())) {
       retVal.add(next);
     }
   }
   return java.util.Collections.unmodifiableList(retVal);
 }
 public boolean[] getKeyUsage() {
   Extension e = getExtension(KeyUsage.ID);
   if (e != null) {
     KeyUsage ku = (KeyUsage) e.getValue();
     boolean[] result = new boolean[9];
     boolean[] b = ku.getKeyUsage().toBooleanArray();
     System.arraycopy(b, 0, result, 0, b.length);
     return result;
   }
   return null;
 }
 /**
  * Returns <code>true</code> if all required extension dependencies have been meet for this <code>
  * ManifestResource</code> object.
  *
  * @return boolean true if all extension dependencies have been satisfied
  */
 public boolean isFulfilled() {
   if (requiredExtensions == null) {
     return true;
   }
   Iterator<Extension> it = requiredExtensions.iterator();
   while (it.hasNext()) {
     Extension ext = it.next();
     if (!ext.isFulfilled()) return false;
   }
   return true;
 }
 public List getExtendedKeyUsage() throws CertificateParsingException {
   Extension e = getExtension(ExtendedKeyUsage.ID);
   if (e != null) {
     List a = ((ExtendedKeyUsage) e.getValue()).getPurposeIds();
     List b = new ArrayList(a.size());
     for (Iterator it = a.iterator(); it.hasNext(); ) {
       b.add(it.next().toString());
     }
     return Collections.unmodifiableList(b);
   }
   return null;
 }
Example #18
0
  public Extension getExtension(String name) {
    if (name == null) return null;

    for (int i = 0; i < extensionList.size(); i++) {
      Extension p = getExtension(i);
      if (p.getName().equalsIgnoreCase(name)) {
        return p;
      }
    }

    return null;
  }
Example #19
0
  /**
   * Add an extension to this connector. This method is protected to allow extensions to select
   * which targets they can extend.
   *
   * @param extension the extension to add
   */
  protected void addExtension(Extension extension) {
    ClientConnector previousParent = extension.getParent();
    if (previousParent == this) {
      // Nothing to do, already attached
      return;
    } else if (previousParent != null) {
      throw new IllegalStateException(
          "Moving an extension from one parent to another is not supported");
    }

    extensions.add(extension);
    extension.setParent(this);
    markAsDirty();
  }
Example #20
0
 private static String getExtensionPostfix(TypeElement interface_decl) {
   String interface_simple_name = interface_decl.getSimpleName().toString();
   Extension extension_annotation = interface_decl.getAnnotation(Extension.class);
   if (extension_annotation == null) {
     int underscore_index = interface_simple_name.indexOf("_");
     if (underscore_index != -1) {
       return interface_simple_name.substring(0, underscore_index);
     } else {
       return "";
     }
   } else {
     return extension_annotation.postfix();
   }
 }
Example #21
0
 @FXML
 private void saveCode() {
   FileChooser fc = new FileChooser();
   fc.setTitle("保存先を指定");
   fc.setInitialFileName(contest.getSelectionModel().getSelectedItem().getValue());
   fc.getExtensionFilters().addAll(Extension.getFilterList());
   fc.setSelectedExtensionFilter(Extension.of(languageLabel.getText()).getFilter());
   Optional.ofNullable(fc.showSaveDialog(root.getScene().getWindow()))
       .ifPresent(
           f -> {
             try {
               Files.write(f.toPath(), ((String) obj.call("getCode")).getBytes());
             } catch (IOException e) {
             }
           });
 }
 private ServerMessage notifySend(Extension extension, ServerMessage message) {
   try {
     return extension.send(this, message);
   } catch (Throwable x) {
     _logger.info("Exception while invoking extension " + extension, x);
     return message;
   }
 }
 private boolean notifySendMeta(Extension extension, Mutable message) {
   try {
     return extension.sendMeta(this, message);
   } catch (Throwable x) {
     _logger.info("Exception while invoking extension " + extension, x);
     return true;
   }
 }
Example #24
0
  public static void delete(String name) throws Throwable {
    if (!Profiler.canEnter()) forbidden();
    checkAuthenticity();

    CMSImage image = CMSImage.findById(name);
    image.delete();
    Extension.invoke("afterDelete", image);
    redirect(Router.reverse("cms.Admin.imagelist").url + "?" + request.querystring);
  }
Example #25
0
 @FXML
 private void setCode() {
   if (submission.getSelectionModel().isEmpty()) return;
   try {
     obj.call(
         "setCode",
         api.getCode(
             submission.getSelectionModel().getSelectedItem().getId(),
             contest.getSelectionModel().getSelectedItem().getValue()));
   } catch (Exception e) {
     getAlert(e, "提出コードの取得に失敗しました。").show();
     return;
   }
   languageLabel.setText(submission.getSelectionModel().getSelectedItem().getLanguage());
   Extension lang = Extension.of(languageLabel.getText());
   if (Stream.of(Extension.C, Extension.CPP).anyMatch(e -> e.equals(lang)))
     obj.call("setMode", "c_cpp");
   else obj.call("setMode", lang.toString().toLowerCase());
 }
 /**
  * Write the extension to the OutputStream.
  *
  * @param out the OutputStream to write the extension to.
  * @exception IOException on encoding errors.
  */
 public void encode(OutputStream out) throws IOException {
   DerOutputStream tmp = new DerOutputStream();
   if (extensionValue == null) {
     extensionId = PKIXExtensions.SubjectAlternativeName_Id;
     // critical = false;
     encodeThis();
   }
   super.encode(tmp);
   out.write(tmp.toByteArray());
 }
 /**
  * Write the extension to the DerOutputStream.
  *
  * @param out the DerOutputStream to write the extension to.
  * @exception IOException on encoding errors.
  */
 public void encode(OutputStream out) throws IOException {
   DerOutputStream tmp = new DerOutputStream();
   if (this.extensionValue == null) {
     this.extensionId = PKIXExtensions.SubjectInfoAccess_Id;
     this.critical = false;
     encodeThis();
   }
   super.encode(tmp);
   out.write(tmp.toByteArray());
 }
 /**
  * Write the extension to the DerOutputStream.
  *
  * @param out the DerOutputStream to write the extension to.
  * @exception IOException on encoding errors.
  */
 public void encode(OutputStream out) throws IOException {
   DerOutputStream tmp = new DerOutputStream();
   if (extensionValue == null) {
     extensionId = PKIXExtensions.CertificatePolicies_Id;
     critical = false;
     encodeThis();
   }
   super.encode(tmp);
   out.write(tmp.toByteArray());
 }
Example #29
0
  public static void savePage(@Valid CMSPage page, boolean active) throws Throwable {
    if (!Profiler.canEdit(page.name)) forbidden();

    checkAuthenticity();

    page.locale = defaultString(page.locale, Lang.get());
    page.active = active;

    if (request.params.get("delete") != null) {
      page.delete();
      Extension.invoke("afterDelete", page);
      index();
    }

    if (validation.hasErrors()) renderTemplate("@edit", page);

    page.save();
    Extension.invoke("afterSave", page);
    if (request.params.get("savePage") != null) Frontend.show(null, page.name);
    index();
  }
  /**
   * Return the set of <code>Extension</code> objects representing optional packages that are
   * required by the application associated with the specified <code>Manifest</code>.
   *
   * @param manifest Manifest to be parsed
   * @return List of required extensions, or null if the application does not require any extensions
   */
  private ArrayList<Extension> getRequiredExtensions(Manifest manifest) {

    Attributes attributes = manifest.getMainAttributes();
    String names = attributes.getValue("Extension-List");
    if (names == null) return null;

    ArrayList<Extension> extensionList = new ArrayList<Extension>();
    names += " ";

    while (true) {

      int space = names.indexOf(' ');
      if (space < 0) break;
      String name = names.substring(0, space).trim();
      names = names.substring(space + 1);

      String value = attributes.getValue(name + "-Extension-Name");
      if (value == null) continue;
      Extension extension = new Extension();
      extension.setExtensionName(value);
      extension.setImplementationURL(attributes.getValue(name + "-Implementation-URL"));
      extension.setImplementationVendorId(attributes.getValue(name + "-Implementation-Vendor-Id"));
      String version = attributes.getValue(name + "-Implementation-Version");
      extension.setImplementationVersion(version);
      extension.setSpecificationVersion(attributes.getValue(name + "-Specification-Version"));
      extensionList.add(extension);
    }
    return extensionList;
  }