Package sonia.scm.repository.work
Class SimpleWorkingCopyFactory<R,W,C extends RepositoryProvider>
java.lang.Object
sonia.scm.repository.work.SimpleWorkingCopyFactory<R,W,C>
- Type Parameters:
R
- Type of central repository locationW
- Type of working copy for repositoryC
- Type of repository context
- All Implemented Interfaces:
jakarta.servlet.ServletContextListener
,EventListener
,WorkingCopyFactory<R,
W, C>
public abstract class SimpleWorkingCopyFactory<R,W,C extends RepositoryProvider>
extends Object
implements WorkingCopyFactory<R,W,C>, jakarta.servlet.ServletContextListener
This class is responsible to govern the creation, the reuse and the destruction
of working copies. For every repository type there has to be an implementation
of this class to provide the repository specific logic to create, initialize,
reclaim and clean up working copies. To do this, the following methods have to be
implemented:
The general process looks like this:

initialize(C, File, String)
- Creates a new clone of the repository for the given context in the given directory with the given branch checked out (if branches are supported).
reclaim(C, File, String)
- Reclaim the working directory with a already checked out clone of the repository given in the context, so that the directory is not modified in respect to the repository and the given branch is checked out (if branches are supported).
closeWorkingCopy(W)
- Closes resources allocated for the working copy, so that the directory can be put to the cache. Will be called at the end of the operation.
closeRepository(R)
- Closes resources allocated for the central repository.
The general process looks like this:

-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
class
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleWorkingCopyFactory
(WorkingCopyPool workingCopyPool) Deprecated.SimpleWorkingCopyFactory
(WorkingCopyPool workingCopyPool, io.micrometer.core.instrument.MeterRegistry meterRegistry) Constructs a newSimpleWorkingCopyFactory
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
closeRepository
(R repository) protected abstract void
closeWorkingCopy
(W workingCopy) void
contextDestroyed
(jakarta.servlet.ServletContextEvent sce) void
contextInitialized
(jakarta.servlet.ServletContextEvent sce) createWorkingCopy
(C repositoryContext, String initialBranch) protected abstract SimpleWorkingCopyFactory.ParentAndClone<R,
W> initialize
(C context, File target, String initialBranch) protected abstract SimpleWorkingCopyFactory.ParentAndClone<R,
W>
-
Constructor Details
-
SimpleWorkingCopyFactory
Deprecated.Constructs a newSimpleWorkingCopyFactory
- Parameters:
workingCopyPool
- pool which provides working copies
-
SimpleWorkingCopyFactory
public SimpleWorkingCopyFactory(WorkingCopyPool workingCopyPool, io.micrometer.core.instrument.MeterRegistry meterRegistry) Constructs a newSimpleWorkingCopyFactory
- Parameters:
workingCopyPool
- pool which provides working copiesmeterRegistry
- registry to collect metrics
-
-
Method Details
-
createWorkingCopy
- Specified by:
createWorkingCopy
in interfaceWorkingCopyFactory<R,
W, C extends RepositoryProvider>
-
contextDestroyed
public void contextDestroyed(jakarta.servlet.ServletContextEvent sce) - Specified by:
contextDestroyed
in interfacejakarta.servlet.ServletContextListener
-
contextInitialized
public void contextInitialized(jakarta.servlet.ServletContextEvent sce) - Specified by:
contextInitialized
in interfacejakarta.servlet.ServletContextListener
-
initialize
-
reclaim
protected abstract SimpleWorkingCopyFactory.ParentAndClone<R,W> reclaim(C context, File target, String initialBranch) throws SimpleWorkingCopyFactory.ReclaimFailedException -
closeRepository
- Throws:
Exception
-
closeWorkingCopy
- Throws:
Exception
-
SimpleWorkingCopyFactory(sonia.scm.repository.work.WorkingCopyPool,io.micrometer.core.instrument.MeterRegistry)
instead