com.speedment.runtime.application.internal.util.JpmsUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of runtime-application Show documentation
Show all versions of runtime-application Show documentation
The runtime bundle of Speedment that all projects must depend on to use
the framework.
/*
*
* Copyright (c) 2006-2019, Speedment, Inc. All Rights Reserved.
*
* Licensed 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 com.speedment.runtime.application.internal.util;
import com.speedment.common.logger.Logger;
import com.speedment.common.logger.LoggerManager;
import com.speedment.runtime.core.ApplicationBuilder;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.util.*;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.*;
public final class JpmsUtil {
private static final Logger LOGGER = LoggerManager.getLogger(ApplicationBuilder.LogType.MODULE_SYSTEM.getLoggerName());
private JpmsUtil() {}
public static void logModulesIfEnabled() {
final Map> moduleNames = modules().stream()
.map(Object::toString)
.map(JpmsUtil::removeModuleTag)
.collect(groupingBy(JpmsUtil::initialPath, TreeMap::new, mapping(JpmsUtil::restPath, toList())));
LOGGER.debug("JPMS Modules: ");
moduleNames.forEach((key, value) -> LOGGER.debug("%s.%s", key, format(value)));
}
private static String format(List value) {
if (value.size() == 1) {
return value.iterator().next();
} else {
return value.stream().collect(Collectors.joining(", ", "[", "]"));
}
}
private static Set