Package org.apache.nutch.webapp.common

Examples of org.apache.nutch.webapp.common.ServiceLocator


 
  static Ontology ontology;
 
  public void nutchPerform(ComponentContext tileContext, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext) throws ServletException, IOException {

    ServiceLocator locator=getServiceLocator(request);

    if (ontology != null) {
      LOG.info("Calling ontology with parameter:" + locator.getSearch().getQueryString());
      request.setAttribute(ATTR_NAME, ontology.subclasses(locator.getSearch().getQueryString()));
    }
  }
View Full Code Here


      request.setAttribute(REQ_ATTR_CLUSTERS, clusterResult);
    }
  }

  public void start(ServletContext servletContext) {
    ServiceLocator locator = getServiceLocator(servletContext);
    try {
      clusterer = new OnlineClustererFactory(locator.getConfiguration())
          .getOnlineClusterer();
    } catch (PluginRuntimeException e) {
      LOG.info("Could not initialize Clusterer, is the plugin enabled?");
      return;
    }
View Full Code Here

   (non-Javadoc)
   * @see org.apache.nutch.webapp.common.Startable#start(javax.servlet.ServletContext)
   */
  public void start(ServletContext servletContext) {
   
    ServiceLocator locator=getServiceLocator(servletContext);
   
    try {
      String urls = locator.getConfiguration().get("extension.ontology.urls");
      ontology = new org.apache.nutch.ontology.OntologyFactory(locator.getConfiguration()).getOntology();
     
      LOG.info("Initializing Ontology with urls:" + urls);

      //FIXME initialization code should be in Ontology instead
      if (urls==null || urls.trim().equals("")) {
View Full Code Here

 
  public void nutchPerform(ComponentContext tileContext,
      HttpServletRequest request, HttpServletResponse response,
      ServletContext servletContext) throws ServletException, IOException {
   
    ServiceLocator locator=getServiceLocator(request);
   
    if(ClusteringPresearchExtension.isClusteringActive(locator)) {
      request.setAttribute(REQ_ATTR_CLUSTERING_ENABLED, "1");
    }
  }
View Full Code Here

  static HashMap context;
 
  public void nutchPerform(ComponentContext tileContext,
      HttpServletRequest request, HttpServletResponse response,
      ServletContext servletContext) throws ServletException, IOException {
    ServiceLocator serviceLocator=getServiceLocator(request);
    HashMap context=new HashMap();
    KeyMatch[] matches=keymatcher.getMatches(serviceLocator.getSearch().getQuery(),context);
    request.setAttribute(ATTR_KEYMATCHES, matches);
  }
View Full Code Here

    request.setAttribute(ATTR_KEYMATCHES, matches);
  }

  public void start(ServletContext servletContext) {
    LOG.info("Starting keymatcher");
    ServiceLocator serviceLocator=getServiceLocator(servletContext);
    keymatcher=new SimpleKeyMatcher(serviceLocator.getConfiguration());
    context=new HashMap();
    //how many matches
    context.put(CountFilter.KEY_COUNT,"1");
    LOG.info("Starting keymatcher ok");
  }
View Full Code Here

  public void nutchPerform(ComponentContext tileContext,
      HttpServletRequest request, HttpServletResponse response,
      ServletContext servletContext) throws ServletException, IOException {

    ServiceLocator locator = getServiceLocator(request);
    Search search;
   
    // key used for caching results, should really be something else but a part of user
    // definable String
    String key = request.getQueryString().replace("?","_").replace("&","_");
    StringBuffer cacheKey=new StringBuffer(key.length()*2);
    for(int i=0;i<key.length();i++){
      cacheKey.append(key.charAt(i)).append(java.io.File.separatorChar);
    }
   
    if(LOG.isDebugEnabled()){
      LOG.debug("cache key:" + cacheKey);
    }
    if (cacheKey != null) {
      try {
        search = manager.getSearch(cacheKey.toString(), locator);
        request.setAttribute(Search.REQ_ATTR_SEARCH, search);
        if(LOG.isDebugEnabled()) {
          LOG.debug("Using cached");
        }
      } catch (NeedsRefreshException e) {
        try{
          super.nutchPerform(tileContext, request, response, servletContext);
          search = (Search) locator.getSearch();
          manager.putSearch(cacheKey.toString(),
            search);
        } catch (Exception ex){
          LOG.info("Cancelling update");
          manager.cancelUpdate(cacheKey.toString());
View Full Code Here

      }
    }
  }

  public void start(ServletContext servletContext) {
    ServiceLocator locator=getServiceLocator(servletContext);
    manager=CacheManager.getInstance(locator.getConfiguration());
  }
View Full Code Here

  public static final String ATTR_SPELL_QUERY="spellCheckerQuery";
 
  public void nutchPerform(ComponentContext tileContext,
      HttpServletRequest request, HttpServletResponse response,
      ServletContext servletContext) throws ServletException, IOException {
    ServiceLocator serviceLocator=getServiceLocator(request);

    SpellCheckerTerms spellCheckerTerms = null;
    if (spellCheckerBean != null) {
            spellCheckerTerms = spellCheckerBean.checkSpelling(serviceLocator.getSearch().getQuery(), serviceLocator.getSearch().getQueryString());
    }

    SearchForm form=(SearchForm)serviceLocator.getSearchForm().clone();
    form.setValue(SearchForm.NAME_QUERYSTRING,spellCheckerTerms.getSpellCheckedQuery());
    String spellQuery = form.getParameterString("utf-8");
   
    request.setAttribute(ATTR_SPELL_TERMS, spellCheckerTerms);
    request.setAttribute(ATTR_SPELL_QUERY, spellQuery);
View Full Code Here

  public void nutchPerform(ComponentContext tileContext,
      HttpServletRequest request, HttpServletResponse response,
      ServletContext servletContext) throws ServletException, IOException {
   
    boolean hasSelectedCollection=false;
    ServiceLocator serviceLocator = getServiceLocator(request);
    Collection collections=collectionManager.getAll();
   
    ArrayList wrapped=new ArrayList();
    Iterator i=collections.iterator();
   
    String value=serviceLocator.getSearchForm().getValueString(SubcollectionIndexingFilter.FIELD_NAME);
   
    while(i.hasNext()){
      Subcollection collection=(Subcollection)i.next();
      boolean checked=(value!=null && value.equals(collection.getId()));
      wrapped.add(new SubcollectionWrapper(collection,checked));
View Full Code Here

TOP

Related Classes of org.apache.nutch.webapp.common.ServiceLocator

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.