Search in sources :

Example 1 with ExtensionFinder

use of com.cloudbees.sdk.extensibility.ExtensionFinder in project acceptance-test-harness by jenkinsci.

the class AdditionalBinderDsl method subworld.

/**
 * Creates another injector and bind them using the given closure.
 *
 * The newly created injector will be returned.
 */
public SubWorld subworld(final Closure config) {
    final Binder binder = getBinder();
    // final SubWorldBuilder sub = new SubWorldBuilder(name);
    try {
        final SubWorld sw = new SubWorld();
        World w = World.get();
        sw.injector = Guice.createInjector(Modules.override(new ExtensionFinder(w.getClassLoader())).with(new AbstractModule() {

            @Override
            protected void configure() {
                AdditionalBinderDsl.this.setBinder(binder());
                config.setDelegate(AdditionalBinderDsl.this);
                config.run();
                bind(SubWorld.class).toInstance(sw);
            }
        }));
        return sw;
    } catch (CreationException e) {
        throw new RuntimeException("Failed to create a sub-world", e);
    } finally {
        setBinder(binder);
    }
}
Also used : Binder(com.google.inject.Binder) ExtensionFinder(com.cloudbees.sdk.extensibility.ExtensionFinder) CreationException(com.google.inject.CreationException) AbstractModule(com.google.inject.AbstractModule)

Example 2 with ExtensionFinder

use of com.cloudbees.sdk.extensibility.ExtensionFinder in project acceptance-test-harness by jenkinsci.

the class World method configure.

@Override
protected void configure() {
    // lowest priority is our default binding
    Module m = new FallbackConfig();
    // let extensions override the fallback config
    m = Modules.override(m).with(new ExtensionFinder(cl));
    // user config trumps everything
    m = Modules.override(m).with(new Config());
    install(m);
}
Also used : FallbackConfig(org.jenkinsci.test.acceptance.FallbackConfig) ExtensionFinder(com.cloudbees.sdk.extensibility.ExtensionFinder) FallbackConfig(org.jenkinsci.test.acceptance.FallbackConfig) Config(org.jenkinsci.test.acceptance.Config) Module(com.google.inject.Module) AbstractModule(com.google.inject.AbstractModule)

Aggregations

ExtensionFinder (com.cloudbees.sdk.extensibility.ExtensionFinder)2 AbstractModule (com.google.inject.AbstractModule)2 Binder (com.google.inject.Binder)1 CreationException (com.google.inject.CreationException)1 Module (com.google.inject.Module)1 Config (org.jenkinsci.test.acceptance.Config)1 FallbackConfig (org.jenkinsci.test.acceptance.FallbackConfig)1