Examples of ServiceLocator


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

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

    ServiceLocator locator = getServiceLocator(request);
    NutchBean bean = locator.getNutchBean();

    LOG.info("Cache request from " + request.getRemoteAddr());

    Hit hit = new Hit(Integer.parseInt(request.getParameter("idx")),
                      Integer.parseInt(request.getParameter("id")));

    HitDetails details = bean.getDetails(hit);
    String id = "idx=" + hit.getIndexNo() + "&id=" + hit.getIndexDocNo();

    Metadata metaData = bean.getParseData(details).getContentMeta();

    String content = null;
    String contentType = (String) metaData.get(Metadata.CONTENT_TYPE);


    if (contentType.startsWith("text/html")) {
      // FIXME : it's better to emit the original 'byte' sequence
      // with 'charset' set to the value of 'CharEncoding',
      // but I don't know how to emit 'byte sequence' in JSP.
      // out.getOutputStream().write(bean.getContent(details)) may work,
      // but I'm not sure.
      String encoding = (String) metaData.get("CharEncodingForConversion");
      if (encoding != null) {
        try {
          content = new String(bean.getContent(details), encoding);
        } catch (UnsupportedEncodingException e) {
          //fallback to configured charset
          content = new String(bean.getContent(details), locator
              .getConfiguration().get("parser.character.encoding.default"));
        }
      } else {
        //construct String with system default encoding
        content = new String(bean.getContent(details));
View Full Code Here

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

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

    ServiceLocator locator = getServiceLocator(request);

    Search search = locator.getSearch();
    search.launchSearch();
  }
View Full Code Here

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

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

    ServiceLocator locator = getServiceLocator(request);

    // get base page from tiles context
    String baseName = (String) tileContext.getAttribute("basePage");

    // get arequest attribute name (where content will be put)
    // from tiles context
    String attrName = (String) tileContext.getAttribute("attrName");

    // if not available use default
    if (attrName == null) {
      attrName = "content";
    }

    // get users preferred locale
    Locale locale = locator.getLocale();

    // see if we have a cached content available
    StringBuffer content = (StringBuffer) cached.get(baseName + locale);

    // not available, try to read from file
View Full Code Here

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

  }

  public void nutchPerform(ComponentContext tileContext,
      HttpServletRequest request, HttpServletResponse response,
      ServletContext servletContext) throws ServletException, IOException {
    ServiceLocator locator = getServiceLocator(request);
    NutchBean bean = locator.getNutchBean();

    LOG.info("anchors request from " + request.getRemoteAddr());
    Hit hit = new Hit(Integer.parseInt(request.getParameter("idx")), Integer
        .parseInt(request.getParameter("id")));
View Full Code Here

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

   * session from being created.
   */
  protected void processLocale(HttpServletRequest request,
      HttpServletResponse response) {

    ServiceLocator locator = WebappInstanceServiceLocator.getFrom(request);

    if (locator == null) {
      locator = new WebappInstanceServiceLocator(request, getServletContext());
      WebappInstanceServiceLocator.register(request,
          (WebappInstanceServiceLocator) locator);
    }

    Config.set(request, Config.FMT_LOCALE, locator.getLocale());
  }
View Full Code Here

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

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

    ServiceLocator locator = getServiceLocator(request);
    NutchBean bean = locator.getNutchBean();

    Hit hit = new Hit(Integer.parseInt(request.getParameter("idx")), Integer
        .parseInt(request.getParameter("id")));
    HitDetails details = bean.getDetails(hit);
    Query query = Query.parse(request.getParameter("query"), locator
        .getConfiguration());

    // put explanation and hitDetails into request so view can access them
    request.setAttribute("explanation", bean.getExplanation(query, hit));
    request.setAttribute("hitDetails", details.toHtml());
View Full Code Here

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

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

    ServiceLocator locator = getServiceLocator(request);

    if (tileContext.getAttribute("action").equals("save")) {
      LOG.info("save");
      Preferences p = Preferences.parse(request.getQueryString(), "&", "=");
      LOG.info("setting cookie");
      Preferences.setPreferencesCookie(request, response, p);
      LOG.info("setting attribute");
      request.setAttribute("preferences", p);
    } else {
      LOG.info("view");
      request.setAttribute("preferences", locator.getPreferences());
    }
  }
View Full Code Here

Examples of org.apache.olio.webapp.util.ServiceLocator

    public void contextInitialized(ServletContextEvent sce) {
        context = sce.getServletContext();
        getContext().setAttribute(WebConstants.MF_KEY, this);
        WebappUtil.setContext(getContext().getContextPath());

        ServiceLocator sloc = ServiceLocator.getInstance();
        jmakiUsage = Boolean.parseBoolean(sloc.getString("webapp.jmakiUsage", "false"));
        useCache = Boolean.parseBoolean(sloc.getString("useLocalCache", "true"));
    }
View Full Code Here

Examples of org.apache.olio.webapp.util.ServiceLocator

     */
    public void write(FileItemStream item, String fileName) throws Exception {
        // use name for update of session
        String itemName = item.getName();

        ServiceLocator locator = ServiceLocator.getInstance();

        FileSystem fs = locator.getFileSystem();

        logger.fine("Getting fileItem from memory - " + itemName);

        OutputStream fout = fs.create(fileName);

View Full Code Here

Examples of org.apache.olio.webapp.util.ServiceLocator

    public void writeWithThumbnail(FileItemStream item,
            String imageName, String thumbnailName) throws Exception {
        // use name for update of session
        String itemName = item.getName();

        ServiceLocator locator = ServiceLocator.getInstance();

        FileSystem fs = locator.getFileSystem();

        logger.fine("Getting fileItem from memory - " + itemName);

        OutputStream imgOut = null;
        OutputStream thumbOut = null;
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.