/** * Creates a map of classnames to mapped services. * <p> * They key of the map is the service name. * The value is the name providing the service which comes first in the classpath. * * @param serviceName the service class * @return the map */ @Override public synchronized Map<String, String> createNameMap(String serviceName) { Map<String, String> nameMap = new HashMap<>(); for (Map.Entry<String, URL> entry : ServiceFactory.getServiceFinder(Constants.MAPPED_SERVICE_PATH).findServiceConfigurations(serviceName).entrySet()) { String configuration = entry.getKey(); List<String> parts = StringHelper.split(configuration, ":= "); if (parts.size() != 2) { throw new TentackleRuntimeException("invalid service configuration '" + configuration + "' in " + entry.getValue()); } nameMap.putIfAbsent(parts.get(1), parts.get(0)); } return nameMap; }
/** * Creates a map of names to all mapped services.<p> * They key of the map is the service name. * The value is a list of names providing the service ordered by discovery along the classpath. * * @param serviceName the service class * @return the map */ @Override public synchronized Map<String, Set<String>> createNameMapToAll(String serviceName) { Map<String, Set<String>> nameMap = new HashMap<>(); for (Map.Entry<String, URL> entry : ServiceFactory.getServiceFinder(Constants.MAPPED_SERVICE_PATH).findServiceConfigurations(serviceName).entrySet()) { String configuration = entry.getKey(); List<String> parts = StringHelper.split(configuration, ":= "); if (parts.size() != 2) { throw new TentackleRuntimeException("invalid service configuration '" + configuration + "' in " + entry.getValue()); } String key = parts.get(1); Set<String> serviceList = nameMap.computeIfAbsent(key, k -> new HashSet<>()); serviceList.add(parts.get(0)); } return nameMap; }
findServiceConfigurations(serviceName).entrySet()) { ModuleInfo info = ModuleSorter.INSTANCE.getModuleInfo(entry.getValue()); List<String> parts = StringHelper.split(entry.getKey(), ":= ");