Package org.apache.nutch.plugin

Examples of org.apache.nutch.plugin.Extension


    if (point != null) {

      Extension[] extensions = point.getExtensions();

      for (int i = 0; i < extensions.length; i++) {
        Extension extension = extensions[i];

        WebAppModule module = new WebAppModule(extension.getDescriptor()
            .getClassLoader(), conf);
        Iterator iterator = module.getPaths().iterator();

        while (iterator.hasNext()) {
          String path = (String) iterator.next();
View Full Code Here


          + " extensions available for UI");

      for (int i = 0; i < extensions.length; i++) {
        LOG.info("Adding definitions from "
            + extensions[i].getDescriptor().getName());
        Extension extension = extensions[i];
        addToSet(definitions, extension);
      }
    } else {
      LOG.info("Cannot find extension point '" + UIExtensionPoint.X_POINT_ID
          + "'");
View Full Code Here

    String contentType, command, timeoutString;

    for (int i = 0; i < extensions.length; i++)
    {
      Extension extension = extensions[i];

      // only look for extensions defined by plugin parse-ext
      // Changed the id from parse-ext to parse-waxext. St.Ack.
      if (!extension.getDescriptor().getPluginId().equals("parse-waxext"))
      {
        continue;
      }

      contentType = extension.getAttribute("contentType");
     
      if (contentType == null || contentType.equals(""))
      {
        continue;
      }
     
      timeoutString = extension.getAttribute("timeout");
     
      if (timeoutString == null || timeoutString.equals(""))
      {
        timeoutString = "" + TIMEOUT_DEFAULT;
      }
     
      command = extension.getAttribute("command");
     
      if (command == null || command.equals(""))
      {
        continue;
      }
View Full Code Here

        if (point == null)
          throw new RuntimeException(URLFilter.X_POINT_ID + " not found.");
        Extension[] extensions = point.getExtensions();
        HashMap filterMap = new HashMap();
        for (int i = 0; i < extensions.length; i++) {
          Extension extension = extensions[i];
          URLFilter filter = (URLFilter) extension.getExtensionInstance();
          if (!filterMap.containsKey(filter.getClass().getName())) {
            filterMap.put(filter.getClass().getName(), filter);
          }
        }
        if (orderedFilters == null) {
View Full Code Here

  }
   
  /** Unit test for <code>getExtensions(String)</code> method. */
  @Test
  public void testGetExtensions() throws Exception {
    Extension ext = parserFactory.getExtensions("text/html").get(0);
    Assert.assertEquals("parse-tika", ext.getDescriptor().getPluginId());
    ext = parserFactory.getExtensions("text/html; charset=ISO-8859-1").get(0);
    Assert.assertEquals("parse-tika", ext.getDescriptor().getPluginId());
    ext = parserFactory.getExtensions("foo/bar").get(0);
    Assert.assertEquals("parse-tika", ext.getDescriptor().getPluginId());
  }
View Full Code Here

   
    List<URLNormalizer> normalizers = new Vector<URLNormalizer>(extensions.size());

    Iterator<Extension> it = extensions.iterator();
    while (it.hasNext()) {
      Extension ext = it.next();
      URLNormalizer normalizer = null;
      try {
        // check to see if we've cached this URLNormalizer instance yet
        normalizer = (URLNormalizer) objectCache.getObject(ext.getId());
        if (normalizer == null) {
          // go ahead and instantiate it and then cache it
          normalizer = (URLNormalizer) ext.getExtensionInstance();
          objectCache.setObject(ext.getId(), normalizer);
        }
        normalizers.add(normalizer);
      } catch (PluginRuntimeException e) {
        e.printStackTrace();
        LOG.warn("URLNormalizers:PluginRuntimeException when "
                + "initializing url normalizer plugin "
                + ext.getDescriptor().getPluginId()
                + " instance in getURLNormalizers "
                + "function: attempting to continue instantiating plugins");
      }
    }
    return normalizers.toArray(new URLNormalizer[normalizers
View Full Code Here

      impls = new HashSet<String>(Arrays.asList(names));
    }
    Extension[] extensions = this.extensionPoint.getExtensions();
    HashMap<String, Extension> normalizerExtensions = new HashMap<String, Extension>();
    for (int i = 0; i < extensions.length; i++) {
      Extension extension = extensions[i];
      if (impls != null && !impls.contains(extension.getClazz()))
        continue;
      normalizerExtensions.put(extension.getClazz(), extension);
    }
    List<Extension> res = new ArrayList<Extension>();
    if (orders == null) {
      res.addAll(normalizerExtensions.values());
    } else {
      // first add those explicitly named in correct order
      for (int i = 0; i < orders.length; i++) {
        Extension e = normalizerExtensions.get(orders[i]);
        if (e != null) {
          res.add(e);
          normalizerExtensions.remove(orders[i]);
        }
      }
View Full Code Here

    this.conf = conf;

    String pluginName = "urlfilter-suffix";
    Extension[] extensions = PluginRepository.get(conf).getExtensionPoint(URLFilter.class.getName()).getExtensions();
    for (int i = 0; i < extensions.length; i++) {
      Extension extension = extensions[i];
      if (extension.getDescriptor().getPluginId().equals(pluginName)) {
        attributeFile = extension.getAttribute("file");
        break;
      }
    }
    if (attributeFile != null && attributeFile.trim().equals("")) attributeFile = null;
    if (attributeFile != null) {
View Full Code Here

            throw new RuntimeException(IndexWriter.X_POINT_ID
                + " not found.");
          Extension[] extensions = point.getExtensions();
          HashMap<String, IndexWriter> indexerMap = new HashMap<String, IndexWriter>();
          for (int i = 0; i < extensions.length; i++) {
            Extension extension = extensions[i];
            IndexWriter writer = (IndexWriter) extension
                .getExtensionInstance();
            LOG.info("Adding " + writer.getClass().getName());
            if (!indexerMap.containsKey(writer.getClass().getName())) {
              indexerMap.put(writer.getClass().getName(), writer);
            }
View Full Code Here

    String pluginName = "urlfilter-prefix";
    Extension[] extensions = PluginRepository.get(conf).getExtensionPoint(
        URLFilter.class.getName()).getExtensions();
    for (int i = 0; i < extensions.length; i++) {
      Extension extension = extensions[i];
      if (extension.getDescriptor().getPluginId().equals(pluginName)) {
        attributeFile = extension.getAttribute("file");
        break;
      }
    }
    if (attributeFile != null && attributeFile.trim().equals(""))
      attributeFile = null;
View Full Code Here

TOP

Related Classes of org.apache.nutch.plugin.Extension

Copyright © 2018 www.massapicom. 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.