Search in sources :

Example 1 with ClassSpace

use of org.sonatype.guice.bean.reflect.ClassSpace in project hudson-2.x by hudson.

the class SmoothieContainerBootstrap method bootstrap.

public SmoothieContainer bootstrap(final ClassLoader classLoader, final Class... types) {
    log.info("Bootstrapping Smoothie");
    // Build the root space for the given types
    ClassSpace space = new ClassSpaceFactory().create(classLoader, types);
    // Start up the container
    SmoothieContainer container = new SmoothieContainerImpl(new ExtensionModule(space, true));
    Smoothie.setContainer(container);
    // Enable aspect-based injection
    InjectomaticAspectHelper.setEnabled(true);
    return container;
}
Also used : ClassSpace(org.sonatype.guice.bean.reflect.ClassSpace) SmoothieContainer(org.hudsonci.inject.SmoothieContainer) ExtensionModule(org.hudsonci.inject.internal.extension.ExtensionModule)

Example 2 with ClassSpace

use of org.sonatype.guice.bean.reflect.ClassSpace in project pom-manipulation-ext by release-engineering.

the class PlexusTestRunner method createTest.

@Override
protected Object createTest() throws Exception {
    final TestClass testClass = getTestClass();
    final DefaultContainerConfiguration config = new DefaultContainerConfiguration();
    config.setAutoWiring(true);
    config.setClassPathScanning(PlexusConstants.SCANNING_ON);
    config.setComponentVisibility(PlexusConstants.GLOBAL_VISIBILITY);
    config.setName(testClass.getName());
    final DefaultPlexusContainer container = new DefaultPlexusContainer(config);
    final ClassSpace cs = new URLClassSpace(Thread.currentThread().getContextClassLoader());
    container.addPlexusInjector(Arrays.<PlexusBeanModule>asList(new PlexusAnnotatedBeanModule(cs, Collections.emptyMap())));
    return container.lookup(testClass.getJavaClass());
}
Also used : DefaultContainerConfiguration(org.codehaus.plexus.DefaultContainerConfiguration) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) ClassSpace(org.sonatype.guice.bean.reflect.ClassSpace) URLClassSpace(org.sonatype.guice.bean.reflect.URLClassSpace) TestClass(org.junit.runners.model.TestClass) URLClassSpace(org.sonatype.guice.bean.reflect.URLClassSpace) PlexusAnnotatedBeanModule(org.sonatype.guice.plexus.binders.PlexusAnnotatedBeanModule)

Aggregations

ClassSpace (org.sonatype.guice.bean.reflect.ClassSpace)2 DefaultContainerConfiguration (org.codehaus.plexus.DefaultContainerConfiguration)1 DefaultPlexusContainer (org.codehaus.plexus.DefaultPlexusContainer)1 SmoothieContainer (org.hudsonci.inject.SmoothieContainer)1 ExtensionModule (org.hudsonci.inject.internal.extension.ExtensionModule)1 TestClass (org.junit.runners.model.TestClass)1 URLClassSpace (org.sonatype.guice.bean.reflect.URLClassSpace)1 PlexusAnnotatedBeanModule (org.sonatype.guice.plexus.binders.PlexusAnnotatedBeanModule)1