public FileRepositoryCollection createFileRepositoryCollection ( File file ) { Class < ? extends FileRepositoryCollection > clazz ; String extension = FileExtensionUtils . findExtensionFromPossibilities ( file . getName ( ) , fileRepositoryCollections . keySet ( ) ) ; clazz = fileRepositoryCollections . get ( extension ) ; if ( clazz == null ) { throw new MolgenisDataException ( "Unknown extension for file '" + file . getName ( ) + "'" ) ; } Constructor < ? extends FileRepositoryCollection > ctor ; try { ctor = clazz . getConstructor ( File . class ) ; } catch ( Exception e ) { throw new MolgenisDataException ( "Exception creating [" + clazz + "] missing constructor FileRepositorySource(File file)" ) ; } FileRepositoryCollection fileRepositoryCollection = BeanUtils . instantiateClass ( ctor , file ) ; autowireCapableBeanFactory . autowireBeanProperties ( fileRepositoryCollection , AutowireCapableBeanFactory . AUTOWIRE_BY_TYPE , false ) ; try { fileRepositoryCollection . init ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } return fileRepositoryCollection ; }
Factory method for creating a new FileRepositorySource