Search in sources :

Example 1 with PluginClassLoader

use of org.hudsonci.inject.internal.plugin.PluginClassLoader in project hudson-2.x by hudson.

the class InjectomaticImpl method inject.

public void inject(final Object component) {
    checkNotNull(component);
    Class type = component.getClass();
    if (!isInjectable(type)) {
        log.trace("Type not injectable; skipping: {}", type);
        return;
    }
    // Find the injector for the component
    ClassLoader tmp = type.getClassLoader();
    Injector injector;
    // If the component belongs to a plugin, then use the plugin's injector
    if (tmp instanceof PluginClassLoader) {
        PluginClassLoader cl = (PluginClassLoader) tmp;
        injector = container.injector(cl.getPlugin());
    } else {
        // Use the root injector if we did not load from a plugin
        injector = ((SmoothieContainerImpl) container).rootInjector();
    }
    if (log.isTraceEnabled()) {
        log.trace("Injecting: {}", OID.get(component));
    }
    injector.injectMembers(component);
}
Also used : Injector(com.google.inject.Injector) PluginClassLoader(org.hudsonci.inject.internal.plugin.PluginClassLoader) PluginClassLoader(org.hudsonci.inject.internal.plugin.PluginClassLoader)

Aggregations

Injector (com.google.inject.Injector)1 PluginClassLoader (org.hudsonci.inject.internal.plugin.PluginClassLoader)1