Package de.phleisch.app.itsucks.core

Examples of de.phleisch.app.itsucks.core.Dispatcher


    ClassPathXmlApplicationContext context =
      new ClassPathXmlApplicationContext(
          ApplicationConstants.CORE_SPRING_CONFIG_FILE);
   
    //load dispatcher from spring
    Dispatcher dispatcher = (Dispatcher) context.getBean("Dispatcher");

    //configure an download job filter
    DownloadJobFilter filter = new DownloadJobFilter();
    filter.setAllowedHostNames(new String[] {".*"});
    filter.setMaxRecursionDepth(1);
    filter.setSaveToDisk(new String[] {
        ".*jpg",
        ".*png",
        ".*gif"});
   
    //add the filter to the dispatcher
    dispatcher.addJobFilter(filter);   
   
    //create an job factory
    DownloadJobFactory jobFactory = (DownloadJobFactory)
      context.getBean("JobFactory");
   
    //create an initial job
    UrlDownloadJob job = jobFactory.createDownloadJob();
    job.setUrl(new URL("http://itsucks.sourceforge.net/"));
    job.setSavePath(new File("/tmp/crawl")); //change this for windows
    job.setIgnoreFilter(true);
    dispatcher.addJob(job);
   
    mLog.info("Start demo dispatcher");
   
    //start the dispatcher
    dispatcher.processJobs();
   
    mLog.info("Demo dispatcher finished");
   
    //dump all found urls
    Collection<Job> content =
      dispatcher.getJobManager().getJobList().getContent();
   
    for (Job finishedJob : content) {
      mLog.info(finishedJob);
    }
   
View Full Code Here

TOP

Related Classes of de.phleisch.app.itsucks.core.Dispatcher

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.