mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 16:35:45 +01:00
Test module
This commit is contained in:
committed by
René Pfeuffer
parent
3a68e5ff2b
commit
d8af1ea8d0
@@ -26,22 +26,23 @@ package sonia.scm.lifecycle.modules;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import sonia.scm.plugin.PluginLoader;
|
||||
import sonia.scm.repository.work.NoneCachingWorkingCopyPool;
|
||||
import sonia.scm.repository.work.WorkingCopyPool;
|
||||
|
||||
public class WorkingCopyPoolModule extends AbstractModule {
|
||||
public static final String DEFAULT_WORKING_COPY_POOL_STRATEGY = "sonia.scm.repository.work.NoneCachingWorkingCopyPool";
|
||||
public static final String DEFAULT_WORKING_COPY_POOL_STRATEGY = NoneCachingWorkingCopyPool.class.getName();
|
||||
public static final String WORKING_COPY_POOL_STRATEGY_PROPERTY = "scm.workingCopyPoolStrategy";
|
||||
private final PluginLoader pluginLoader;
|
||||
private final ClassLoader classLoader;
|
||||
|
||||
public WorkingCopyPoolModule(PluginLoader pluginLoader) {
|
||||
this.pluginLoader = pluginLoader;
|
||||
this.classLoader = pluginLoader.getUberClassLoader();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
String workingCopyPoolStrategy = System.getProperty(WORKING_COPY_POOL_STRATEGY_PROPERTY, DEFAULT_WORKING_COPY_POOL_STRATEGY);
|
||||
try {
|
||||
Class<? extends WorkingCopyPool> strategyClass = (Class<? extends WorkingCopyPool>) pluginLoader.getUberClassLoader().loadClass(workingCopyPoolStrategy);
|
||||
Class<? extends WorkingCopyPool> strategyClass = (Class<? extends WorkingCopyPool>) classLoader.loadClass(workingCopyPoolStrategy);
|
||||
bind(WorkingCopyPool.class).to(strategyClass);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("could not instantiate class for working copy pool: " + workingCopyPoolStrategy, e);
|
||||
|
||||
Reference in New Issue
Block a user