Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 358486

Summary: Make it easier to use JGit in a web-server
Product: [Technology] JGit Reporter: Thomas Hallgren <thomas>
Component: JGitAssignee: Project Inbox <jgit.core-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: remy.suen
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Thomas Hallgren CLA 2011-09-21 16:08:18 EDT
The use-case is a servlet engine that servers many users. A user in this context, is not an operating system user. This means that the SshSessionFactory (we're using key pairs, not passwords) and SystemReader used by JGit must be provided by other means.

Today, this can be done in one of two ways:

Synchronize all jgit operations and use a prologue/epilogue where the SshSessionFactory and SystemReader is first assigned and then, once the command has completed, reset to what they were before.

OR

Create a SshSessionFactory and SystemReader that uses InheritableThreadLocal instances to store user specific credentials and config. This way, they can be assigned once when the process starts, and the prologue need only initialize the thread local with correct data. The advantage with this approach is that it doesn't need to be synchronized and several JGit actions can run in parallel. This approach will break if JGit would use a thread pool.

I'm not overly happy with any of them. What I would like to have is a way to pass the SshSessionFactory and SystemReader to each command that is executed rather than having to assign them to a static variable. Perhaps this could be done as an extension to the CredentialsProvider?