2 #include "URL_Visitor_Factory.h"
3 #include "Web_Crawler.h"
6 Web_Crawler::~Web_Crawler ()
8 delete this->url_visitor_factory_
;
11 Web_Crawler::Web_Crawler ()
12 : url_visitor_factory_ (0)
17 Web_Crawler::open (int argc
, ACE_TCHAR
*argv
[])
19 if (OPTIONS::instance ()->parse_args (argc
, argv
) == -1)
21 // @@ Put the ACE_Service_Config::open() stuff here somewhere...
24 // For now just hardcode this to create "validation" visitors.
25 ACE_NEW_RETURN (this->url_visitor_factory_
,
26 URL_Validation_Visitor_Factory
,
35 // Make the appropriate <URL_Visitor>.
36 Auto_Destroyer
<URL_Visitor
> visitor (this->url_visitor_factory_
->make_visitor ());
39 ACE_ERROR_RETURN ((LM_ERROR
,
44 // Make the appropriate <Command_Processor>.
45 Auto_Destroyer
<Command_Processor
> cp (this->url_visitor_factory_
->make_command_processor ());
48 ACE_ERROR_RETURN ((LM_ERROR
,
50 "make_command_processor"),
53 // Set the <Command_Processor> in the <Options> to make it visible.
54 OPTIONS::instance ()->command_processor (*cp
);
56 // Set the <URL_Visitor> in the <Options> to make it visible.
57 OPTIONS::instance ()->visitor (*visitor
);
59 // @@ You fill in here...
60 ACE_URL_Addr
*url_addr
;
61 ACE_NEW_RETURN (url_addr
,
62 ACE_URL_Addr (OPTIONS::instance()->hostname (),
63 OPTIONS::instance()->path_name (),
64 OPTIONS::instance()->port_no ()), //KIRTHIKA
66 Auto_Destroyer
<ACE_URL_Addr
> url_addr_ptr (url_addr
);
69 ACE_NEW_RETURN (http_url
,
70 HTTP_URL (**url_addr_ptr
),
73 Auto_Destroyer
<HTTP_URL
> http_url_ptr (http_url
);
75 URL_Command
*url_command
;
76 ACE_NEW_RETURN (url_command
,
77 URL_Command (*http_url_ptr
),
79 // Auto_Destroyer<URL_Command> url_command_ptr (url_command);
81 if (cp
->insert (url_command
) != 0)
82 ACE_ERROR_RETURN ((LM_ERROR
,
86 if (cp
->execute () != 0)
87 ACE_ERROR_RETURN ((LM_ERROR
,