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 ; 14 15 16 22 public class SpiderContextFactory { 23 24 public static SpiderContext createContext(URL 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 context.setAgent(new AgentImpl(context)); 39 40 return context; 41 } 42 } 43 | Popular Tags |