View Javadoc

1   /*
2    * Copyright James Leigh (c) 2007.
3    *
4    * Licensed under the Aduna BSD-style license.
5    */
6   package org.openrdf.repository.flushable;
7   
8   import org.openrdf.repository.Repository;
9   import org.openrdf.repository.RepositoryConnection;
10  import org.openrdf.repository.RepositoryException;
11  import org.openrdf.repository.base.RepositoryWrapper;
12  
13  /**
14   * @see FlushableConnection
15   * @author James Leigh
16   */
17  public class FlushableRepository extends RepositoryWrapper {
18  	private boolean autoFlush = true;
19  
20  	public FlushableRepository() {
21  		super();
22  	}
23  
24  	public FlushableRepository(Repository delegate) {
25  		super(delegate);
26  	}
27  
28  	public FlushableRepository(Repository delegate, boolean autoFlush) {
29  		super(delegate);
30  		this.autoFlush = autoFlush;
31  	}
32  
33  	@Override
34  	public RepositoryConnection getConnection() throws RepositoryException {
35  		RepositoryConnection c = super.getConnection();
36  		FlushableConnection conn = new FlushableConnection(this, c);
37  		conn.setAutoFlush(autoFlush);
38  		return conn;
39  	}
40  
41  	public void setAutoFlush(boolean autoFlush) {
42  		this.autoFlush = autoFlush;
43  	}
44  }