public static boolean createResource ( String name , AbstractModule module ) throws StorageAlreadyExistsException , TTException { File file = new File ( ROOT_PATH ) ; File storageFile = new File ( STORAGE_PATH ) ; if ( ! file . exists ( ) || ! storageFile . exists ( ) ) { file . mkdirs ( ) ; StorageConfiguration configuration = new StorageConfiguration ( storageFile ) ; // Creating and opening the storage. // Making it ready for usage. Storage . truncateStorage ( configuration ) ; Storage . createStorage ( configuration ) ; } IStorage storage = Storage . openStorage ( storageFile ) ; Injector injector = Guice . createInjector ( module ) ; IBackendFactory backend = injector . getInstance ( IBackendFactory . class ) ; IRevisioning revision = injector . getInstance ( IRevisioning . class ) ; Properties props = StandardSettings . getProps ( storageFile . getAbsolutePath ( ) , name ) ; ResourceConfiguration mResourceConfig = new ResourceConfiguration ( props , backend , revision , new FileDataFactory ( ) , new FilelistenerMetaDataFactory ( ) ) ; storage . createResource ( mResourceConfig ) ; return true ; }
Create a new storage with the given name and backend .