private void finish() { // Call finish on each plugin // Let's not log this, since this is not used often for (Plugin p : mPlugins) { if (!mCrashedPlugins.contains(p)) { try { p.finish(this); } catch (Exception e) { e.printStackTrace(); addHeaderLine("Plugin crashed while finishing data: " + p.getClass().getName()); } } } }
protected void addSection(String name, String fileName, InputStream is, boolean limitSize) { int limit = Integer.MAX_VALUE; if (limitSize) { limit = mContext.getLimit(); } String headerLine = name + ": " + fileName; Section sl = new Section(this, name); int ret = readFile(sl, fileName, is, limit); if (ret == READ_FAILED) { headerLine += "<span style=\"color: #f00;\"> (READ FAILED!)</span>"; } else if (ret == READ_PARTS) { headerLine += "<span style=\"color: #f00;\"> (READ LAST " + (limit / 1024 / 1024) + "MB ONLY!)</span>"; addSection(sl); } else if (ret == READ_ALL) { addSection(sl); } addHeaderLine(headerLine); addSource(new SourceFile(fileName, name)); }
/** * Return a new connection to the SQL database. This will return always the same instance, so if * you close it, you're doomed. If connection failed, null will be returned (which can happen if * the jdbc libraries are not found) * * @return A connection to the database or null. */ public Connection getSQLConnection() { if (mSQLConnection != null) return mSQLConnection; // Don't try again if (mSQLFailed) return null; try { Class.forName("org.sqlite.JDBC"); String fnBase = "raw/report.db"; String fn = mDoc.getOutDir() + fnBase; File f = new File(fn); f.delete(); // We must create a new database every time mSQLConnection = DriverManager.getConnection("jdbc:sqlite:" + fn); if (mSQLConnection != null) { mSQLConnection.setAutoCommit(false); addHeaderLine("Note: SQLite report database created as " + fn); } } catch (Throwable t) { printErr(2, "Cannot make DB connection: " + t); mSQLFailed = true; } return mSQLConnection; }
private void runPlugins() { mCrashedPlugins = new HashSet<Plugin>(); // First, sort the plugins based on prio Collections.sort( mPlugins, new Comparator<Plugin>() { @Override public int compare(Plugin o1, Plugin o2) { return o1.getPrio() - o2.getPrio(); } }); // Resetting and initializing data printOut(1, "Resetting plugins..."); for (Plugin p : mPlugins) { try { p.reset(); } catch (Exception e) { e.printStackTrace(); addHeaderLine("Plugin crashed while resetting: " + p.getClass().getName()); mCrashedPlugins.add(p); } } // Installing hooks printOut(1, "Installing hooks..."); for (Plugin p : mPlugins) { if (!mCrashedPlugins.contains(p)) { try { p.hook(this); } catch (Exception e) { e.printStackTrace(); addHeaderLine("Plugin crashed while hooking: " + p.getClass().getName()); mCrashedPlugins.add(p); } } } // Then plugin should process the input data first printOut(1, "Plugins are loading data..."); for (Plugin p : mPlugins) { if (!mCrashedPlugins.contains(p)) { printOut(2, "Running (load) plugin: " + p.getClass().getName() + "..."); try { p.load(this); } catch (Exception e) { e.printStackTrace(); addHeaderLine("Plugin crashed while loading data: " + p.getClass().getName()); mCrashedPlugins.add(p); } } } // Finally, each plugin should save the generated data printOut(1, "Plugins are generating output..."); for (Plugin p : mPlugins) { if (!mCrashedPlugins.contains(p)) { printOut(2, "Running (generate) plugin: " + p.getClass().getName() + "..."); try { p.generate(this); } catch (Exception e) { e.printStackTrace(); addHeaderLine("Plugin crashed while generating data: " + p.getClass().getName()); } } } }