From: Marcus <the...@us...> - 2004-03-24 16:08:36
|
Update of /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25675 Modified Files: ScannerConfig.java ScannerPlugin.java Log Message: improvements Index: ScannerConfig.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner/ScannerConfig.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ScannerConfig.java 22 Mar 2004 13:27:08 -0000 1.5 --- ScannerConfig.java 24 Mar 2004 15:57:55 -0000 1.6 *************** *** 104,123 **** protected ScannerConfig(ActionServlet a, ModuleConfig m) throws IllegalArgumentException { ! HashMap conf = null; ! PlugInConfig[] pluginConfigs = m.findPlugInConfigs(); ! ! //get the config... there has to be another way to get it ! for (int x = 0; x < pluginConfigs.length; x++) { ! if (pluginConfigs[x].getClassName().equals(ScannerPlugin.class ! .getName())) { ! conf = (HashMap) pluginConfigs[x].getProperties(); ! ! break; //leave loop if config found ! } ! } ! ! if (conf == null) { ! throw new IllegalArgumentException("plugin config not found"); ! } String path = a.getServletContext().getRealPath("/WEB-INF"); --- 104,108 ---- protected ScannerConfig(ActionServlet a, ModuleConfig m) throws IllegalArgumentException { ! HashMap conf = junk.plugin.PluginTools.getPluginConfig(ScannerPlugin.class, m); String path = a.getServletContext().getRealPath("/WEB-INF"); Index: ScannerPlugin.java =================================================================== RCS file: /cvsroot/junk/junk/WEB-INF/classes/junk/plugin/scanner/ScannerPlugin.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ScannerPlugin.java 22 Mar 2004 13:27:08 -0000 1.7 --- ScannerPlugin.java 24 Mar 2004 15:57:55 -0000 1.8 *************** *** 32,37 **** --- 32,39 ---- import junk.util.NameOnline; + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; + import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; *************** *** 61,65 **** */ public class ScannerPlugin implements PlugIn, Runnable { ! /** @deprecated use KEY_HOSTS_MAP */ public static final String HOSTS_MAP_KEY = ScannerPlugin.KEY_HOSTS_MAP; --- 63,70 ---- */ public class ScannerPlugin implements PlugIn, Runnable { ! /** ! * deprecated ! * @deprecated use KEY_HOSTS_MAP ! */ public static final String HOSTS_MAP_KEY = ScannerPlugin.KEY_HOSTS_MAP; *************** *** 130,134 **** public void init(ActionServlet a, ModuleConfig m) throws ServletException { ! this.actionServlet = a; try { --- 135,139 ---- public void init(ActionServlet a, ModuleConfig m) throws ServletException { ! this.actionServlet = a; try { *************** *** 182,185 **** --- 187,194 ---- } + /** + * not sure if i need this anyway... + * @param conf fnoc + */ protected void setConf(ScannerConfig conf) { this.conf = conf; *************** *** 234,238 **** } ! /** load an deserialize the hostmap. * @return loaded map */ --- 243,247 ---- } ! /** load and deserialize the hostmap. * @return loaded map */ *************** *** 240,254 **** String path = this.conf.getSaveMapPath(); HostMap h = null; try { ! FileInputStream f = new FileInputStream(path); ! ObjectInputStream o = new ObjectInputStream(f); h = (HostMap) o.readObject(); ! o.close(); ! f.close(); ! log.info("Loaded persistent data map (" + path + ")"); ! } catch (Exception e) { ! h = populateMap(); //if there is no data, populate map ! log.warn("No persistent data map found", e); } --- 249,283 ---- String path = this.conf.getSaveMapPath(); HostMap h = null; + FileInputStream f = null; + ObjectInputStream o = null; try { ! f = new FileInputStream(path); ! o = new ObjectInputStream(f); h = (HostMap) o.readObject(); ! log.info("Persistent data map loaded (" + path + ")"); ! } catch (IOException e1) { ! log.info("Failed to load persistent data map. " ! + "This should only happen once. ( " + e1.getMessage() + ")"); ! } catch (Exception ex) { ! log.warn("Error loading persistent data map. " ! + "This is not critical, but should not happen.", ex); ! } finally { ! if (h == null) { ! h = populateMap(); //if there is no data, populate map ! } ! ! try { //cleanup. don't care if this fails. ! ! if (o != null) { ! o.close(); ! } ! ! if (f != null) { ! f.close(); ! } ! } catch (IOException e11) { ! ; ! } } *************** *** 289,300 **** log.info("Hostmap saved (" + path + ")"); } catch (Exception e) { ! log.warn("Could not save hostmap", e); } } ! /** scans the net. * @return <CODE>true</CODE> if the scan was performed. - * @param standalone true, if the method is started standalone - * (out of struts) */ private synchronized boolean scan() { --- 318,328 ---- log.info("Hostmap saved (" + path + ")"); } catch (Exception e) { ! log.warn("Could not save hostmap (" + path + ")", e); } } ! /** ! * scans the net. * @return <CODE>true</CODE> if the scan was performed. */ private synchronized boolean scan() { |