ascherbakoff commented on a change in pull request #460: URL: https://github.com/apache/ignite-3/pull/460#discussion_r759411235
########## File path: modules/runner/src/main/java/org/apache/ignite/internal/configuration/ServiceLoaderModulesProvider.java ########## @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.configuration; + +import static java.util.stream.Collectors.toUnmodifiableList; + +import java.util.List; +import java.util.ServiceLoader; +import java.util.ServiceLoader.Provider; + +/** + * Provides {@link ConfigurationModule}s using {@link ServiceLoader} mechanism. + * Uses {@link ConfigurationModule} interface to query the ServiceLoader. + * + * @see ConfigurationModule + */ +public class ServiceLoaderModulesProvider { Review comment: Having CompoundModule and ConfigurationModules classes looks like an overcomplication to me. I woud instead implemented it in the following way (or just allow the configuration manager to accept a list of modules): ``` public class ServiceLoaderModulesProvider { List<ConfigurationModule> local = new ArrayList<>(); List<ConfigurationModule> distributed = new ArrayList<>(); public void loadExtensions() { // Load configuration extensions. ServiceLoader.load(ConfigurationModule.class).stream(). map(Provider::get). forEach(m -> (m.type() == ConfigurationType.LOCAL ? local : distributed).add(m)); // Load other extensions. } public Iterable<RootKey<?, ?>> getRootKeys(ConfigurationType type) { return CollectionUtils.concat((type == LOCAL ? local : distributed).stream().map(cm -> cm.rootKeys()). collect(Collectors.toList()).toArray(new Collection[0])); } ... } ``` Another point here is the responsibility of ServiceLoaderModulesProvider. I suppose it to do service loading for all Ignite extensions in the future. Also, I would rename it to ExtensionsProvider. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
