View Javadoc

1   /*
2    * Copyright James Leigh (c) 2007.
3    *
4    * Licensed under the Aduna BSD-style license.
5    */
6   package org.openrdf.repository.threadproxy;
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   * Repository that uses a Connection Proxy, redirecting to a Thread specific
15   * Connection.
16   * 
17   * @author James Leigh
18   */
19  public class ThreadProxyRepository extends RepositoryWrapper {
20  
21  	private ThreadProxyRepositoryConnection con;
22  
23  	public ThreadProxyRepository() {
24  		super();
25  	}
26  
27  	public ThreadProxyRepository(Repository repository) {
28  		super(repository);
29  	}
30  
31  	@Override
32  	public void setDelegate(Repository repository) {
33  		super.setDelegate(repository);
34  		con = new ThreadProxyRepositoryConnection(this);
35  	}
36  
37  	@Override
38  	public RepositoryConnection getConnection() throws RepositoryException {
39  		con.getDelegate(); // ensure Connection is created
40  		return con;
41  	}
42  }