/** * Creates a new {@link MemoryFeatureStore} instance for the given {@link AppSchema}. * * @param schema * application schema, must not be <code>null</code> * @param storageCRS * crs used for stored geometries, may be <code>null</code> (no transformation on inserts) * @param metadata * @throws FeatureStoreException */ MemoryFeatureStore( AppSchema schema, ICRS storageCRS, MemoryFeatureStoreMetadata metadata, ConnectionProvider lockConnection ) throws FeatureStoreException { this.schema = schema; this.storageCRS = storageCRS; this.metadata = metadata; this.storedFeatures = new StoredFeatures( schema, storageCRS, null ); // TODO lockManager = new DefaultLockManager( this, lockConnection ); }
@Override public synchronized FeatureStoreTransaction acquireTransaction() throws FeatureStoreException { while ( this.activeTransaction != null ) { Thread holder = this.transactionHolder; // check if transaction holder variable has (just) been cleared or if the other thread // has been killed (avoid deadlocks) if ( holder == null || !holder.isAlive() ) { this.activeTransaction = null; this.transactionHolder = null; break; } try { // wait until the transaction holder wakes us, but not longer than 5000 // milliseconds (as the transaction holder may very rarely get killed without // signalling us) wait( 5000 ); } catch ( InterruptedException e ) { // nothing to do } } StoredFeatures workingCopy = new StoredFeatures( schema, storageCRS, storedFeatures ); this.activeTransaction = new MemoryFeatureStoreTransaction( this, workingCopy, lockManager ); this.transactionHolder = Thread.currentThread(); return this.activeTransaction; }