KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > javacoding > jspider > core > SpiderContextFactory


1 package net.javacoding.jspider.core;
2
3
4 import net.javacoding.jspider.api.event.EventSink;
5 import net.javacoding.jspider.core.dispatch.EventDispatcher;
6 import net.javacoding.jspider.core.dispatch.impl.EventDispatcherImpl;
7 import net.javacoding.jspider.core.impl.*;
8 import net.javacoding.jspider.core.storage.Storage;
9 import net.javacoding.jspider.core.storage.StorageFactory;
10 import net.javacoding.jspider.core.throttle.ThrottleFactory;
11 import net.javacoding.jspider.core.util.config.*;
12
13 import java.net.URL JavaDoc;
14
15
16 /**
17  *
18  * $Id: SpiderContextFactory.java,v 1.12 2003/04/03 15:57:14 vanrogu Exp $
19  *
20  * @author Günther Van Roey
21  */

22 public class SpiderContextFactory {
23
24     public static SpiderContext createContext(URL JavaDoc baseURL) {
25
26         EventSink[] sinks = new PluginFactory().createPlugins();
27         PropertySet props = ConfigurationFactory.getConfiguration().getPluginsConfiguration();
28         PropertySet filterProps = new MappedPropertySet ( ConfigConstants.CONFIG_FILTER, props );
29         EventDispatcher dispatcher = new EventDispatcherImpl("Global Event Dispatcher", sinks, filterProps);
30         dispatcher.initialize();
31
32         Storage storage = new StorageFactory().createStorage();
33         ThrottleFactory throttleFactory = new ThrottleFactory();
34
35         SpiderContext context = new SpiderContextImpl(baseURL, dispatcher, throttleFactory, storage);
36
37         //todo: This is quite weird, isn't it? REFACTOR the relationship between Agent and Context! HOW ???
38
context.setAgent(new AgentImpl(context));
39
40         return context;
41     }
42 }
43
Popular Tags