mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 17:56:17 +01:00
Prepare search api for different types (#1732)
We introduced a new annotation '@IndexedType' which gets collected by the scm-annotation-processor. All classes which are annotated are index and searchable. This opens the search api for plugins.
This commit is contained in:
@@ -223,6 +223,10 @@ public final class ExtensionCollector
|
||||
return webElements;
|
||||
}
|
||||
|
||||
public Set<Class<?>> getIndexedTypes() {
|
||||
return indexedTypes;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -255,7 +259,7 @@ public final class ExtensionCollector
|
||||
private void collectExtensions(ClassLoader defaultClassLoader, ScmModule module) {
|
||||
for (ClassElement extension : module.getExtensions()) {
|
||||
if (isRequirementFulfilled(extension)) {
|
||||
Class<?> extensionClass = loadExtension(defaultClassLoader, extension);
|
||||
Class<?> extensionClass = load(defaultClassLoader, extension);
|
||||
appendExtension(extensionClass);
|
||||
}
|
||||
}
|
||||
@@ -265,25 +269,34 @@ public final class ExtensionCollector
|
||||
Set<Class<?>> classes = new HashSet<>();
|
||||
for (ClassElement element : classElements) {
|
||||
if (isRequirementFulfilled(element)) {
|
||||
Class<?> loadedClass = loadExtension(defaultClassLoader, element);
|
||||
Class<?> loadedClass = load(defaultClassLoader, element);
|
||||
classes.add(loadedClass);
|
||||
}
|
||||
}
|
||||
return classes;
|
||||
}
|
||||
|
||||
private Collection<Class<?>> collectIndexedTypes(ClassLoader defaultClassLoader, Iterable<ClassElement> descriptors) {
|
||||
Set<Class<?>> types = new HashSet<>();
|
||||
for (ClassElement descriptor : descriptors) {
|
||||
Class<?> loadedClass = load(defaultClassLoader, descriptor);
|
||||
types.add(loadedClass);
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
private Set<WebElementExtension> collectWebElementExtensions(ClassLoader defaultClassLoader, Iterable<WebElementDescriptor> descriptors) {
|
||||
Set<WebElementExtension> webElementExtensions = new HashSet<>();
|
||||
for (WebElementDescriptor descriptor : descriptors) {
|
||||
if (isRequirementFulfilled(descriptor)) {
|
||||
Class<?> loadedClass = loadExtension(defaultClassLoader, descriptor);
|
||||
Class<?> loadedClass = load(defaultClassLoader, descriptor);
|
||||
webElementExtensions.add(new WebElementExtension(loadedClass, descriptor));
|
||||
}
|
||||
}
|
||||
return webElementExtensions;
|
||||
}
|
||||
|
||||
private Class<?> loadExtension(ClassLoader classLoader, ClassElement extension) {
|
||||
private Class<?> load(ClassLoader classLoader, ClassElement extension) {
|
||||
try {
|
||||
return classLoader.loadClass(extension.getClazz());
|
||||
} catch (ClassNotFoundException ex) {
|
||||
@@ -320,6 +333,7 @@ public final class ExtensionCollector
|
||||
restResources.addAll(collectClasses(classLoader, module.getRestResources()));
|
||||
|
||||
webElements.addAll(collectWebElementExtensions(classLoader, module.getWebElements()));
|
||||
indexedTypes.addAll(collectIndexedTypes(classLoader, module.getIndexedTypes()));
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
@@ -327,6 +341,8 @@ public final class ExtensionCollector
|
||||
/** Field description */
|
||||
private final Set<WebElementExtension> webElements = Sets.newHashSet();
|
||||
|
||||
private final Set<Class<?>> indexedTypes = Sets.newHashSet();
|
||||
|
||||
/** Field description */
|
||||
private final Set<Class> restResources = Sets.newHashSet();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user