/** * Adds and completely initializes a synthetic resource from string. * * @param workspace * may not be <code>null</code> * @param providerClass * may not be <code>null</code> * @param id * may not be <code>null</code> * @param content * configuration content, may not be <code>null</code> * @return the initialized resource */ public static <T extends Resource> T activateSynthetic( Workspace workspace, Class<? extends ResourceProvider<T>> providerClass, String id, String content ) { IncorporealResourceLocation<? extends Resource> loc; ResourceIdentifier<T> identifier = new DefaultResourceIdentifier<T>( providerClass, id ); Charset cs = Charset.forName( "UTF-8" ); loc = new IncorporealResourceLocation<T>( content.getBytes( cs ), identifier ); workspace.add( loc ); workspace.prepare( identifier ); return workspace.init( identifier, null ); }
ws.add( loc ); ws.prepare( id ); SQLFeatureStore fs = (SQLFeatureStore) ws.init( id, null ); String[] sql = DDLCreator.newInstance( fs.getSchema(), fs.getDialect() ).getDDL(); for ( String string : sql ) {
ws.add( new DefaultResourceLocation<FeatureStore>( new File( storeFile ), identifier ) ); ws.prepare( identifier ); FeatureStore store = ws.init( identifier, null );
/** * Adds and completely initializes a synthetic resource from an URL. * * @param workspace * may not be <code>null</code> * @param providerClass * may not be <code>null</code> * @param id * may not be <code>null</code> * @param content * configuration content, may not be <code>null</code> * @return the initialized resource */ public static <T extends Resource> T activateFromUrl( Workspace workspace, Class<? extends ResourceProvider<T>> providerClass, String id, URL content ) { IncorporealResourceLocation<? extends Resource> loc; ResourceIdentifier<T> identifier = new DefaultResourceIdentifier<T>( providerClass, id ); try { loc = new IncorporealResourceLocation<T>( IOUtils.toByteArray( content ), identifier ); workspace.add( loc ); workspace.prepare( identifier ); return workspace.init( identifier, null ); } catch ( Exception e ) { throw new ResourceInitException( "Unable to load URL " + content + ": " + e.getLocalizedMessage(), e ); } }
/** * Adds and completely initializes a synthetic resource from file. * * @param workspace * may not be <code>null</code> * @param providerClass * may not be <code>null</code> * @param id * may not be <code>null</code> * @param content * configuration content, may not be <code>null</code> * @return the initialized resource */ public static <T extends Resource> T activateFromFile( Workspace workspace, Class<? extends ResourceProvider<T>> providerClass, String id, File content ) { DefaultResourceLocation<? extends Resource> loc; ResourceIdentifier<T> identifier = new DefaultResourceIdentifier<T>( providerClass, id ); loc = new DefaultResourceLocation<T>( content, identifier ); workspace.add( loc ); workspace.prepare( identifier ); return workspace.init( identifier, null ); }
/** * Destroys and initializes all resources connected to the resource with the given id. * * @param workspace * may not be <code>null</code> * @param id * may not be <code>null</code> */ public static void reinitializeChain( Workspace workspace, ResourceIdentifier<? extends Resource> id ) { ResourceNode<? extends Resource> node = workspace.getDependencyGraph().getNode( id ); List<ResourceMetadata<? extends Resource>> list = new ArrayList<ResourceMetadata<? extends Resource>>(); ResourceMetadata<? extends Resource> meta = workspace.getResourceMetadata( id.getProvider(), id.getId() ); if ( meta == null ) { return; } list.add( meta ); collectDependencies( list, node ); collectDependents( list, node ); ResourceGraph g = new ResourceGraph( list ); list = g.toSortedList(); workspace.destroy( list.get( 0 ).getIdentifier() ); for ( ResourceMetadata<? extends Resource> md : list ) { workspace.add( md.getLocation() ); workspace.init( md.getIdentifier(), null ); } }