diff --git a/src/main/java/com/guicedee/guicedinjection/GuiceContext.java b/src/main/java/com/guicedee/guicedinjection/GuiceContext.java index 812f230..0c48e0d 100644 --- a/src/main/java/com/guicedee/guicedinjection/GuiceContext.java +++ b/src/main/java/com/guicedee/guicedinjection/GuiceContext.java @@ -652,27 +652,6 @@ private String[] getModulesExclusionList() } return strings.toArray(new String[0]); } - /* - *//** - * Registers a module for scanning when filtering is enabled - * - * @param javaModuleName The name in the module-info.java file - * - * @return This instance - *//* - @SuppressWarnings("unchecked") - public static void registerModule(String javaModuleName) - { - instance().registerModuleForScanning.add(javaModuleName); - instance() - .getConfig() - .setIncludeModuleAndJars(true); - } - - public static void registerModule(com.google.inject.Module module) - { - instance().modules.add(module); - }*/ /** * Returns a complete list of generic exclusions @@ -762,6 +741,12 @@ public Set getLoader(Class loaderType, @SuppressWarnings("unused") boo .get(loaderType); } + @Override + public boolean isBuildingInjector() + { + return buildingInjector; + } + /** * Returns the current classpath scanner * @@ -852,14 +837,6 @@ private void loadPostStartups() { log.log(Level.SEVERE, "Cannot execute post startup - ", e); } - /*try - { - value.parallelStream() - .forEach(IGuicePostStartup::postLoad); - } catch (Throwable T) - { - log.log(Level.SEVERE, "Cannot execute post startup - ", T); - }*/ } GuiceContext.log.fine("Completed with Post Startups Key [" + key + "]"); } @@ -1000,20 +977,6 @@ public > Set getLoader(Class loaderType, ServiceLo .get(loaderType); } - /** - * Method getAllLoadedServices returns the allLoadedServices of this GuiceContext object. - *

- * A list of all the loaded singleton sets - * - * @return the allLoadedServices (type Map Class, Set ) of this GuiceContext object. - */ - @SuppressWarnings("WeakerAccess") - /*@NotNull - public static Map getAllLoadedServices() - { - return allLoadedServices; - }*/ - /** * If this scanner is registered to run asynchronously * @@ -1032,166 +995,4 @@ public void setAsync(boolean async) { this.async = async; } - - //Map> loaderClasses = new ConcurrentHashMap<>(); - - /** - * Method loaderToSet, converts a ServiceLoader into a TreeSet - * - * @param loader of type ServiceLoader - * - * @return Set - */ - //@SuppressWarnings("unchecked") - /*@NotNull - public > Set loaderToSet(ServiceLoader loader) - { - @SuppressWarnings("rawtypes") - Set loadeds = new HashSet<>(); - - String type = loader.toString(); - type = type.replace("java.util.ServiceLoader[", ""); - type = type.substring(0, type.length() - 1); - - if (!loaderClasses.containsKey(type)) - { - GuiceConfig config = GuiceContext - .instance() - .getConfig(); - if (config.isServiceLoadWithClassPath()) - { - for (ClassInfo classInfo : instance() - .getScanResult() - .getClassesImplementing(type)) - { - Class load = (Class) classInfo.loadClass(); - loadeds.add(load); - } - } - try - { - for (T newInstance : loader) - { - loadeds.add(newInstance.getClass()); - } - } - catch (Throwable T) - { - log.log(Level.SEVERE, "Unable to provide instance of " + type + " to TreeSet", T); - } - loaderClasses.put(type, loadeds); - } - - Set outcomes = new TreeSet<>(); - for (Class aClass : loaderClasses.get(type)) - { - outcomes.add((T) IGuiceContext.get(aClass)); - } - return outcomes; - }*/ - - /*public > Set> loadClassSet(ServiceLoader loader) - { - String type = loader.toString(); - type = type.replace("java.util.ServiceLoader[", ""); - type = type.substring(0, type.length() - 1); - - if (!loaderClasses.containsKey(type)) - { - Set loadeds = new HashSet<>(); - GuiceConfig config = GuiceContext - .instance() - .getConfig(); - if (config.isServiceLoadWithClassPath()) - { - for (ClassInfo classInfo : instance() - .getScanResult() - .getClassesImplementing(type)) - { - @SuppressWarnings("unchecked") - Class load = (Class) classInfo.loadClass(); - loadeds.add(load); - } - } - try - { - for (T newInstance : loader) - { - //noinspection unchecked - loadeds.add((Class) newInstance.getClass()); - } - } - catch (Throwable T) - { - log.log(Level.SEVERE, "Unable to provide instance of " + type + " to TreeSet", T); - } - loaderClasses.put(type, loadeds); - } - //noinspection unchecked - return (Set) loaderClasses.get(type); - }*/ - - /** - * Method loaderToSet, converts a ServiceLoader into a TreeSet - * - * @param loader of type ServiceLoader - * - * @return Set - */ - /*@SuppressWarnings("unchecked") - @NotNull - public Set loaderToSetNoInjection(ServiceLoader loader) - { - Set> loadeds = new HashSet<>(); - GuiceConfig config = GuiceContext - .instance() - .getConfig(); - String type = loader.toString(); - type = type.replace("java.util.ServiceLoader[", ""); - type = type.substring(0, type.length() - 1); - if (config.isServiceLoadWithClassPath() && !buildingInjector && instance().getScanResult() != null) - { - for (ClassInfo classInfo : instance() - .getScanResult() - .getClassesImplementing(type)) - { - Class load = (Class) classInfo.loadClass(); - loadeds.add(load); - } - } - Set> completed = new LinkedHashSet<>(); - Set output = new LinkedHashSet<>(); - try - { - for (T newInstance : loader) - { - output.add(newInstance); - completed.add((Class) newInstance.getClass()); - } - } - catch (java.util.ServiceConfigurationError T) - { - log.log(Level.WARNING, "Cannot load services - ", T); - } - catch (Throwable T) - { - log.log(Level.SEVERE, "Cannot load services - ", T); - } - for (Class newInstance : loadeds) - { - if (completed.contains(newInstance)) - { - continue; - } - try - { - output.add((T) newInstance.getDeclaredConstructor()); - } - catch (NoSuchMethodException e) - { - log.log(Level.SEVERE, "Cannot load a service through default constructor", e); - } - } - return output; - }*/ }