mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 22:15:45 +01:00
support for non auto binding extension points and treat guice modules as normal extension points
This commit is contained in:
@@ -123,18 +123,6 @@ public class DefaultPluginLoader implements PluginLoader
|
||||
return extensionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Set<Module> getInjectionModules()
|
||||
{
|
||||
return ImmutableSet.copyOf(collector.getInjectionModules());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -93,6 +93,29 @@ public final class ExtensionBinder
|
||||
logger.info("bind extensions to extension points");
|
||||
|
||||
for (ExtensionPointElement epe : collector.getExtensionPointElements())
|
||||
{
|
||||
bindExtensionPoint(collector, epe);
|
||||
}
|
||||
|
||||
logger.info("bind loose extensions");
|
||||
bindLooseExtensions(collector.getLooseExtensions());
|
||||
logger.info("bind rest providers");
|
||||
bindRestProviders(collector.getRestProviders());
|
||||
logger.info("bind rest resources");
|
||||
bindRestResource(collector.getRestResources());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param collector
|
||||
* @param epe
|
||||
*/
|
||||
private void bindExtensionPoint(ExtensionCollector collector,
|
||||
ExtensionPointElement epe)
|
||||
{
|
||||
if (epe.isAutoBind())
|
||||
{
|
||||
if (epe.isMultiple())
|
||||
{
|
||||
@@ -113,13 +136,10 @@ public final class ExtensionBinder
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("bind loose extensions");
|
||||
bindLooseExtensions(collector.getLooseExtensions());
|
||||
logger.info("bind rest providers");
|
||||
bindRestProviders(collector.getRestProviders());
|
||||
logger.info("bind rest resources");
|
||||
bindRestResource(collector.getRestResources());
|
||||
else
|
||||
{
|
||||
logger.debug("bind type of {} is manual", epe.getClazz());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,10 +39,6 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Module;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -60,14 +56,6 @@ import java.util.Set;
|
||||
public final class ExtensionCollector
|
||||
{
|
||||
|
||||
/**
|
||||
* the logger for ExtensionCollector
|
||||
*/
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(ExtensionCollector.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
@@ -100,9 +88,12 @@ public final class ExtensionCollector
|
||||
public Collection<Class> byExtensionPoint(ExtensionPointElement epe)
|
||||
{
|
||||
Collection<Class> collection = extensions.get(epe);
|
||||
if ( collection == null ){
|
||||
|
||||
if (collection == null)
|
||||
{
|
||||
collection = Collections.EMPTY_SET;
|
||||
}
|
||||
|
||||
return collection;
|
||||
}
|
||||
|
||||
@@ -181,17 +172,6 @@ public final class ExtensionCollector
|
||||
return extensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Set<Module> getInjectionModules()
|
||||
{
|
||||
return injectionModules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -254,24 +234,6 @@ public final class ExtensionCollector
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param extension
|
||||
*/
|
||||
private void appendModule(Class extension)
|
||||
{
|
||||
try
|
||||
{
|
||||
injectionModules.add((Module) extension.newInstance());
|
||||
}
|
||||
catch (IllegalAccessException | InstantiationException ex)
|
||||
{
|
||||
logger.error("could not create instance of module", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -282,14 +244,7 @@ public final class ExtensionCollector
|
||||
{
|
||||
for (Class extension : module.getExtensions())
|
||||
{
|
||||
if (Module.class.isAssignableFrom(extension))
|
||||
{
|
||||
appendModule(extension);
|
||||
}
|
||||
else
|
||||
{
|
||||
appendExtension(extension);
|
||||
}
|
||||
appendExtension(extension);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,6 +260,7 @@ public final class ExtensionCollector
|
||||
{
|
||||
extensionPointIndex.put(epe.getClazz(), epe);
|
||||
}
|
||||
|
||||
restProviders.addAll(Lists.newArrayList(module.getRestProviders()));
|
||||
restResources.addAll(Lists.newArrayList(module.getRestResources()));
|
||||
}
|
||||
@@ -314,9 +270,6 @@ public final class ExtensionCollector
|
||||
/** Field description */
|
||||
private final Set<Class> looseExtensions = Sets.newHashSet();
|
||||
|
||||
/** Field description */
|
||||
private final Set<Module> injectionModules = Sets.newHashSet();
|
||||
|
||||
/** Field description */
|
||||
private final Set<Class> restProviders = Sets.newHashSet();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user