/** * @param modelLocation The directory with the Jena TDB model. Will be created * if not existent. * @return * @throws IllegalArgumentException if <code>null</code> is parsed; * if the parsed {@link File} exists but is not a directory; if the parsed * File does NOT exists AND can not be created. */ public static DatasetGraphTDB initTDBDataset(File modelLocation) { if(modelLocation == null){ throw new IllegalArgumentException("The parsed Jena TDB directory" + "MUST NOT be NULL!"); } if(modelLocation.exists() && !modelLocation.isDirectory()){ throw new IllegalArgumentException("The configured RDF model directory "+ modelLocation+"exists but is not a Directory"); } else if(!modelLocation.exists()){ if(!modelLocation.mkdirs()){ throw new IllegalArgumentException("Unable to create the configured RDF model directory "+ modelLocation+"!"); } } Location location = new Location(modelLocation.getAbsolutePath()); //TODO: change this to support transactions // TDBMaker.createDatasetGraphTransaction(location); // if we need transaction support! return TDBMaker.createDatasetGraphTDB(location); }
@Test public void factory2() { DatasetGraphMakerTDB f = TDBMaker.getImplFactory() ; TDBMaker.clearDatasetCache() ; DatasetGraphTDB dg0 = TDBFactory.createDatasetGraph(Location.mem()) ; // Uncached. TDBMaker.setImplFactory(TDBMaker.uncachedFactory) ; DatasetGraphTDB dg1 = TDBFactory.createDatasetGraph(Location.mem()) ; DatasetGraphTDB dg2 = TDBFactory.createDatasetGraph(Location.mem()) ; assertNotSame(dg1, dg2) ; // Switch back to cached. TDBMaker.setImplFactory(f) ; DatasetGraphTDB dg3 = TDBFactory.createDatasetGraph(Location.mem()) ; assertNotSame(dg3, dg1) ; assertNotSame(dg3, dg2) ; assertSame(dg3, dg0) ; }
@After public void after() { graphLocation.release() ; TDBMaker.clearDatasetCache() ; }
/** * @param modelLocation The directory with the Jena TDB model. Will be created * if not existent. * @return * @throws IllegalArgumentException if <code>null</code> is parsed; * if the parsed {@link File} exists but is not a directory; if the parsed * File does NOT exists AND can not be created. */ public static DatasetGraphTDB initTDBDataset(File modelLocation) { if(modelLocation == null){ throw new IllegalArgumentException("The parsed Jena TDB directory" + "MUST NOT be NULL!"); } if(modelLocation.exists() && !modelLocation.isDirectory()){ throw new IllegalArgumentException("The configured RDF model directory "+ modelLocation+"exists but is not a Directory"); } else if(!modelLocation.exists()){ if(!modelLocation.mkdirs()){ throw new IllegalArgumentException("Unable to create the configured RDF model directory "+ modelLocation+"!"); } } Location location = new Location(modelLocation.getAbsolutePath()); //TODO: change this to support transactions // TDBMaker.createDatasetGraphTransaction(location); // if we need transaction support! return TDBMaker.createDatasetGraphTDB(location); }