use of org.eclipse.sisu.space.URLClassSpace in project nexus-public by sonatype.
the class TaskSchedulerHelper method init.
public void init(@Nullable final Integer poolSize, @Nullable final JobFactory factory) throws Exception {
eventManager = new SimpleEventManager();
applicationDirectories = mock(ApplicationDirectories.class);
baseUrlManager = mock(BaseUrlManager.class);
nodeAccess = mock(NodeAccess.class);
lastShutdownTimeService = mock(LastShutdownTimeService.class);
statusDelayedExecutor = mock(DatabaseStatusDelayedExecutor.class);
Module module = binder -> {
Properties properties = new Properties();
properties.put("basedir", util.getBaseDir());
if (poolSize != null) {
properties.put("nexus.quartz.poolSize", poolSize);
}
binder.bind(ParameterKeys.PROPERTIES).toInstance(properties);
binder.bind(EventManager.class).toInstance(eventManager);
File workDir = util.createTempDir(util.getTargetDir(), "workdir");
when(applicationDirectories.getWorkDirectory(anyString())).thenReturn(workDir);
binder.bind(ApplicationDirectories.class).toInstance(applicationDirectories);
binder.bind(BaseUrlManager.class).toInstance(baseUrlManager);
binder.bind(DatabaseInstance.class).annotatedWith(Names.named("config")).toInstance(databaseInstance);
doAnswer(i -> {
((Runnable) i.getArguments()[0]).run();
return null;
}).when(statusDelayedExecutor).execute(any(Runnable.class));
binder.bind(DatabaseStatusDelayedExecutor.class).toInstance(statusDelayedExecutor);
when(nodeAccess.getId()).thenReturn("test-12345");
when(nodeAccess.getMemberIds()).thenReturn(ImmutableSet.of("test-12345"));
binder.bind(NodeAccess.class).toInstance(nodeAccess);
if (factory != null) {
binder.bind(JobFactory.class).toInstance(factory);
}
binder.bind(LastShutdownTimeService.class).toInstance(lastShutdownTimeService);
when(lastShutdownTimeService.estimateLastShutdownTime()).thenReturn(Optional.empty());
// filtering by feature flag is not supported here yet
binder.bind(JobStore.class).to(JobStoreImpl.class);
};
this.injector = Guice.createInjector(new WireModule(module, new StateGuardModule(), new SpaceModule(new URLClassSpace(TaskSchedulerHelper.class.getClassLoader()), BeanScanning.INDEX)));
injector.injectMembers(this);
}
use of org.eclipse.sisu.space.URLClassSpace in project nexus-public by sonatype.
the class AbstractSecurityTest method doSetUp.
@Before
public final void doSetUp() throws Exception {
List<Module> modules = new ArrayList<>();
customizeModules(modules);
modules.add(new SpaceModule(new URLClassSpace(getClass().getClassLoader()), BeanScanning.INDEX));
Guice.createInjector(new WireModule(modules));
setUp();
}
use of org.eclipse.sisu.space.URLClassSpace in project concord by walmartlabs.
the class CurrentClasspathModule method configure.
@Override
protected void configure() {
ClassLoader cl = this.getClass().getClassLoader();
install(new SpaceModule(new URLClassSpace(cl), BeanScanning.GLOBAL_INDEX));
}
use of org.eclipse.sisu.space.URLClassSpace in project concord by walmartlabs.
the class ProcessDependenciesModule method configure.
@Override
protected void configure() {
try {
ClassLoader cl = loadDependencies(workDir, dependencies, debug);
// required to support ScriptEngines from external dependencies
Thread.currentThread().setContextClassLoader(cl);
install(new SpaceModule(new URLClassSpace(cl), BeanScanning.GLOBAL_INDEX));
bind(ClassLoader.class).annotatedWith(Names.named("runtime")).toInstance(cl);
} catch (IOException e) {
addError(e);
}
}
use of org.eclipse.sisu.space.URLClassSpace in project concord by walmartlabs.
the class MigrateDB method main.
public static void main(String[] args) throws Exception {
EnvironmentSelector environmentSelector = new EnvironmentSelector();
Config cfg = new ConfigurationProcessor("concord-server", environmentSelector.select()).process();
Injector injector = Guice.createInjector(new WireModule(new SpaceModule(new URLClassSpace(MigrateDB.class.getClassLoader()), BeanScanning.CACHE), new OllieConfigurationModule("com.walmartlabs.concord.server", cfg), new DatabaseModule()));
new MigrateDB().run(injector);
}
Aggregations