mohankreddy / crawler4j

Automatically exported from code.google.com/p/crawler4j
0 stars 0 forks source link

Impossible to use crawler with a constructor that has multiple argument / Crawlcontroller only supports the default constructor #84

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. what if i wanted construct MyCrawler with parameter before passing it to the 
contructor ?
2. what if i wanted some data in the visit(Page page) method to be variable, 
which would be set at the constructor or in Setter methods
3.

What is the expected output? What do you see instead?

impossible

What version of the product are you using? On what operating system?
version 2.6.1 , Windows 7 64 bit 

Please provide any additional information below.

how you this problem be resolved ? i want add a constructor with parameter but 
the  <T extends WebCrawler> void start(Class<T> _c, int numberOfCrawlers) will 
create a "new instance" (i.e a new object) from the default contrucstor 
constructor with 

   for (int i = 1; i <= numberofCrawlers; i++) {
                                T crawler = _c.newInstance(); here!!!!
                                Thread thread = new Thread(crawler, "Crawler " + i);
                                crawler.setThread(thread);

Original issue reported on code.google.com by ndjockab...@yahoo.fr on 29 Sep 2011 at 9:42

GoogleCodeExporter commented 9 years ago
For generic types, you have to use the default constructor. Still you can have 
another function, e.g. init(params), to set the parameters.

-Yasser

Original comment by ganjisaffar@gmail.com on 29 Sep 2011 at 2:13

GoogleCodeExporter commented 9 years ago
but this parameter can't be used in the crawl controller , because the call is 
made by a "class" ! how do i for example set the some parameter in the 
shouldVisit(WebUrl url) at runtime ?

Original comment by ndjockab...@yahoo.fr on 29 Sep 2011 at 2:28