@Test public void testLoadSafe() throws Exception { ObjectSerializer os = new ObjectSerializer(System.getProperty("java.io.tmpdir")); File f = UnitTestUtil.getTestScratchFile("foo"); os.saveAttachment(f, new Long(2), false); assertNotNull(os.loadAttachment(f, Long.class)); assertNull(os.loadSafe(f, Integer.class)); }
public <T> T loadSafe(File cacheFile, Class<T> clazz) { try { if (cacheFile.exists()) { return clazz.cast(loadAttachment(cacheFile, clazz)); } return null; } catch (Exception e) { LogManager.logWarning(LogConstants.CTX_RUNTIME, e, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50043, cacheFile.getAbsolutePath())); } cacheFile.delete(); return null; }
ObjectSerializer { public <T> T loadSafe(File cacheFile, Class<T> clazz) { try { if (cacheFile.exists()) { return clazz.cast(loadAttachment(cacheFile, clazz)); } return null; } catch (Exception e) { LogManager.logWarning(LogConstants.CTX_RUNTIME, e, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50043, cacheFile.getAbsolutePath())); } cacheFile.delete(); return null; } }
ObjectSerializer { public <T> T loadSafe(File cacheFile, Class<T> clazz) { try { if (cacheFile.exists()) { return clazz.cast(loadAttachment(cacheFile, clazz)); } return null; } catch (Exception e) { LogManager.logWarning(LogConstants.CTX_RUNTIME, e, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50043, cacheFile.getAbsolutePath())); } cacheFile.delete(); return null; } ObjectSerializer(String path); }
ObjectSerializer { public <T> T loadSafe(File cacheFile, Class<T> clazz) { try { if (cacheFile.exists()) { return clazz.cast(loadAttachment(cacheFile, clazz)); } return null; } catch (Exception e) { LogManager.logWarning(LogConstants.CTX_RUNTIME, e, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50043, cacheFile.getAbsolutePath())); } cacheFile.delete(); return null; } ObjectSerializer(String path); T loadAttachment(File attachmentsStore, Class<T> expected); boolean saveAttachment(File attachmentsStore, Object attachment, boolean force); File buildVDBFile(VDBMetaData vdb); File buildVdbXml(VDBMetaData vdb); File buildModelFile(VDBMetaData vdb, String modelName); boolean isStale(VDBMetaData vdb, long timeAfter); void removeAttachments(VDBMetaData vdb); void removeAttachment(File file); T loadSafe(File cacheFile, Class<T> clazz); OutputStream getVdbXmlOutputStream(VDBMetaData vdb); }
ObjectSerializer { public <T> T loadSafe(File cacheFile, Class<T> clazz) { try { if (cacheFile.exists()) { return clazz.cast(loadAttachment(cacheFile, clazz)); } return null; } catch (Exception e) { LogManager.logWarning(LogConstants.CTX_RUNTIME, e, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50043, cacheFile.getAbsolutePath())); } cacheFile.delete(); return null; } ObjectSerializer(String path); T loadAttachment(File attachmentsStore, Class<T> expected); boolean saveAttachment(File attachmentsStore, Object attachment, boolean force); File buildVDBFile(VDBMetaData vdb); File buildVdbXml(VDBMetaData vdb); File buildModelFile(VDBMetaData vdb, String modelName); boolean isStale(VDBMetaData vdb, long timeAfter); void removeAttachments(VDBMetaData vdb); void removeAttachment(File file); T loadSafe(File cacheFile, Class<T> clazz); OutputStream getVdbXmlOutputStream(VDBMetaData vdb);  }