support for non auto binding extension points and treat guice modules as normal extension points

This commit is contained in:
Sebastian Sdorra
2014-12-19 17:41:46 +01:00
parent f64f29bb2e
commit bfd67c5aef
9 changed files with 93 additions and 88 deletions

View File

@@ -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();