Update Injector and create injectable object factory
- Using e.g. Factory<Converter> instead of the injector directly makes its purpose more specific and disallows any future abuse of the injector's functions
This commit is contained in:
@@ -2,6 +2,7 @@ package tools.dependencygraph;
|
||||
|
||||
import ch.jalu.injector.handlers.instantiation.DependencyDescription;
|
||||
import ch.jalu.injector.handlers.instantiation.Instantiation;
|
||||
import ch.jalu.injector.handlers.instantiation.StandardInjectionProvider;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Multimap;
|
||||
@@ -14,7 +15,6 @@ import fr.xephi.authme.process.AsynchronousProcess;
|
||||
import fr.xephi.authme.process.SynchronousProcess;
|
||||
import fr.xephi.authme.security.crypts.EncryptionMethod;
|
||||
import org.bukkit.event.Listener;
|
||||
import tools.utils.InjectorUtils;
|
||||
import tools.utils.ToolTask;
|
||||
import tools.utils.ToolsConstants;
|
||||
|
||||
@@ -114,7 +114,7 @@ public class DrawDependency implements ToolTask {
|
||||
}
|
||||
|
||||
private List<String> getDependencies(Class<?> clazz) {
|
||||
Instantiation<?> instantiation = InjectorUtils.getInstantiationMethod(clazz);
|
||||
Instantiation<?> instantiation = new StandardInjectionProvider().safeGet(clazz);
|
||||
return instantiation == null ? null : formatInjectionDependencies(instantiation);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package tools.utils;
|
||||
|
||||
import ch.jalu.injector.InjectorBuilder;
|
||||
import ch.jalu.injector.handlers.instantiation.DependencyDescription;
|
||||
import ch.jalu.injector.handlers.instantiation.Instantiation;
|
||||
import ch.jalu.injector.handlers.instantiation.InstantiationProvider;
|
||||
import ch.jalu.injector.handlers.instantiation.StandardInjectionProvider;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -24,7 +22,7 @@ public final class InjectorUtils {
|
||||
* @return the class' dependencies, or null if no instantiation method found
|
||||
*/
|
||||
public static Set<Class<?>> getDependencies(Class<?> clazz) {
|
||||
Instantiation<?> instantiation = getInstantiationMethod(clazz);
|
||||
Instantiation<?> instantiation = new StandardInjectionProvider().safeGet(clazz);
|
||||
if (instantiation == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -35,21 +33,4 @@ public final class InjectorUtils {
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the instantiation method for the given class.
|
||||
*
|
||||
* @param clazz the class to process
|
||||
* @return the instantiation method for the class, or null if none applicable
|
||||
*/
|
||||
public static Instantiation<?> getInstantiationMethod(Class<?> clazz) {
|
||||
List<InstantiationProvider> providers = InjectorBuilder.createInstantiationProviders();
|
||||
for (InstantiationProvider provider : providers) {
|
||||
Instantiation<?> instantiation = provider.get(clazz);
|
||||
if (instantiation != null) {
|
||||
return instantiation;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user